aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDylan Araps <dylan.araps@gmail.com>2020-03-12 21:47:39 +0200
committerDylan Araps <dylan.araps@gmail.com>2020-03-12 21:47:39 +0200
commit44aaae774fe99172fe28510c37542d70ea59d952 (patch)
tree1663306b7280d9fa90fb938ab59f20423742ce9a
parentc8aca296c1dfcb38846525f08eb6668a3daf7b1c (diff)
downloadpfetch-44aaae774fe99172fe28510c37542d70ea59d952.tar.gz
wm: Fix issues. Related to #48
-rwxr-xr-xpfetch72
1 files changed, 28 insertions, 44 deletions
diff --git a/pfetch b/pfetch
index 04d27a0..4b5af36 100755
--- a/pfetch
+++ b/pfetch
@@ -845,51 +845,35 @@ get_wm() {
# To extract the name, everything before '_NET_WM_NAME = \"'
# is removed and everything after the next '"' is removed.
wm=$(xprop -id "$id" -notype -len 25 -f _NET_WM_NAME 8t)
-
- # Handle cases of a window manager _not_ populating the
- # '_NET_WM_NAME' atom. Display nothing in this case.
- case $wm in
- *'_NET_WM_NAME = '*)
- wm=${wm##*_NET_WM_NAME = \"}
- wm=${wm%%\"*}
- ;;
-
- *)
- # Fallback to checking the process list
- # for the select few window managers which
- # don't set '_NET_WM_NAME'.
- #
- # TODO: This is currently limited to 'grep'
- # implementations providing the '-o'
- # flag. This needs to be replaced with
- # a command which searches for a list
- # of strings and returns _only_ the
- # first match's contents (also ensuring
- # the search itself isn't matched).
- #
- # A generic parser isn't possible as
- # the output of 'ps' is _not_ the same
- # between implementations and across
- # operating systems.
- #
- # The simple search method above works
- # regardless of 'ps' implementation.
- #
- # Disable the shellcheck warning about using
- # 'pgrep' instead of 'ps | grep' as 'pgrep'
- # is not always available.
- # shellcheck disable=2009
- wm=$(ps x | grep -o \
- -e '[c]atwm' \
- -e '[f]vwm' \
- -e '[d]wm' \
- -e '[2]bwm' \
- -e '[m]onsterwm' \
- -e '[w]maker' \
- -e '[s]owm')
- ;;
- esac
}
+
+ # Handle cases of a window manager _not_ populating the
+ # '_NET_WM_NAME' atom. Display nothing in this case.
+ case $wm in
+ *'_NET_WM_NAME = '*)
+ wm=${wm##*_NET_WM_NAME = \"}
+ wm=${wm%%\"*}
+ ;;
+
+ *)
+ # Fallback to checking the process list
+ # for the select few window managers which
+ # don't set '_NET_WM_NAME'.
+ while read -r ps_line; do
+ case $ps_line in
+ *catwm*) wm=catwm ;;
+ *fvwm*) wm=fvwm ;;
+ *dwm*) wm=dwm ;;
+ *2bwm*) wm=2bwm ;;
+ *monsterwm*) wm=monsterwm ;;
+ *wmaker*) wm='Window Maker' ;;
+ *sowm*) wm=sowm ;;
+ esac
+ done <<-EOF
+ $(ps x)
+ EOF
+ ;;
+ esac
;;
esac