Hyprland Socket 2 crashing when connecting from script started through Hyprland itself

Hyprland version
Hyprland 0.50.1 built from branch  at commit 4e242d086e20b32951fdc0ebcbfb4d41b5be8dcc  ([gha] Nix: update inputs).
Date: Sat Jul 19 21:37:06 2025
Tag: v0.50.1, commits: 6291
built against:
 aquamarine 0.9.2
 hyprlang 0.6.3
 hyprutils 0.8.1
 hyprcursor 0.1.12
 hyprgraphics 0.1.5


no flags were set

Describe your issue / feature…

I wrote a script that listens to socket2 to detect when Firefox renames a browser window for an extension, so that the script can toggle the window to be floating. When I run the script in my terminal, it works fine. However when I autostart it from Hyprland with exec, it disconnects from the socket almost as soon as the script starts. I’ve tried adding a loop around the socat, this leads to the script rapidly disconnecting and reconnecting from the socket, however it does start receiving events in the brief period it’s connected.

The script:

#!/usr/bin/env fish

function handleLine
    notify-send "got event from hyprland: $argv"

    if string match -rq '^(?<event>.*)>>(?<args>.*)$' -- "$argv"
        if string match -raq '(?<vars>[^,]*),?' -- "$args"
            handleEvent $event $vars
        end
    end
end

function handleEvent
    set -l event $argv[1]
    set -l vars $argv[2..]

    if test $LOG_EVENTS
        echo $event $vars
    end

    # make Firefox extension windows float
    if test $event = windowtitlev2 && string match -rq 'Extension.*Mozilla Firefox' -- "$vars[2]"
        hyprctl dispatch setfloating address:0x$vars[1]
    end
end

env >/tmp/listener-env.txt

notify-send "hello from the listener.fish script. env variables: XDG_RUNTIME_DIR: $XDG_RUNTIME_DIR HYPRLAND_INSTANCE_SIGNATURE $HYPRLAND_INSTANCE_SIGNATURE"
echo "hi for the logs"

while true
    socat - "UNIX-CONNECT:$XDG_RUNTIME_DIR/hypr/$HYPRLAND_INSTANCE_SIGNATURE/.socket2.sock" | while read -l line
        handleLine "$line"
    end
    notify-send "socat disconnected. reconnecting"
end

notify-send "stopping the listener script :("

How I start it in the config:

exec-once = uwsm app – fish -c “~/.config/hypr/scripts/listener.fish” >> /tmp/listener-logs.txt 2>&1

Starting it via hyprctl dispatch results in the same behavior.

Thanks in advance!

My guess would be HYPRLAND_INSTANCE_SIGNATURE not being passed correctly (since uwsm).

It prints the environment variables to /tmp/listener-env.txt and when checking it, $HYPRLAND_INSTANCE_SIGNATURE is there and it’s the correct value.

Also notable is that when I put the socat in a while true loop, the script starts working, though when looking at the logs the socket terminates very quickly. It seems that in the brief moment the socket is connected, it does actually send events through.

dunno what’s up then

1 Like