Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'm running Linux Mint. I have a script the gets run whenever I login that remaps my mouse buttons. However, when the computer suspends, the mouse buttons revert to their default mapping.

I'd like to have my script re-run whenever the computer awakes from suspend. How can I do this? Currently I'm just calling the script from the "Startup Applications" control panel.

I already tried putting some copies of my script in subdirectories within /etc/pm, but that didn't work.

EDIT: Actually when my computer comes out of suspend, sometimes the mouse mapping hasn't been reset. But when I turn the monitors off, then back on (using their power buttons) the mouse mapping has always been reset. How can I prevent this? (Or where can I put a script so it will run when the monitors turn back on?)

share|improve this question

It is possible that the reason why your script "doesn't work" is due to several reasons:

  • The script is not executable. It should be executable (run chmod +x on it).
  • The script is running as root when the system reboots (I think). To run it as your user, try something like:

case "$1" in
sudo -u USERNAME env DISPLAY=:0 zenity --info --text "do stuff on suspend" ;;
sudo -u USERNAME env DISPLAY=:0 zenity --info --text "do stuff on resume"

(stolen shamelessly from AskUbuntu).

Obviously you can replace the zenity call with the action you want to take when resuming from suspend. USERNAME should be the user you're normally logged in as (if this changes a lot, that could get complicated).

share|improve this answer
It's executable. I added sudo -u but that didn't fix it, though clearly I needed to add that---just forget to include that before. Thanks for pointing that out. – Jeff Aug 11 '13 at 21:43
+1 for showing thaw|resume - the template script I was looking for only had thaw, and I needed resume to get out of a sleep, rather then suspend state. – davidgo Sep 1 '13 at 8:36

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .