|
5 | 5 | # - If only HDMI-1 is connected, explicitly turn HDMI-2 off to avoid a larger |
6 | 6 | # virtual framebuffer / overlapping desktop regions. |
7 | 7 |
|
| 8 | +# Log autostart output for debugging |
| 9 | +mkdir -p "$HOME/.cache" || true |
| 10 | +exec >>"$HOME/.cache/openbox-autostart.log" 2>&1 |
| 11 | +echo "[autostart] $(date '+%Y-%m-%d %H:%M:%S') starting" |
| 12 | + |
8 | 13 | # Give X a moment to bring outputs up (especially on Raspberry Pi) |
9 | | -( sleep 1 \ |
10 | | - && if xrandr | grep -q "^HDMI-2 connected"; then \ |
11 | | - xrandr --output HDMI-1 --mode 1920x1080 --primary --pos 0x0 --rotate normal \ |
12 | | - --output HDMI-2 --mode 1920x1080 --pos 1920x0 --rotate normal \ |
13 | | - --fb 3840x1080; \ |
14 | | - else \ |
15 | | - xrandr --output HDMI-1 --mode 1920x1080 --primary --pos 0x0 --rotate normal \ |
16 | | - --output HDMI-2 --off \ |
17 | | - --fb 1920x1080; \ |
18 | | - fi \ |
19 | | - && xrdb -merge "$HOME/.Xdefaults" \ |
| 14 | +( |
| 15 | + sleep 1 |
| 16 | + |
| 17 | + # Resolve tool paths (PATH can be minimal under Openbox) |
| 18 | + XRANDR="$(command -v xrandr || echo /usr/bin/xrandr)" |
| 19 | + XRDB="$(command -v xrdb || echo /usr/bin/xrdb)" |
| 20 | + |
| 21 | + echo "[autostart] XRANDR=$XRANDR" |
| 22 | + "$XRANDR" --version || true |
| 23 | + echo "[autostart] xrandr outputs:" |
| 24 | + XR_OUT="$($XRANDR || true)" |
| 25 | + echo "$XR_OUT" |
| 26 | + |
| 27 | + # Always try to set HDMI-1 first (independent call), so a bad HDMI-2 EDID |
| 28 | + # can't prevent HDMI-1 from switching to 1920x1080. |
| 29 | + echo "[autostart] Setting HDMI-1 to 1920x1080" |
| 30 | + "$XRANDR" --output HDMI-1 --mode 1920x1080 --primary --pos 0x0 --rotate normal || true |
| 31 | + |
| 32 | + # Decide whether HDMI-2 is a real, usable second monitor. |
| 33 | + # On some setups HDMI-2 can appear as 'connected' but only offers 1024x768 |
| 34 | + # (0mm x 0mm), which indicates missing/invalid EDID. |
| 35 | + HDMI2_CONNECTED=0 |
| 36 | + echo "$XR_OUT" | grep -q "^HDMI-2 connected" && HDMI2_CONNECTED=1 || true |
| 37 | + |
| 38 | + HDMI2_HAS_1080P=0 |
| 39 | + # Look for 1920x1080 in the HDMI-2 mode list (indented lines after HDMI-2 header) |
| 40 | + echo "$XR_OUT" | awk ' |
| 41 | + /^HDMI-2 connected/{in2=1; next} |
| 42 | + /^HDMI-/{in2=0} |
| 43 | + in2{print} |
| 44 | + ' | grep -q "1920x1080" && HDMI2_HAS_1080P=1 || true |
| 45 | + |
| 46 | + if [ "$HDMI2_CONNECTED" -eq 1 ] && [ "$HDMI2_HAS_1080P" -eq 1 ]; then |
| 47 | + echo "[autostart] HDMI-2 connected + has 1920x1080: extending to the right" |
| 48 | + "$XRANDR" \ |
| 49 | + --output HDMI-2 --mode 1920x1080 --pos 1920x0 --rotate normal \ |
| 50 | + --fb 3840x1080 || true |
| 51 | + else |
| 52 | + echo "[autostart] HDMI-2 absent or missing 1920x1080: disabling HDMI-2 and forcing 1920x1080 fb" |
| 53 | + "$XRANDR" --output HDMI-2 --off || true |
| 54 | + "$XRANDR" --fb 1920x1080 || true |
| 55 | + fi |
| 56 | + |
| 57 | + echo "[autostart] Reloading Xresources from $HOME/.Xdefaults" |
| 58 | + "$XRDB" -merge "$HOME/.Xdefaults" || true |
| 59 | + |
| 60 | + echo "[autostart] $(date '+%Y-%m-%d %H:%M:%S') display config done" |
20 | 61 | ) & |
21 | 62 |
|
22 | 63 | # Set gradient background (after layout) |
23 | 64 | ( sleep 2 && feh --bg-scale "$HOME/.config/thinOS/backgrounds/gradient.png" ) & |
24 | 65 |
|
25 | | -# Autostart PyRDPConnect in full-screen mode |
26 | | -python3 /usr/share/PyRDPConnect/src/main.py & |
27 | | - |
28 | 66 | # Start devmon for automount (with notifications) |
29 | | -( sleep 2 && /usr/local/bin/thinos-devmon ) & |
| 67 | +( sleep 3 && /usr/local/bin/thinos-devmon ) & |
| 68 | + |
| 69 | +# Autostart PyRDPConnect in full-screen mode |
| 70 | +( sleep 4 && python3 /usr/share/PyRDPConnect/src/main.py ) & |
0 commit comments