#!/usr/bin/env bash

socat - UNIX-CONNECT:/tmp/hypr/$HYPRLAND_INSTANCE_SIGNATURE/.socket2.sock |
while read line
do
	if [[ "$line" == activewindow* ]]; then
		pid="$(hyprctl activewindow | rg pid | cut -d' ' -f2)"
		if [[ -n $pid  ]]; then
			dbus-send --system --dest=com.system76.Scheduler --type=method_call /com/system76/Scheduler com.system76.Scheduler.SetForegroundProcess uint32:$pid
		fi
		pid=""
	fi
done