On 2017-04-02 08:08, Andrei Borzenkov wrote:
02.04.2017 04:53, Carlos E. R. пишет:
Hi,
I wrote a /usr/lib/systemd/system-sleep/mine-sleep script. I have in it:
#!/bin/sh
case $1 in pre) echo "mine-sleep locking screen" DISPLAY=:0.0 xscreensaver-command -lock
...
Why does it fail with "xscreensaver-command: can't open display :0.0"? When I do it as root in a terminal it does work.
How exactly are you running command "as root in terminal"? After "su"? When logging in on another vt?
su - Tried now in a vt. I get this text: minas-tirith:~ # xscreensaver -lock xscreensaver: 09:45:54: warning: $DISPLAY is not set: defaulting to ":0.0". No protocol specified xscreensaver: 09:45:54: Can't open display: :0.0 xscreensaver: 09:45:54: initial effective uid/gid was root/root (0/0) xscreensaver: 09:45:54: running as nobody/nobody (65534/65533) xscreensaver: 09:45:54: This is probably because you're logging in as root. You shouldn't log in as root: you should log in as a normal user, and then `su' as needed. If you insist on logging in as root, you will have to turn off X's security features before xscreensaver will work. Please read the manual and FAQ for more information: http://www.jwz.org/xscreensaver/faq.html http://www.jwz.org/xscreensaver/man.html minas-tirith:~ # If does not change if I set DISPLAY first. I have to go, can't read that doc now. -- Cheers / Saludos, Carlos E. R. (from 42.2 x86_64 "Malachite" (Minas Tirith))