From 07c610ad3af4dce0b2280dee0fb5d7fe6c08e937 Mon Sep 17 00:00:00 2001 From: Ahwx Date: Mon, 31 Mar 2025 21:29:24 +0200 Subject: [PATCH] feat: adds hyprlock --- modules/home/hyprlock/default.nix | 123 ++++++++++++++++++++++++++++++ modules/home/hyprlock/scripts.nix | 47 ++++++++++++ 2 files changed, 170 insertions(+) create mode 100644 modules/home/hyprlock/default.nix create mode 100644 modules/home/hyprlock/scripts.nix diff --git a/modules/home/hyprlock/default.nix b/modules/home/hyprlock/default.nix new file mode 100644 index 0000000..69a3d44 --- /dev/null +++ b/modules/home/hyprlock/default.nix @@ -0,0 +1,123 @@ +{ pkgs, username, ... }: +{ + imports = [ (import ./scripts.nix) ]; + + home.packages = with pkgs; [ + hyprlock + ]; + + home.file = { + "/home/${username}/.config/hypr/hyprlock.conf" = { + executable = false; + text = '' + # GENERAL + general { + no_fade_in = true + grace = 1 + disable_loading_bar = false + hide_cursor = true + ignore_empty_input = true + text_trim = true + } + + #BACKGROUND + background { + monitor = + path = screenshot + blur_passes = 2 + contrast = 0.8916 + brightness = 0.7172 + vibrancy = 0.1696 + vibrancy_darkness = 0 + } + + # TIME HR + label { + monitor = + text = cmd[update:1000] echo -e "$(date +"%H")" + color = rgba(255, 255, 255, 1) + shadow_pass = 2 + shadow_size = 3 + shadow_color = rgb(0,0,0) + shadow_boost = 1.2 + font_size = 150 + # font_family = JetBrains Mono Nerd Font Mono ExtraBold + font_family = AlfaSlabOne + position = 0, -250 + halign = center + valign = top + } + + # TIME + label { + monitor = + text = cmd[update:1000] echo -e "$(date +"%M")" + # color = 0xff$color0 + color = rgba(255, 255, 255, 1) + font_size = 150 + # font_family = JetBrains Mono Nerd Font Mono ExtraBold + font_family = AlfaSlabOne + position = 0, -420 + halign = center + valign = top + } + + # DATE + label { + monitor = + text = cmd[update:1000] echo -e "$(date +"%d %b %A")" + color = rgba(255, 255, 255, 1) + font_size = 14 + font_family = JetBrains Mono Nerd Font Mono ExtraBold + position = 0, -130 + halign = center + valign = center + } + + # WEATHER + label { + monitor = + text = cmd[update:1000] echo "$(bash /home/${username}/.local/bin/weather.sh)" + color = rgba(255, 255, 255, 1) + font_size = 10 + font_family = JetBrains Mono Nerd Font Mono ExtraBold + position = 0, 465 + halign = center + valign = center + } + + # INPUT FIELD + input-field { + monitor = + size = 250, 60 + outline_thickness = 0 + outer_color = rgba(0, 0, 0, 1) + dots_size = 0.1 # Scale of input-field height, 0.2 - 0.8 + dots_spacing = 1 # Scale of dots' absolute size, 0.0 - 1.0 + dots_center = true + inner_color = rgba(0, 0, 0, 1) + font_color = rgba(200, 200, 200, 1) + fade_on_empty = false + font_family = JetBrains Mono Nerd Font Mono + placeholder_text =  $USER + hide_input = false + position = 0, -470 + halign = center + valign = center + zindex = 10 + } + # Information + label { + monitor = + text = cmd[update:1000] echo -e "$(/home/${username}/.local/bin/hyprlock-battery.sh)" + color = rgba(255, 255, 255, 1) + font_size = 12 + font_family = JetBrains Mono Nerd Font Mono ExtraBold + position = -20, -510 + halign = right + valign = center + } + ''; + }; + }; +} diff --git a/modules/home/hyprlock/scripts.nix b/modules/home/hyprlock/scripts.nix new file mode 100644 index 0000000..400e37b --- /dev/null +++ b/modules/home/hyprlock/scripts.nix @@ -0,0 +1,47 @@ +{ username, ... }: +{ + home.file = { + "/home/${username}/.local/bin/weather.sh" = { + executable = true; + text = '' + #!/usr/bin/env bash + + # Get the current city using IP geolocation + CITY=$(curl -s https://ipinfo.io/city 2>/dev/null) + + # Check if CITY is retrieved successfully + if [[ -n "$CITY" ]]; then + # Fetch weather info for the detected city from wttr.in + weather_info=$(curl -s "wttr.in/$CITY?format=%c+%C+%t" 2>/dev/null) + + # Check if the weather info is valid + if [[ -n "$weather_info" ]]; then + echo "$weather_info" + else + echo "Weather info unavailable for $CITY" + fi + else + echo "Unable to determine your location" + fi + ''; + }; + "/home/${username}/.local/bin/hyprlock-battery.sh" = { + executable = true; + text = '' + #!/usr/bin/env bash + + battery_percentage=$(cat /sys/class/power_supply/*/capacity) + battery_status=$(cat /sys/class/power_supply/*/status) + charging_icon="󱐋" + + # Check if the battery is charging + if [ "$battery_status" = "Charging" ]; then + battery_icon="$charging_icon" + fi + + # Output the battery percentage and icon + echo "$battery_percentage% $battery_icon" + ''; + }; + }; +}