-
Notifications
You must be signed in to change notification settings - Fork 213
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
WIP of #125: screen locking detection
wont be able to have separate backend tho, will be able to hack the shell script tho to do it. currently only supports xscreensaver
- Loading branch information
Showing
3 changed files
with
47 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
from shlex import split | ||
from subprocess import check_output, check_call, CalledProcessError, PIPE | ||
|
||
|
||
def xscreensaver_detect(): | ||
try: | ||
check_call(split('pgrep xscreensaver'), stdout=PIPE) | ||
except CalledProcessError: | ||
return False | ||
else: | ||
return True | ||
|
||
|
||
def xscreensaver_is_locked(): | ||
return 'screen locked' in check_output(split('xscreensaver-command -time')) | ||
|
||
|
||
def is_locked(): | ||
if xscreensaver_detect(): | ||
return xscreensaver_is_locked() | ||
return True |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters