diff options
| -rwxr-xr-x | bin/lock_screen_watcher | 29 |
1 files changed, 22 insertions, 7 deletions
diff --git a/bin/lock_screen_watcher b/bin/lock_screen_watcher index 1ba9779..b8dd886 100755 --- a/bin/lock_screen_watcher +++ b/bin/lock_screen_watcher @@ -2,6 +2,7 @@ import argparse import sys import subprocess +import lsb_release from gi.repository import GObject @@ -20,13 +21,27 @@ class SceenSaverStatusHelper(threading.Thread): self.quit = False def query(self): - p = subprocess.Popen(["gnome-screensaver-command", "-q"], stdout=subprocess.PIPE) - stdout, stderr = p.communicate() - # parse the stdout string from the command "gnome-screensaver-command -q" - # the result should be "active" or "inactive" - if "active" == stdout.decode().split(" ")[-1][0:-1] : - print("the screensaver is active") - self._loop.quit() + if (lsb_release.get_distro_information()["ID"] == "Ubuntu"): + if (lsb_release.get_distro_information()["CODENAME"] == "trusty"): + # trusty uses login screen as screen saver + process_ps = subprocess.Popen(["ps", "aux"], stdout=subprocess.PIPE) + process_grep = subprocess.Popen(["grep", + "/usr/lib/unity/unity-panel-service --lockscreen-mode"], + stdin=process_ps.stdout, + stdout=subprocess.PIPE, + stderr=subprocess.STDOUT) + process_ps.stdout.close() + stdout = process_grep.communicate()[0] + if (len(stdout.decode().split("\n")) == 3): + print("the screensaver is active") + self._loop.quit() + p = subprocess.Popen(["gnome-screensaver-command", "-q"], stdout=subprocess.PIPE) + stdout, stderr = p.communicate() + # parse the stdout string from the command "gnome-screensaver-command -q" + # the result should be "active" or "inactive" + if "active" == stdout.decode().split(" ")[-1].rstrip() : + print("the screensaver is active") + self._loop.quit() def run(self): while not self.quit: |
