Add timer
script for desktop machines
Based on https://github.com/sdaschner/dotfiles/blob/master/bin/timer and https://github.com/sdaschner/dotfiles/blob/master/bin/_timer. Seen in https://youtu.be/8CZIv3MJvic?si=PiVPM_vwuUKI7ak3&t=1460.
This commit is contained in:
parent
b30909b32a
commit
b36ca8086e
5 changed files with 62 additions and 12 deletions
lib
nixos/home-manager
shared
wsl2
|
@ -24,7 +24,9 @@ let
|
||||||
username
|
username
|
||||||
;
|
;
|
||||||
};
|
};
|
||||||
shared-packages = import "${self}/lib/shared/home-manager-packages.nix" { inherit inputs pkgs; };
|
shared-packages = import "${self}/lib/shared/home-manager-packages.nix" {
|
||||||
|
inherit desktop inputs pkgs;
|
||||||
|
};
|
||||||
in
|
in
|
||||||
{
|
{
|
||||||
imports =
|
imports =
|
||||||
|
|
|
@ -1,22 +1,23 @@
|
||||||
{ inputs, pkgs, ... }:
|
{
|
||||||
|
desktop,
|
||||||
|
inputs,
|
||||||
|
pkgs,
|
||||||
|
...
|
||||||
|
}:
|
||||||
let
|
let
|
||||||
php = pkgs.php82;
|
php = pkgs.php82;
|
||||||
phpPackages = pkgs.php82Packages;
|
phpPackages = pkgs.php82Packages;
|
||||||
|
|
||||||
inherit (pkgs) writeShellApplication;
|
inherit (pkgs) writeShellApplication;
|
||||||
|
|
||||||
scripts = {
|
_timer = writeShellApplication (import ./scripts/_timer.nix);
|
||||||
notetaker = writeShellApplication (import ./scripts/notetaker.nix);
|
notetaker = writeShellApplication (import ./scripts/notetaker.nix);
|
||||||
run = writeShellApplication (import ./scripts/run.nix { inherit pkgs; });
|
run = writeShellApplication (import ./scripts/run.nix { inherit pkgs; });
|
||||||
t = writeShellApplication (import ./scripts/t.nix { inherit pkgs; });
|
t = writeShellApplication (import ./scripts/t.nix { inherit pkgs; });
|
||||||
};
|
timer = writeShellApplication (import ./scripts/timer.nix);
|
||||||
in
|
in
|
||||||
with pkgs;
|
with pkgs;
|
||||||
[
|
[
|
||||||
scripts.notetaker
|
|
||||||
scripts.run
|
|
||||||
scripts.t
|
|
||||||
|
|
||||||
age
|
age
|
||||||
awscli2
|
awscli2
|
||||||
bitwarden-cli
|
bitwarden-cli
|
||||||
|
@ -58,4 +59,14 @@ with pkgs;
|
||||||
xdg-utils
|
xdg-utils
|
||||||
xh
|
xh
|
||||||
yarn
|
yarn
|
||||||
|
|
||||||
|
# Scripts.
|
||||||
|
notetaker
|
||||||
|
run
|
||||||
|
t
|
||||||
|
]
|
||||||
|
++ pkgs.lib.optionals desktop [
|
||||||
|
# Scripts.
|
||||||
|
_timer
|
||||||
|
timer
|
||||||
]
|
]
|
||||||
|
|
13
lib/shared/scripts/_timer.nix
Normal file
13
lib/shared/scripts/_timer.nix
Normal file
|
@ -0,0 +1,13 @@
|
||||||
|
{
|
||||||
|
name = "_timer";
|
||||||
|
|
||||||
|
runtimeInputs = [ ];
|
||||||
|
|
||||||
|
text = ''
|
||||||
|
mins=$1
|
||||||
|
message=''${2:-Time out!}
|
||||||
|
|
||||||
|
sleep -- "$mins" * 60
|
||||||
|
notify-send -t 0 "''${message}" "Your timer of $mins min is over" -u normal
|
||||||
|
'';
|
||||||
|
}
|
20
lib/shared/scripts/timer.nix
Normal file
20
lib/shared/scripts/timer.nix
Normal file
|
@ -0,0 +1,20 @@
|
||||||
|
{
|
||||||
|
name = "timer";
|
||||||
|
|
||||||
|
runtimeInputs = [ ];
|
||||||
|
|
||||||
|
text = ''
|
||||||
|
if [[ "$1" == "" ]]; then
|
||||||
|
echo "Usage: ''${0##*/} <mins> [message]"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
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
|
||||||
|
'';
|
||||||
|
}
|
|
@ -16,7 +16,11 @@ let
|
||||||
username
|
username
|
||||||
;
|
;
|
||||||
};
|
};
|
||||||
shared-packages = import "${self}/lib/shared/home-manager-packages.nix" { inherit inputs pkgs; };
|
|
||||||
|
shared-packages = import "${self}/lib/shared/home-manager-packages.nix" {
|
||||||
|
inherit inputs pkgs;
|
||||||
|
desktop = false;
|
||||||
|
};
|
||||||
in
|
in
|
||||||
inputs.home-manager.lib.homeManagerConfiguration {
|
inputs.home-manager.lib.homeManagerConfiguration {
|
||||||
inherit pkgs;
|
inherit pkgs;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue