diff options
| author | Taihsiang Ho <taihsiang.ho@canonical.com> | 2014-05-28 11:26:47 +0000 |
|---|---|---|
| committer | Daniel Manrique <> | 2014-05-28 11:26:47 +0000 |
| commit | e01e9b21ff60b086652863e643cb372a9259a9d4 (patch) | |
| tree | d76da61c53c9d90e5848f8490b17b53782b16c79 | |
| parent | c48849d38b485d932a9b0bc6a34d690d51fe6104 (diff) | |
| parent | 112dd66aa471dbefb5cc4cf9c945ac280c969b46 (diff) | |
"automatic merge by tarmac [r=zkrynicki][bug=][author=taihsiangho]"
| -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: |
