Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

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
add comment

1 Answer 1

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:
#!/bin/bash

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

(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
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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