X-Git-Url: https://git.donarmstrong.com/?a=blobdiff_plain;f=.xsession;h=8ddaf1dcef90016da2286d0a478a007622c2e729;hb=84674da173dc629325926488a0351fe3c4c88766;hp=ac39605dada28860a316652ece45e6bc68c83b1b;hpb=d52327408bd6e1bed0d0c5af3c1deeeb8ab5a9d5;p=x_base.git diff --git a/.xsession b/.xsession old mode 100644 new mode 100755 index ac39605..8ddaf1d --- a/.xsession +++ b/.xsession @@ -1,4 +1,32 @@ -LANG="en_US.UTF-8" +#!/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) @@ -7,12 +35,13 @@ if [ -d ~/tmp ]; then export TMPDIR=$(echo ~/tmp) fi; -if [ "$HOSTNAME" == "archimedes" ]; then - xmodmap -e 'keycode 158 = XF86AudioRaiseVolume' - xmodmap -e 'keycode 146 = XF86AudioLowerVolume' - xmodmap -e 'keysym Super_L = Multi_key' - xset r rate 170 40 +# 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; @@ -22,37 +51,44 @@ if [ -e ~/.xsession_$HOSTNAME ]; then . ~/.xsession_$HOSTNAME fi; - -if [ -x /usr/bin/gkrellm ]; then - /usr/bin/gkrellm & +# make a backup of the .Xauthority +if [ -e ~/.Xauthority ]; then + cp -f .Xauthority .Xauthority.bak fi -if [ -x /usr/bin/xmms ]; then - /usr/bin/xmms & -fi +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 [ -x /usr/bin/xsetbg ]; then - if [ "$(hostname)" == "archimedes" ] && [ -r /home/don/pictures/dh-demon_tag.jpg ]; then - /usr/bin/xsetbg -zoom 125 -fit -center -border gray17 /home/don/pictures/dh-demon_tag.jpg - fi; +if cmd_exists redshift; then + fork redshift; fi; -if [ -x /usr/bin/xscreensaver -a -e ~/.xscreensaver ]; then - /usr/bin/xscreensaver & +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 /usr/bin/ion3 ]; then -# exec /usr/bin/ion3; -#el -if [ -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 [ -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 - # 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;