1 # Shell configuration file.
3 # Copyright (C) 2013 Simon Ruderich
5 # This file is free software: you can redistribute it and/or modify
6 # it under the terms of the GNU General Public License as published by
7 # the Free Software Foundation, either version 3 of the License, or
8 # (at your option) any later version.
10 # This file is distributed in the hope that it will be useful,
11 # but WITHOUT ANY WARRANTY; without even the implied warranty of
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 # GNU General Public License for more details.
15 # You should have received a copy of the GNU General Public License
16 # along with this file. If not, see <http://www.gnu.org/licenses/>.
19 # Normal umask for root (readable by all users).
20 if test "`id -u`" -eq 0; then
22 # Restricted umask for normal users (readable only by me).
27 # Disable flow control (^s ^q). I use GNU Screen/Tmux which also supports this
28 # in a similar way (entering copy mode) and enabling flow control by accident
34 # Auto-logout after timeout on TTYs. It's easy to forget to logout after
35 # switching back to X11 from a TTY.
36 timeout_setup_screen_lock() {
37 echo "Locking GNU screen after $timeout seconds (TTY detected)."
38 screen -X idle $timeout lockscreen
41 timeout_setup_tmux_lock() {
42 echo "Locking Tmux after $timeout seconds (TTY detected)."
43 tmux set-option lock-after-time $timeout
46 timeout_setup_shell_lock() {
47 echo "Auto-logout after $timeout seconds (TTY detected)."
52 local timeout >/dev/null 2>&1
55 # `tty` doesn't work inside a pseudo-terminal as provided by GNU
58 # The following settings for GNU Screen/Tmux will only auto-lock new
59 # sessions, not when attaching to existing sessions!
61 if test -n "$STY"; then
64 timeout_setup_screen_lock
67 elif test -n "$TMUX"; then
68 if ! type vlock >/dev/null; then
69 echo "vlock not found, locking won't work in Tmux!" >&2
72 case "`tmux display -p '#{client_tty}'`" in
74 timeout_setup_tmux_lock
77 # Not on TTY, nothing to do.
80 echo 'Tmux < 1.8 found, TTY check might be incorrect!' >&2
82 local client >/dev/null 2>&1
83 client=`printf '%s' "$TMUX" | sed 's/^.*,\([0-9]*\)$/\1/'`
85 case "`tmux list-clients \
86 | grep -E "^/dev/.*?: $client "`" in
88 timeout_setup_tmux_lock
94 echo 'TERM=screen but neither $STY nor $TMUX found!' >&2
95 timeout_setup_shell_lock
102 timeout_setup_shell_lock
108 unset timeout_setup_screen_lock
109 unset timeout_setup_tmux_lock
110 unset timeout_setup_screen_lock