#!/bin/sh cmd_exists () { if which "$1" >/dev/null 2>&1; then return 0; else return 1; fi; } fork () { ( "$@" >/dev/null 2>&1 & ) } echo "Starting new session" DATE=$(date "+%Y%m%d_%H%M%S") # track xsession errors mv ~/.xsession-errors ~/.xsession-errors_${DATE}; ln -sf ~/.xsession-errors_${DATE} ~/.xsession-errors-current; # delete old xsession error files find ~/ -maxdepth 1 -mindepth 1 -type f \ -iname '.xsession-errors_*' -ctime +30 -delete; if locale -a |grep -qi en_US.utf8; then LANG="en_US.UTF-8" else LANG=C fi; export LANG HOSTNAME=$(hostname) if [ -d ~/tmp ]; then export TMPDIR=$(echo ~/tmp) fi; # No clue why this has changed from Alt_R to Down, but we really want Down. if ! xmodmap -pk|grep -qe '116.*Down'; then xmodmap -e 'keycode 116 = Super_L' xmodmap -e 'keycode 115 = Multi_key' fi; xmodmap -e 'clear mod4' xmodmap -e 'add mod4 = Super_L Super_R' if [ -e ~/.Xresources_$HOSTNAME ]; then xrdb -merge < ~/.Xresources_$HOSTNAME; fi; if [ -e ~/.xsession_$HOSTNAME ]; then . ~/.xsession_$HOSTNAME fi; # make a backup of the .Xauthority if [ -e ~/.Xauthority ]; then cp -f .Xauthority .Xauthority.bak fi if [ -e ~/bin/screensaver ]; then ~/bin/screensaver on; elif cmd_exists i3lock && cmd_exists xss-lock; then fork xss-lock -l -- ~/bin/locker elif cmd_exists slock && cmd_exists xautolock; then fork xautolock -notifier true -bell 0 -locker slock; if cmd_exists xss-lock; then fork xss-lock -- xautolock -locknow; fi; elif cmd_exists xscreensaver && [ -e ~/.xscreensaver ]; then fork XENVIRONMENT=~/.xscreensaver /usr/bin/xscreensaver; elif cmd_exists xautolock; then fork xautolock -notifier true -bell 0; if cmd_exists xss-lock; then fork xss-lock -- xautolock -locknow; fi; fi; if cmd_exists redshift; then fork redshift; fi; if cmd_exists mpd && [ -e ~/.mpdconf ]; then fork mpd; MPD_HOST=$(awk '/^bind_to_address/{print $2}' ~/.mpdconf|sed "s|~|$HOME|; s/^\"//; s/\"$//; "); export MPD_HOST; elif cmd_exists mopidy && [ -e ~/.config/mopidy/mopidy.conf ]; then fork mopidy; fi; if [ -x /sbin/iw ] && cmd_exists nm-applet && /sbin/iw list|grep -q '^Wiphy'; then fork nm-applet; fi; if cmd_exists i3; then if [ -x ~/.config/i3/build_config.sh ]; then ~/.config/i3/build_config.sh; fi; exec /usr/bin/i3; else for prog in awesome ion3 openbox stterm st rxvt rxvt-unicode xterm; do if cmd_exists $prog; then exec $(which $prog) fi done; fi;