Window Manager: Added support for getting window manager with xprop

master
Dylan 10 years ago
parent c99d472ebb
commit f0416ec78e
  1. 1
      1.1.md
  2. 2
      README.md
  3. 61
      fetch

@ -31,6 +31,7 @@ at launch or in script.
**Window Manager:** **Window Manager:**
- Added support for `$XINITRC` - Added support for `$XINITRC`
- Added support for `xprop`
**Shell:** **Shell:**

@ -82,7 +82,7 @@ https://github.com/dylanaraps/fetch/wiki/Customizing-Info
- **Note:** The script can now also use iTerm2's builtin image rendering instead of w3m!<br \> - **Note:** The script can now also use iTerm2's builtin image rendering instead of w3m!<br \>
Enable it by changing `$image_backend` to `iterm2` or by using the launch flag `--image_backend`. Enable it by changing `$image_backend` to `iterm2` or by using the launch flag `--image_backend`.
- Image Cropping, Resizing etc: `ImageMagick` - Image Cropping, Resizing etc: `ImageMagick`
- More accurate window manager detection: `wmctrl` - More accurate window manager detection: `wmctrl` or `xprop`
**Linux / BSD:** **Linux / BSD:**

61
fetch

@ -12,7 +12,7 @@
# Optional Dependencies: (You'll lose these features without them) # Optional Dependencies: (You'll lose these features without them)
# Displaying Images: w3m + w3m-img # Displaying Images: w3m + w3m-img
# Image Cropping: ImageMagick # Image Cropping: ImageMagick
# More accurate window manager detection: wmctrl # More accurate window manager detection: wmctrl or xprop
# [ Linux / BSD ] Wallpaper Display: feh, nitrogen or gsettings # [ Linux / BSD ] Wallpaper Display: feh, nitrogen or gsettings
# [ Linux / BSD ] Current Song: mpc or cmus # [ Linux / BSD ] Current Song: mpc or cmus
# [ Linux / BSD ] Resolution detection: xorg-xdpyinfo # [ Linux / BSD ] Resolution detection: xorg-xdpyinfo
@ -652,39 +652,54 @@ getshell () {
# Window Manager {{{ # Window Manager {{{
getwindowmanager () { getwindowmanager () {
# Check for window manager using wmctrl and xprop
if type -p wmctrl >/dev/null 2>&1; then if type -p wmctrl >/dev/null 2>&1; then
windowmanager="$(wmctrl -m | head -n1)" windowmanager="$(wmctrl -m | head -n1)"
windowmanager=${windowmanager/Name: } windowmanager=${windowmanager/Name: }
elif [ "$XDG_CURRENT_DESKTOP" ]; then elif type -p xprop >/dev/null 2>&1; then
windowmanager="$XDG_CURRENT_DESKTOP" # Get id of window manager
wid=$(xprop -root _NET_SUPPORTING_WM_CHECK 2>/dev/null)
wid=${wid//* }
elif [ "$XINITRC" ]; then windowmanager="$(xprop -id $wid 8s _NET_WM_NAME 2>/dev/null)"
windowmanager=$(grep "^[^#]*exec" "$XINITRC") windowmanager=${windowmanager/*\(*\) = \"}
windowmanager=${windowmanager/\"}
fi
elif [ -e "$HOME/.xinitrc" ]; then # If the window manager wasn't found, fallback to
windowmanager=$(grep "^[^#]*exec" "${HOME}/.xinitrc") # checking files / envars.
if [ -z "$windowmanager" ]; then
if [ "$XDG_CURRENT_DESKTOP" ]; then
windowmanager="$XDG_CURRENT_DESKTOP"
else elif [ "$XINITRC" ]; then
case "$os" in windowmanager=$(grep "^[^#]*exec" "$XINITRC")
"Mac OS X")
windowmanager="Quartz Compositor"
;;
"Windows") elif [ -e "$HOME/.xinitrc" ]; then
windowmanager="Explorer" windowmanager=$(grep "^[^#]*exec" "${HOME}/.xinitrc")
;;
*) else
windowmanager="Unknown" case "$os" in
;; "Mac OS X")
windowmanager="Quartz Compositor"
;;
esac "Windows")
fi windowmanager="Explorer"
;;
*)
windowmanager="Unknown"
;;
windowmanager="${windowmanager/exec }" esac
windowmanager="${windowmanager/-session}" fi
windowmanager="${windowmanager^}"
windowmanager="${windowmanager/exec }"
windowmanager="${windowmanager/-session}"
windowmanager="${windowmanager^}"
fi
} }
# }}} # }}}

Loading…
Cancel
Save