Using vlock without changing VT from X

X screen lockers are fine, but I sometimes have stuff open on other TTYs that I want to lock as well. For this reason I would like to use vlock -a to lock all TTYs at the same time. However, I am typically in an X session when I want to run this command.

vlock cannot be run from within X because it complains that the current terminal is not a virtual console. I tried to make some solution with chvt but I don’t know how to run the command in that console afterwards.

How can I lock all TTYs without exiting X (preferably using vlock, but I’m open to other suggestions)?

Answer

See this command line option:

   -n,--new
          Switch to a new virtual console before locking all console sessions.

What I always do is sudo vlock -ans, works inside / outside Xorg.

It will jump back to the original VT when you unlocked it.

EDIT

Too bad, Arch Linux replaced the original vlock package with the one provided by kbd package. That one can lock only the current console, which is useless to you. (none of -a -n -s is supported, sigh)

The workaround can be tricky, you must manually install the original vlock, and mask kbd from upgrading in pacman.conf

See this link for further information

Attribution
Source : Link , Question Author : Zhao Xi , Answer Author : daisy

Leave a Comment