Commit | Line | Data |
---|---|---|
d6c84e8b SK |
1 | #! /bin/bash |
2 | ||
3 | set -e | |
4 | ||
ac1c27a5 SK |
5 | LOG_FILE=~/var/log/xlaunch.log |
6 | ||
7 | log() { | |
8 | local -r fmt="$1" | |
9 | shift | |
10 | ||
11 | printf "${fmt}\n" $@ | twrap.sh >> "$LOG_FILE" | |
12 | } | |
13 | ||
e2b9f534 SK |
14 | launch_then_killall() { |
15 | local -r program="$1" | |
16 | local -r timeout="${2:-1}" # 2nd arg or default to 1. | |
17 | ||
18 | "$program"& | |
19 | sleep "$timeout" | |
20 | killall "$program" | |
21 | } | |
22 | ||
23 | dpi_scale() { | |
24 | # IDK what magic is at work here, but launching mate-appearance-properties | |
25 | # does the job better than setting scaling variables. | |
26 | # TODO Get to the bottom of how it works and replicate directly. | |
ac1c27a5 | 27 | # TODO Try this: https://wiki.archlinux.org/title/HiDPI#Xorg |
e2b9f534 SK |
28 | launch_then_killall 'mate-appearance-properties' 1 |
29 | ||
30 | # GDK 3 (GTK 3) | |
31 | # https://wiki.archlinux.org/index.php/HiDPI#GDK_3_(GTK_3) | |
32 | #export GDK_SCALE=2 | |
33 | ||
34 | # QT | |
35 | # https://wiki.archlinux.org/index.php/HiDPI#Qt_5 | |
36 | # https://doc.qt.io/qt-5/highdpi.html | |
37 | # https://blog.qt.io/blog/2016/01/26/high-dpi-support-in-qt-5-6/ | |
38 | #export QT_SCALE_FACTOR=2 # Causes qutebrowser UI fonts to have large gaps. | |
39 | #export QT_FONT_DPI=192 # Scales qutebrowser UI fonts as expected. | |
40 | } | |
d6c84e8b SK |
41 | |
42 | launch_common() { | |
ac1c27a5 SK |
43 | local -r scripts_dir=~/.xlaunch.d |
44 | ||
45 | # XXX dunst lazily started by dbus? | |
46 | dunst --startup_notification -conf ~/.config/dunst/dunstrc & | |
d6c84e8b SK |
47 | xbindkeys |
48 | xscreensaver & | |
e2b9f534 SK |
49 | dpi_scale& |
50 | #mpd --kill || true | |
51 | #mpd | |
ac1c27a5 SK |
52 | log '[error] Looking for scripts in directory: "%s"' "$scripts_dir" |
53 | for script in "$scripts_dir"/*; do | |
54 | log '[debug] Launching script: "%s"' "$script" | |
d6c84e8b SK |
55 | "$script" |
56 | done | |
57 | } | |
58 | ||
59 | launch_specialized() { | |
658bbf0d SK |
60 | local -r scripts_dir=~/.xlaunch.d."$(hostname)" |
61 | ||
ac1c27a5 | 62 | log '[error] Looking for scripts in directory: "%s"' "$scripts_dir" |
57081bde | 63 | if test -d "$scripts_dir" |
658bbf0d SK |
64 | then |
65 | for script in "$scripts_dir"/*; do | |
ac1c27a5 | 66 | log '[debug] Launching script: "%s"' "$script" |
658bbf0d SK |
67 | "$script" |
68 | done | |
57081bde | 69 | else |
ac1c27a5 | 70 | log '[error] scripts_dir not found: %s' "$scripts_dir" |
658bbf0d | 71 | fi |
d6c84e8b SK |
72 | } |
73 | ||
ac1c27a5 SK |
74 | main() { |
75 | log '[info] Starting X11' | |
76 | ||
77 | launch_common | |
78 | launch_specialized | |
79 | ||
80 | log '[info] Launching dwm' | |
81 | exec dwm | |
82 | } | |
d6c84e8b | 83 | |
ac1c27a5 | 84 | main |