Skip to content

Instantly share code, notes, and snippets.

@meeuw
Last active January 25, 2019 20:14
Show Gist options
  • Select an option

  • Save meeuw/5eca1474db918f73f4862f702277a88e to your computer and use it in GitHub Desktop.

Select an option

Save meeuw/5eca1474db918f73f4862f702277a88e to your computer and use it in GitHub Desktop.
script to load/unlock using juicessh gestures
#!/usr/bin/env python3
import dbus
import tty
import termios
import sys
def getchar():
#Returns a single character from standard input
fd = sys.stdin.fileno()
old_settings = termios.tcgetattr(fd)
try:
tty.setraw(sys.stdin.fileno())
ch = sys.stdin.read(1)
finally:
termios.tcsetattr(fd, termios.TCSADRAIN, old_settings)
return ch
system_bus = dbus.SystemBus()
login1 = system_bus.get_object('org.freedesktop.login1', '/org/freedesktop/login1')
login1_manager = dbus.Interface(login1, dbus_interface='org.freedesktop.login1.Manager')
seat = None
for i in login1_manager.ListSessions():
session, uid, user, seat, objectpath = i
if seat:
break
if not seat:
print("no seats found")
print("UNLOCK <=== SWIPE ===> LOCK")
while 1:
c = getchar()
if c == "\x01":
ctrla = True
elif ctrla and c == "p":
login1_manager.UnlockSession(session)
ctrla = False
elif ctrla and c == "n":
login1_manager.LockSession(session)
ctrla = False
elif ctrla and c == "q":
sys.exit()
else:
ctrla = False
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment