You are not logged in.
I have the following script that I'm trying to run from Openbox that tells me if my cap lock or numb lock is on or off. When I run this from the cli it works correctly, but if launched from my keybindings in Openbox it is always telling me that the numb lock or cap lock is on.
!/bin/bash
#used to send message to desktop when
#caps lock and num lock are on
#must have libnotify installed or
#xfce4-notifyd if using xfce
#set path to icons
caps_on_icon=/home/gumper/Bin/icons/capslock-on.xpm
caps_off_icon=/home/gumper/Bin/icons/capslock-off.xpm
numbs_on_icon=/home/gumper/Bin/icons/numlock-on.xpm
numbs_off_icon=/home/gumper/Bin/icons/numlock-off.xpm
#check to see if caps or nums are on or off
status=`xset q | grep LED | cut -d ':' -f4`
#check which pressed key is calling script by checking
#argument sent to script
key_press=$1
if [$status = 00000000 ]; then
status=both_off
elif [$status = 00000001 ]; then
status=caps_on
elif [$status = 00000002 ]; then
status=numbs_on
elif [$status = 00000003 ]; then
status=both_on
else status=error
fi
case "$key_press" in
cap_lock)
case "$status" in
both_off) notify-send "Caps lock" " OFF " -i $caps_off_icon &;;
caps_on ) notify-send "Caps lock" " ON " -i $caps_on_icon &;;
both_on ) notify-send "Caps lock" " ON " -i $caps_on_icon &;;
numbs_on) notify-send "Caps lock" " OFF " -i $caps_off_icon &;;
error ) notify-send "Shut'er down clancy" &;;
esac ;;
numb_lock)
case "$status" in
both_off) notify-send "Num lock" " OFF " -i $numbs_off_icon &;;
caps_on ) notify-send "Num lock" " OFF " -i $numbs_off_icon &;;
both_on ) notify-send "Num lock" " ON " -i $numbs_on_icon &;;
numbs_on) notify-send "Num lock" " ON " -i $numbs_on_icon &;;
error ) notify-send "Shut'er down clancy" &;;
esac
esac
exit 0The keybindings that I'm using in Openbox are as follows:
<keybind key="Num_Lock">
<action name="Execute">
<command>sh ~/Bin/notify-send_cap_message.sh numb_lock</command>
</action>
</keybind>
<keybind key="Caps_Lock">
<action name="Execute">
<command>sh ~/Bin/notify-send_cap_message.sh cap_lock</command>
</action>
</keybind> I'm assuming that it has something to do with "xset" but I'm not sure what.
Any ideas on why this doesn't work correctly when called from Openbox?
Ready yourselves, ready yourselves
Let us shine the light of Jesus in the darkest night
Ready yourselves, ready yourselves
May the powers of darkness tremble as our praises rise .... Casting Crowns-Until The Whole World Hears.
Offline
I'm no guru at all, but i'd look into this;
status=`xset q | grep LED | cut -d ':' -f4`And change it to;
status=$(xset q | grep LED | cut -d ':' -f4)In short, brackets instead of those sinlge qoutes back ticks. (I knew that)
Last edited by swanson (2012-04-22 18:43:36)
Offline
I'm no guru at all, but i'd look into this;
status=`xset q | grep LED | cut -d ':' -f4`And change it to;
status=$(xset q | grep LED | cut -d ':' -f4)In short, brackets instead of those sinlge qoutes.
Just tried your suggestion and I have the same results.
Thanks though.
Ready yourselves, ready yourselves
Let us shine the light of Jesus in the darkest night
Ready yourselves, ready yourselves
May the powers of darkness tremble as our praises rise .... Casting Crowns-Until The Whole World Hears.
Offline
In short, brackets instead of those sinlge qoutes.
Those look like back ticks to me. Not single quotes. Not that your suggestion is wrong though. Would probably be worth looking into actually. What catches my eye is this:
<command>sh ~/Bin/notify-send_cap_message.sh cap_lock</command>Maybe openbox is not expanding "~". Also, maybe you can try (as long as your script has executable permissions (I am sure it probably does just wanted to throw that in there)) just calling the full path of the script without sh . Nevermind I call bash in mine and it works fine. I do put the full path in though (bash /home/username/path/to/script.sh).
Offline
Ok, I have another piece to the puzzle. If I add this:
sleep 1before the "xset" command, then it works ok. So it must be a timing issue somewhere?
Ready yourselves, ready yourselves
Let us shine the light of Jesus in the darkest night
Ready yourselves, ready yourselves
May the powers of darkness tremble as our praises rise .... Casting Crowns-Until The Whole World Hears.
Offline
Ok, I have another piece to the puzzle. If I add this:
sleep 1before the "xset" command, then it works ok. So it must be a timing issue somewhere?
Are you adding it to the script itself or to the openbox keybind command?
Offline
Gumper wrote:Ok, I have another piece to the puzzle. If I add this:
sleep 1before the "xset" command, then it works ok. So it must be a timing issue somewhere?
Are you adding it to the script itself or to the openbox keybind command?
I'm adding it to the script right before the "xset" command is called.
Last edited by Gumper (2012-04-22 18:59:40)
Ready yourselves, ready yourselves
Let us shine the light of Jesus in the darkest night
Ready yourselves, ready yourselves
May the powers of darkness tremble as our praises rise .... Casting Crowns-Until The Whole World Hears.
Offline