wm: Add fallback to non-EWMH WMs

This commit is contained in:
Dylan Araps 2019-10-20 00:00:02 +03:00
parent 5893e26575
commit 1045166df2
No known key found for this signature in database
GPG Key ID: 46D62DD9F1DE636E

37
pfetch
View File

@ -709,7 +709,7 @@ get_wm() {
# atom..
#
# List of window managers which fail to set the name atom:
# catwm, fvwm, dwm, 2bwm and monster.
# catwm, fvwm, dwm, 2bwm, monster, wmaker and sowm [mine! ;)].
#
# The final downside to this approach is that it does _not_
# support Wayland environments. The only solution which supports
@ -781,7 +781,40 @@ get_wm() {
wm=${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
}
;;