Git Product home page Git Product logo

yubilock's Introduction

Yubilock

Yubilock is a simple program that will lock your screen if a Yubikey is removed from the computer.

A better solution

As others have pointed out, it can be achieved more elegantly with a udev rule, I'll keep this here for posterity and to serve as a reference for dbus/python3 stuff in case somebody needs it.

The udev rule in question is:

ACTION=="remove", ATTRS{idVendor}=="1050", RUN+="/bin/loginctl lock-sessions"

Adding this to a /etc/udev/rules.d/80-yubilock.rules file should do the trick.

That will lock the screen for any USB device made by Yubico, you could add your specifi device ID as ATTRS{idProduct} if you want to narrow that down further.

Thanks to masta from reddit!

Why?

First of all: why not? :)

I find myself working from cybercafes/coworking spaces quite often, and realized whenever I had to leave my computer, I systematically did two things:

  1. Remove my Yubikey from the USB port it's plugged into
  2. Lock my screen

This program is a simple attempt at optimising this aspect of my life. Removing the Yubikey now triggers a screen lock!

Simple!

Dependencies

Yubilock is currently thought to be run on Ubuntu, using python3. As such, the following (system) dependencies are required:

sudo apt-get install python3 python3-pyudev python3-dbus

This program depends on DBus's system and session busses to be available to the running user. Therefore, it needs a working DBus environment. Normal logged in users on a default Ubuntu install should have this, but i.e. containers won't by default.

Instructions

Simply run the ./yubilock script as a normal logged in user from a terminal.

It doesn't do anything fancy yet, and will simply log information about Yubikeys on stdout.

The future

An applet? Who knows!

yubilock's People

Contributors

chrisglass avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.