add(bitwarden): added window rule for bitwarden extension via socket listening
This commit is contained in:
@@ -0,0 +1,40 @@
|
||||
{pkgs, ...}: let
|
||||
hyprctl = "${pkgs.hyprland}/bin/hyprctl";
|
||||
jq = "${pkgs.jq}/bin/jq";
|
||||
socat = "${pkgs.socat}/bin/socat";
|
||||
|
||||
hypr-window-rules = pkgs.writeShellScriptBin "hypr-window-rules" ''
|
||||
handle() {
|
||||
local event="$1"
|
||||
case "$event" in
|
||||
windowtitlev2*)
|
||||
local data="''${event#windowtitlev2>>}"
|
||||
local addr="0x''${data%%,*}"
|
||||
local title="''${data#*,}"
|
||||
|
||||
if echo "$title" | grep -qi "bitwarden"; then
|
||||
local info
|
||||
info=$(${hyprctl} clients -j | ${jq} -r --arg addr "$addr" \
|
||||
'.[] | select(.address == $addr) | "\(.class)|\(.floating)"')
|
||||
local class="''${info%|*}"
|
||||
local floating="''${info#*|}"
|
||||
|
||||
if [[ "$class" == "firefox" && "$floating" == "false" ]]; then
|
||||
${hyprctl} dispatch togglefloating "address:$addr"
|
||||
fi
|
||||
fi
|
||||
;;
|
||||
esac
|
||||
}
|
||||
|
||||
${socat} - \
|
||||
"UNIX-CONNECT:$XDG_RUNTIME_DIR/hypr/$HYPRLAND_INSTANCE_SIGNATURE/.socket2.sock" \
|
||||
| while IFS= read -r line; do handle "$line"; done
|
||||
'';
|
||||
in {
|
||||
home.packages = [hypr-window-rules];
|
||||
|
||||
wayland.windowManager.hyprland.settings.exec-once = [
|
||||
"hypr-window-rules"
|
||||
];
|
||||
}
|
||||
Reference in New Issue
Block a user