From 48156bb495d8fdf2b7bd967076dfb7237afc1dba Mon Sep 17 00:00:00 2001 From: Thomas Maeder Date: Sat, 7 Mar 2026 10:56:51 +0100 Subject: [PATCH 1/2] replace AM/PM and MM/DD/YYYY with more human-readable formats --- update-motd-static.d/20-update | 2 +- update-motd.d/10-welcome | 5 ++++- update-motd.d/15-system | 22 ++++++---------------- 3 files changed, 11 insertions(+), 18 deletions(-) mode change 100644 => 100755 update-motd-static.d/20-update diff --git a/update-motd-static.d/20-update b/update-motd-static.d/20-update old mode 100644 new mode 100755 index f7bd1cb..708ccf5 --- a/update-motd-static.d/20-update +++ b/update-motd-static.d/20-update @@ -29,7 +29,7 @@ msgColor="38;5;103" # Count apt-get update --quiet=2 -pkgCount="$(apt-get -s dist-upgrade | grep -Po '^\d+(?= upgraded)')" +pkgCount="$(LANG= LC_ALL= apt-get -s dist-upgrade | grep -Po '^\d+(?= upgraded)')" setCountColor "$pkgCount" # Message diff --git a/update-motd.d/10-welcome b/update-motd.d/10-welcome index f69962a..2cc8a6c 100644 --- a/update-motd.d/10-welcome +++ b/update-motd.d/10-welcome @@ -1,5 +1,8 @@ #!/bin/bash +. /etc/default/locale +export LANG + function color (){ echo "\e[$1m$2\e[0m" } @@ -30,7 +33,7 @@ deviceLabel=" $(color $deviceColor " $deviceName ")" me="$(color $userColor " $me ")" codename="$(grep 'VERSION_CODENAME' /etc/os-release | cut -d '=' -f 2)" greetings="$(color $greetingsColor " * Welcome") $me $(color $greetingsColor To) $(color $codenameColor $codename)\n" -greetings="$greetings$(color $greetingsColor " * $(date +"%a %b %d %Y, %I:%M:%S %p")")\n" +greetings="$greetings$(color $greetingsColor " * $(date +"%c")")\n" # OS greetings="$greetings$(color $greetingsColor " * $(uname -srm)")" diff --git a/update-motd.d/15-system b/update-motd.d/15-system index 198fcd1..f1946ce 100644 --- a/update-motd.d/15-system +++ b/update-motd.d/15-system @@ -1,5 +1,8 @@ #!/bin/bash +. /etc/default/locale +export LANG + function color (){ echo "\e[$1m$2\e[0m" } @@ -13,20 +16,7 @@ function sec2time (){ ((input=input%3600)) ((mins=input/60)) - local daysPlural="s" - local hoursPlural="s" - local minsPlural="s" - - if [[ $days -eq 0 || $days -eq 1 ]]; then - daysPlural="" - fi - if [[ $hours -eq 0 || $hours -eq 1 ]]; then - hoursPlural="" - fi - if [[ $mins -eq 0 || $mins -eq 1 ]]; then - minsPlural="" - fi - echo "$days day$daysPlural $hours hr$hoursPlural $mins min$minsPlural" + echo "${days}d ${hours}h ${mins}m" } statsLabelColor="38;5;143" bulletColor="38;5;241" @@ -37,7 +27,7 @@ me=$(logname) # Last Login read loginIP loginDate <<< $(last $me --time-format iso -2 | awk 'NR==1 { print $3,$4 }') if [[ $loginDate == *T* ]]; then - login="$(date -d $loginDate +"%a %b %d %Y, %I:%M %p") $(color $dimInfoColor "* $loginIP")" + login="$(date -d $loginDate +"%c") $(color $dimInfoColor "* $loginIP")" else # First Login login="None" @@ -51,7 +41,7 @@ label2="$(vcgencmd measure_temp | cut -c "6-9")°C" label2="$(color $statsLabelColor "Temp") $(color $bulletColor "...")$(color $statsLabelColor ".") $(color $infoColor $label2)" uptime="$(sec2time $(cut -d "." -f 1 /proc/uptime))" -uptime="$uptime $(color $dimInfoColor "* $(date -d "@"$(grep btime /proc/stat | cut -d " " -f 2) +"%m-%d-%y %H:%M")")" +uptime="$uptime $(color $dimInfoColor "* $(date -d "@"$(grep btime /proc/stat | cut -d " " -f 2) +"%c")")" label3="$uptime" label3="$(color $statsLabelColor "Uptime") $(color $bulletColor "..")$(color $statsLabelColor ".") $(color $infoColor "$label3")" From b101d1c345d0902fbdb3f7cea9795c9bcdf36f87 Mon Sep 17 00:00:00 2001 From: Thomas Maeder Date: Thu, 19 Mar 2026 03:33:58 +0100 Subject: [PATCH 2/2] an IP address is an IP address is an IP address --- update-motd.d/15-system | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/update-motd.d/15-system b/update-motd.d/15-system index f1946ce..6ef4d2d 100644 --- a/update-motd.d/15-system +++ b/update-motd.d/15-system @@ -38,7 +38,7 @@ label1="$login" label1="$(color $statsLabelColor "Last") $(color $bulletColor "....")$(color $statsLabelColor ".") $(color $infoColor "$label1")" label2="$(vcgencmd measure_temp | cut -c "6-9")°C" -label2="$(color $statsLabelColor "Temp") $(color $bulletColor "...")$(color $statsLabelColor ".") $(color $infoColor $label2)" +label2="$(color $statsLabelColor "Temp") $(color $bulletColor "........")$(color $statsLabelColor ".") $(color $infoColor $label2)" uptime="$(sec2time $(cut -d "." -f 1 /proc/uptime))" uptime="$uptime $(color $dimInfoColor "* $(date -d "@"$(grep btime /proc/stat | cut -d " " -f 2) +"%c")")" @@ -47,19 +47,19 @@ label3="$uptime" label3="$(color $statsLabelColor "Uptime") $(color $bulletColor "..")$(color $statsLabelColor ".") $(color $infoColor "$label3")" label4="$(awk -v a="$(awk '/cpu /{print $2+$3+$4+$5+$6+$7+$8+$9+$10,$5}' /proc/stat; sleep 0.3)" '/cpu /{split(a,b," "); printf "%.1f%%", 100*(($2+$3+$4+$5+$6+$7+$8+$9+$10-b[1])-($5-b[2]))/($2+$3+$4+$5+$6+$7+$8+$9+$10-b[1])}' /proc/stat)" -label4="$(color $statsLabelColor "Cpu") $(color $bulletColor "....")$(color $statsLabelColor ".") $(color $infoColor $label4)" +label4="$(color $statsLabelColor "Cpu") $(color $bulletColor ".........")$(color $statsLabelColor ".") $(color $infoColor $label4)" label5="$(df -h ~ | awk 'NR==2 { printf "%sB / %sB \\e[38;5;144m* Free: %sB\\e[0m",$3,$2,$4; }')" label5="$(color $statsLabelColor "Disk") $(color $bulletColor "....")$(color $statsLabelColor ".") $(color $infoColor "$label5")" label6="$(/bin/ls -d /proc/[0-9]* | wc -l)" -label6="$(color $statsLabelColor "Procs") $(color $bulletColor "..")$(color $statsLabelColor ".") $(color $infoColor $label6)" +label6="$(color $statsLabelColor "Procs") $(color $bulletColor ".......")$(color $statsLabelColor ".") $(color $infoColor $label6)" label7="$(free -h --si | awk 'NR==2 { printf "%sB / %sB \\e[38;5;144m* Free: %sB\\e[0m",$3,$2,$4; }')" label7="$(color $statsLabelColor "Memory") $(color $bulletColor "..")$(color $statsLabelColor ".") $(color $infoColor "$label7")" label8="$(hostname -I)" -label8="$(color $statsLabelColor "IP") $(color $bulletColor ".....")$(color $statsLabelColor ".") $(color $infoColor $label8)" +label8="$(color $statsLabelColor "IP address") $(color $bulletColor "..")$(color $statsLabelColor ".") $(color $infoColor $label8)" # Print echo