In Saucy salamander I need to run a script each time I login then each time I unlock the session after manual lock or auto sleep.
I can't use "Startup Application" for that because it wouldn't trigger on unlock.
In Saucy salamander I need to run a script each time I login then each time I unlock the session after manual lock or auto sleep.
I can't use "Startup Application" for that because it wouldn't trigger on unlock.
Found this, which was made by Ubuntu Forums user opus1. Maybe it can help.
This is what the post gives as a solution:
For anyone interested, here's what I did: I looked at the logs
(specifically /var/logs/auth.log) and saw that an entry is made when
ever the password is checked and accepted. My log said:
Aug 7 14:10:57 mumble gnome-screensaver-dialog: gkr-pam: unlocked login keyring
Ultimately I found an application called "Swatch" which monitors a log
for you and will run a script when a string that you specify appears
in that log. Swatch requires a config file (.swatchrc), and mine looks
like this:
watchfor /unlocked login keyring/
exec /root/.gnome2/nautilus-scripts/wakeServer
where "/unlocked login keyring/" is the string to look for and "exec"
defines the script to run when it is found. My wakeServer script looks
like this:
#!/bin/bash
#wake the server
wakeonlan AA:BB:CC:DD:EE:FF
#record info in the log file
myVar="woke server at login:"
echo "$myVar">>/home/me/.serverWake.log
date>>/home/me/.serverWake.log
where "AA:BB:CC:DD:EE:FF" is the MAC address of my server.
Swatch will need to be entered as a start-up application (create an
entry in System | Preferences | Startup applications called
"runSwatch" and make the command "swatch --tail-file /var/log/auth.log
--daemon". (In Debian, only root can read logs So the start up command needs to be prefaced with "sudo" and swatch will need to be added to
the sudoers file without a password. In Ubuntu it appears non-root
users can read logs. There could be a security issue with granting
password-less access to swatch, but in my case it seems acceptable).
So far it has worked perfectly!