aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rwxr-xr-xpfetch37
1 files changed, 35 insertions, 2 deletions
diff --git a/pfetch b/pfetch
index 324291d..98dbef4 100755
--- a/pfetch
+++ b/pfetch
@@ -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
}
;;