From 67be4f8f3bc1386935235d02d0124bab8810ac85 Mon Sep 17 00:00:00 2001 From: end-4 <97237370+end-4@users.noreply.github.com> Date: Thu, 29 Feb 2024 16:40:44 +0700 Subject: [PATCH] hyprlock: add battery --- .../ags/scripts/templates/hypr/hyprlock.conf | 18 ++++++++++-- .config/hypr/hyprlock.conf | 28 +++++++++++++------ .config/hypr/hyprlock/status.sh | 22 +++++++++++++++ 3 files changed, 57 insertions(+), 11 deletions(-) create mode 100755 .config/hypr/hyprlock/status.sh diff --git a/.config/ags/scripts/templates/hypr/hyprlock.conf b/.config/ags/scripts/templates/hypr/hyprlock.conf index 3ad0f0d6f..5a42af563 100644 --- a/.config/ags/scripts/templates/hypr/hyprlock.conf +++ b/.config/ags/scripts/templates/hypr/hyprlock.conf @@ -40,7 +40,7 @@ label { # Clock halign = center valign = center } -label { +label { # Greeting monitor = text = hi $USER !!! color = $text_color @@ -51,7 +51,7 @@ label { halign = center valign = center } -label { +label { # lock icon monitor = text = lock color = $text_color @@ -62,7 +62,7 @@ label { halign = center valign = bottom } -label { +label { # "locked" text monitor = text = locked color = $text_color @@ -72,4 +72,16 @@ label { position = 0, 50 halign = center valign = bottom +} + +label { # Status + monitor = + text = cmd[update:5000] ~/.config/hypr/hyprlock/status.sh + color = $text_color + font_size = 14 + font_family = $font_family + + position = 30, -30 + halign = left + valign = top } \ No newline at end of file diff --git a/.config/hypr/hyprlock.conf b/.config/hypr/hyprlock.conf index f2299434d..71d9034be 100644 --- a/.config/hypr/hyprlock.conf +++ b/.config/hypr/hyprlock.conf @@ -1,13 +1,13 @@ -$text_color = rgba(eae0e4FF) -$entry_background_color = rgba(120F1111) -$entry_border_color = rgba(9a8d9555) -$entry_color = rgba(d1c2cbFF) +$text_color = rgba(ede0deFF) +$entry_background_color = rgba(130F0F11) +$entry_border_color = rgba(a08c8955) +$entry_color = rgba(d8c2bfFF) $font_family = Gabarito $font_family_clock = Gabarito $font_material_symbols = Material Symbols Rounded background { - color = rgba(120F1177) + color = rgba(130F0F77) # path = {{ SWWW_WALL }} path = screenshot blur_size = 5 @@ -40,7 +40,7 @@ label { # Clock halign = center valign = center } -label { +label { # Greeting monitor = text = hi $USER !!! color = $text_color @@ -51,7 +51,7 @@ label { halign = center valign = center } -label { +label { # lock icon monitor = text = lock color = $text_color @@ -62,7 +62,7 @@ label { halign = center valign = bottom } -label { +label { # "locked" text monitor = text = locked color = $text_color @@ -72,4 +72,16 @@ label { position = 0, 50 halign = center valign = bottom +} + +label { # Status + monitor = + text = cmd[update:5000] ~/.config/hypr/hyprlock/status.sh + color = $text_color + font_size = 14 + font_family = $font_family + + position = 30, -30 + halign = left + valign = top } \ No newline at end of file diff --git a/.config/hypr/hyprlock/status.sh b/.config/hypr/hyprlock/status.sh new file mode 100755 index 000000000..794c468f4 --- /dev/null +++ b/.config/hypr/hyprlock/status.sh @@ -0,0 +1,22 @@ +#!/usr/bin/env bash + +############ Variables ############ +enable_battery=false + +####### Check availability ######## +for battery in /sys/class/power_supply/*BAT*; do + if [[ -f "$battery/uevent" ]]; then + enable_battery=true + break + fi +done + +############# Output ############# +if [[ $enable_battery == true ]]; then + if [[ $(cat /sys/class/power_supply/*/status | head -1) == "Charging" ]]; then + echo -n "(+) " + fi + echo -n "$(cat /sys/class/power_supply/*/capacity | head -1)"% remaining +fi + +echo '' \ No newline at end of file