Skip to content

Commit

Permalink
Newer xidlehook versions don't have mode argument to --timer
Browse files Browse the repository at this point in the history
Support versions of xidlehook which have removed the `mode` argument
to `--timer`, while continuing, at least for the time being, to
also support the older syntax.

Fixes #24.
  • Loading branch information
jikamens committed May 24, 2020
1 parent 0ce7cf7 commit b04cae2
Showing 1 changed file with 19 additions and 7 deletions.
26 changes: 19 additions & 7 deletions client/plugins/screenlock.py
Original file line number Diff line number Diff line change
Expand Up @@ -121,14 +121,26 @@ def xidlehook_status(user, display):
timers = []
try:
while args:
# xidlehook timers always have 4 positional arguments
# https://github.com/jD91mZM2/xidlehook/blob/cbc3302e3485a8308d6ba5dd6b4d069d322908dd/src/main.rs#L122 # noqa
# xidlehook timers have either 3 or 4 positional arguments
# depending on the version of xidlehook being used. Older
# versions have "mode" (which can be "normal" or "primary",
# "duration", "command", and "canceller", but newer versions
# (as of 2020-05-24) omit the "mode" argument. Eventually the
# backward-compatibility support for the "mode" argument can
# be removed.
if args[0] == '--timer':
timers.append({
'time': int(args[2]),
'locker': args[3]
})
del args[0:5]
if args[1] in ("normal", "primary"):
timers.append({
'time': int(args[2]),
'locker': args[3]
})
del args[0:5]
else:
timers.append({
'time': int(args[1]),
'locker': args[2]
})
del args[0:4]
else:
args.pop(0)
except Exception:
Expand Down

0 comments on commit b04cae2

Please sign in to comment.