47 lines
1.1 KiB
Nix
47 lines
1.1 KiB
Nix
|
|
{ lib, pkgs, stdenv, hyprland, ripgrep, socat, dbus, ... }:
|
|
|
|
stdenv.mkDerivation rec {
|
|
pname = "hyprland-system76-scheduler-integration";
|
|
version = "0.1.0";
|
|
|
|
nativeBuildInputs = [
|
|
socat
|
|
dbus
|
|
hyprland
|
|
ripgrep
|
|
];
|
|
|
|
dontUnpack = "true";
|
|
dontBuild = true;
|
|
|
|
installPhase = ''
|
|
runHook preInstall
|
|
|
|
mkdir -p $out/bin
|
|
|
|
cat <<EOF > $out/bin/hyprland-system76-scheduler-hook.sh
|
|
#!${pkgs.bash}/bin/bash
|
|
echo "opening socket.."
|
|
${pkgs.socat}/bin/socat -u UNIX-CLIENT:/tmp/hypr/\''$HYPRLAND_INSTANCE_SIGNATURE/.socket2.sock STDOUT |
|
|
while read line; do
|
|
if [[ "\''$line" == activewindow* ]]; then
|
|
echo "got \''$line."
|
|
pid="\''$(${pkgs.hyprland}/bin/hyprctl activewindow | ${pkgs.ripgrep}/bin/rg pid | ${pkgs.coreutils}/bin/cut -d' ' -f2)"
|
|
if [[ -n \''$pid ]]; then
|
|
echo "sending \''$pid!"
|
|
${pkgs.dbus}/bin/dbus-send --system --dest=com.system76.Scheduler --type=method_call /com/system76/Scheduler com.system76.Scheduler.SetForegroundProcess uint32:\''$pid
|
|
fi
|
|
pid=""
|
|
fi
|
|
echo "continuing.."
|
|
done
|
|
echo "finished."
|
|
EOF
|
|
chmod +x $out/bin/hyprland-system76-scheduler-hook.sh
|
|
|
|
runHook postInstall
|
|
'';
|
|
|
|
|
|
}
|