Improve wayland wm detection

- permission denied spam from fuser was getting conflated into stdout
- unquote the inner $tmp_pid refereence, so that the shell will strip
  whitespace properly around the output pid number
This commit is contained in:
Joshua T Corbin 2023-12-29 11:12:04 -05:00
parent ccd5d9f526
commit 7d0816bdf2

View file

@ -1899,9 +1899,9 @@ get_wm() {
esac esac
if [[ -O "${XDG_RUNTIME_DIR}/${WAYLAND_DISPLAY:-wayland-0}" ]]; 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)" || if tmp_pid="$(lsof -t "${XDG_RUNTIME_DIR}/${WAYLAND_DISPLAY:-wayland-0}" 2>/dev/null)" ||
tmp_pid="$(fuser "${XDG_RUNTIME_DIR}/${WAYLAND_DISPLAY:-wayland-0}" 2>&1)"; then tmp_pid="$(fuser "${XDG_RUNTIME_DIR}/${WAYLAND_DISPLAY:-wayland-0}" 2>/dev/null)"; then
wm="$(ps -p "${tmp_pid}" -ho comm=)" wm="$(ps -p ${tmp_pid} -ho comm=)"
else else
# lsof may not exist, or may need root on some systems. Similarly fuser. # 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 # On those systems we search for a list of known window managers, this can mistakenly