3

I have a custom script (uses $DISPLAY) for setting up the extra buttons on my mouse. I want to run this script every time I log into the system. I have added the script as a Startup Application via the Ubuntu (18.10) GUI (Gnome 3.30.1). It runs after I turn on my PC or reboot it, but fails to run after the PC resumes from sleep.

How can I make the script run after the PC resumes from sleep? (Preferably without having to maintain a separate script).

Naximus
  • 131

2 Answers2

6

Run Script when Resuming from Suspend

Create a new file /lib/systemd/system-sleep/resume and copy in:

#!/bin/sh

case $1/$2 in pre/) echo "Going to $2..." # Place your pre suspend commands here, or exit 0 # if no pre suspend action required exit 0 ;; post/) echo "Waking up from $2..." # Place your post suspend (resume) commands here, or exit 0 # if no post suspend action required mouse_script.sh ;; esac

NOTE: replace user mouse_script.sh (third line from the bottom) with your script name. Provide the full path name if the script is not in your path (echo $PATH).

Then mark it executable with the command:

sudo chmod +x /lib/systemd/system-sleep/resume
-1

You can call it from /etc/init.d/rc.local

sudo nano /etc/init.d/rc.local

and add the path to your script