0

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!!

1

1 Answer 1

0

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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.