Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion update-motd-static.d/20-update
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
5 changes: 4 additions & 1 deletion update-motd.d/10-welcome
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
#!/bin/bash

. /etc/default/locale
export LANG

function color (){
echo "\e[$1m$2\e[0m"
}
Expand Down Expand Up @@ -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)")"
Expand Down
30 changes: 10 additions & 20 deletions update-motd.d/15-system
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
#!/bin/bash

. /etc/default/locale
export LANG

function color (){
echo "\e[$1m$2\e[0m"
}
Expand All @@ -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"
Expand All @@ -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"
Expand All @@ -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
Expand Down