2

as we could use xflock4 command to lock the screen (ask for a password to continue) in an X session; I need a similar way to lock the tty1 session. Is there any? (logout is not working when I call in a script.)

Edit

Here is my full script:

#!/bin/bash

if [[ $(id -u) > 0 ]]; then
    if [[ "$DISPLAY" == "" ]]; then 
        sudo "$0" "$(whoami)"
    else
        gksu "$0" "$(whoami)"
    fi
    exit
fi

physlock -d -u $1
pm-suspend
2

If vlock doesn't work for you, try physlock. It doesn't inhibit suspension and hibernation which is nice if you want to lock automatically when the computer sleeps. Also, physlock locks all tty's by default.

2

vlock might be what you're searching for.

  • when I use vlock in the script, it says "vlock: stdin is not a terminal" and does not work as expected. I'm searching for a way for that error. – ceremcem Jan 31 '15 at 19:36
  • Should be run as root: sudo vlock ... – MajorBriggs Jan 31 '15 at 20:11
  • That was what I was doing, but it didn't work either. – ceremcem Jan 31 '15 at 22:09
0

If you want a shellscript solution (which happens to work on OSX too), see bashlock.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.