I wanted a way to simultaneously lock all of the computers – a mixture of Linux, MacOS and Windows boxen – on my desk, when I’m going to step away. Here’s what I came up with:
One button. And everything locks. Nice!
Here’s how it works:
- The mini keyboard is just 10 cheap mechanical keys wired up to a CH552 chip. It’s configured to send CTRL+ALT+F13 through CTRL+ALT+F221 when one of its keys are pressed.
- The “lock” key is captured by my KVM tool Deskflow (which I migrated to when Barrier became neglected, which in turn I migrated to when I fell out of love with Synergy). It then relays this hotkey across to all currently-connected machines2.
- That shortcut is captured by each recipient machine in different ways:
- The Linux computers run LXDE, so I added a line to
/etc/xdg/openbox/rc.xml
to set a<keybind>
that executesxscreensaver-command -lock
. - For the Macs, I created a Quick Action in Automator that runs
pmset displaysleepnow
as a shell script3, and then connected that via Keyboard Shortcuts > Services. - On the Windows box, I’ve got AutoHotKey running anyway, so I just have it run
{ DllCall("LockWorkStation") }
when it hears the keypress.
- The Linux computers run LXDE, so I added a line to
That’s all there is to is! A magic “lock all my computers, I’m stepping away” button, that’s much faster and more-convenient than locking two to five computers individually.
Footnotes
1 F13 through F24 are absolutely valid “standard” key assignments, of course: it’s just that the vast majority of keyboards don’t have keys for them! This makes them excellent candidates for non-clashing personal-use function keys, but I like to append one or more modifier keys to the as well to be absolutely certain that I don’t interact with things I didn’t intend to!
2 Some of the other buttons on my mini keyboard are mapped to “jumping” my cursor to particular computers (if I lose it, which happens more often than I’d like to admit), and “locking” my cursor to the system it’s on.
3 These boxes are configured to lock as soon as the screen blanks; if yours don’t then you might need a more-sophisticated script.