Thursday, May 2, 2024
 Popular · Latest · Hot · Upcoming
7
rated 0 times [  7] [ 0]  / answers: 1 / hits: 3654  / 3 Years ago, tue, september 14, 2021, 8:05:26

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.


More From » login

 Answers
1

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!



[#27664] Wednesday, September 15, 2021, 3 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
atelti

Total Points: 194
Total Questions: 129
Total Answers: 110

Location: North Korea
Member since Tue, Jun 16, 2020
4 Years ago
atelti questions
Fri, Aug 26, 22, 02:44, 2 Years ago
Sat, Dec 10, 22, 21:37, 1 Year ago
Sat, Apr 9, 22, 13:57, 2 Years ago
;