NOT after boot!
NOT after restart!
NOT just after wakeup!
AFTER login (when I entered my user password after a wakeup)
Why I do not want to run the script after wakeup (before login)?
Yes, I can place the script to the /lib/systemd/system-sleep/ directory. But I get the following error: systemd-sleep[235332]: [!] There has been no profile initialized yet. Please run 'protonvpn init'.
The error means that I must run the command AFTER login.
QUESTION:
How to run the script (a single terminal command) AFTER I logged in after wakeup?
In other words, where is the directory or a file where I can place my script or add a terminal command?
In the “Settings” -> “Startup and Shutdown” there are options:
Run on: - Startup - Logout - Before session startup
I just tested with the “Run on: Startup” option, but it does not run on wakeup after sleep when I logged in. Are you sure that the script must run on wakeup after sleep after login screen? If yes, then maybe I do something wrong.
#!/bin/bash
dbus-monitor --session "type='signal',interface='org.kde.ScreenSaver'" | \
( while true
do read X
if echo $X | grep "boolean false" &> /dev/null; then
# PASTE YOUR COMMAND HERE
fi
done )
Run it in background (do not kill).
The script will execute the command on unlock after wakeup.