add(bitwarden): added window rule for bitwarden extension via socket listening

This commit is contained in:
kenji
2026-05-31 12:47:43 -05:00
parent 53f9e2d925
commit 1a435a8676
3 changed files with 42 additions and 2 deletions
+40
View File
@@ -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"
];
}