ShadowArch/EtcFiles/profile.d/shadowarch-session.sh

19 lines
805 B
Bash

# Set up screen/tmux safety nest by default for remote sessions
if [ -n "$SSH_CLIENT" ]; then
# Prefer tmux
if [ -x "$(which tmux 2>/dev/null)" ] && [ -z "$TMUX" ]; then
if [ `tmux list-sessions | grep created | wc -l` -eq 0 ]; then
exec tmux
elif [ `tmux list-sessions | grep created | wc -l` -eq 1 ] && [ `tmux list-sessions | grep attached | wc -l` -eq 0 ]; then
exec tmux a -d -t `tmux list-sessions | grep created | cut -f 1 -d ':'`
else
tmux list-sessions
fi
alias tat="exec tmux a -d -t"
fi;
### XFCE4 ###
elif [ `who -m | egrep "^$(whoami)" | awk '{ print $2; }' | egrep -c "^tty"` -eq 1 ] && [ -x /usr/sbin/startxfce4 ] && [ `pgrep -ac xinit` -eq 0 ] && [ `whoami` != 'root' ]; then
exec startxfce4
fi