From 4b44f8eceb31ed13453a5ba5f0a735d52d92e065 Mon Sep 17 00:00:00 2001
From: John Titor <50095635+JohnRTitor@users.noreply.github.com>
Date: Fri, 10 May 2024 12:15:33 +0530
Subject: [PATCH 1/2] lockscreen.sh: immediately lock screen if invoked, this
removes the lag
---
config/hypr/scripts/LockScreen.sh | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/config/hypr/scripts/LockScreen.sh b/config/hypr/scripts/LockScreen.sh
index 56d496a..ce2320a 100755
--- a/config/hypr/scripts/LockScreen.sh
+++ b/config/hypr/scripts/LockScreen.sh
@@ -2,4 +2,4 @@
# /* ---- 💫 https://github.com/JaKooLit 💫 ---- */ ##
# For Hyprlock
-hyprlock -q
\ No newline at end of file
+hyprlock -q --immediate
\ No newline at end of file
From 4cd64ff0b907f8d8d6503bcb7c858ca25494d1cb Mon Sep 17 00:00:00 2001
From: John Titor <50095635+JohnRTitor@users.noreply.github.com>
Date: Fri, 10 May 2024 12:16:30 +0530
Subject: [PATCH 2/2] hyprlock: use UptimeNixOS script to get the output if
uptime -p not available
---
config/hypr/hyprlock.conf | 3 ++-
config/hypr/scripts/UptimeNixOS.sh | 33 ++++++++++++++++++++++++++++++
2 files changed, 35 insertions(+), 1 deletion(-)
create mode 100644 config/hypr/scripts/UptimeNixOS.sh
diff --git a/config/hypr/hyprlock.conf b/config/hypr/hyprlock.conf
index f41d646..eec6d31 100644
--- a/config/hypr/hyprlock.conf
+++ b/config/hypr/hyprlock.conf
@@ -4,6 +4,7 @@
# Sourcing colors generated by wallust
source = $HOME/.config/hypr/wallust/wallust-hyprland.conf
+$Scripts = $HOME/.config/hypr/scripts
general {
grace = 1
@@ -99,7 +100,7 @@ label {
# uptime
label {
monitor =
- text = cmd[update:60000] echo " "$(uptime -p)" "
+ text = cmd[update:60000] echo " "$(uptime -p || $Scripts/UptimeNixOS.sh)" "
color = $color12
font_size = 24
font_family = JetBrains Mono Nerd Font 10
diff --git a/config/hypr/scripts/UptimeNixOS.sh b/config/hypr/scripts/UptimeNixOS.sh
new file mode 100644
index 0000000..654ae2c
--- /dev/null
+++ b/config/hypr/scripts/UptimeNixOS.sh
@@ -0,0 +1,33 @@
+#!/usr/bin/env bash
+# Script parses /proc/uptime to get the system uptime
+# and prints it in a human-readable format
+# This is a workaround for system where `uptime` command is taken from coreutils
+# where `uptime -p` is not supported
+
+if [[ -r /proc/uptime ]]; then
+ s=$(< /proc/uptime)
+ s=${s/.*}
+else
+ echo "Error UptimeNixOS.sh: Uptime could not be determined." >&2
+ exit 1
+fi
+
+d="$((s / 60 / 60 / 24)) days"
+h="$((s / 60 / 60 % 24)) hours"
+m="$((s / 60 % 60)) minutes"
+
+# Remove plural if < 2.
+((${d/ *} == 1)) && d=${d/s}
+((${h/ *} == 1)) && h=${h/s}
+((${m/ *} == 1)) && m=${m/s}
+
+# Hide empty fields.
+((${d/ *} == 0)) && unset d
+((${h/ *} == 0)) && unset h
+((${m/ *} == 0)) && unset m
+
+uptime=${d:+$d, }${h:+$h, }$m
+uptime=${uptime%', '}
+uptime=${uptime:-$s seconds}
+
+echo "up $uptime"