Skip to content

Instantly share code, notes, and snippets.

@obi12341
Last active July 16, 2019 13:18
Show Gist options
  • Save obi12341/23da49075b49cf93664c235224143a5d to your computer and use it in GitHub Desktop.
Save obi12341/23da49075b49cf93664c235224143a5d to your computer and use it in GitHub Desktop.
yubikey activate lockscreen on remove and restart pcscd on add
[Unit]
Description=User suspend actions
[Service]
Type=simple
Environment=DISPLAY=:0
Environment=DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/1000/bus
ExecStart=/usr/bin/betterlockscreen -l dim
[Install]
WantedBy=multi-user.target
# Udev rules for letting the console user access the Yubikey USB
# device node, needed for challenge/response to work correctly.
ACTION=="add", SUBSYSTEM=="input", ENV{ID_VENDOR_ID}=="1050", ENV{PROP}=="0", RUN+="/usr/local/bin/yubi_on.sh"
ACTION=="remove", SUBSYSTEM=="input", ENV{ID_VENDOR_ID}=="1050", ENV{PROP}=="0", RUN+="/usr/local/bin/yubi_off.sh"
#!/usr/bin/env bash
export USER_ID=1000
export USER_NAME=patrick
export XAUTHORITY="/home/$USER_NAME/.Xauthority"
export DISPLAY=:0
export DBUS_SESSION_BUS_ADDRESS="unix:path=/run/user/$USER_ID/bus"
/usr/bin/sudo -u $USER_NAME -E /usr/bin/systemctl --no-block --user start i3lock.service
/usr/bin/sudo -u $USER_NAME -E /usr/bin/notify-send 'Yubikey off'
#!/usr/bin/env bash
export USER_ID=1000
export USER_NAME=patrick
export XAUTHORITY="/home/$USER_NAME/.Xauthority"
export DISPLAY=:0
export DBUS_SESSION_BUS_ADDRESS="unix:path=/run/user/$USER_ID/bus"
/usr/bin/systemctl --no-block restart pcscd.service
/usr/bin/sudo -u $USER_NAME -E /usr/bin/notify-send 'Yubikey on'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment