During the suspend and resume phases, Ubuntu (really every Linux system using pm-utils) executes a series of scripts located in the directory /etc/pm/sleep.d/
; they are executed in alphabetic order --- from 0..9A..Z during suspend, and the other way around during resume. Conventionally all scripts start with a number (00,01,02...) and there is also a conventional meaning to the numbering. More info on the really well made page on Arch Linux doc site. Scripts are called with an argument that can be "suspend", "resume", "hibernate", "thaw" so they can know why they are called.
So if you want to unload and reload the wacom module at suspend and resume, respectively, you can add a script --- for example, /etc/pm/sleep.d/04_myscript
with the content:
#!/bin/sh
case "$1" in
resume|thaw)
modprobe wacom
;;
suspend|hibernate)
rmmod wacom
;;
esac
exit 0
And remember to make the script executable and readable by root, with
chmod 755 /etc/pm/sleep.d/04_myscript
Caveats:
all of the above must be done as root; so to edit the script and to change its permission you have to add the appropriate sudo
.
this is really a hack --- unloading and reloading the module can confuse applications. For example, it will definitely confuse xournal
that would not be able to see the touchscreen after tat unless you restart it.
sudo rmmod wacom; sudo modprobe wacom
? If it works it can be easily scripted. – Rmano Aug 14 '14 at 14:45