#!/bin/bash # Launches waybar on the profile's main monitor. # # waybar can only pin a bar to an output by name, and the name differs per # machine -- eDP-1 on the laptop, DP-1 on mainPC -- while DP-1 exists on both, # so no static list can express "the main monitor". Resolve it from Hyprland # instead: in both hypr/configs/profiles/*.lua the main monitor is the one at # position 0x0. waybar/config.jsonc includes the fragment written here. frag="${XDG_CACHE_HOME:-$HOME/.cache}/waybar-output.jsonc" mkdir -p "$(dirname "$frag")" out=$(hyprctl monitors -j 2>/dev/null | jq -r 'map(select(.x == 0 and .y == 0)) | .[0].name // empty') if [ -n "$out" ]; then printf '{ "output": "%s" }\n' "$out" > "$frag" else # Nothing at 0x0 (or Hyprland not up): fall back to a bar on every output. printf '{}\n' > "$frag" fi exec waybar "$@"