chore: debug nix-updates waybar indicator

This commit is contained in:
Swarsel 2024-08-10 17:14:05 +02:00
parent 560bc48259
commit d96c4de8dd
Signed by: swarsel
GPG key ID: 26A54C31F2A4FD84
4 changed files with 8 additions and 24 deletions

View file

@ -4567,25 +4567,21 @@ done
updates="$(cd ~/.dotfiles && nix flake lock --update-input nixpkgs && nix build .#nixosConfigurations."$HOSTNAME".config.system.build.toplevel && nvd diff /run/current-system ./result | grep -c '\[U')" updates="$(cd ~/.dotfiles && nix flake lock --update-input nixpkgs && nix build .#nixosConfigurations."$HOSTNAME".config.system.build.toplevel && nvd diff /run/current-system ./result | grep -c '\[U')"
alt="has-updates"
if [[ $updates -eq 0 ]]; then
alt="updated"
fi
tooltip="System updated" tooltip="System updated"
if [[ $updates != 0 ]]; then if [[ $updates != 0 ]]; then
tooltip=$(cd ~/.dotfiles && nvd diff /run/current-system ./result | grep -e '\[U' | awk '{ for (i=3; i<NF; i++) printf $i " "; if (NF >= 3) print $NF; }' ORS='\\n' ) tooltip=$(cd ~/.dotfiles && nvd diff /run/current-system ./result | grep -e '\[U' | awk '{ for (i=3; i<NF; i++) printf $i " "; if (NF >= 3) print $NF; }' ORS='\\n' )
fi fi
echo "{ \"text\":\"$updates\", \"alt\":\"$alt\", \"tooltip\":\"$tooltip\" }" echo "{ \"text\":\"$updates\", \"tooltip\":\"$tooltip\" }"
#+end_src #+end_src
#+begin_src nix :tangle pkgs/update-checker/default.nix #+begin_src nix :tangle pkgs/update-checker/default.nix
{ writeShellApplication, sway}: { writeShellApplication, nvd}:
writeShellApplication { writeShellApplication {
name = "update-checker"; name = "update-checker";
runtimeInputs = [ nvd ];
text = builtins.readFile ../../scripts/update-checker.sh; text = builtins.readFile ../../scripts/update-checker.sh;
} }
#+end_src #+end_src
@ -7666,11 +7662,7 @@ The rest of this configuration is found here:
interval = 3600; interval = 3600;
tooltip = true; tooltip = true;
return-type = "json"; return-type = "json";
format = "{} {icon} ?"; format = "{} ";
format-icons = {
has-updates = "";
updated= "";
};
}; };
"group/hardware" = { "group/hardware" = {

View file

@ -1,6 +1,7 @@
{ writeShellApplication, sway }: { writeShellApplication, nvd }:
writeShellApplication { writeShellApplication {
name = "update-checker"; name = "update-checker";
runtimeInputs = [ nvd ];
text = builtins.readFile ../../scripts/update-checker.sh; text = builtins.readFile ../../scripts/update-checker.sh;
} }

View file

@ -35,11 +35,7 @@
interval = 3600; interval = 3600;
tooltip = true; tooltip = true;
return-type = "json"; return-type = "json";
format = "{} {icon} ?"; format = "{} ";
format-icons = {
has-updates = "";
updated = "";
};
}; };
"group/hardware" = { "group/hardware" = {

View file

@ -1,13 +1,8 @@
updates="$(cd ~/.dotfiles && nix flake lock --update-input nixpkgs && nix build .#nixosConfigurations."$HOSTNAME".config.system.build.toplevel && nvd diff /run/current-system ./result | grep -c '\[U')" updates="$(cd ~/.dotfiles && nix flake lock --update-input nixpkgs && nix build .#nixosConfigurations."$HOSTNAME".config.system.build.toplevel && nvd diff /run/current-system ./result | grep -c '\[U')"
alt="has-updates"
if [[ $updates -eq 0 ]]; then
alt="updated"
fi
tooltip="System updated" tooltip="System updated"
if [[ $updates != 0 ]]; then if [[ $updates != 0 ]]; then
tooltip=$(cd ~/.dotfiles && nvd diff /run/current-system ./result | grep -e '\[U' | awk '{ for (i=3; i<NF; i++) printf $i " "; if (NF >= 3) print $NF; }' ORS='\\n' ) tooltip=$(cd ~/.dotfiles && nvd diff /run/current-system ./result | grep -e '\[U' | awk '{ for (i=3; i<NF; i++) printf $i " "; if (NF >= 3) print $NF; }' ORS='\\n' )
fi fi
echo "{ \"text\":\"$updates\", \"alt\":\"$alt\", \"tooltip\":\"$tooltip\" }" echo "{ \"text\":\"$updates\", \"tooltip\":\"$tooltip\" }"