From 8120e9088f1f63366b0b07e85bdaa19122cb2a85 Mon Sep 17 00:00:00 2001 From: Daniel Olsen Date: Mon, 23 May 2022 04:14:19 +0200 Subject: [PATCH] Add countdown module --- profiles/xsession/polybar.nix | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/profiles/xsession/polybar.nix b/profiles/xsession/polybar.nix index 489c3d4..b1618ad 100644 --- a/profiles/xsession/polybar.nix +++ b/profiles/xsession/polybar.nix @@ -45,7 +45,7 @@ in module-margin-right = "2"; modules-left = "i3 title"; - modules-right = "minecraft wlan eth filesystem uquota cpu memory battery date"; + modules-right = "countdown minecraft wlan eth filesystem uquota cpu memory battery date"; }; "module/i3" = { @@ -179,6 +179,16 @@ in label = "%date% %time%"; }; + "module/countdown" = { + type = "custom/script"; + exec-if = "test -f $HOME/countdown"; + exec = "" + pkgs.writers.writeBash "countdown" '' + secs=$(( $(${pkgs.coreutils}/bin/date +%s -d $(${pkgs.coreutils}/bin/cat $HOME/countdown)) - $( ${pkgs.coreutils}/bin/date +%s ) )) + printf '%d:%02d:%02d:%02d\n' $((secs/86400)) $((secs%86400/3600)) $((secs%3600/60)) $((secs%60)) + ''; + interval = 1; + }; + "module/minecraft" = { type = "custom/script"; exec = "" + pkgs.writers.writePython3 "minecraft_status" { libraries = [ pkgs.python3.pkgs.mcstatus ]; flakeIgnore = [ "E722" ]; } ''