From 8fb4cdc0375701ac4929f5d8ebb8624316714d12 Mon Sep 17 00:00:00 2001 From: oluceps Date: Sun, 13 Oct 2024 23:30:19 +0800 Subject: [PATCH] + hyprlock --- home/hypr/hyprlock.conf | 7 +++--- hosts/graphBase.nix | 4 +-- modules/swayidle.nix | 55 ++++++++++++++++++++++++++++++++++++++++- 3 files changed, 59 insertions(+), 7 deletions(-) diff --git a/home/hypr/hyprlock.conf b/home/hypr/hyprlock.conf index 11118cf2..0006271e 100644 --- a/home/hypr/hyprlock.conf +++ b/home/hypr/hyprlock.conf @@ -44,7 +44,7 @@ input-field { # DATE label { monitor = - text = cmd[update:1000] echo "$(date +"%A, %B %d")" + text = cmd[update:1000] get-date color = rgba(242, 243, 244, 0.75) font_size = 22 font_family = JetBrains Mono @@ -56,7 +56,7 @@ label { # TIME label { monitor = - text = cmd[update:1000] echo "$(date +"%-I:%M")" + text = cmd[update:1000] get-time color = rgba(242, 243, 244, 0.75) font_size = 95 font_family = Intel One Mono Medium @@ -72,8 +72,7 @@ image { path = $HOME/Pictures/photo_2023-08-01_01-12-50.jpg size = 100 border_size = 2 - border_color = $foreground - position = 0, -100 + position = 0, -50 halign = center valign = center } diff --git a/hosts/graphBase.nix b/hosts/graphBase.nix index e3c64e74..512ef838 100644 --- a/hosts/graphBase.nix +++ b/hosts/graphBase.nix @@ -179,13 +179,13 @@ timeouts = [ { timeout = 900; - command = "${pkgs.hyprlock}/bin/hyprlock"; + command = "${pkgs.hyprlock}/bin/hyprlock --immediate"; } ]; events = [ { event = "lock"; - command = "${pkgs.hyprlock}/bin/hyprlock"; + command = "${pkgs.hyprlock}/bin/hyprlock --immediate"; } { event = "before-sleep"; diff --git a/modules/swayidle.nix b/modules/swayidle.nix index 8c89bf03..b73ce7d0 100644 --- a/modules/swayidle.nix +++ b/modules/swayidle.nix @@ -146,7 +146,60 @@ in Restart = "always"; # swayidle executes commands using "sh -c", so the PATH needs to contain a shell. Environment = [ - "PATH=${makeBinPath [ pkgs.bash ]}" + "PATH=${ + let + genGetFormattedDate = + { format, type }: + { + stdenv, + writeTextDir, + }: + stdenv.mkDerivation (finalAttrs: { + name = "simple-date"; + src = writeTextDir "src/get-date.c" '' + #include + #include + #include + + int main() { + struct timeval tv; + struct tm *tm; + char buffer[30]; + + gettimeofday(&tv, NULL); + tm = localtime(&tv.tv_sec); + strftime(buffer, 30, "${format}", tm); + printf("%s\n", buffer); + + return 0; + } + ''; + + buildPhase = '' + mkdir -p $out + gcc $src/src/get-date.c + ''; + installPhase = '' + install -Dm555 a.out $out/bin/get-${type} + ''; + }); + in + ( + [ + { + format = "%A, %B %d"; + type = "date"; + } + { + format = "%-I:%M"; + type = "time"; + } + ] + |> map genGetFormattedDate + |> map (i: pkgs.callPackage i { }) + |> makeBinPath + ) + }" "WAYLAND_DISPLAY=wayland-1" ]; ExecStart = "${cfg.package}/bin/swayidle -w ${concatStringsSep " " args}";