diff --git a/.gitignore b/.gitignore index 510ee38..4b5413a 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,3 @@ /hyprland/ignore.conf /scheme/current.conf +/hyprlock.conf diff --git a/hyprland/execs.conf b/hyprland/execs.conf index 2bd59dd..4d02d37 100644 --- a/hyprland/execs.conf +++ b/hyprland/execs.conf @@ -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 diff --git a/scripts/gen-hyprlock.fish b/scripts/gen-hyprlock.fish new file mode 100755 index 0000000..02980b1 --- /dev/null +++ b/scripts/gen-hyprlock.fish @@ -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 diff --git a/scripts/monitor-hyprlock.fish b/scripts/monitor-hyprlock.fish new file mode 100755 index 0000000..6dd5803 --- /dev/null +++ b/scripts/monitor-hyprlock.fish @@ -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 diff --git a/hyprlock.conf b/scripts/templates/hyprlock-base.conf similarity index 72% rename from hyprlock.conf rename to scripts/templates/hyprlock-base.conf index b35ca09..68c7f4a 100644 --- a/hyprlock.conf +++ b/scripts/templates/hyprlock-base.conf @@ -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 -} diff --git a/scripts/templates/hyprlock-monitor.conf b/scripts/templates/hyprlock-monitor.conf new file mode 100644 index 0000000..aa9057e --- /dev/null +++ b/scripts/templates/hyprlock-monitor.conf @@ -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 +}