From 447a2a23566d4a0b7a0c100eefa0d7e1f8797c38 Mon Sep 17 00:00:00 2001 From: GaugeK Date: Sun, 9 Aug 2020 03:38:31 +1000 Subject: [PATCH] Add *really* hacky WM checker I am not proud of this. --- README.md | 4 +++- posixfetch | 25 ++++++++++++++++++++++++- 2 files changed, 27 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 9e61852..9111d10 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,5 @@ fetch written in POSIX shell with no external commands -![](http://0x0.st/i3yK.png) +
+ +
diff --git a/posixfetch b/posixfetch index cf2af74..5de3ff1 100755 --- a/posixfetch +++ b/posixfetch @@ -24,6 +24,28 @@ while [ ! "$term" ]; do ppid=$(ppid "$ppid") done +## WM +# requires the WM to include 'wm' +pg() { + ab= + for i in /proc/[0-9]*; do + ab="$ab ${i##*/}" + read -r a < "$i"/comm + case $a in + *$1*) echo "$a" "${i##*/}"; break;; + esac + done +} +[ "$DISPLAY" ] && { + xorg="$(pg Xorg)" + xorg="${xorg##* }" + aa="$(pg wm)" + # make sure it was started near enough after the X server + [ "${aa##* }" -gt "$xorg" ] && + [ "${aa##* }" -lt "$((xorg + 20))" ] && + wm="${aa%% *}" +} + ## Distro . /etc/os-release # lol EZ @@ -102,11 +124,12 @@ read -r model < /sys/devices/virtual/dmi/id/product_name } print() { - printf '\033[35m%6s\033[0m | %s\n' "$1" "$2" + printf '\033[34m%6s\033[0m | %s\n' "$1" "$2" } print os "$ID" print sh "${SHELL##*/}" +[ "$wm" ] && print wm "$wm" print up "${d}d ${h}:${m}" [ "$gtk" ] && print gtk "$gtk" print cpu "$vendor $cpu"