add bitwarden floating script

This commit is contained in:
Simon Rieger 2025-04-10 13:09:17 +02:00
parent 599e893e97
commit 653676880e
2 changed files with 37 additions and 0 deletions

View file

@ -22,6 +22,9 @@ exec-once = blueman-applet &
exec-once = waybar & hyprpaper & firefox exec-once = waybar & hyprpaper & firefox
exec-once = hypridle exec-once = hypridle
# Bitwarden Window Floating
exec-once = ~/.config/hypr/scripts/bitwarden.sh
# Clipboard Manager # Clipboard Manager
exec-once = wl-paste --type text --watch cliphist store # Stores only text data exec-once = wl-paste --type text --watch cliphist store # Stores only text data

View file

@ -0,0 +1,34 @@
#!/usr/bin/env bash
handle_windowtitlev2 () {
# Description: emitted when a window title changes.
# Format: `WINDOWADDRESS,WINDOWTITLE`
windowaddress=${1%,*}
windowtitle=${1#*,}
case $windowtitle in
*"(Bitwarden"*"manager) - Bitwarden"*)
hyprctl --batch \
"dispatch togglefloating address:0x$windowaddress;"\
"dispatch resizewindowpixel exact 20% 54%,address:0x$windowaddress;"\
"dispatch centerwindow"
;;
# specificwindowtitle) commands;;
esac
}
handle() {
# $1 Format: `EVENT>>DATA`
# example: `workspace>>2`
event=${1%>>*}
data=${1#*>>}
case $event in
windowtitlev2) handle_windowtitlev2 "$data";;
# anyotherevent) handle_otherevent "$data";;
*) echo "unhandled event: $event" ;;
esac
}
socat -U - UNIX-CONNECT:$XDG_RUNTIME_DIR/hypr/$HYPRLAND_INSTANCE_SIGNATURE/.socket2.sock | while read -r line; do handle "$line"; done