| 1 | #!/bin/bash |
| 2 | # gar session wrapper - sets up environment before starting gar |
| 3 | # This script is typically installed to /usr/local/share/gar/gar-session.sh |
| 4 | |
| 5 | # Find gar binary - check common locations (user local first for dev overrides) |
| 6 | GAR_BIN="${GAR_BIN:-}" |
| 7 | if [ -z "$GAR_BIN" ]; then |
| 8 | for path in "$HOME/.local/bin/gar" /usr/local/bin/gar /usr/bin/gar; do |
| 9 | if [ -x "$path" ]; then |
| 10 | GAR_BIN="$path" |
| 11 | break |
| 12 | fi |
| 13 | done |
| 14 | fi |
| 15 | |
| 16 | # Fallback to PATH lookup |
| 17 | if [ -z "$GAR_BIN" ] || [ ! -x "$GAR_BIN" ]; then |
| 18 | GAR_BIN="$(command -v gar 2>/dev/null || true)" |
| 19 | fi |
| 20 | |
| 21 | if [ -z "$GAR_BIN" ] || [ ! -x "$GAR_BIN" ]; then |
| 22 | echo "ERROR: gar binary not found. Please ensure gar is installed." >&2 |
| 23 | exit 1 |
| 24 | fi |
| 25 | |
| 26 | # Optional: configure monitor layout |
| 27 | # Uncomment and customize for your setup: |
| 28 | # xrandr --output eDP-1 --mode 2880x1800 --pos 0x0 |
| 29 | # xrandr --output DP-1 --mode 1920x1080 --pos 0x0 \ |
| 30 | # --output HDMI-1 --mode 2560x1440 --pos 1920x0 |
| 31 | |
| 32 | # Ensure gar config directory exists |
| 33 | mkdir -p ~/.config/gar |
| 34 | |
| 35 | # ═══════════════════════════════════════════════════════════════════ |
| 36 | # SYSTEMD SESSION SETUP - Required for user services like garbg |
| 37 | # Pattern from sway-systemd, i3-session, and ArchWiki systemd/User |
| 38 | # ═══════════════════════════════════════════════════════════════════ |
| 39 | |
| 40 | # Import DISPLAY and XAUTHORITY to systemd user session |
| 41 | # This allows user services to connect to X11 |
| 42 | systemctl --user import-environment DISPLAY XAUTHORITY |
| 43 | |
| 44 | # Also update D-Bus activation environment (for D-Bus services) |
| 45 | if command -v dbus-update-activation-environment &> /dev/null; then |
| 46 | dbus-update-activation-environment DISPLAY XAUTHORITY |
| 47 | fi |
| 48 | |
| 49 | # Start gar-session.target - this binds to graphical-session.target |
| 50 | # (graphical-session.target has RefuseManualStart=yes, so we use our own target) |
| 51 | systemctl --user start gar-session.target |
| 52 | |
| 53 | # ═══════════════════════════════════════════════════════════════════ |
| 54 | |
| 55 | # Compositor is now managed by gar itself via start_compositor() |
| 56 | # based on the "compositor" setting in init.lua ("picom", "garchomp", or "none") |
| 57 | # Do NOT start picom here - it causes dual-compositor conflicts when garchomp is selected |
| 58 | |
| 59 | # Set log level |
| 60 | export GAR_LOG=info |
| 61 | |
| 62 | # garbar is now launched natively by gar when gar.bar is configured in init.lua |
| 63 | # (Legacy polybar launch removed - use gar.bar config instead) |
| 64 | |
| 65 | # Start gar |
| 66 | exec "$GAR_BIN" |