JLErvin / berry

:strawberry: A healthy, byte-sized window manager
MIT License
1.01k stars 46 forks source link

Focus window from another desktop not auto switching desktop #166

Closed K4zoku closed 2 years ago

K4zoku commented 2 years ago

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.

K4zoku commented 2 years ago

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

K4zoku commented 2 years ago

okay, i fixed it myself

K4zoku commented 2 years ago

forgot to open PR