]> ruderich.org/simon Gitweb - config/dotfiles.git/commitdiff
shell/rc: Use shell timeout in Tmux if vlock wasn't found.
authorSimon Ruderich <simon@ruderich.org>
Wed, 20 Nov 2013 21:54:42 +0000 (22:54 +0100)
committerSimon Ruderich <simon@ruderich.org>
Sat, 7 Dec 2013 20:03:38 +0000 (21:03 +0100)
shell/rc

index aa15002c26c8b1c48f39cdc6ddcb8f30eef93420..c3cfade3fe47375778746c16d279912d2e4d159e 100644 (file)
--- 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