How to fix the Folderview screenlet properties dialog exception throw

0
Categories: Linux, Python, Screenlets
Posted on: 15th January 2012 by: Ishan Thilina Somasiri

Folderview screenlet is one of the screenlets that I have found very useful. But it doesn’t function correctly with the new python version (python 2.7). When the option is selected to view the properties dialog it gives the following exception.

Traceback (most recent call last):

  File “/usr/lib/python2.7/site-packages/screenlets/__init__.py”, line 1913, in button_press

    self.menuitem_callback(widget,’info’)

  File “/usr/lib/python2.7/site-packages/screenlets/__init__.py”, line 2119, in menuitem_callback

    self.show_settings_dialog()

  File “/usr/lib/python2.7/site-packages/screenlets/__init__.py”, line 1570, in show_settings_dialog

    se.set_info(self.__name__, glib.markup_escape_text(self.__desc__), ‘(c) ‘ + glib.markup_escape_text(self.__author__), 

TypeError: glib.markup_escape_text() argument 1 must be string or read-only buffer, not None

 

It seems that the variable __desc__ is not set when calling the glib.markup_escape_text() method. So until some geek comes and fix this bug, we can use the following method to overcome this burden. (You’ll be able to follow the same procedure if you are getting this error for some other screenlet too :-D )

  • Open __init__.py  in /usr/lib/python2.7/site-packages/screenlets with root privileges. 
  • Find the line se.set_info(self.__name__, glib.markup_escape_text(self.__desc__), ‘(c) ‘ + glib.markup_escape_text(self.__author__) . This should approximately be in the line 1570.
  • Add the following code segment before that line.

if not self.__desc__:

self.__desc__=’Description not set’

(keep in mind that python is sensitive to indentations).

  • Save and restart the screenlet.
 

Congratulations…! You have fixed a bug in a very naive way….! .

Set brightness automatically at the startup in Linux

Categories: Linux, Python
Posted on: 25th September 2011 by: Ishan Thilina Somasiri

When ever I restart (or logout and login) my laptop the LCD display brightness is set to the maximum value. Even if I set the brightness settings in the power to the value I need, they won’t be in effect when I restart the machine.

 

To solve this problem I wrote the following python script. First you need to add it to the startup applications list. The command to be given in the startup applications is “python /<path>/<to>/<script>/setBrightness.py”.

 

By default, the script will set the brightness to the minimum value. But if you want to change this, you can do that by editing the value 0 of the “value” variable to any value between 0 to 100.

Download::

http://ishans.info/attachments/category/40/setBrightness.py

 

PS:

 

It seems that D-bus interfaces have been changed recently (From Gnome 3 onwards). So if you use Ubuntu 11.10 or any other gnome 3 compatible OS, please use the following script.

 

http://ishans.info/attachments/article/65/setBrightness.py

 

All of the above code can now be conveniently accessed from Git-hub via https://github.com/ishanthilina/setBrightness . There are branches for every version of the script.

Start empathy automatically when network connection is available

0
Categories: Linux, Python
Posted on: 24th September 2011 by: Ishan Thilina Somasiri

I have noticed that Empathy (the default multi-protocol chat client in Ubuntu 11.04) doesn’t re-login to the accounts after the network is dropped and re-connected. So I wrote the following python script to solve this problem. The script will be using D-bus signals to detect the network connection status.This will make empathy to,

 

  • connect automatically when network connection is established (even when empathy is not running).
  • re-login to accounts when the network gets dropped and reconnect again(very useful when using wireless connections).

 

 

To use this script add it to the startup applications. Command to be given is “python /<path>/<to>/<script>/empathyConnect.py

 

Download:: http://ishans.info/attachments/article/64/empathyConnect.py