gardesk/gar / db679da

Browse files

Add xrandr monitor setup to session scripts

Authored by mfwolffe <wolffemf@dukes.jmu.edu>
SHA
db679daf28856fa90e1148f7950e23e9502e0f6f
Parents
531d253
Tree
63864e4

3 changed files

StatusFile+-
A gar-session.sh 15 0
M gar.desktop 3 3
M start-gar.sh 55 13
gar-session.shadded
@@ -0,0 +1,15 @@
1
+#!/bin/bash
2
+# gar session wrapper - sets up monitors before starting gar
3
+
4
+# Configure monitor layout: 1080p -> 1440p -> 4k (left to right)
5
+# Output names: DP-1 (1080p), HDMI-1 (1440p), HDMI-0 (4k)
6
+xrandr \
7
+  --output DP-1 --mode 1920x1080 --pos 0x0 \
8
+  --output HDMI-1 --mode 2560x1440 --pos 1920x0 \
9
+  --output HDMI-0 --mode 3840x2160 --pos 4480x0
10
+
11
+# Set log level
12
+export GAR_LOG=info
13
+
14
+# Start gar
15
+exec /home/mfwolffe/GithubOrgs/tenseleyFlow/gar/target/release/gar
gar.desktopmodified
@@ -1,6 +1,6 @@
11
 [Desktop Entry]
22
 Name=gar
3
-Comment=Tiling window manager with smart splits
4
-Exec=gar
5
-Type=XSession
3
+Comment=A tiling window manager
4
+Exec=/home/mfwolffe/GithubOrgs/tenseleyFlow/gar/gar-session.sh
5
+Type=Application
66
 DesktopNames=gar
start-gar.shmodified
@@ -1,15 +1,16 @@
11
 #!/usr/bin/env bash
22
 # Start gar window manager on a real X session
33
 #
4
-# PANIC MODE: Alt+Shift+Escape to exit gar immediately
5
-# BACKUP: Ctrl+Alt+F2 to switch to TTY2 if gar freezes
4
+# IMPORTANT: Run this from a TTY, not from Hyprland!
5
+#   1. Press Ctrl+Alt+F2 to switch to TTY2
6
+#   2. Login
7
+#   3. Run: ~/GithubOrgs/tenseleyFlow/gar/start-gar.sh
68
 #
7
-# Usage:
8
-#   ./start-gar.sh        # Start on next available display
9
-#   ./start-gar.sh :2     # Start on specific display
9
+# PANIC MODE: Super+Shift+Escape to exit gar immediately
10
+# BACKUP: Ctrl+Alt+F3 to switch to another TTY if gar freezes
1011
 #
1112
 # To return to Hyprland after exiting:
12
-#   Just log out and log back in, or run: Hyprland
13
+#   Press Ctrl+Alt+F1 (or wherever SDDM is running)
1314
 
1415
 set -e
1516
 
@@ -23,17 +24,48 @@ if [[ ! -x "$GAR_BIN" ]]; then
2324
     exit 1
2425
 fi
2526
 
26
-# Find display
27
-DISPLAY_NUM="${1:-:1}"
27
+# Check if running from a TTY
28
+if [[ -z "$XDG_SESSION_TYPE" ]] || [[ "$XDG_SESSION_TYPE" == "tty" ]]; then
29
+    echo "Good: Running from TTY"
30
+else
31
+    echo "WARNING: You appear to be running from a graphical session."
32
+    echo "For best results, switch to a TTY first (Ctrl+Alt+F2)"
33
+    echo ""
34
+    read -p "Continue anyway? [y/N] " -n 1 -r
35
+    echo
36
+    if [[ ! $REPLY =~ ^[Yy]$ ]]; then
37
+        exit 1
38
+    fi
39
+fi
40
+
41
+# Find an available display
42
+for i in 1 2 3 4 5; do
43
+    if [[ ! -e "/tmp/.X$i-lock" ]]; then
44
+        DISPLAY_NUM=":$i"
45
+        break
46
+    fi
47
+done
48
+
49
+if [[ -z "$DISPLAY_NUM" ]]; then
50
+    echo "Error: No available display found"
51
+    exit 1
52
+fi
53
+
54
+# Detect current VT
55
+CURRENT_VT=$(tty | grep -o 'tty[0-9]*' | grep -o '[0-9]*' || echo "")
56
+if [[ -z "$CURRENT_VT" ]]; then
57
+    CURRENT_VT=7
58
+fi
2859
 
2960
 echo "========================================"
3061
 echo "  Starting gar window manager"
3162
 echo "========================================"
3263
 echo ""
33
-echo "  PANIC MODE: Alt+Shift+Escape"
34
-echo "  TTY ESCAPE: Ctrl+Alt+F2"
64
+echo "  PANIC MODE: Super+Shift+Escape"
65
+echo "  TTY ESCAPE: Ctrl+Alt+F$((CURRENT_VT == 2 ? 3 : 2))"
3566
 echo ""
3667
 echo "  Display: $DISPLAY_NUM"
68
+echo "  VT: $CURRENT_VT"
3769
 echo "========================================"
3870
 echo ""
3971
 
@@ -44,6 +76,14 @@ cat > "$XINITRC" << EOF
4476
 # Set up environment
4577
 export GAR_LOG=info
4678
 
79
+# Configure monitor layout: 1080p -> 1440p -> 4k (left to right)
80
+# Wait a moment for X to fully initialize
81
+sleep 0.5
82
+xrandr \\
83
+  --output DP-1 --mode 1920x1080 --pos 0x0 \\
84
+  --output HDMI-1 --mode 2560x1440 --pos 1920x0 \\
85
+  --output HDMI-0 --mode 3840x2160 --pos 4480x0
86
+
4787
 # Start gar
4888
 exec $GAR_BIN
4989
 EOF
@@ -53,13 +93,15 @@ chmod +x "$XINITRC"
5393
 cleanup() {
5494
     rm -f "$XINITRC"
5595
     echo ""
56
-    echo "gar exited. You can now return to your normal session."
96
+    echo "gar exited. Press Ctrl+Alt+F1 to return to SDDM/Hyprland."
5797
 }
5898
 trap cleanup EXIT
5999
 
60100
 # Start X with gar
61101
 echo "Starting X server with gar..."
62
-echo "Press Ctrl+C here or Alt+Shift+Escape in gar to exit"
102
+echo "Press Ctrl+C here or Super+Shift+Escape in gar to exit"
63103
 echo ""
64104
 
65
-startx "$XINITRC" -- "$DISPLAY_NUM" vt$(tty | grep -o '[0-9]*' || echo 7)
105
+# Use xinit directly - show all output for debugging
106
+# -keeptty is required for systemd-logind integration
107
+xinit "$XINITRC" -- "$DISPLAY_NUM" "vt$CURRENT_VT" -keeptty