-
Notifications
You must be signed in to change notification settings - Fork 0
/
lockmon
executable file
·38 lines (32 loc) · 1009 Bytes
/
lockmon
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
#!/bin/bash
# Based on https://superuser.com/a/832111
# Add a service like the following to ~/.config/systemd/user/lockmon.service
#
# [Unit]
# Description=Log GNOME locks and unlocks
#
# [Service]
# Type=simple
# ExecStart=%h/.local/bin/lockmon
# Restart=always
# TimeoutStopSec=5
#
# [Install]
# WantedBy=default.target
#
# ... and run: systemctl --user enable --now lockmon
exit_report() {
echo "Monitoring Terminated."
}
trap "exit_report; exit;" 0
format-log() {
while IFS= read -r line; do
echo "$line" \
| grep "boolean" \
| sed 's/ boolean true/Screen Locked/' \
| sed 's/ boolean false/Screen Unlocked/'
done
}
echo "Monitoring Started."
dbus-monitor --session "type='signal',interface='org.gnome.ScreenSaver'" \
| format-log \