From 9b975c15a2b8ab40b76e4f3922b43df1ec2c149c Mon Sep 17 00:00:00 2001 From: Simon Ruderich Date: Wed, 20 Nov 2013 22:54:42 +0100 Subject: [PATCH] shell/rc: Use shell timeout in Tmux if vlock wasn't found. --- shell/rc | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/shell/rc b/shell/rc index aa15002..c3cfade 100644 --- a/shell/rc +++ b/shell/rc @@ -39,9 +39,18 @@ timeout_setup_screen_lock() { echo } timeout_setup_tmux_lock() { - echo "Locking Tmux after $timeout seconds (TTY detected)." - tmux set-option lock-after-time $timeout - echo + if type vlock >/dev/null; then + echo "Locking Tmux after $timeout seconds (TTY detected)." + tmux set-option lock-after-time $timeout + echo + + else + echo "vlock not found, locking won't work in Tmux!" >&2 + echo "Falling back to shell timeout." >&2 + echo + + timeout_setup_shell_lock + fi } timeout_setup_shell_lock() { echo "Auto-logout after $timeout seconds (TTY detected)." @@ -65,10 +74,6 @@ case "$TERM" in ;; esac elif test -n "$TMUX"; then - if ! type vlock >/dev/null; then - echo "vlock not found, locking won't work in Tmux!" >&2 - fi - case "`tmux display -p '#{client_tty}'`" in /dev/tty[0-9]*) timeout_setup_tmux_lock -- 2.45.2