Category Archives: hotkeys

Running custom apps on laptop using hotkeys

This is a continuation to earlier post which speaks of configuring hotkeys on a linux, using xbindkeys. In addition here is a package for slackware 13 64 bit – xbindkeys-1.8.3-x86_64.txz. Also the source is here, so if you are on a different distribution or another o/s, you can get the source and compile it for yourself. We shall be adding some more eyecandy by adding an on screen display (OSD). Here we shall make use of xosd. Again, the source for xosd is here. And the package is here – xosd-2.2.14-x86_64.txz.

So lets begin cooking. Get the packages and install them. Once this is done, we need to find the keycode using ‘xev’ as mentioned in earlier post. In this upgraded version, we run a small bash script which does the tasks of calling osd_cat to show some meaningful messages on the screen and run the application. In a few scripts we also read the status of some switches / variables and swap the status from on off or mute unmute.

Below is part of the .xbindkeysrc file

“sh $HOME/scr/launch.firefox.sh”
c:180

“sh $HOME/scr/headfone.switch.sh”
Mod4 + c:74

“sh $HOME/scr/wifi_switch.sh”
c:246

“sh $HOME/scr/launch.amarok.sh”
c:163

“sh $HOME/scr/master.audio.switch.sh”
c:121

“sh $HOME/scr/launch.dolphin.sh”
c:156

And here we have the scripts

headphone.switch.sh

if [ `amixer sget Front | grep -i 'Front Left:' | grep -c off` == "1" ]; then
  amixer -q sset Master unmute
  amixer -q sset Side unmute
  amixer -q sset Front unmute
  amixer -q sset Center unmute
  amixer -q sset LFE unmute
  amixer -q sset Surround unmute
  osd_cat -d 2 -c red -p middle -A centre -f “-adobe-helvetica-bold-r-normal-*-*-300-*-*-p-*-*-*” $HOME/scr/messages/headfone.switch.off.txt &
  sleep 3s
  kill %1
else
#  amixer -q sset Master mute
  amixer -q sset Side mute
  amixer -q sset Front mute
  amixer -q sset Center mute
  amixer -q sset LFE mute
  amixer -q sset Surround unmute
  osd_cat -d 2 -c green -p middle -A centre -f “-adobe-helvetica-bold-r-normal-*-*-300-*-*-p-*-*-*” $HOME/scr/messages/headfone.switch.on.txt &
  sleep 3s
  kill %1
fi

launch amarok

amarok &
osd_cat -d 2 -p middle -A centre -c green -f “-adobe-helvetica-bold-r-normal-*-*-300-*-*-p-*-*-*” $HOME/scr/messages/amarok.txt &
sleep 2s
kill %2
exit 1

wifi switch

if [ `/sbin/iwconfig wlan0 | grep -c Tx-Power=off` == "1" ]; then
  sudo /sbin/iwconfig wlan0 txpower on
  osd_cat -d 2 -p middle -A centre -c green -f “-adobe-helvetica-bold-r-normal-*-*-300-*-*-p-*-*-*” $HOME/scr/messages/wifi.on.txt &
  sleep 3s
  kill %1
  #echo “code is beyond”
else
  sudo /sbin/iwconfig wlan0 txpower off
  osd_cat -d 2 -p middle -A centre -c red -f “-adobe-helvetica-bold-r-normal-*-*-300-*-*-p-*-*-*” $HOME/scr/messages/wifi.off.txt &
  sleep 3s
  kill %1
  #echo “working :)
fi

Looks like this >>>

http://sites.google.com/site/psibianopen/Home/wifi.off.jpeg?attredirects=0

Bluewhite64 12.2 package : xbindkeys-1.8.2 and setting up hot keys on laptops

The package : xbindkeys-1.8.2.tgz and here is part of my configuration file for binding the keys :

#increase volume by 5%
“amixer -c 0 sset Master playback volume 5%+ &> /dev/null”

c:176

#decrease volume by 5%
“amixer -c 0 sset Master Playback Volume 5%- &> /dev/null”
c:174

#execute the browser
“firefox”
c:178

“amarok”
c:236

“konqueror”
c:159

“sh /home/rahul/scr/mute.sh”
c:160

Also note that this configuration works for the laptop acer aspire as 7530g, to find the hotkeys on your laptop / desktop keyboard, just open a new terminal, and type in “xev”, a small x window appears, let it remain active, next press the hot key and see the output in the terminal, it would be something like this:

KeyRelease event, serial 35, synthetic NO, window 0x1e00001,
root 0x13e, subw 0×0, time 2530749, (1039,664), root:(1043,734),
state 0×10, keycode 236 (keysym 0×0, NoSymbol), same_screen YES,
XLookupString gives 0 bytes:
XFilterEvent returns: False

The keycode number is what can be used in the configuration file .xbindkeysrc which stays in your home directory, viz. /home/$USER/.xbindkeysrc, and the owner of this file should be $USER. for example -

“amarok”
c:236

pressing the key would start amarok.

For muting and unmuting the sound a small script is used mute.sh, whose contents are:

snd_status=(`amixer -c 0 sget Master Playback Volume | egrep “\[on|off\]$”`)
cur_vol=$(echo ${snd_status[5]} | tr ‘[|]|%’ ‘ ‘)
echo cur_vol = $cur_vol
if [ $cur_vol == "off" ]
then
amixer -c 0 sset Master unmute #Playback Volume 0% &> /dev/null
else
amixer -c 0 sset Master mute #Playback Volume 50% &> /dev/null

After
editing the file you need to kill xbindkeys and restart if it is running for the changes to take effect.