TTYAUTOLOCK(1)

πŸ“¦ version 0.26.6, in ubuntu stonking

πŸ’– TTYAUTOLOCK(1) β€” the "bestie bestie lock my screen" page πŸ’–

okay so welcome to TTYAUTOLOCK(1), from the General Commands Manual section, and yes this whole thing is about ttyautolock β€” the little guy that locks your session the second your TTY stops being the one in the spotlight. main character energy in a binary, fr fr πŸŽ€


✨ NAME ✨

ttyautolock β€” locks your session if the TTY it's associated with loses focus 🫢


✨ SYNOPSIS ✨

 [SESSION_ID | auto]

✨ DESCRIPTION ✨

so here's the whole vibe πŸ’™ β€” you give it either a SESSION_ID or the magic word auto, and it goes and finds the TTY that's associated with that session. then it just… watches. πŸ‘€

Specifically, it sits there watching /sys/class/tty/tty0/active for changes. And the moment it sees a transition from the associated TTY to literally any other one? boom. it locks the session. πŸ’…

and how does it lock it, you ask? via "loginctl lock-session". that's the whole move. iconic.

as for the auto argument β€” that one relies on the behavior of "loginctl show-session auto". so it's not doing any guessing of its own, it's trusting loginctl to handle it. no cap. 🌸


✨ SYSTEMD USER SERVICE ✨

there's a unit called ttyautolock@.service 🧚 and if you use it with the default auto specifier, you can just enable and start it, and it will always lock your graphical session whenever you switch TTYs. set it and forget it, honestly obsessed. πŸ”₯

but that's not the only way!! it can also be started on-demand, and with a custom session ID as the specifier instead of auto. your setup, your rules. πŸ‘‘


✨ SEE ALSO ✨


tiny heads-up bestie: the whole locking thing rides on "loginctl lock-session" and the watching rides on changes to /sys/class/tty/tty0/active, so those are the two things doing all the heavy lifting here. 🫢

sign-off szn 🌈 this page came from the General Commands Manual, it's dated 2026-06-29, and yes it's filed under TTYAUTOLOCK(1). love that for us. mwah πŸ’‹πŸ’–

πŸ“¦ where this page comes from