#!/bin/sh # Under a uwsm-managed session, systemd brings up graphical-session.target and # starts the xdg-desktop-portal units natively, in the right order. In that case # we must NOT manually kill/relaunch them — doing so fights systemd and causes # the portal to crash (broken pipe), which left apps stuck in light mode. # # So: wait briefly for graphical-session.target. If it comes up (uwsm), bow out. # If it never does (a bare "Hyprland" session, e.g. launched directly from GDM), # fall through and start the portals manually as before. for _ in $(seq 1 10); do if systemctl --user -q is-active graphical-session.target; then exit 0 fi sleep 0.5 done # Bare session fallback: start the portals by hand. killall -e xdg-desktop-portal-hyprland 2>/dev/null killall xdg-desktop-portal 2>/dev/null /usr/lib/xdg-desktop-portal-hyprland & sleep 2 /usr/lib/xdg-desktop-portal &