@@ -1,15 +1,16 @@ |
| 1 | 1 | #!/usr/bin/env bash |
| 2 | 2 | # Start gar window manager on a real X session |
| 3 | 3 | # |
| 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 |
| 6 | 8 | # |
| 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 |
| 10 | 11 | # |
| 11 | 12 | # 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) |
| 13 | 14 | |
| 14 | 15 | set -e |
| 15 | 16 | |
@@ -23,17 +24,48 @@ if [[ ! -x "$GAR_BIN" ]]; then |
| 23 | 24 | exit 1 |
| 24 | 25 | fi |
| 25 | 26 | |
| 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 |
| 28 | 59 | |
| 29 | 60 | echo "========================================" |
| 30 | 61 | echo " Starting gar window manager" |
| 31 | 62 | echo "========================================" |
| 32 | 63 | 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))" |
| 35 | 66 | echo "" |
| 36 | 67 | echo " Display: $DISPLAY_NUM" |
| 68 | +echo " VT: $CURRENT_VT" |
| 37 | 69 | echo "========================================" |
| 38 | 70 | echo "" |
| 39 | 71 | |
@@ -44,6 +76,14 @@ cat > "$XINITRC" << EOF |
| 44 | 76 | # Set up environment |
| 45 | 77 | export GAR_LOG=info |
| 46 | 78 | |
| 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 | + |
| 47 | 87 | # Start gar |
| 48 | 88 | exec $GAR_BIN |
| 49 | 89 | EOF |
@@ -53,13 +93,15 @@ chmod +x "$XINITRC" |
| 53 | 93 | cleanup() { |
| 54 | 94 | rm -f "$XINITRC" |
| 55 | 95 | 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." |
| 57 | 97 | } |
| 58 | 98 | trap cleanup EXIT |
| 59 | 99 | |
| 60 | 100 | # Start X with gar |
| 61 | 101 | 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" |
| 63 | 103 | echo "" |
| 64 | 104 | |
| 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 |