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 # xscreensaver-command: can't open display :0.0 ;; post) if [ "$2" = suspend ]; then echo "mine-sleep adjusting brigthness" echo 10 > /sys/class/backlight/acpi_video0/brightness fi ;; esac
For now, I'm interested only in the "xscreensaver-command" sequence. The rest appears to work.
I get this in the log:
** <3.6> 2017-04-01 13:35:21 minas-tirith systemd-sleep 18597 - - mine-sleep locking screen <3.5> 2017-04-01 13:35:21 minas-tirith dbus 1584 - - [system] Successfully activated service 'org.freedesktop.nm_dispatcher' <3.6> 2017-04-01 13:35:21 minas-tirith systemd 1 - - Started Network Manager Script Dispatcher Service. <3.6> 2017-04-01 13:35:21 minas-tirith systemd-sleep 18597 - - INFO: running /usr/lib/systemd/system-sleep/grub2.sleep for hibernate <3.6> 2017-04-01 13:35:21 minas-tirith systemd-sleep 18597 - - INFO: Running prepare-grub .. <3.6> 2017-04-01 13:35:21 minas-tirith systemd 1 - - Stopping Deferred execution scheduler... <3.6> 2017-04-01 13:35:21 minas-tirith systemd 1 - - Stopped Deferred execution scheduler. <3.6> 2017-04-01 13:35:21 minas-tirith systemd-sleep 18597 - - No protocol specified ** <3.6> 2017-04-01 13:35:21 minas-tirith systemd-sleep 18597 - - xscreensaver-command: can't open display :0.0
...
<3.4> 2017-04-01 13:35:31 minas-tirith systemd-sleep 18601 - - /usr/lib/systemd/system-sleep/mine-sleep failed with error code 1.
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?
Ideas?