-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathstart-gar.sh
More file actions
executable file
·122 lines (106 loc) · 3.16 KB
/
Copy pathstart-gar.sh
File metadata and controls
executable file
·122 lines (106 loc) · 3.16 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
#!/usr/bin/env bash
# Start gar window manager on a real X session
#
# IMPORTANT: Run this from a TTY, not from Hyprland!
# 1. Press Ctrl+Alt+F2 to switch to TTY2
# 2. Login
# 3. Run: ~/GithubOrgs/tenseleyFlow/gar/start-gar.sh
#
# PANIC MODE: Super+Shift+Escape to exit gar immediately
# BACKUP: Ctrl+Alt+F3 to switch to another TTY if gar freezes
#
# To return to Hyprland after exiting:
# Press Ctrl+Alt+F1 (or wherever SDDM is running)
set -e
GAR_DIR="$(cd "$(dirname "$0")" && pwd)"
GAR_BIN="$GAR_DIR/target/release/gar"
# Check if gar is built
if [[ ! -x "$GAR_BIN" ]]; then
echo "Error: gar not found at $GAR_BIN"
echo "Run: nix-shell --run 'cargo build --release'"
exit 1
fi
# Check if running from a TTY
if [[ -z "$XDG_SESSION_TYPE" ]] || [[ "$XDG_SESSION_TYPE" == "tty" ]]; then
echo "Good: Running from TTY"
else
echo "WARNING: You appear to be running from a graphical session."
echo "For best results, switch to a TTY first (Ctrl+Alt+F2)"
echo ""
read -p "Continue anyway? [y/N] " -n 1 -r
echo
if [[ ! $REPLY =~ ^[Yy]$ ]]; then
exit 1
fi
fi
# Find an available display
for i in 1 2 3 4 5; do
if [[ ! -e "/tmp/.X$i-lock" ]]; then
DISPLAY_NUM=":$i"
break
fi
done
if [[ -z "$DISPLAY_NUM" ]]; then
echo "Error: No available display found"
exit 1
fi
# Detect current VT
CURRENT_VT=$(tty | grep -o 'tty[0-9]*' | grep -o '[0-9]*' || echo "")
if [[ -z "$CURRENT_VT" ]]; then
CURRENT_VT=7
fi
echo "========================================"
echo " Starting gar window manager"
echo "========================================"
echo ""
echo " PANIC MODE: Super+Shift+Escape"
echo " TTY ESCAPE: Ctrl+Alt+F$((CURRENT_VT == 2 ? 3 : 2))"
echo ""
echo " Display: $DISPLAY_NUM"
echo " VT: $CURRENT_VT"
echo "========================================"
echo ""
# Create xinitrc for gar
XINITRC=$(mktemp)
cat > "$XINITRC" << EOF
#!/bin/sh
# Set up environment
export GAR_LOG=info
# Configure monitor layout: 1080p -> 1440p -> 4k (left to right)
# Wait a moment for X to fully initialize
sleep 0.5
xrandr \\
--output DP-1 --mode 1920x1080 --pos 0x0 \\
--output HDMI-1 --mode 2560x1440 --pos 1920x0 \\
--output HDMI-0 --mode 3840x2160 --pos 4480x0
# Ensure gar config directory exists
mkdir -p ~/.config/gar
# Launch compositor before WM (for proper screen repainting)
# gar generates picom.conf on startup and signals picom to reload
if command -v picom > /dev/null 2>&1; then
if [[ -f ~/.config/gar/picom.conf ]]; then
picom -b --config ~/.config/gar/picom.conf &
else
# First run: start with GLX backend, gar will generate config and signal reload
picom -b --backend glx &
fi
sleep 0.1
fi
# Start gar
exec $GAR_BIN
EOF
chmod +x "$XINITRC"
# Trap to clean up
cleanup() {
rm -f "$XINITRC"
echo ""
echo "gar exited. Press Ctrl+Alt+F1 to return to SDDM/Hyprland."
}
trap cleanup EXIT
# Start X with gar
echo "Starting X server with gar..."
echo "Press Ctrl+C here or Super+Shift+Escape in gar to exit"
echo ""
# Use xinit directly - show all output for debugging
# -keeptty is required for systemd-logind integration
xinit "$XINITRC" -- "$DISPLAY_NUM" "vt$CURRENT_VT" -keeptty