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
+1
View File
@@ -14,6 +14,7 @@
./hypr/rules.nix
./scripts/movement.nix
./scripts/window-rules.nix
./scripts/workspace-toggle.nix
];
wayland.windowManager.hyprland.enable = true;
+1 -2
View File
@@ -3,8 +3,7 @@
windowrule = [
# Make all inactive windows transparent
"match:class .*, opacity 1 0.8"
# But make Firefox windows opaque again (last rule wins)
"match:title (?i)bitwarden, float on"
"match:class firefox, match:title (?i).*bitwarden.*, no_screen_share on"
];
workspace = [
];
+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"
];
}