aboutsummaryrefslogtreecommitdiff
path: root/X/xsession.sh
blob: 76cbc85b8d63aa5cededca73461182a8bac075d5 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
# Custom i3wm X session to fit into Debian's way of doing things

# Monitor and wallpaper setup is very machine-specific, and isn't versioned in
# here.  Neither xrandr(1) nor xwallpaper(1) have config files, so we fake it
# with xargs and looking for a file with argument tokens to read in
# XDG_CONFIG_HOME, which will almost always be:
#
# - ~/.config/xrandr/config
# - ~/.config/xwallpaper/config
#
# We figure each one out in a subshell, so that we can use a temporary variable
# for the configuration path without polluting the namespace of the rest of
# this script.
#
for program in xrandr xwallpaper ; do (
    command -v -- "$program" >/dev/null 2>&1 || exit
    config=${XDG_CONFIG_HOME:-"$HOME"/.config}/"$program"/config
    [ -e "$config" ] || exit
    xargs -- "$program" < "$config"
) ; done

# Set a few keyboard map options
# - Remap Caps Lock as another Control key
# - Remap right Alt as a Compose key
# - Kill X server with Ctrl+Alt+Backspace
setxkbmap \
    -option caps:ctrl_modifier \
    -option compose:ralt \
    -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
if [ -n "$BROWSER" ] ; then
    export BROWSER
fi

# Load all supplementary scripts in ~/.xsession.d
for sh in "$HOME"/.xsession.d/*.sh ; do
    [ -e "$sh" ] || continue
    . "$sh"
done
unset -v sh

# Start i3 window manager now that everything's ready
exec i3