hyprlock: multiple styles

Choose style using config
This commit is contained in:
2 * r + 2 * t 2025-03-09 23:27:08 +11:00
parent 240e3520a7
commit 6ca12dc56f
8 changed files with 206 additions and 75 deletions

View file

@ -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

View file

@ -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

8
scripts/monitor-config.fish Executable file
View file

@ -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

View file

@ -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
}

View file

@ -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 = <i>󰌾 Logged in as </i><span foreground="##$primary">$USER</span>
fail_text = <i>$FAIL ($ATTEMPTS)</i>
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
}

View file

@ -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
}

View file

@ -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
}

View file

@ -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