You are not logged in.
I have a calculator mapped to the calculator key on my keyboard in Openbox. I'd like that key to shut the application down when finished. Is there a simple way to do this in rc.xml?
Last edited by skottish (2008-11-26 15:26:11)
Offline
if it has to be the same key that opens and closes it then you will need a script like this i'm pretty sure.
found this on a site for thunar scripts a long time ago and just replaced thunar with xcalc, could use any program.
need to install wmctrl for it to work.
opens a xcalc if none are open already, if ones open it closes it. so bound to your key should work the way you want.
#!/bin/sh
xcalc_wm_class="xcalc"
xcalc_exec="xcalc"
# no xcalc started, so start one
if [ -z "`wmctrl -lx | grep xcalc`" ]; then
$xcalc_exec &
else
# search for existing xcalc on current desktop and close it
current_desk=`wmctrl -d | grep '*' | cut -d ' ' -f 1`
xcalc_on_this_desk=`wmctrl -lx | grep "$current_desk[ ]*$xcalc_wm_class" | cut -d ' ' -f 1`
if [ -n "$xcalc_on_this_desk" ]; then
wmctrl -i -c $xcalc_on_this_desk
else
# no xcalcs on current desktop, so open a new one
wmctrl -x -R $xcalc_wm_class
fi;
fi;
Offline
Thanks droog.
I knew that there would be a way with a script, but I was wondering if Openbox had this built in. I've become amazed on how well designed Openbox is. Up until now every time I thought I needed to write a script, I ended up just changing single line in rc.xml to get the behavior that I wanted. This is a good solution though, and I'll use it.
Offline