hyprlock: regen config per monitor

So media widget fits properly
This commit is contained in:
2 * r + 2 * t 2025-03-02 19:36:39 +11:00
parent 18f9811459
commit af6b650d2e
6 changed files with 83 additions and 48 deletions

1
.gitignore vendored
View file

@ -1,2 +1,3 @@
/hyprland/ignore.conf
/scheme/current.conf
/hyprlock.conf

View file

@ -29,5 +29,9 @@ exec-once = mpris-proxy
# Resize and move picture in picture windows
exec-once = caelestia pip -d
# Regenerate hyprlock config on monitor changes
exec = ~/.config/hypr/scripts/gen-hyprlock.fish
exec-once = ~/.config/hypr/scripts/monitor-hyprlock.fish
# SafeEyes
exec-once = uwsm app -- ags run -d ~/.local/share/caelestia/safeeyes

19
scripts/gen-hyprlock.fish Executable file
View file

@ -0,0 +1,19 @@
#!/bin/fish
set -l src (dirname (status filename))
cp $src/templates/hyprlock-base.conf $src/../hyprlock.conf
for monitor in (hyprctl monitors -j | jq -r '.[] | "\(.name) \(.width) \(.height)"')
set -l monitor (string split ' ' $monitor)
set -l name $monitor[1]
set -l width $monitor[2]
set -l height $monitor[3]
set -l tmp (mktemp)
cp $src/templates/hyprlock-monitor.conf $tmp
sed -n 's/.*{{ \(.*\) }}.*/\1/p' $src/templates/hyprlock-monitor.conf | while read expr
sed -i "s|{{ $expr }}|$(echo "echo $expr" | .)|g" $tmp
end
cat $tmp >> $src/../hyprlock.conf
end

10
scripts/monitor-hyprlock.fish Executable file
View file

@ -0,0 +1,10 @@
#!/bin/fish
set -l src (dirname (status filename))
socat -U - UNIX-CONNECT:$XDG_RUNTIME_DIR/hypr/$HYPRLAND_INSTANCE_SIGNATURE/.socket2.sock | while read line
switch $line
case 'monitor*'
$src/gen-hyprlock.fish
end
end

View file

@ -141,51 +141,3 @@ image { # Player cover art
halign = center
valign = bottom
}
label { # Player identity
monitor =
text = cmd[update:1000] $scripts/truncate.fish $font_family-Bold 14 180 "$(caelestia shell media identity)"
color = rgb($subtext0)
font_size = 12
font_family = $font_family
position = 1640, 170
halign = left
valign = bottom
}
label { # Player track title
monitor =
text = cmd[update:1000] $scripts/truncate.fish $font_family-Bold 14 160 "$($player_cmd xesam:title)"
color = rgb($text)
font_size = 14
font_family = $font_family Bold
position = 1640, 142
halign = left
valign = bottom
}
label { # Player track artist
monitor =
text = cmd[update:1000] $scripts/truncate.fish $font_family-Bold 14 120 "$($player_cmd xesam:artist)"
color = rgb($text)
font_size = 12
font_family = $font_family
position = 1640, 120
halign = left
valign = bottom
}
label { # Player track time
monitor =
text = cmd[update:1000] $scripts/track-time.fish
color = rgb($subtext0)
font_size = 12
font_family = $font_family
position = -1540, 110
halign = right
valign = bottom
}

View file

@ -0,0 +1,49 @@
# MONITOR {{ $name }}
label { # Player identity
monitor = {{ $name }}
text = cmd[update:1000] $scripts/truncate.fish $font_family-Bold 14 180 "$(caelestia shell media identity)"
color = rgb($subtext0)
font_size = 12
font_family = $font_family
position = {{ (math $width / 2 - 80) }}, 170
halign = left
valign = bottom
}
label { # Player track title
monitor = {{ $name }}
text = cmd[update:1000] $scripts/truncate.fish $font_family-Bold 14 160 "$($player_cmd xesam:title)"
color = rgb($text)
font_size = 14
font_family = $font_family Bold
position = {{ (math $width / 2 - 80) }}, 142
halign = left
valign = bottom
}
label { # Player track artist
monitor = {{ $name }}
text = cmd[update:1000] $scripts/truncate.fish $font_family-Bold 14 120 "$($player_cmd xesam:artist)"
color = rgb($text)
font_size = 12
font_family = $font_family
position = {{ (math $width / 2 - 80) }}, 120
halign = left
valign = bottom
}
label { # Player track time
monitor = {{ $name }}
text = cmd[update:1000] $scripts/track-time.fish
color = rgb($subtext0)
font_size = 12
font_family = $font_family
position = {{ (math 180 - $width / 2) }}, 110
halign = right
valign = bottom
}