From 6ca12dc56f433c1527f81702e2f58b29e76e3b18 Mon Sep 17 00:00:00 2001
From: 2 * r + 2 * t <61896496+soramanew@users.noreply.github.com>
Date: Sun, 9 Mar 2025 23:27:08 +1100
Subject: [PATCH] hyprlock: multiple styles
Choose style using config
---
hyprland/execs.conf | 3 +
scripts/gen-hyprlock.fish | 31 +++--
scripts/monitor-config.fish | 8 ++
scripts/templates/hyprlock/base.conf | 14 +++
.../templates/hyprlock/futuristic/main.conf | 75 ++++++++++++
.../hyprlock/futuristic/per-monitor.conf | 35 ++++++
.../round/main.conf} | 111 ++++++++----------
.../round/per-monitor.conf} | 4 +-
8 files changed, 206 insertions(+), 75 deletions(-)
create mode 100755 scripts/monitor-config.fish
create mode 100644 scripts/templates/hyprlock/base.conf
create mode 100644 scripts/templates/hyprlock/futuristic/main.conf
create mode 100644 scripts/templates/hyprlock/futuristic/per-monitor.conf
rename scripts/templates/{hyprlock-base.conf => hyprlock/round/main.conf} (88%)
rename scripts/templates/{hyprlock-monitor.conf => hyprlock/round/per-monitor.conf} (84%)
diff --git a/hyprland/execs.conf b/hyprland/execs.conf
index 4d02d37..bf90c12 100644
--- a/hyprland/execs.conf
+++ b/hyprland/execs.conf
@@ -33,5 +33,8 @@ exec-once = caelestia pip -d
exec = ~/.config/hypr/scripts/gen-hyprlock.fish
exec-once = ~/.config/hypr/scripts/monitor-hyprlock.fish
+# Reload hyprland when config changes (to regenerate everything)
+exec-once = ~/.config/hypr/scripts/monitor-config.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
index 02980b1..c5f6609 100755
--- a/scripts/gen-hyprlock.fish
+++ b/scripts/gen-hyprlock.fish
@@ -2,18 +2,27 @@
set -l src (dirname (status filename))
-cp $src/templates/hyprlock-base.conf $src/../hyprlock.conf
+set -q XDG_CONFIG_HOME && set -l config $XDG_CONFIG_HOME/caelestia || set -l config $HOME/.config/caelestia
-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]
+cp $src/templates/hyprlock/base.conf $src/../hyprlock.conf
- 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
+test -f $config/hypr.json && set -l style (jq -r '.hyprlock.style' $config/hypr.json)
+test -f "$src/templates/hyprlock/$style/main.conf" || set -l style round
+
+cat $src/templates/hyprlock/$style/main.conf >> $src/../hyprlock.conf
+
+if test -f $src/templates/hyprlock/$style/per-monitor.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/$style/per-monitor.conf $tmp
+ sed -n 's/.*{{ \(.*\) }}.*/\1/p' $src/templates/hyprlock/$style/per-monitor.conf | while read expr
+ sed -i "s|{{ $expr }}|$(echo "echo $expr" | .)|g" $tmp
+ end
+ cat $tmp >> $src/../hyprlock.conf
end
- cat $tmp >> $src/../hyprlock.conf
end
diff --git a/scripts/monitor-config.fish b/scripts/monitor-config.fish
new file mode 100755
index 0000000..f7ef9fc
--- /dev/null
+++ b/scripts/monitor-config.fish
@@ -0,0 +1,8 @@
+#!/bin/fish
+
+set -q XDG_CONFIG_HOME && set -l config $XDG_CONFIG_HOME || set -l config $HOME/.config
+set -l config_path $config/caelestia/hypr.json
+
+inotifywait -e 'close_write,moved_to,create' -m (dirname $config_path) | while read dir events file
+ test "$dir$file" = $config_path && hyprctl reload
+end
diff --git a/scripts/templates/hyprlock/base.conf b/scripts/templates/hyprlock/base.conf
new file mode 100644
index 0000000..dab6d4f
--- /dev/null
+++ b/scripts/templates/hyprlock/base.conf
@@ -0,0 +1,14 @@
+source = ~/.config/hypr/scheme/current.conf
+
+$scripts = ~/.config/hypr/scripts
+$media_cmd = caelestia shell media
+$player_cmd = playerctl -p "$($media_cmd bus_name | cut -d . -f 4)"
+$metadata_cmd = $player_cmd metadata
+
+animation {
+ bezier = linear, 1, 1, 0, 0
+ animation = fadeIn, 1, 5, linear
+ animation = fadeOut, 1, 3, linear
+ animation = inputField, 1, 2, linear
+ animation = inputFieldColors, 1, 3, linear
+}
diff --git a/scripts/templates/hyprlock/futuristic/main.conf b/scripts/templates/hyprlock/futuristic/main.conf
new file mode 100644
index 0000000..17a5aaa
--- /dev/null
+++ b/scripts/templates/hyprlock/futuristic/main.conf
@@ -0,0 +1,75 @@
+$font_family_clock = Speculum
+$font_family_extras = Departure Mono
+
+$cpu_temps = cat /sys/class/thermal/thermal_zone*/temp
+$get_cpu_temp = fish -c 'math -s 1 \( ($cpu_temps | string join +) \) / ($cpu_temps | wc -l) / 1000'
+$get_cpu_load = top -bn1 | grep 'Cpu(s)' | sed 's/.*, *\([0-9.]*\)%* id.*/\1/' | awk '{print 100 - $1}'
+
+$has_media = playerctl status > /dev/null
+$print_media = printf '%s: %s\nBy: %s' "$($player_cmd status)" "$($metadata_cmd xesam:title)" "$($metadata_cmd xesam:artist)"
+$get_media = $has_media && $print_media || printf 'No media playing\nTry playing something!'
+
+background {
+ color = rgb($crust)
+ path = $HOME/.local/state/caelestia/wallpaper/current
+ blur_passes = 3
+ blur_size = 3
+ noise = 0.05
+ contrast = 1
+ brightness = 0.8
+ vibrancy = 0.2
+ vibrancy_darkness = 0.2
+}
+
+input-field {
+ monitor =
+ size = 320, 60
+ outline_thickness = 0
+ dots_size = 0.225
+ dots_spacing = 0.2
+ inner_color = rgba($primary45)
+ font_color = rgb($text)
+ check_color = rgb($sky)
+ fail_color = rgb($error)
+ fade_on_empty = false
+ placeholder_text = Logged in as $USER
+ fail_text = $FAIL ($ATTEMPTS)
+ swap_font_color = true
+ rounding = 0
+
+ position = 0, -120
+ halign = center
+ valign = center
+}
+
+label { # Clock
+ monitor =
+ text = cmd[update:1000] date +'%H//%M//%S'
+ color = rgb($primary)
+ font_size = 110
+ font_family = $font_family_clock
+
+ shadow_passes = 2
+ shadow_size = 2
+ shadow_color = rgb(a0a0a0)
+
+ position = 0, 70
+ halign = center
+ valign = center
+}
+
+label { # Date
+ monitor =
+ text = cmd[update:5000] date +'%D'
+ color = rgba($secondarybf)
+ font_size = 60
+ font_family = $font_family_clock
+
+ shadow_passes = 2
+ shadow_size = 2
+ shadow_color = rgb(a0a0a0)
+
+ position = 355, -35
+ halign = center
+ valign = center
+}
diff --git a/scripts/templates/hyprlock/futuristic/per-monitor.conf b/scripts/templates/hyprlock/futuristic/per-monitor.conf
new file mode 100644
index 0000000..65e9714
--- /dev/null
+++ b/scripts/templates/hyprlock/futuristic/per-monitor.conf
@@ -0,0 +1,35 @@
+
+# MONITOR {{ $name }}
+label { # CPU info
+ monitor = {{ $name }}
+ text = cmd[update:5000] printf '%s°C :CPU Temp\n%s%% :CPU Load' "$($get_cpu_temp)" "$($get_cpu_load)"
+ color = rgb($secondary)
+ font_size = 14
+ font_family = $font_family_extras
+ text_align = right
+
+ shadow_passes = 2
+ shadow_size = 2
+ shadow_color = rgb(a0a0a0)
+
+ position = -{{ (math $width / 2 + 175) }}, -120
+ halign = right
+ valign = center
+}
+
+label { # Media playing
+ monitor = {{ $name }}
+ text = cmd[update:1000] $get_media
+ color = rgb($secondary)
+ font_size = 14
+ font_family = $font_family_extras
+ text_align = left
+
+ shadow_passes = 2
+ shadow_size = 2
+ shadow_color = rgb(a0a0a0)
+
+ position = {{ (math $width / 2 + 175) }}, -120
+ halign = left
+ valign = center
+}
diff --git a/scripts/templates/hyprlock-base.conf b/scripts/templates/hyprlock/round/main.conf
similarity index 88%
rename from scripts/templates/hyprlock-base.conf
rename to scripts/templates/hyprlock/round/main.conf
index add30f3..c084e91 100644
--- a/scripts/templates/hyprlock-base.conf
+++ b/scripts/templates/hyprlock/round/main.conf
@@ -1,18 +1,5 @@
-source = ~/.config/hypr/scheme/current.conf
-
$font_family = JetBrainsMonoNF
-$scripts = ~/.config/hypr/scripts
-$media_cmd = caelestia shell media
$truncate_cmd = test "$($media_cmd identity)" != 'No media' && $scripts/truncate.fish $font_family
-$player_cmd = playerctl -p "$($media_cmd bus_name | cut -d . -f 4)" metadata
-
-animation {
- bezier = linear, 1, 1, 0, 0
- animation = fadeIn, 1, 5, linear
- animation = fadeOut, 1, 3, linear
- animation = inputField, 1, 2, linear
- animation = inputFieldColors, 1, 3, linear
-}
background {
color = rgb($crust)
@@ -46,6 +33,55 @@ input-field {
valign = bottom
}
+shape { # Player background
+ monitor =
+ size = 400, 110
+ color = rgba($base66)
+ rounding = 20
+
+ position = 0, 100
+ halign = center
+ valign = bottom
+}
+
+shape { # Player fallback cover art
+ monitor =
+ size = 90, 90
+ color = rgba($surface266)
+ rounding = 5
+
+ position = -140, 110
+ halign = center
+ valign = bottom
+}
+
+label { # Player fallback cover art icon
+ monitor =
+ text =
+ color = rgb($subtext0)
+ font_size = 40
+ font_family = $font_family
+
+ position = -135, 120
+ halign = center
+ valign = bottom
+}
+
+image { # Player cover art
+ monitor =
+ size = 84
+ border_size = 3
+ border_color = rgb($text)
+ rounding = 5
+ reload_time = 1
+ reload_cmd = caelestia shell media cover_art
+
+ position = -140, 110
+ halign = center
+ valign = bottom
+ zindex = 1
+}
+
label { # Clock
monitor =
text = $TIME
@@ -117,52 +153,3 @@ label { # Weather if no battery
halign = left
valign = bottom
}
-
-shape { # Player background
- monitor =
- size = 400, 110
- color = rgba($base66)
- rounding = 20
-
- position = 0, 100
- halign = center
- valign = bottom
-}
-
-shape { # Player fallback cover art
- monitor =
- size = 90, 90
- color = rgba($surface266)
- rounding = 5
-
- position = -140, 110
- halign = center
- valign = bottom
-}
-
-label { # Player fallback cover art icon
- monitor =
- text =
- color = rgb($subtext0)
- font_size = 40
- font_family = $font_family
-
- position = -135, 120
- halign = center
- valign = bottom
-}
-
-image { # Player cover art
- monitor =
- size = 84
- border_size = 3
- border_color = rgb($text)
- rounding = 5
- reload_time = 1
- reload_cmd = caelestia shell media cover_art
-
- position = -140, 110
- halign = center
- valign = bottom
- zindex = 1
-}
diff --git a/scripts/templates/hyprlock-monitor.conf b/scripts/templates/hyprlock/round/per-monitor.conf
similarity index 84%
rename from scripts/templates/hyprlock-monitor.conf
rename to scripts/templates/hyprlock/round/per-monitor.conf
index e2490f4..859e559 100644
--- a/scripts/templates/hyprlock-monitor.conf
+++ b/scripts/templates/hyprlock/round/per-monitor.conf
@@ -14,7 +14,7 @@ label { # Player identity
label { # Player track title
monitor = {{ $name }}
- text = cmd[update:1000] $truncate_cmd-Bold 14 150 "$($player_cmd xesam:title)" || echo 'No media playing'
+ text = cmd[update:1000] $truncate_cmd-Bold 14 150 "$($metadata_cmd xesam:title)" || echo 'No media playing'
color = rgb($text)
font_size = 14
font_family = $font_family Bold
@@ -26,7 +26,7 @@ label { # Player track title
label { # Player track artist
monitor = {{ $name }}
- text = cmd[update:1000] $truncate_cmd 12 100 "$($player_cmd xesam:artist)"
+ text = cmd[update:1000] $truncate_cmd 12 100 "$($metadata_cmd xesam:artist)"
color = rgb($text)
font_size = 12
font_family = $font_family