Skip to content

Commit

Permalink
Fix for "no root" alert
Browse files Browse the repository at this point in the history
In Unix, `keyboard` requires root to set up a key listener. Instead of letting the listener thread fail with an exception, we'll skip setting up the listener in a non-root Unix setting.
  • Loading branch information
glitchassassin committed May 12, 2019
1 parent a53e6e3 commit 0bd7549
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion lackey/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,13 @@
def _abort_script():
thread.interrupt_main()

keyboard.add_hotkey("alt+shift+c", _abort_script, suppress=True)
# If we are not on Unix, or if we are on Unix and have root privileges, start the
# alt+shift+c hotkey listener to abort the script
if (not hasattr(os, "geteuid") or os.geteuid() == 0):
keyboard.add_hotkey("alt+shift+c", _abort_script, suppress=True)
print("Use Alt+Shift+C to abort script manually")
else:
print("No root privileges: Unable to set Alt+Shift+C listener to abort script.")

## Sikuli patching: Functions that map to the global Screen region
## Don't try this at home, kids!
Expand Down

0 comments on commit 0bd7549

Please sign in to comment.