diff options
| author | Dylan Araps <dylan.araps@gmail.com> | 2019-10-20 00:00:02 +0300 |
|---|---|---|
| committer | Dylan Araps <dylan.araps@gmail.com> | 2019-10-20 00:00:02 +0300 |
| commit | 1045166df2424d28ca140f6350062c3ba5b5396d (patch) | |
| tree | dbcc7bf4b6857ae665f930b9dafee8021da01674 | |
| parent | 5893e265752ca0dca85beb4204cf26d0ca9354a2 (diff) | |
| download | pfetch-1045166df2424d28ca140f6350062c3ba5b5396d.tar.gz | |
wm: Add fallback to non-EWMH WMs
| -rwxr-xr-x | pfetch | 37 |
1 files changed, 35 insertions, 2 deletions
@@ -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 } ;; |
