1 # Shell configuration file.
3 # Copyright (C) 2013-2014 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 and ^q). I use GNU Screen/Tmux which also supports
28 # this in a similar way (entering copy mode) and enabling flow control by
29 # accident is annoying.
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 if type vlock >/dev/null; then
43 echo "Locking Tmux after $timeout seconds (TTY detected)."
44 tmux set-option lock-after-time $timeout
48 echo "vlock not found, locking won't work in Tmux!" >&2
49 echo "Falling back to shell timeout." >&2
52 timeout_setup_shell_logout
55 timeout_setup_shell_logout() {
56 echo "Auto-logout after $timeout seconds (TTY detected)."
61 local timeout >/dev/null 2>&1
64 # `tty` doesn't work inside a pseudo-terminal as provided by GNU
67 # The following settings for GNU Screen/Tmux will only auto-lock new
68 # sessions, not when attaching to existing sessions!
70 if test -n "$STY"; then
73 timeout_setup_screen_lock
76 elif test -n "$TMUX"; then
77 case "`tmux display -p '#{client_tty}'`" in
79 timeout_setup_tmux_lock
82 # Not on TTY, nothing to do.
85 echo 'Tmux < 1.8 found, TTY check might be incorrect!' >&2
87 local client >/dev/null 2>&1
88 client=`printf '%s' "$TMUX" | sed 's/^.*,\([0-9]*\)$/\1/'`
90 case "`tmux list-clients \
91 | grep -E "^/dev/.*?: $client "`" in
93 timeout_setup_tmux_lock
99 echo 'TERM=screen but neither $STY nor $TMUX found!' >&2
100 timeout_setup_shell_logout
107 timeout_setup_shell_logout
113 unset timeout_setup_screen_lock
114 unset timeout_setup_tmux_lock
115 unset timeout_setup_screen_lock