2

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.

gg-79
  • 610
  • 1
  • 5
  • 16
  • 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 02 '13 at 09:45
  • Yes, the script runs fine from the command line. – gg-79 Jun 02 '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 02 '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 03 '13 at 07:30
  • Sorry, perhaps I was unclear. Use just the line touch /tmp/resumed_okay without anything else. – Sparhawk Jun 03 '13 at 10:47
  • Ok, I added 'touch /tmp/resumed_okay' before the first exit of the original script. In this case, the file was created. The problem is due to the fact that I want to run the commands as su I guess.. – gg-79 Jun 03 '13 at 11:18
  • Okay good, so now we know that the resume script is being triggered at least. I don't quite understand what the commands you are trying to run are, though. zenity is for creating dialogue boxes, right? So it seems like your commands are to create a dialogue box but not do anything else? – Sparhawk Jun 03 '13 at 11:46
  • Ok, I understand I made a mess. What I want to do is to execute the lines 'synclient TapButton2=0' and 'modprobe iwlagn 11n_disable=1' automatically at resume from suspend. Any idea how to change the script to achieve that? – gg-79 Jun 03 '13 at 15:18
  • Ah, I just checked the link you gave. There they used zenity to display the dialogue box just as an example. – Sparhawk Jun 03 '13 at 16:26

1 Answers1

1

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.
Sparhawk
  • 6,929
  • 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 03 '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 03 '13 at 17:04
  • Nice find (and a +1 for it too :-). Glad I could help! – Sparhawk Jun 04 '13 at 01:18