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..6ef4d2d 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" @@ -48,28 +38,28 @@ 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) +"%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")" 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