X-Git-Url: https://git.donarmstrong.com/?a=blobdiff_plain;f=.xsession;h=4fdd2399092d7f9a888903302dddd64b8f56c805;hb=eebc703c5544ff7324213049247ead7e917d9f07;hp=29306397edf7f893afe588c0935c807ff9c58e1c;hpb=2ba286fad7c0af775203e9dd698496cc2176fc49;p=x_base.git diff --git a/.xsession b/.xsession index 2930639..4fdd239 100755 --- a/.xsession +++ b/.xsession @@ -1,14 +1,26 @@ #!/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 ~/.xsession-errors-current ~/.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; + -iname '.xsession-errors_*' -ctime +30 -delete; if locale -a |grep -qi en_US.utf8; then LANG="en_US.UTF-8" @@ -44,25 +56,39 @@ if [ -e ~/.Xauthority ]; then cp -f .Xauthority .Xauthority.bak fi -if [ -x /usr/bin/xautolock ]; then - /usr/bin/xautolock -notifier true -bell 0 & -elif [ -x /usr/bin/xscreensaver -a -e ~/.xscreensaver ]; then - /usr/bin/xscreensaver & +if cmd_exists slock && cmd_exists xautolock; then + fork xautolock -notifer true -bell 0 -locker slock; +elif cmd_exists xscreensaver && [ -e ~/.xscreensaver ]; then + fork XENVIRONMENT=~/.xscreensaver /usr/bin/xscreensaver; +elif cmd_exists xautolock; then + fork xautolock -notifer true -bell 0; +fi; + +if cmd_exists redshift; then + fork redshift; +fi; + +if cmd_exists mopidy && [ -e ~/.config/mopidy/mopidy.conf ]; then + fork mopidy; +elif 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; +fi; + +if [ -x /sbin/iw ] && cmd_exists nm-applet && /sbin/iw list|grep -q '^Wiphy'; then + fork nm-applet; fi; -if [ -x /usr/bin/awesome ]; then - exec /usr/bin/awesome; -elif [ -x /usr/bin/ion3 ]; then - exec /usr/bin/ion3; -elif [ -x /usr/bin/openbox ]; then - exec /usr/bin/openbox; -elif [ -x /usr/bin/rxvt ]; then - exec /usr/bin/rxvt; -elif [ -x /usr/bin/rxvt-unicode ]; then - exec /usr/bin/rxvt-unicode; -elif [ -x /usr/bin/xterm ]; then - exec /usr/bin/xterm; +if cmd_exists i3; then + if [ -x ~/.config/i3/build_config.sh ]; then + ~/.config/i3/build_config.sh; + fi; + exec /usr/bin/i3; else - # we're screwed. - sleep 2s; + for prog in awesome ion3 openbox stterm st rxvt rxvt-unicode xterm; do + if cmd_exists $prog; then + exec $(which $prog) + fi + done; fi;