1

systemctl hybrid-sleep or anything similar is, according to the manual, supposed to execute all scripts found in /lib/systemd/system-sleep and after that continue it's own execution. Instead it completely and utterly ignores every single script I put in there:

gnome-terminal -e "touch Documents/qwert"
while [ 1 ] 
do
    echo hi
done

^ this should go in an infinite loop after creating a file. I've also tried things like touch /home/u/Documents/qwert etc.

I'm pretty puzzled actually. It might actually be caused by the fact that hybrid-sleep, hibernate, etc. all lead to a crash before complete execution, i.e. my laptop is unable to enter any kind of power saving mode and instead goes into a completely frozen state with a blank screen - however, it logs out before that and only crashes after a couple of seconds, so I assume the scripts should be executed just fine; after all those should be executed even before logging out.

  • 1
    gnome-terminal won't run from there as there is no X server for it to connect to (it's running as root, not as your logged in user). gnome-terminal isn't needed and is overkill here anyway. just run touch /home/u/Documents/qwert without gnome-terminal -e – cas Oct 26 '15 at 22:57
  • 1
    also: 1. make sure the script is executable (with chmod +x scriptname). 2. maybe add #! /bin/sh as the first line of the script. – cas Oct 26 '15 at 22:57
  • @cas Man... I feel kinda dumb now. Adding #! /bin/sh was all that was needed. I've never had to use that before because I was starting all my scripts from the terminal. Thank you. – SaphirShroom Oct 27 '15 at 7:34
  • OK, i'll turn my comments into an answer. – cas Oct 27 '15 at 7:37
1

gnome-terminal won't run from there as there is no X server for it to connect to (it's running as root, not as your logged in user). gnome-terminal isn't needed and is overkill here anyway. Just run touch /home/u/Documents/qwert without gnome-terminal -e

also:

  1. Make sure the script is executable (with chmod +x scriptname).

  2. Add #! /bin/sh or (#! /bin/bash if you use any bash-only features) as the first line of the script.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.