diff --git a/modules/homelab/motd/default.nix b/modules/homelab/motd/default.nix index f4e4c3a..b55331a 100644 --- a/modules/homelab/motd/default.nix +++ b/modules/homelab/motd/default.nix @@ -24,11 +24,11 @@ in { environment.etc."motd".text = '' #!/usr/bin/env bash - active="\033[1;34m" - inactive="\033[1;31m" - headings="\033[1;35m" - bold="\e[1m" - reset="\033[0m" + active=$'\033[1;34m' + inactive=$'\033[1;31m' + headings=$'\033[1;35m' + bold=$'\e[1m' + reset=$'\033[0m' memory=`free -m | awk 'NR==2{printf "%s/%sMB (%.2f%%)\n", $3,$2,$3*100 / $2 }'` load1=`cat /proc/loadavg | awk {'print $1'}` load5=`cat /proc/loadavg | awk {'print $2'}` @@ -62,13 +62,13 @@ in { ${lib.concatStringsSep "\n" (map (service: '' if systemctl list-units --type=service --all | grep -q "${service}"; then status=$(systemctl is-active ${service} 2>/dev/null) - if [ "''${status}" = "active" ]; then - echo -e " ''${active}${service}''${reset} - running" + if [ "$status" = "active" ]; then + printf "%-15s %s%s\n" "''${active}${service}''${reset}" "running" else - echo -e " ''${inactive}${service}''${reset} - not running" + printf "%-15s %s%s\n" "''${active}${service}''${reset}" "not running" fi else - echo -e " ''${inactive}${service}''${reset} - not found" + printf "%-15s %s%s\n" "''${active}${service}''${reset}" "not found" fi '') motd_list)}