Compare commits

...

2 Commits

Author SHA1 Message Date
bed974bd4d waybar: pin the bar to the main monitor of the active profile
The previous fix listed both profiles' primaries, "output": ["eDP-1",
"DP-1"] -- but DP-1 is the laptop's second monitor too, so the laptop
would have got a bar on it as well as on eDP-1. No static list can express
"the main monitor" when the two machines share an output name.

Resolve it at launch instead. hypr/scripts/bar asks Hyprland for the
monitor at position 0x0 -- the main monitor in both profiles -- writes
{"output": "<name>"} to ~/.cache/waybar-output.jsonc, and execs waybar;
waybar/config.jsonc includes that fragment. autostart/services, the
bar_reload bind and the performance script all go through the wrapper, so
a reload re-resolves after docking. Signals still target the waybar
process, not the wrapper.

Verified all three paths on mainPC: the fragment pins the bar to DP-1
only, an empty fragment falls back to a bar on every output, and a
fragment naming a disconnected output maps nothing (the failure mode this
started from). Config parses on both profiles.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01StGBghPW9Dm7z7uj2VNWHr
2026-09-04 16:55:33 +02:00
9e045cf096 waybar: show the bar on this machine's primary output
The deployed config pinned "output": "eDP-1", the laptop's internal
display. On the PC waybar started fine but never mapped a layer surface,
so there was no bar and SIGUSR1 had nothing to toggle. Listed both
profiles' primaries instead -- waybar skips names that are not connected,
so the one file works on the laptop and the PC.

Two bugs in the same config that this uncovered:

- bars/main.jsonc included modules/temperature.cpu.jsonc, but the file is
  temperature-cpu.jsonc, so the temperature#cpu module the bar referenced
  was silently absent.
- get_wg_status.sh ran `sudo wg show` with no tty, logging "a terminal is
  required to read the password" on every poll. Now `sudo -n`, which fails
  instantly and falls into the existing "disconnected" branch, and starts
  working as-is if a NOPASSWD rule is ever added.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01StGBghPW9Dm7z7uj2VNWHr
2026-09-04 16:52:15 +02:00
7 changed files with 42 additions and 10 deletions

View File

@@ -1,6 +1,9 @@
-- Was: configs/default_apps.conf
local bar = "waybar"
-- The bar is launched through a wrapper that pins it to this machine's main
-- monitor (see hypr/scripts/bar); signals still go to the waybar process.
local bar = os.getenv("HOME") .. "/.config/hypr/scripts/bar"
local bar_proc = "waybar"
local notifications = "swaync-client"
local terminal = "kitty"
@@ -8,8 +11,8 @@ return {
launcher = "rofi -show drun",
bar = bar,
bar_toggle = "killall -SIGUSR1 " .. bar,
bar_reload = "killall " .. bar .. "; " .. bar,
bar_toggle = "killall -SIGUSR1 " .. bar_proc,
bar_reload = "killall " .. bar_proc .. "; " .. bar,
notifications = notifications,
notifications_read = notifications .. " -C",

View File

@@ -9,8 +9,8 @@ awww-daemon --format xrgb &
# Pyprland Daemon
pypr --debug /tmp/pypr.log &
# Bar
waybar &
# Bar (wrapper pins it to the main monitor of the active profile)
"$HOME"/.config/hypr/scripts/bar &
# Notification Daemon
swaync &

23
hypr/scripts/bar Executable file
View File

@@ -0,0 +1,23 @@
#!/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 "$@"

View File

@@ -17,7 +17,7 @@ if [ "$HYPRGAMEMODE" = true ]; then
fi
killall waybar
waybar > /dev/null 2>&1 &
"$HOME"/.config/hypr/scripts/bar > /dev/null 2>&1 &
# Hyprland performance
if [ "$HYPRGAMEMODE" = true ]; then

View File

@@ -7,7 +7,7 @@
"~/.config/waybar/modules/pulseaudio.jsonc",
"~/.config/waybar/modules/cpu.jsonc",
"~/.config/waybar/modules/memory.jsonc",
"~/.config/waybar/modules/temperature.cpu.jsonc",
"~/.config/waybar/modules/temperature-cpu.jsonc",
"~/.config/waybar/modules/battery.jsonc",
"~/.config/waybar/modules/network.jsonc",
"~/.config/waybar/modules/wireguard.jsonc",

View File

@@ -1,9 +1,13 @@
[
{
"include": "~/.config/waybar/bars/main.jsonc",
"include": [
"~/.config/waybar/bars/main.jsonc",
// "output", resolved per machine by hypr/scripts/bar -- see the comment
// there. Missing file just means a bar on every monitor.
"~/.cache/waybar-output.jsonc",
],
"height": 50,
"layer": "top",
"output": "eDP-1",
"mode": "dock",
"exclusive": true,
"passtrough": false,

View File

@@ -44,7 +44,9 @@ function format {
}
# Read wg show output and format
wg_show_output=$(sudo wg show)
# -n so a missing NOPASSWD sudoers rule fails instantly instead of blocking
# the module on a password prompt it has no terminal to ask on.
wg_show_output=$(sudo -n wg show 2>/dev/null)
if [[ -z $wg_show_output ]]; then
echo "{ \"text\": \"---\", \"tooltip\": \"disconnected\", \"class\": \"\", \"percentage\": 0 }"