bash script to periodically change the cursor theme.

#!/bin/bash
[[ \”$1\” == \”\” ]] && time=5 || time=$1
[[ \”$2\” == \”\” ]] && (
cd ~/.icons
cont=\”y\”
echo \”Select one of the icon themes\”
echo \”When you like some theme just press Ctrl+c\”
for i in *
do
[[ -d $i/cursors ]] && (
echo \”Now trying …. : $i\”
gconftool-2 –type string -s  /desktop/gnome/peripherals/mouse/cursor_theme \”$i\”
sleep $time
)
done
) || gconftool-2 –type string -s  /desktop/gnome/peripherals/mouse/cursor_theme \”$2\”

How does it work/How to use:

just copy paste the script in ~/bin or any other directory and make it executable. Now run the script without any parameter to check out all the themes one after the other, changing your cursor every 5 seconds.

If you want to chnage the timer, just provide the time in seconds as first parameter.

If you want to chnage to specific theme, just provide the theme name as second parameter.

This can also be used as a script running in the background to change the cursor every specified time and thus making your friends dazzled.

Bugzilla Automation with perl — add, update or query any bug in Bugzilla using perl and www series modules for perl.

Today I was trying to do some queries and see if I could create a new bug or update a existing bug in the Bugzilla. The one that I was trying to access was on version 2.0 and not on 3.0. This being the case, the XMLRPC interface was not working properly and to top it all, I was wanted to query quite a lot of bugs. So, I went out to evaluate how to avoid the manual work and get this done faster. Here\’s some of my findings:

Note: If you have direct access to the bugzilla database, dont bother with any of these, simplest is to directly query the database 🙂

There is a Bugzilla client for windows called MyZilla. This is a freeware, but I ran into problems running this with wine and did not bother to debug the same.

There is a python plugin to use bugzilla. The package name in Fedora for the same is \”python-bugzilla.noarch\”. You can install this with

sudo yum install python-bugzilla.noarch

This uses the XML-RPC interface to talk to the bugzilla. So not of much use for me. But this is quite powerful tool. The man page for the tool is available here.

Lets try perl now to do what we want to. Let take a simple example using the perl mechanize module (taken from here):

#!/usr/bin/perl

use WWW::Mechanize;

my $link = \”https://x.x/bt/query.cgi?GoAheadAndLogIn=1\”;

my $login = \”x\\@gx.com\”;

my $pass = \”xx\”;

my $mech = WWW::Mechanize->new();

$mech->agent_alias( \’Windows IE 6\’ );

$mech->get( $link );

my %login = ( \”Bugzilla_login\”=> $login,

\”Bugzilla_password\”=> $pass);

$mech->set_fields(%login);

$mech->click( \’GoAheadAndLogIn\’ );

Now, thats a pretty neat script. That will allow me to login to the Bugzilla account. But I still need to do some investigation and spend some time to execute my query and get the result. Haaaaaaaaa.. Am I the first one to think about this. NO. There is a perl module \”perl-WWW-Bugzilla.noarch\”. This module provides some funtionality to add and update the bugs in bugzilla. If you look at the pm files for the module you will get enough hint to enter a new bug or update an existing bug. You can install this with :

sudo yum install perl-WWW-Bugzilla.noarch

There is a module \”perl-Fedora-Bugzilla\”, which is more useful for the Fedora Bugzilla. This also uses the XML-RPC interface and \”Fedora\’s Bugzilla implementation has a large number of custom methods.  This module aims to expose them, in a kinder, gentler way.\” So, still no luck.

Let\’s get back to basic\’s before we go any further. Lets try to do it with wget and shell and perl scripts.

Lets create a file with the list of bugs (each in seperate line) and call it list. And then execute the following:

for i in `cat list`; do wget http://1.1.1.2/bugzilla/long_list.cgi?buglist=$i -O $i -o temp;  echo -n \”$i\” ;cat $i  |egrep \’Summary|Product\’| awk -F\’;\’ \'{printf \”\\t%s\\t\”,$2}\’; echo ;done

This will print the result neatly as

Bug ID         Product               Headline

and also save all the details of the bugs in individual files with Bug ID as the file name. Quite near, but need more to do for the execution of query. I still need the bug id\’s for this to work.

Let\’s now try to use a perl script with shell script called buglist. The script and readme are available here. The readme and the scripts are quite descriptive and you need to do minimal amount of chages to make this work. So finally I settled with this one with the changes required for my work. Hope this helps you when you are stuck with something in Bugzilla.

bash – change theme for gtk in gnome and take screenshot from script.

I wrote a blog on bash script to change the icon/cursor theme using a bash script. Lets extend the same concept a little more and use the script to change the gtk theme for gnome and at the same time take a screenshot also.

#!/bin/bash
path=\”/tmp/screenshot\”
[[ \”$1\” == \”\” ]] && time=5 || time=$1
[[ \”$2\” == \”\” ]] && (
cd ~/.themes
cont=\”y\”
echo \”Select one of the icon themes\”
echo \”When you like some theme just press Ctrl+c\”
for i in *
do
[[ -d $i/cursors ]] || (
echo \”Now trying …. : $i\”
gconftool-2 –type string -s  /desktop/gnome/interface/gtk_theme \”$i\”
sleep 1
j=$(echo \”$path/$i\”).jpg
import -window root -quality 95 \”$j\”
sleep $time
)
done
) || gconftool-2 –type string -s  /desktop/gnome/interface/gtk_theme \”$2\”

This use\’s the import command to take the screenshot. Hope you like it. You can specify the path for the screenshots in the path variable at the begining of the script.