Invoke shell functions in response to Hyprland socket2 events.
shellevents
reads Hyprland events from stdin as documented in the Hyprland Wiki. Please read Events list to understand what each event means. Also, see shellevents_default.sh
for the supported function names.
We'll use socat
to connect to Hyprland socket2, so make sure you have socat
installed.
submaps.sh
and notifywindow.sh
are two included examples. In this guide we'll use notifywindow.sh
.
- Run
shellevents
withnotifywindow.sh
:
socat -u UNIX-CONNECT:$XDG_RUNTIME_DIR/hypr/$HYPRLAND_INSTANCE_SIGNATURE/.socket2.sock EXEC:"/path/to/shellevents /path/to/notifywindow.sh",nofork
- Open your browser of choice with reddit.com, and you should see the notification. It needs to be reddit.com when you open your browser.
shellevents_default.sh
is the events reference. We'll generate acustom_event_file.sh
:
cp /path/to/shellevents_default.sh /path/to/custom_event_file.sh
- In
custom_event_file.sh
, add your custom handlers for the events you want to handle.
Note: The comment inside each handler shows the variables that are set when the handler is invoked.
event_openwindow() {
: # WINDOWADDRESS WORKSPACENAME WINDOWCLASS WINDOWTITLE
}
- Run the following command:
socat -u UNIX-CONNECT:$XDG_RUNTIME_DIR/hypr/$HYPRLAND_INSTANCE_SIGNATURE/.socket2.sock EXEC:"/path/to/shellevents /path/to/custom_event_file.sh",nofork
- If you have made changes, reload
custom_event_file.sh
:
killall shellevents -USR1
-
Simply add the above
socat
toexec-once
to runshellevents
during Hyprland startup. -
To help debugging, enable
verbose
output by passing-v
as the first argument toshellevents
. It'll print all events tostderr
to help debugging.