Bash script not working as required with xbindkeys

Posted by RanRag on Ask Ubuntu See other posts from Ask Ubuntu or by RanRag
Published on 2012-07-05T14:22:05Z Indexed on 2012/11/26 17:27 UTC
Read the original article Hit count: 399

Filed under:
|
|
|

I made a simple bash script to display a notification whenever my capslock key is pressed. It works fine when I call it like bash capsnotify.sh.

The problem now is when I bind my above script to capslock key using xbindkeys tool it doesn't work as required. It shows a notification caps ON when my caps is on but it doesn't show caps OFF notification when my caps is off instead it again shows the caps ON notification.

capsnotify.sh

#!/bin/bash

value=$(xset -q | awk '/Caps/ {print $4}')

if [ "$value" == "on" ]

then    
    notify-send "caps ON"

elif [ "$value" == "off" ]

then    
    notify-send "caps OFF"    
fi

.xbindkeysrc

"bash /home/ranveer/capsnotify.sh"
  m:0x2 + c:66

So, the problem is after binding my caps lock key on both events(on/off) it shows caps ON notification.

© Ask Ubuntu or respective owner

Related posts about 12.04

Related posts about bash