Когда это выполняется,
#!/bin/bash
#
# located in /lib/systemd/system-sleep/
# Created 4/2/19
exec 2> /tmp/systemd_suspend_test_err.txt
if [ "${1}" = "pre" ]; then
# Do the thing you want before suspend here
echo "we are suspending $(date)." > /home/andy/Downloads/message.txt
elif [ "${1}" = "post" ]; then
# Do the thing you want after resume here
echo "and we are back from being suspended $(date)" >> /home/andy/Downloads/message.txt
#sleep 10
#notify-send "Computer is returning from suspend." -t 2000
gxmessage does NOT work and neither does inotify-send
/usr/bin/gxmessage -fg red -font 'sans 30' -timeout 3 'Back from being suspended.'
fi
Я получаю это в /tmp/systemd_suspend_test_err.txt.
Unable to init server: Could not connect: Connection refused
gxmessage: unable to initialize GTK
Перед приостановкой можно записать xhost +, который позволит клиентам соединяться от любого хоста (не рекомендуемый в производственном ENV - проблемы безопасности). Затем приостановите и возобновитесь, поле с красным текстом появляется.
# gxmessage works IF xhost + is run first.
gxmessage -timeout 5 -fg red -display :0 'Back from being suspended.'