Read the statement by Michael Teeuw here.
ubuntu - run the script before sleeping and after waking up the PC
-
Hello everyone, can I ask for help? I’m sorry, I’m using a translator, I can’t speak English.
I am using the new Ubuntu, where I have Domoticz server and MagicMirror running.
after 15 minutes the PC goes to sleep and then wakes up with PIR (ESP8266).After waking up, it takes a long time for the domoticz server to start working and sending Information to MagicMirror. I don’t want to solve it with service monitor.
I would like to set up a script:
before putting the PC to sleep run “sudo service domoticz.sh stop”
after waking up the PC run “sudo service domoticz.sh start”
it works reliably in the command line, it just needs a password that I enter and it’s ok.I saw somewhere that something like this can be used, but I don’t know exactly where to write, save and that it doesn’t ask for a password. Would someone be willing to write the exact procedure where to write what and save? I found a lot of versions and maybe I got it wrong or the instructions are for older Ubuntu
First of all thank you very much for the joy and newbie to ubuntu.
#!/bin/sh PATH=/sbin:/usr/sbin:/bin:/usr/bin case "$1" in pre) #code execution BEFORE sleeping/hibernating/suspending ;; post) #code execution AFTER resuming ;; esac exit 0
-
what does this
PC goes to sleep and then wakes up with PIR (ESP8266).
is there a MagicMirror module? or??
whatever does that is where you want to call your script to do the server shutdown and startup
exactly what you do on the console.if this requires sudo authority, you can add your userid to the /etc/sudoers file
to not prompt for your password
(google search)