summaryrefslogtreecommitdiff
path: root/bin/i3-startup-always
blob: 61377c5b9119c74f95bb00910551d5f3046169eb (plain)
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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
#!/bin/sh

# idempotent X settings

. $HOME/.shenv

xrdb -merge "$HOME/.Xresources"

# ---- don't let other local users spawn windows on my main X session

xhost -local:

# ---- no bell please

xset b off

# ---- keyboard settings

xset r rate 380 25

# enable numlock if using USB keyboard, with an exception
if ! lsusb | grep -q "SiGma Micro Keyboard TRACER Gamma Ivory"; then
    . /etc/X11/Xsession.d/55numlockx
fi

# disable caps lock if I accidently hit it before running this script
if xset -q | grep "Caps Lock: *on" >/dev/null; then
    xdotool key Caps_Lock
fi

# ---- wallpaper rotation

# if [ -e "$HOME/local/wallpaper.png" ] \
#        && ! systemctl --user --quiet is-enabled i3-rotate-wallpaper.timer; then
#     # Persistent=true only works if the timer has been triggered at
#     # least once, but my computer is generally suspended at midnight.
#     # So pretend that the job just fired
#     mkdir -p "$HOME/.local/share/systemd/timers"
#     touch "$HOME/.local/share/systemd/timers/stamp-i3-rotate-wallpaper.timer"

#     systemctl --user --now enable i3-rotate-wallpaper.timer
# fi

# ---- monitor settings

# if this machine is always plugged into the same monitor, may
# `convert ~/lib/annex/doc/img/wallpaper/foo -resize 1366x768\!
# ~/local/wallpaper.png` or add a cronjob to call i3-rotate-wallpaper.
# Otherwise, stick to a solid colour, because doing otherwise requires
# resizing the image file, setting the root window and restarting
# i3lock every time an external monitor is plugged or unplugged
#
# For images that look bad stretched, to get black borders: convert foo.jpg -resize 1920x1080 -background black -gravity center -extent 1920x1080 ~/local/wallpaper.png

# xsetroot -solid \#2c2c2e
# xsetroot -solid \#111111
# xsetroot -solid \#E5E5E5
xsetroot -solid \#FFFFF6

# machine-specific display settings
if [ "$(hostname -f)" = "iris.silentflame.com" ]; then
    set-half-brightness
    if xrandr | grep "VGA-1 connected"; then
        xrandr \
            --output VGA-1 --primary --mode 1920x1080 --pos 0x0 --rotate normal \
            --output LVDS-1 --mode 1366x768 --pos 1920x312 --rotate normal
    else
        xrandr \
            --output VGA-1 --off \
            --output LVDS-1 --primary --mode 1366x768 --pos 0x0 --rotate normal
    fi
fi

# use wallpaper.png if it's the right size
if i3-wallpaper --check-have; then
    feh --bg-scale --no-xinerama $HOME/local/wallpaper.png

    # restart i3lock, in case the wallpaper changed
    i3-startup-i3lock
# old fallback to a tileable image
# else
#     feh --bg-tile ~/lib/img/diagmonds_2X.png
fi