Skip to content

Instantly share code, notes, and snippets.

@bigeagle
Created March 25, 2016 08:07
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bigeagle/da9dd84ed85826f429d5 to your computer and use it in GitHub Desktop.
Save bigeagle/da9dd84ed85826f429d5 to your computer and use it in GitHub Desktop.
#!/usr/bin/env python2
# -*- coding:utf-8 -*-
from __future__ import print_function, division, unicode_literals
from udevedu.utils import invoke
import os
def init():
print("Monitoring Yubikey Remove Event")
def check(action, device):
return (
action == "remove" and
device.get('ID_VENDOR_ID') == '1050' and
device.get('ID_MODEL_ID') in ('0111', '0407') and
device.get('DEVNAME', '').startswith('/dev/input/event')
)
def react(action, device):
if os.getenv("XDG_SESSION_DESKTOP") == "i3":
cmd = "i3lock -c 000000".split()
invoke(*cmd)
# vim: ts=4 sw=4 sts=4 expandtab
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment