[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

bash, xbindkeys and dual screen



Hi all,

I have a problem - basically with some bash codes. I have dual screen and one mouse, and I want to switch my mouse back and forth from screen 1 to screen 2 etc by pressing a keyboard. In order to do that, I did the following:

1. install switchscreen, then by typing "switchscreen 0" or "switchscreen 1" will switch me to Desktop 0 or 1.

2. typing "switchscreen 0" or 1 is annoying, then I create a script /bin/switchnow like below:
########################
#!/bin/bash

case $DISPLAY in
 :0.0 ) exec switchscreen 1
 ;;
 :0.1 ) exec switchscreen 0
esac
########################
and make it executable, then now by typing just switchnow on terminal, I will move back and forth from Desktop 0 and 1. Obviously it works :)

3. I install xbindkeys, find the corresponding key and create ~/.xbindkeysrc as follow
########################
# shortcut 2
"switchnow"
m:0x0 + c:118
########################

Okey, everything seems to be done now. I press the key, and from Desktop 0, I am switched to Desktop 1. But when I press the same key again, nothing happens. :(

It *seems* that when xbindkeys works and executes switchnow, the value of DISPLAY is kept unchanged to be :0.0. But in desktop 1, open terminal and when I type "echo $DISPLAY" then I get :0.1. I guess I wrote the script incorrectly, or did I miss something here?

I do not know programming, and do not know bash either. So please do not blame me if I am too noob to bash :D.

Thanks a million,

KC.



Reply to: