Originally Posted by
daou
Replacing sudo by su -c didn't make X app start, but it made the X app output some error (there was no output before) :
Code:
Cannot open display:
It made me think that maybe the environment was not correctly set by btnx so I examined the environment with 'export' from my script and found out that it was lacking X window variables.
Then all became clear : when btnx starts the first time from init.d there is no X window so when it executes commands it spawns shells without X window support.
When manually restarted, btnx receives current xterm environment so X apps can run.
Anyway, my solution is to setup DISPLAY and XAUTHORITY at the begining of my script like this :
Code:
#!/bin/sh
# /root/bin/btnx-su.sh
umask 022 # To read/write files.
export DISPLAY=':0.0'
export XAUTHORITY=`ls /tmp/.gdm*`
su -c "$1" odierick
The above script is a wrapper. Here is the actual function of the button :
Code:
#!/bin/sh
# /home/odierick/bin/DoubleClic.sh
xte 'mouseclick 1' 'mouseclick 1' 2>&1 >/home/odierick/btnx.log
And in btnx-config the button is associated with the command :
Code:
/root/bin/btnx-su.sh /home/odierick/bin/DoubleClic.sh
And finally I can execute X apps with a mouse button without restarting btnx!
What is not clear is why restarting with btnx-config doesn't provide a full environment to btnx.
Should you investigate this further here is some information :
Initially btnx environment has no DISPLAY nor XAUTHORITY variable so at first commands have no X window support.
When restarted in btnx-config those variables become :
Code:
export DISPLAY=':0.0'
export XAUTHORITY='/tmp/libgksu-cvFQDg/.Xauthority'
It seems that X apps cannot open display with this environment.
When btnx is manually restarted it finally is :
Code:
export DISPLAY=':0.0'
export XAUTHORITY='/tmp/.gdmZQ3GAU'
and X apps can open display.
Anyway, my issue is resolved, thanks Daou!
Bookmarks