SHORT ANSWER:
type CTRL+ALT+F2 when AFK, and CTRL+ALT+F7` when coming back.
LONG ANSWER:
Although I upvoted the solution proposed by @cas, I think that opening a cat
terminal has a few disadvantages:
- when the sloppy mouse option is enabled, it suffices that the cat pushes the mouse outside of the window area of the terminal to redirect the input to application in the background (or the desktop). As a result, the
cat
command becomes useless because it is no longer receiving any input.
- some unix/linux installations come with super easy key bindings which switch the foreground application receiving the input coming from the keyboard, again rendering the
cat
command useless; e.g. on my system, the SUPER
key opens the application menu.
Opening a vim
terminal as @DanJab suggested is subject to the same issues of using a terminal with cat
.
Locking the session as suggested by @BlueWizard has the disadvantage that one has to type again his/her own password. This is clearly a sensible approach when leaving the computer unattended in public spaces for a long time, but it's a bit of an overkill for short breaks at home, especially when the login password is both long and complex to type.
Thus, my proposed solution is to use the combination
CTRL+ALT+F2
so as to temporarily switch the system to a login terminal. Unless the cat figures out your own login and password or, against all possible odds, inadvertently presses CTRL+ALT+F7, your session should be completely safe.
This works on any Linux system that I have tried, requires no extra configuration/script, it's very fast to use and easy to remember.
ctrl-s
freezes output, not input. – ctrl-alt-delor Jul 29 '17 at 8:25