The Computer Oracle

Is there a way to call a script when Ubuntu wakes up from suspend or hibernate mode?

--------------------------------------------------
Rise to the top 3% as a developer or hire one of them at Toptal: https://topt.al/25cXVn
--------------------------------------------------

Music by Eric Matyas
https://www.soundimage.org
Track title: Puzzle Game 5 Looping

--

Chapters
00:00 Is There A Way To Call A Script When Ubuntu Wakes Up From Suspend Or Hibernate Mode?
00:29 Accepted Answer Score 14
01:06 Thank you

--

Full question
https://superuser.com/questions/60473/is...

--

Content licensed under CC BY-SA
https://meta.stackexchange.com/help/lice...

--

Tags
#ubuntu #script #hibernate #suspend

#avk47



ACCEPTED ANSWER

Score 14


First of all, you have found a bug. The user is not supposed to bother with the touchpad configuration being lost after resume. You go to Launchpad and report this bug, so that it can be properly identified and fixed.

Then, after that, go to /etc/pm/sleep.d/ and add a script that will be executed before and after suspending or hibernating. The script receives a single command-line parameter "suspend", "resume", "hibernate" or "thaw", it should inspect this argument and take the appropriate action. There should be at least one other script in that directory (99laptop-mode) that you can use as a reference.