Window Manager: Added support for getting window manager with xprop
This commit is contained in:
parent
c99d472ebb
commit
f0416ec78e
3 changed files with 44 additions and 28 deletions
1
1.1.md
1
1.1.md
|
@ -31,6 +31,7 @@ at launch or in script.
|
|||
**Window Manager:**
|
||||
|
||||
- Added support for `$XINITRC`
|
||||
- Added support for `xprop`
|
||||
|
||||
**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 \>
|
||||
Enable it by changing `$image_backend` to `iterm2` or by using the launch flag `--image_backend`.
|
||||
- Image Cropping, Resizing etc: `ImageMagick`
|
||||
- More accurate window manager detection: `wmctrl`
|
||||
- More accurate window manager detection: `wmctrl` or `xprop`
|
||||
|
||||
**Linux / BSD:**
|
||||
|
||||
|
|
69
fetch
69
fetch
|
@ -12,7 +12,7 @@
|
|||
# Optional Dependencies: (You'll lose these features without them)
|
||||
# Displaying Images: w3m + w3m-img
|
||||
# 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 ] Current Song: mpc or cmus
|
||||
# [ Linux / BSD ] Resolution detection: xorg-xdpyinfo
|
||||
|
@ -652,39 +652,54 @@ getshell () {
|
|||
# Window Manager {{{
|
||||
|
||||
getwindowmanager () {
|
||||
# Check for window manager using wmctrl and xprop
|
||||
if type -p wmctrl >/dev/null 2>&1; then
|
||||
windowmanager="$(wmctrl -m | head -n1)"
|
||||
windowmanager=${windowmanager/Name: }
|
||||
|
||||
elif [ "$XDG_CURRENT_DESKTOP" ]; then
|
||||
windowmanager="$XDG_CURRENT_DESKTOP"
|
||||
elif type -p xprop >/dev/null 2>&1; then
|
||||
# Get id of window manager
|
||||
wid=$(xprop -root _NET_SUPPORTING_WM_CHECK 2>/dev/null)
|
||||
wid=${wid//* }
|
||||
|
||||
elif [ "$XINITRC" ]; then
|
||||
windowmanager=$(grep "^[^#]*exec" "$XINITRC")
|
||||
|
||||
elif [ -e "$HOME/.xinitrc" ]; then
|
||||
windowmanager=$(grep "^[^#]*exec" "${HOME}/.xinitrc")
|
||||
|
||||
else
|
||||
case "$os" in
|
||||
"Mac OS X")
|
||||
windowmanager="Quartz Compositor"
|
||||
;;
|
||||
|
||||
"Windows")
|
||||
windowmanager="Explorer"
|
||||
;;
|
||||
|
||||
*)
|
||||
windowmanager="Unknown"
|
||||
;;
|
||||
|
||||
esac
|
||||
windowmanager="$(xprop -id $wid 8s _NET_WM_NAME 2>/dev/null)"
|
||||
windowmanager=${windowmanager/*\(*\) = \"}
|
||||
windowmanager=${windowmanager/\"}
|
||||
fi
|
||||
|
||||
windowmanager="${windowmanager/exec }"
|
||||
windowmanager="${windowmanager/-session}"
|
||||
windowmanager="${windowmanager^}"
|
||||
# If the window manager wasn't found, fallback to
|
||||
# checking files / envars.
|
||||
if [ -z "$windowmanager" ]; then
|
||||
if [ "$XDG_CURRENT_DESKTOP" ]; then
|
||||
windowmanager="$XDG_CURRENT_DESKTOP"
|
||||
|
||||
elif [ "$XINITRC" ]; then
|
||||
windowmanager=$(grep "^[^#]*exec" "$XINITRC")
|
||||
|
||||
elif [ -e "$HOME/.xinitrc" ]; then
|
||||
windowmanager=$(grep "^[^#]*exec" "${HOME}/.xinitrc")
|
||||
|
||||
else
|
||||
case "$os" in
|
||||
"Mac OS X")
|
||||
windowmanager="Quartz Compositor"
|
||||
;;
|
||||
|
||||
"Windows")
|
||||
windowmanager="Explorer"
|
||||
;;
|
||||
|
||||
*)
|
||||
windowmanager="Unknown"
|
||||
;;
|
||||
|
||||
esac
|
||||
fi
|
||||
|
||||
windowmanager="${windowmanager/exec }"
|
||||
windowmanager="${windowmanager/-session}"
|
||||
windowmanager="${windowmanager^}"
|
||||
fi
|
||||
}
|
||||
|
||||
# }}}
|
||||
|
|
Loading…
Reference in a new issue