I want to write a script to check whether system is locked or not at certain time.
So can anyone tell me what would be the condition to verify that system is locked or not ?
Thanks in advance!!
I found the answer for ubuntu 14.04
#!/bin/bash
dbus-monitor --session "type='signal',interface='com.ubuntu.Upstart0_6'" | \
(
while true; do
read X
if echo $X | grep "desktop-lock" &> /dev/null; then
SCREEN_LOCKED;
elif echo $X | grep "desktop-unlock" &> /dev/null; then
SCREEN_UNLOCKED;
fi
done
)
This script will print the lock screen activity.
Reference: run-script-on-screen-lock-unlock