Add countdown module

This commit is contained in:
Daniel Lovbrotte Olsen 2022-05-23 04:14:19 +02:00
parent c909f3c008
commit 8120e9088f
1 changed files with 11 additions and 1 deletions

View File

@ -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" ]; } ''