aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDylan Araps <dylan.araps@gmail.com>2019-09-24 10:46:56 +0300
committerDylan Araps <dylan.araps@gmail.com>2019-09-24 10:46:56 +0300
commitfacc6cecaa49e19e4f4ff2328013f77178dd0847 (patch)
treef6011c6bf1231cdcf74391ab487cbdd6175fc421
parent380985a8fab08bb11646c62618185be04e40cad3 (diff)
downloadpfetch-facc6cecaa49e19e4f4ff2328013f77178dd0847.tar.gz
pfetch: Added kernel and uptime
-rwxr-xr-xpfetch24
1 files changed, 24 insertions, 0 deletions
diff --git a/pfetch b/pfetch
index 841051f..d4c11de 100755
--- a/pfetch
+++ b/pfetch
@@ -33,6 +33,28 @@ get_distro() {
log 1 os " " "$distro"
}
+get_kernel() {
+ log 1 kernel " " "$kernel_version"
+}
+
+get_uptime() {
+ case $os in
+ linux)
+ IFS=. read -r s _ < /proc/uptime
+ ;;
+ esac
+
+ d=$((s / 60 / 60 / 24))
+ h=$((s / 60 / 60 % 24))
+ m=$((s / 60 % 60))
+
+ [ "$d" = 0 ] || uptime="${uptime}${d}d "
+ [ "$h" = 0 ] || uptime="${uptime}${h}h "
+ [ "$m" = 0 ] || uptime="${uptime}${m}m "
+
+ log 1 uptime " " "${uptime:-0m}"
+}
+
main() {
# Hide 'stderr' unless the first argument is '-v'. This saves
# polluting the script with '2>/dev/null'.
@@ -50,6 +72,8 @@ main() {
get_os
get_distro
+ get_kernel
+ get_uptime
}
main "$@"