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

19 lines
809 B
Bash
Raw Normal View History

# 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 | grep -E "^$(whoami)" | awk '{ print $2; }' | grep -E -c "^tty"` -eq 1 ] && [ -x /usr/sbin/startxfce4 ] && [ `pgrep -ac xinit` -eq 0 ] && [ `whoami` != 'root' ]; then
exec startxfce4
fi