-# are marked as "(BATTERY)".
-if [ ! -d /sys/class/power_supply/BAT0 ]; then
- echo screenrc: removing battery display
- grep -v '(BATTERY)' screenrc > screenrc.tmp
- mv screenrc.tmp screenrc
+# are marked as "(BATTERY)". Also used for Tmux.
+battery=
+for x in /sys/class/power_supply/BAT*; do
+ test -d "$x" || continue
+ battery="$x"
+done
+apply_optional_replacement screenrc \
+ battery BATTERY "$battery"
+# Display current temperature. Necessary lines are marked as "(TEMPERATURE)".
+# Also used for Tmux.
+temperature=/sys/devices/platform/coretemp.0
+if ! test -d "$temperature"; then
+ temperature=
+fi
+apply_optional_replacement screenrc \
+ temperature TEMPERATURE "$temperature"
+
+
+if installed tmux; then
+ generate tmux.conf .in cat
+
+ apply_optional_replacement tmux.conf \
+ battery BATTERY "$battery"
+ apply_optional_replacement tmux.conf \
+ temperature TEMPERATURE "$temperature"
+
+ # Old Tmux versions can't handle that.
+ generate tmux.conf '' ./bin/remove-continuation.pl
+
+ # Add mappings to switch to windows 10-29 quickly. See tmux-window.pl for
+ # details.
+ perl ./tmux-window.pl 1 "`pwd`/tmux-window2.conf" >tmux-window1.conf
+ perl ./tmux-window.pl 2 >tmux-window2.conf
+ # Set absolute path to tmux-window1.conf in tmux.conf.
+ generate tmux.conf '' simple_cpp \
+ TMUX_WINDOW_PATH -- "`pwd`/tmux-window1.conf"
+
+ # 256 colors not available.
+ if test -z "$use_256colors"; then
+ echo 'tmux.conf: removing 256 colors'
+ sed_i 's/Enable 256 color/Disable 256 color/;
+ s/screen-256color/screen/' tmux.conf
+ fi
+ # Tmux doesn't display a warning if the shell wasn't found!
+ if test ! -x '/bin/zsh'; then
+ echo 'tmux.conf: removing /bin/zsh as shell'
+ sed_i 's/zsh/sh/' tmux.conf
+ fi