-
Notifications
You must be signed in to change notification settings - Fork 0
/
motd
executable file
·44 lines (36 loc) · 1.21 KB
/
motd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
#!/usr/bin/env bash
# Pretty date
if [ "$myPrimaryDevice" == 1 ]; then
yearPercent=$(date +'%j' | awk '{ print int($1*100/365) }')
date +"It's %A, week %V, $yearPercent% of the year."
echo -ne "\n"
fi
# System usage
if [[ ${OSTYPE,,} =~ ^linux ]]; then
upDays="$(awk '{val = $1 / 86400; print val}' OFMT="%.0f" /proc/uptime)"
loadAvg="$(awk '{ printf "%s, %s, %s", $1, $2, $3 }' /proc/loadavg)"
diskUsage=$(df -h /| awk '$NF=="/"{printf "%s", $5}')
memUsage=$(free -m | awk 'NR==2{printf "%.2f%%", $3*100/$2 }')
osRelease=$(test -f /etc/os-release && source /etc/os-release && echo -n " ${NAME} ${VERSION}")
echo "$(uname -s)${osRelease} $(uname -r | cut -d'.' -f1,2) $(uname -p) - Up ${upDays} days"
echo "Load: ${loadAvg} Disk: ${diskUsage} Memory: ${memUsage}"
fi
# Fortune
if [ "$myPrimaryDevice" == 1 ]; then
if command -v fortune &> /dev/null; then
echo -ne "\n"
fortune -s
echo -ne "\n"
fi
fi
# Greetings
if [ "$myPrimaryDevice" == 1 ]; then
HOUR=$(date +%H)
if ((10#$HOUR >= 5 && 10#$HOUR <=11)); then
echo -en "Good morning...\n\n";
elif ((10#$HOUR >= 12 && 10#$HOUR <=20)); then
echo -en "Have a lot of fun...\n\n";
else
echo -en "Enjoy the evening...\n\n";
fi
fi