Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

For event_closewindow, how do I get the target window's WINDOWADDRESS? #109

Open
kohane27 opened this issue Jun 16, 2024 · 3 comments
Open
Labels
bug Something isn't working

Comments

@kohane27
Copy link
Contributor

kohane27 commented Jun 16, 2024

Program

shellevents

Maintainers of the program

trippwill

Bug or Regression?

Bug

Description

Hello! Hope you're doing well.

It's not exactly a bug. I'm trying to use event_closewindow but run into issues: how do I get the target window's WINDOWADDRESS?

event_openwindow provides WINDOWCLASS so it's easy to do so:

event_openwindow() {
    # WINDOWADDRESS WORKSPACENAME WINDOWCLASS WINDOWTITLE
    case "$WINDOWCLASS" in "firefox")
        bash "$HOME"/.config/zsh/scripts/enable-audio.sh
        ;;
    esac
}

But I can't do the same for event_closewindow because it only provides WINDOWADDRESS:

event_closewindow() {
    # WINDOWADDRESS
}

I tried the following:

event_closewindow() {
    # WINDOWADDRESS
    target_address=$(hyprctl --batch clients -j | jq -r '.[] | select(.class == "firefox") | .address')
    if [[ "$WINDOWADDRESS" == "$target_address" ]]; then
        bash "$HOME"/.config/zsh/scripts/disable-audio.sh
    fi
}

But the window is already closed so target_address is always null.

Any input is much appreciated. Thank you.

@kohane27 kohane27 added the bug Something isn't working label Jun 16, 2024
@vaxerski
Copy link
Member

image
it's right here.

@kohane27
Copy link
Contributor Author

Hello it's the creator of Hyprland!

Apologies of my unclear question. I know that I can get the WINDOWADDRESS. I meant how do I get the WINDOWCLASS or WINDOWTITLE from the WINDOWADDRESS.

The WINDOWADDRESS changes on reboot so the following doesn't work:

event_closewindow() {
    # WINDOWADDRESS
    case "$WINDOWADDRESS" in "5a6b54d80ba0")
        bash "$HOME"/.config/zsh/scripts/disable-audio.sh
        ;;
    esac
}

Basically I want the following:

    case "$WINDOWCLASS" in "firefox")
        bash "$HOME"/.config/zsh/scripts/disable-audio.sh
        ;;
    esac

but in event_closewindow instead of event_openwindow. Thanks again!

@vaxerski
Copy link
Member

you can't from the IPC as the window is already gone. You'll need to cache those states (probably launch hyprctl clients once and then just cache window open events)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants