38 lines
932 B
Bash
Executable file
38 lines
932 B
Bash
Executable file
#!/bin/sh
|
|
# fast, cross-platform
|
|
|
|
## Distro
|
|
# freedesktop.org/software/systemd/man/os-release.html
|
|
# a common file that has variables about the distro
|
|
for os in /etc/os-release /usr/lib/os-release; do
|
|
# some POSIX shells exit when trying to source a file that doesn't exist
|
|
[ -f $os ] && . $os && break
|
|
done
|
|
|
|
## Kernel
|
|
read -r _ _ version _ < /proc/version
|
|
kernel=${version%%-*}
|
|
|
|
## Uptime
|
|
# the simple math is shamefully stolen from aosync
|
|
IFS=. read -r uptime _ < /proc/uptime
|
|
d=$((uptime / 60 / 60 / 24))
|
|
up=$(printf %02d:%02d $((uptime / 60 / 60 % 24)) $((uptime / 60 % 60)))
|
|
[ "$d" -gt 0 ] && up="${d}d $up"
|
|
|
|
print() {
|
|
[ "$2" ] && printf '\033[9%sm%6s\033[0m%b%s\n' \
|
|
"${accent:-4}" "$1" "${separator:- }" "$2"
|
|
}
|
|
|
|
print dist "$ID"
|
|
print kern "$kernel"
|
|
print shll "${SHELL##*/}"
|
|
print uptm "$up"
|
|
|
|
# Colors
|
|
printf ' '
|
|
for i in 1 2 3 4 5 6; do
|
|
printf '\033[9%sm%s' "$i" "${colourblocks:-▅▅}"
|
|
done
|
|
printf '\033[0m\n'
|