diff options
author | Tom Ryder <tom@sanctum.geek.nz> | 2022-04-30 19:24:19 +1200 |
---|---|---|
committer | Tom Ryder <tom@sanctum.geek.nz> | 2022-04-30 20:32:41 +1200 |
commit | 39fb6aeb3d9335960f5e45c89d121126606a61f7 (patch) | |
tree | 55fdfadd28d3376a9cafc91e61db0a1c1e01f223 /X | |
parent | Remove no-op ssh-askpass config (diff) | |
download | dotfiles-39fb6aeb3d9335960f5e45c89d121126606a61f7.tar.gz dotfiles-39fb6aeb3d9335960f5e45c89d121126606a61f7.zip |
Refactor xsession entirely, remove subfiles
Diffstat (limited to 'X')
-rw-r--r-- | X/xsession | 43 | ||||
-rw-r--r-- | X/xsession.d/background.sh | 7 | ||||
-rw-r--r-- | X/xsession.d/browser.sh | 26 | ||||
-rw-r--r-- | X/xsession.d/mouse.sh | 2 | ||||
-rw-r--r-- | X/xsession.d/xkb.sh | 5 |
5 files changed, 39 insertions, 44 deletions
@@ -1,12 +1,47 @@ -# If a file ~/.xrandrrc exists for monitor setup, source that first +# If a file ~/.xrandrrc exists for monitor setup, source that first of all and +# wait for it to finish, so that window geometries and monitor order make sense +# for the rest of the session setup. +# # shellcheck disable=SC1091 -[ -e "$HOME"/.xrandrrc ] && . "$HOME"/.xrandrrc +if [ -e "$HOME"/.xrandrrc ] ; then + . "$HOME"/.xrandrrc +fi + +# Set the background, one of two ways: +## 1. If there's a ~/.fehbg from a prior run, just re-run that +if [ -x "$HOME"/.fehbg ] ; then + "$HOME"/.fehbg & +## 2. Otherwise, apply a random background image, if the relevant dir exists +elif [ -d "${XBACKGROUNDS:-"$HOME"/.xbackgrounds}" ] ; then + xrbg & +fi + +# Set a few keyboard map options +# - Remap right Alt as a Compose key +# - Remap Caps Lock as another Control key +# - Kill X server with Ctrl+Alt+Backspace +setxkbmap \ + -option compose:ralt \ + -option ctrl:nocaps \ + -option terminate:ctrl_alt_bksp & + +# Set fast mouse acceleration with a natural threshold +xset mouse 5/2 0 & + +# Pick a GUI browser, depending on availability +if command -v librewolf >/dev/null 2>&1 ; then + BROWSER=librewolf +elif command -v firefox >/dev/null 2>&1 ; then + BROWSER=firefox +fi +export BROWSER # Load all supplementary scripts in ~/.xsession.d for sh in "$HOME"/.xsession.d/*.sh ; do - [ -e "$sh" ] && . "$sh" + [ -e "$sh" ] || continue + . "$sh" done unset -v sh -# Start i3 window manager +# Start i3 window manager now that everything's ready exec i3 diff --git a/X/xsession.d/background.sh b/X/xsession.d/background.sh deleted file mode 100644 index eba56c98..00000000 --- a/X/xsession.d/background.sh +++ /dev/null @@ -1,7 +0,0 @@ -# If there's a ~/.fehbg, just run that; otherwise, try to apply a random -# background image, if the relevant dir exists -if [ -x "$HOME"/.fehbg ] ; then - "$HOME"/.fehbg -elif [ -d "${XBACKGROUNDS:-"$HOME"/.xbackgrounds}" ] ; then - xrbg -fi diff --git a/X/xsession.d/browser.sh b/X/xsession.d/browser.sh deleted file mode 100644 index 0fe65c78..00000000 --- a/X/xsession.d/browser.sh +++ /dev/null @@ -1,26 +0,0 @@ -# Choose a GUI browser with some rough heuristics - -# If LibreWolf or failing that Firefox is available, start by assuming that -if command -v librewolf ; then - BROWSER=librewolf -elif command -v firefox ; then - BROWSER=firefox -fi >/dev/null 2>&1 - -# Consider a switch to Dillo... -if ( - # Don't switch if it's not there - command -v dillo || exit 1 - # Do switch if BROWSER= isn't set yet - [ -n "$BROWSER" ] || exit 0 - # Do switch if we have procfs' meminfo resource, and it says we have less - # than 2GB of RAM; otherwise, conclude we won't switch - [ -e /proc/meminfo ] \ - && awk '$1=="MemTotal:"&&$2<2^20{m++}END{exit!m}' /proc/meminfo -) ; then - BROWSER=dillo -fi >/dev/null 2>&1 - -# Export our choice of browser, if it isn't empty -[ -n "$BROWSER" ] || return -export BROWSER diff --git a/X/xsession.d/mouse.sh b/X/xsession.d/mouse.sh deleted file mode 100644 index 0f5e56d4..00000000 --- a/X/xsession.d/mouse.sh +++ /dev/null @@ -1,2 +0,0 @@ -# Faster mouse acceleration with a natural threshold -xset mouse 5/2 0 diff --git a/X/xsession.d/xkb.sh b/X/xsession.d/xkb.sh deleted file mode 100644 index a5142398..00000000 --- a/X/xsession.d/xkb.sh +++ /dev/null @@ -1,5 +0,0 @@ -# Map Caps Lock as a Ctrl key, use right alt as Compose, kill X server with -# Ctrl+Alt+Backspace -# <https://en.wikipedia.org/wiki/Compose_key#Common_compose_combinations> -command -v setxkbmap >/dev/null 2>&1 || return -setxkbmap -option compose:ralt,ctrl:nocaps,terminate:ctrl_alt_bksp |