hyprland sys76 hooks
This commit is contained in:
parent
a33f73c22f
commit
1f189f7c63
2 changed files with 60 additions and 0 deletions
13
system/syspkgs/hyprland-system76-scheduler-hook.sh
Executable file
13
system/syspkgs/hyprland-system76-scheduler-hook.sh
Executable file
|
@ -0,0 +1,13 @@
|
|||
#!/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
|
47
system/syspkgs/hyprland-system76-scheduler-integration.nix
Normal file
47
system/syspkgs/hyprland-system76-scheduler-integration.nix
Normal file
|
@ -0,0 +1,47 @@
|
|||
|
||||
{ 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
|
||||
'';
|
||||
|
||||
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue