JLErvin / berry

:strawberry: A healthy, byte-sized window manager

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Focus window from another desktop not auto switching desktop

K4zoku opened this issue · comments

As the title says, this is what I discovered when I clicked on a discord notification from a desktop that doesn't contain discord. It focuses on the discord window, I can type, even send messages, but the desktop doesn't automatically switch to the desktop containing the discord.

fixed with an ugly solution

#!/usr/bin/env sh

INTERVAL=0.5

main() {
	while :
	do
		sleep "${INTERVAL}"
		current_desktop="$(xprop -root _NET_CURRENT_DESKTOP | cut -d' ' -f3)"
		active_window="$(xprop -root 32x '\t$0' _NET_ACTIVE_WINDOW | cut -f2)"
		if [ -z "${active_window}" ]; then
			continue
		fi
		active_window_desktop="$(xprop -id "${active_window}" _NET_WM_DESKTOP | cut -d' ' -f3)"
		if [ ! "${current_desktop}" = "${active_window_desktop}" ]; then
			printf "Desktop not match, switching...\n"
			berryc switch_workspace "${active_window_desktop}"
		fi
	done
}

main

and this script cause another annoying bug: not able to switch to an empty desktop

okay, i fixed it myself

forgot to open PR