OS:
Linux Mint 20.3 Cinnamon
Shell Script:
Simple script that watches dbus for system "lock" and "unlock" signals.
Code: Select all
#! /bin/bash
dbus-monitor --session "type='signal',interface='org.cinnamon.ScreenSaver'" |
while read x; do
case "$x" in
*"boolean true"*)
"/home/<user>/scripts/systemLockUnlock/systemOnLock.sh";;
*"boolean false"*)
"/home/<user>/scripts/systemLockUnlock/systemOnUnlock.sh";;
esac
done
Code: Select all
[Unit]
Description=Toggle LED's based when the cinnamon screen saver sends out a locked/unlocked signal.
[Service]
Type=simple
ExecStart=/home/<user>/scripts/systemLockUnlock/lockUnlock.sh
[Install]
WantedBy=default.target
Code: Select all
sudo systemctl daemon-reload; sudo systemctl enable lockUnlock.service; sudo systemctl start lockUnlock.service; sudo systemctl status lockUnlock.service
Code: Select all
Created symlink /etc/systemd/system/default.target.wants/lockUnlock.service → /etc/systemd/system/lockUnlock.service.
● lockUnlock.service - Toggle LED's based on if the system is locked or not.
Loaded: loaded (/etc/systemd/system/lockUnlock.service; enabled; vendor preset: enabled)
Active: inactive (dead) since Sat 2022-07-02 12:22:12 CDT; 6ms ago
Process: 9143 ExecStart=/home/<user>/scripts/systemLockUnlock/lockUnlock.sh (code=exited, status=0/SUCCESS)
Main PID: 9143 (code=exited, status=0/SUCCESS)
Jul 02 12:22:12 <system> systemd[1]: Started Toggle LED's based on if the system is locked or not..
Jul 02 12:22:12 <system> lockUnlock.sh[9145]: Failed to open connection to session bus: Unable to autolaunch a dbus-daemon without a $DISPLA>
Jul 02 12:22:12 <system> systemd[1]: lockUnlock.service: Succeeded.
* Note that user and system names have been replaced with <user> and <system>