#!/bin/sh echo 'ACTION=="add", SUBSYSTEM=="usb", DRIVER=="usbhid", RUN+="/usr/bin/loginctl lock-sessions", RUN+="/usr/bin/logger New USB HID device found, locking sessions"' | sudo tee /etc/udev/rules.d/00-usbhid-lock-screen.rules >> /dev/null sudo systemctl reload udev