Posts Tagged script
Automatic proxy changer
I’ve been hearing a lot of complaints from my friends at college about the mess it creates when they have to switch b/w home networks and college network, especially the proxy problems.
Most of us don’t have proxy set up at home networks. But at college we need to pass through a proxy and we forget about that and end up complaining that the network is down.
Here is a script you need to put up in the startup which will remove the mess. It will check and set/unset the proxy whenever needed.
while [ TRUE ]
do
essid=`iwlist wlan0 scan|grep ESSID|cut -d":" -f2`
if [ "model-2" == $essid ]
then
export HTTP_PROXY='http://192.168.0.2:3128'
else
unset HTTP_PROXY
fi
done
Also please make sure that you set the firefox proxy to “Use the System proxy”.
2 comments August 13, 2009
Alt+F2
I just wrote a class in ruby for the backend for the ALT+F2 replacement i’m working on.
here is the class in ruby
#! /usr/bin/ruby
require 'pathname'
class Doer
def initialize
path=ENV['PATH'].to_s.split(":")
@li=""
@cmdlst=[]
@command=Hash.new()
path.each do |indpath|
inpath=Pathname(indpath)
files=inpath.children(false)
files.each do |fls|
testval=FileTest::executable?(File.join(indpath,fls))
if testval
cmdpth=File.join(indpath,fls).to_s
cmd=fls.to_s
@command.store(cmd,cmdpth)
@cmdlst.push(cmd+"\n")
end
end
end
@cmdlst=@cmdlst.join
end
def updatefind(str)
pattern=Regexp.compile("#{str}.*",Regexp::IGNORECASE)
@li=@cmdlst.scan(pattern)
return @li
end
end
You can try it by passing a string to the updatefind function for getting the list of commands similar to the give string.
For eg:
x=Doer.new()
puts x.updatefind(ARGV[0])
if you are passing the string from command line..
Hope ppl find this useful!!
will update soon with the Qt front end as soon i’m done with it.
Add comment April 12, 2009
Amarok-Music Tracker for pidgin
There is a music tracker plugin that comes along with the pidgin 30 plugins.. but that doesn’t work good for me and i use only amarok for music. So i decided to write myself a music tracker.
A file in .purple/status.track in the home folder is used to keep track of the available and away status.
This one needs to be started explicity with the pidgin.
Here is the code:
pstatus=`cat $HOME/.purple/status.track`
title=$(dcop amarok player title)
title=`echo $title|cut -d'-' -f1`
album=$(dcop amarok player album)
album=`echo $album|cut -d'-' -f1`
purple-remote "setstatus?status=$pstatus&message=Amarok Now Playing: $title : $album"
while [ TRUE ]; do
pstatusn=`cat $HOME/.purple/status.track`
if [ "$pstatusn" != "$pstatus" ]
then
purple-remote "setstatus?status=$pstatusn&message=Amarok Now Playing: $title : $album"
pstatus=$pstatusn
fi
newtitle=$(dcop amarok player title)
stat=$(dcop amarok player isPlaying)
newtitle=`echo $newtitle|cut -d'-' -f1`
if [ "$stat" = true ]
then
if [ "$title" != "$newtitle" ]
then
album=$(dcop amarok player album)
album=`echo $album|cut -d'-' -f1`\
newtitle=$(dcop amarok player title)
newtitle=`echo $newtitle|cut -d'-' -f1`
purple-remote "setstatus?status=$pstatus&message=Amarok Now Playing: $newtitle : $album"
title=$newtitle
fi
elif [ "$stat" = false ]
then
purple-remote "setstatus?status=$pstatus&message=Amarok Now Playing: Amarok Paused"
fi
done
You can also append a message with the music name if you want by editing the script at the purple-remote command lines
6 comments December 30, 2008
Right click>Set As wallpaper ;)
Yeah i can’t open it it everytime then navigate to all the menus and set my background. So i wanted a right click and set as wallpaper.So here it is. First of all let me tell you the limitation of the script. I’m not able to handle files with a space in its path. I guess ‘ll try to fix tat soon. So i had to rename everything on my hdd by replacing the space with an _ .
So here is the “renamer” script first
find -type f -name "*." > files ;
while read x;
y=`echo $x|sed 's;%20;_;g'
mv "$x" "$y" ;
done < files ;
Enter the path to the wallpaper folder in the your path and the extension like .jpg .png etc in the extension field one by one and run the script.
Next is the objective script. I know this one is very bad script here. But my job was done.. so ‘m happy..
write the code in a file at ~/.gnome2/nautilus-scripts and make it an exectuable. You will get the script at the right click as in the old scripts.
test=$NAUTILUS_SCRIPT_SELECTED_URIS
test=`echo $test|sed 's;file\:\/\/;;'`
gconftool-2 -t string -s /desktop/gnome/background/picture_filename "$test"
4 comments November 14, 2008
ISO Mounter
Inspired by the script from gnome-look.org i decided to make my own iso mounter with the GUI
This one mounts your iso file to /media/ISO
right click ,initate script and enter the sudo password and mount it
similarly you can unmount it.
Mounter code:
gksudo -u root -k -m "got r00t?
" echo "this statement is to create a sudo environment">/dev/null
if sudo mount -o loop -t iso9660 “$*” /media/ISO
then
zenity –info –title “ISO Mounter” –text=”ISO Mounted successfuly /media/ISO”
else
zenity –error –title “ISO Mounter” –text=”Error occured during mount operation. Check filetype of $* and if /media/ISO is busy!!”
fi

Unmounter code:
gksudo -u root -k -m "got r00t?
" echo "this statement is to create a sudo environment">/dev/null
if grep “$*” /etc/mtab
then
if zenity –question –title ISO Mounter –text “Confirm unmount”
then
sudo umount “$*”
fi
else
zenity –error –title ISO Mounter –text “Nothing Mounted”
fi

Sorry that you will not be able to unmount it via the default nautilus cd unmount method. You will either have unmount using my script or by using the command
sudo umount /media/ISO
I’ve made the code a little future upgradable.. So whatever u think is useless is not. Coz i have things in mind to implement but now there was no enuf time to code.
For installation use the tar package provided.
To install it extract the .tar.gz, navigate in and type
./install
click here to download the tar
2 comments November 10, 2008
Time Up Dude Ver2
Additional Features form old version
## Snooze for 10mins
## Starts triggering only if HDD temperature above 40 degrees
## Pops when temp is above 49 degrees wateva the time it isĀ
## Additional package needed from previous version : hddtemp
## Resets the counter to 60 when system goes idle for 5 mins
sudo apt-get install hddtemp
The new code is (more…)
1 comment September 23, 2008
Time Up Dude ver1.01
Necessity is the mother of all inventions. Yes that is true. And for inventions to take place there should be a motivator.
I had very bad HDD crashes recently and i think the problem is the extreme use of my system which is on almost for 22 hrs a day on holidays and 14hrs on weekdays.
So i decided to make a tool to notify me when it is 1hr of use and give me options to shutdown and continue using.
This was the first thing i did after installing an OS on the replaced HDD this time. My of the insipriation for trying it out is my senior at college srijith.
He also has a similar tool but more better.
So here goes the stuff.
my username is cyriac
and i belong to a group script on my system.
Basic things to do prior to working my script.
edit the sudoers file.
log in as root
visudo
add the line
%script ALL=NOPASSWD: ALL
note that i belong to the group script
now create a folders in the home directory with names /logs and /logs/timeupdude
mkdir ~/logs/timeupdude -p
make a textfile with name timeupdude
and paste the code below.
work=TRUE
echo "60" > /home/cyriac/logs/timeupdude/testf
while [ $work = TRUE ]
do
tt=`cat /home/cyriac/logs/timeupdude/testf`
if [ $tt -eq 0 ]
then
ans=`zenity - -title "TIME UP DUDE" - -text "YOUR UPTIME IS OVER AN HOUR NOW " - -list - -radiolist - -column "SELECTION" - -column "ACTION" False SHUTDOWN True CONTINUE_WORKING`
if [ $ans = CONTINUE ]
then
echo "60" > /home/cyriac/logs/timeupdude/testf
else
sudo shutdown -ah now
fi
else
sleep 60
tt=`expr $tt - 1`
echo $tt> /home/cyriac/logs/timeupdude/testf
fi
done
Save the file and make it excec by
chmod +x timeupdude
copy the file to /etc/init.d
and add it to the boot up
update-rc.d timeupdude defaults
Now restart the computer and the timeupdude is on the run..
The tool first shows the screen below when it is 1hr.
If SHUTDOWN is pressed the system shuts down else if CONTINUE_WORKING is pressed you can continue working until this window again pops up in 30mins
You can also edit the time by scannin my script.
And this script works with Gnome machines only.
Please note that the options in the zenity needs to be – - ie minusminus. not –
Will come up with a new version with the ideas my `guru`;) suggested..
Please leave comments so that i can find mistakes i made and improve..
2 comments September 21, 2008










