From e5ae3a4be74fb7ec70c2097f7d7b8940bcd65680 Mon Sep 17 00:00:00 2001 From: Oliver Davies Date: Fri, 11 Jul 2025 01:31:02 +0100 Subject: [PATCH] Add `timer` script Based on https://github.com/sdaschner/dotfiles/blob/6b71b580dea4f9762727e0b2d7477226ade182f4/bin/timer and https://github.com/sdaschner/dotfiles/blob/6b71b580dea4f9762727e0b2d7477226ade182f4/bin/_timer. --- home-manager/opdavies/t480.nix | 1 + packages/_timer.nix | 19 +++++++++++++++++++ packages/default.nix | 2 ++ packages/timer.nix | 21 +++++++++++++++++++++ 4 files changed, 43 insertions(+) create mode 100644 packages/_timer.nix create mode 100644 packages/timer.nix diff --git a/home-manager/opdavies/t480.nix b/home-manager/opdavies/t480.nix index fb49a7eb..03ac0cd0 100644 --- a/home-manager/opdavies/t480.nix +++ b/home-manager/opdavies/t480.nix @@ -105,6 +105,7 @@ move-firefox-screenshots setbg tag-release + timer todos-add unmounter update-all-git-repos diff --git a/packages/_timer.nix b/packages/_timer.nix new file mode 100644 index 00000000..6dd00e3b --- /dev/null +++ b/packages/_timer.nix @@ -0,0 +1,19 @@ +{ pkgs }: + +pkgs.writeShellApplication { + name = "_timer"; + + runtimeInputs = with pkgs; [ + coreutils + libnotify + ]; + + text = '' + mins=$1 + message=''${2:-Time out!} + + sleep $((mins * 60)) + + notify-send -t 0 "''${message}" "Your timer of $mins min is over" -u normal + ''; +} diff --git a/packages/default.nix b/packages/default.nix index 892661f7..42aa2aca 100644 --- a/packages/default.nix +++ b/packages/default.nix @@ -6,6 +6,7 @@ let vimPlugins = callPackage ./vim-plugins { }; in { + _timer = callPackage ./_timer.nix { }; backup-websites = callPackage ./backup-websites.nix { }; build-glove80 = callPackage ./build-glove80.nix { }; create-script = callPackage ./create-script.nix { }; @@ -17,6 +18,7 @@ in passmenu-otp = callPackage ./passmenu-otp.nix { }; setbg = callPackage ./setbg.nix { }; tag-release = callPackage ./tag-release.nix { }; + timer = callPackage ./timer.nix { }; tmux-sessionizer = callPackage ./tmux-sessionizer { }; todos-add = callPackage ./todos-add.nix { }; unmounter = callPackage ./unmounter.nix { }; diff --git a/packages/timer.nix b/packages/timer.nix new file mode 100644 index 00000000..8580c10c --- /dev/null +++ b/packages/timer.nix @@ -0,0 +1,21 @@ +{ pkgs }: + +pkgs.writeShellApplication { + name = "timer"; + + runtimeInputs = with pkgs; [ + _timer + coreutils + systemdMinimal + ]; + + text = '' + mins=$1 + message="''${2:-}" + + nohup _timer "$mins" "$message" &> /dev/null & + + echo "timer started for $mins min" + echo "timer started for $mins min, message: '$message'" | systemd-cat -t timer + ''; +}