Bash script not working as required with xbindkeys
- by RanRag
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.