Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

I am trying to run a script after resuming from suspend. I need this script to disable the right click in the touchpad and to fix a problem of my wifi. Accordingly to How to run script after resume and after unlocking screen I placed a script called autorun.sh in /etc/pm/sleep.d:

#! /bin/bash 
case "$1" in
hibernate|suspend)
    sudo -u giorgio env DISPLAY=:0 zenity --info synclient TapButton2=0
    sudo -u giorgio env DISPLAY=:0 zenity --info modprobe iwlagn 11n_disable=1
    exit
    ;;
thaw|resume)
    sudo -u giorgio env DISPLAY=:0 zenity --info synclient TapButton2=0
    sudo -u giorgio env DISPLAY=:0 zenity --info modprobe iwlagn 11n_disable=1
exit
;;
esac
exit

The problem is that when I resume, I realize that the script didn't actually work (the right click is not disabled) and in the log file /var/log/pm-suspend.log I have this lines:

Running hook /etc/pm/sleep.d/autorun.sh resume suspend:

(process:15304): Gtk-WARNING **: Locale not supported by C library.
        Using the fallback 'C' locale.

(process:15310): Gtk-WARNING **: Locale not supported by C library.
        Using the fallback 'C' locale.

What I am missing? Thanks in advance.

share|improve this question
    
Instead of the commands you have there, can you troubleshoot with touch /tmp/resumed_okay or something similar? Also, presumably the commands run fine if you run them manually from the command line? (Also, you don't need the exits in the script.) –  Sparhawk Jun 2 '13 at 9:45
    
Yes, the script runs fine from the command line. –  gg-79 Jun 2 '13 at 10:10
    
Good, so now try running dummy actions with touch /tmp/resumed_okay in your autorun script. Is the file created on resume? –  Sparhawk Jun 2 '13 at 10:41
    
Added this line: sudo -u giorgio env DISPLAY=:0 zenity touch /tmp/resumed_okay No file was created on resume –  gg-79 Jun 3 '13 at 7:30
    
Sorry, perhaps I was unclear. Use just the line touch /tmp/resumed_okay without anything else. –  Sparhawk Jun 3 '13 at 10:47

1 Answer 1

up vote 1 down vote accepted

Try this:

#!/bin/bash 
case "$1" in
    hibernate|suspend|thaw|resume)
        export DISPLAY=:0.0
        sudo -u giorgio synclient TapButton2=0
        sudo -u giorgio modprobe iwlagn 11n_disable=1
        ;;
esac

A few things.

  • You had two branches to your case statement, but they both did the same thing, so I shortened it to a single branch. I don't think that you can have anything other than hibernate|suspend|thaw|resume, but just in case, I left it there.
  • As per my comments, you don't need exit.
  • I'm not 100% sure what env DISPLAY=:0 does, but I replaced it with something that I know works (and is more concise).
  • As per my comments, zenity is for creating dialogue boxes, so I think you must have gotten a bit confused somewhere.
share|improve this answer
    
I think this solution is correct. However, when the laptop finish the resume the effect of 'synclient TapButton2=0' is disappeared, that is, the value of TapButton2 is 3 again. I think when resuming, it runs a script after running my autorun, that recover the old value of TapButton. Is it possible to make it run autorun.sh in the last place? –  gg-79 Jun 3 '13 at 16:55
    
I solved renaming autorun.sh as 00-zrun.sh. Now it runs it at the very end of the resume process and the action is permanent. –  gg-79 Jun 3 '13 at 17:04
    
Nice find (and a +1 for it too :-). Glad I could help! –  Sparhawk Jun 4 '13 at 1:18

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.