Shorten TODO template headings
[khome.git] / home / .xlaunch
index 0cf046b..9f33d9b 100755 (executable)
@@ -2,32 +2,83 @@
 
 set -e
 
+LOG_FILE=~/var/log/xlaunch.log
+
+log() {
+    local -r fmt="$1"
+    shift
+
+    printf "${fmt}\n" $@ | twrap.sh >> "$LOG_FILE"
+}
+
+launch_then_killall() {
+    local -r program="$1"
+    local -r timeout="${2:-1}" # 2nd arg or default to 1.
+
+    "$program"&
+    sleep "$timeout"
+    killall "$program"
+}
+
+dpi_scale() {
+    # IDK what magic is at work here, but launching mate-appearance-properties
+    # does the job better than setting scaling variables.
+    # TODO Get to the bottom of how it works and replicate directly.
+    # TODO Try this: https://wiki.archlinux.org/title/HiDPI#Xorg
+    launch_then_killall 'mate-appearance-properties' 1
+
+    # GDK 3 (GTK 3)
+    # https://wiki.archlinux.org/index.php/HiDPI#GDK_3_(GTK_3)
+    #export GDK_SCALE=2
+
+    # QT
+    # https://wiki.archlinux.org/index.php/HiDPI#Qt_5
+    # https://doc.qt.io/qt-5/highdpi.html
+    # https://blog.qt.io/blog/2016/01/26/high-dpi-support-in-qt-5-6/
+    #export QT_SCALE_FACTOR=2  # Causes qutebrowser UI fonts to have large gaps.
+    #export QT_FONT_DPI=192  # Scales qutebrowser UI fonts as expected.
+}
 
 launch_common() {
+    local -r scripts_dir=~/.xlaunch.d
+
+    # XXX dunst lazily started by dbus?
+    dunst --startup_notification -conf ~/.config/dunst/dunstrc &
     xbindkeys
     xscreensaver &
-    mpd --kill || true
-    mpd
-    for script in ~/.xlaunch.d/*; do
+    dpi_scale&
+    #mpd --kill || true
+    #mpd
+    log '[error] Looking for scripts in directory: "%s"' "$scripts_dir"
+    for script in "$scripts_dir"/*; do
+        log '[debug] Launching script: "%s"' "$script"
         "$script"
     done
 }
 
 launch_specialized() {
-    # XXX dunst lazily started by dbus
     local -r scripts_dir=~/.xlaunch.d."$(hostname)"
 
+    log '[error] Looking for scripts in directory: "%s"' "$scripts_dir"
     if test -d "$scripts_dir"
     then
         for script in "$scripts_dir"/*; do
+            log '[debug] Launching script: "%s"' "$script"
             "$script"
         done
     else
-        printf '[error] scripts_dir not found: %s\n' "$scripts_dir" >&2
+        log '[error] scripts_dir not found: %s' "$scripts_dir"
     fi
 }
 
-launch_common
-launch_specialized
+main() {
+    log '[info] Starting X11'
+
+    launch_common
+    launch_specialized
+
+    log '[info] Launching dwm'
+    exec dwm
+}
 
-exec dwm
+main
This page took 0.026759 seconds and 4 git commands to generate.