Unverified Commit fb572770 authored by Alan Griffiths's avatar Alan Griffiths Committed by GitHub

Better handling of Wayland compositors (#1539)

* Better handling of Wayland compositors * Reinstate setting ps_flags, it's used elsewhere * Try another incantation * Try another incantation * Try another incantation * Use short options and a newline to reduce line-length * Rework to handle the "better way" failing on some systems and fall back to the old method (which has the virtue of working most of the time).
parent 77bac34c
...@@ -1815,7 +1815,14 @@ get_wm() { ...@@ -1815,7 +1815,14 @@ get_wm() {
*) ps_flags=(-e) ;; *) ps_flags=(-e) ;;
esac esac
if [[ $WAYLAND_DISPLAY ]]; then if [[ -O "${XDG_RUNTIME_DIR}/${WAYLAND_DISPLAY:-wayland-0}" ]]; then
if tmp_pid="$(lsof -t "${XDG_RUNTIME_DIR}/${WAYLAND_DISPLAY:-wayland-0}" 2>&1)" ||
tmp_pid="$(fuser "${XDG_RUNTIME_DIR}/${WAYLAND_DISPLAY:-wayland-0}" 2>&1)"; then
wm="$(ps -p "${tmp_pid}" -ho comm=)"
else
# lsof may not exist, or may need root on some systems. Similarly fuser.
# On those systems we search for a list of known window managers, this can mistakenly
# match processes for another user or session and will miss unlisted window managers.
wm=$(ps "${ps_flags[@]}" | grep -m 1 -o -F \ wm=$(ps "${ps_flags[@]}" | grep -m 1 -o -F \
-e arcan \ -e arcan \
-e asc \ -e asc \
...@@ -1844,6 +1851,7 @@ get_wm() { ...@@ -1844,6 +1851,7 @@ get_wm() {
-e westeros \ -e westeros \
-e westford \ -e westford \
-e weston) -e weston)
fi
elif [[ $DISPLAY && $os != "Mac OS X" && $os != "macOS" && $os != FreeMiNT ]]; then elif [[ $DISPLAY && $os != "Mac OS X" && $os != "macOS" && $os != FreeMiNT ]]; then
type -p xprop &>/dev/null && { type -p xprop &>/dev/null && {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment