diff --git a/env/.config/hypr/keybinds.conf b/env/.config/hypr/keybinds.conf index 9e71ce7..d148967 100644 --- a/env/.config/hypr/keybinds.conf +++ b/env/.config/hypr/keybinds.conf @@ -20,6 +20,7 @@ $fileBrowser = nautilus $menu = walker #$pwa = chromium --profile-directory=Default --enable-features=UseOzonePlatform --ozone-platform=wayland $pwa = ~/.local/scripts/launch-webapp +$launchOrFocusWebapp = ~/.local/scripts/launch-or-focus-webapp # Example binds, see https://wiki.hyprland.org/Configuring/Binds/ for more @@ -42,9 +43,10 @@ bind = $mainMod, F, exec, $fileManager bind = $mainMod SHIFT, F, exec, $fileBrowser bind = $mainMod, G, exec, $pwa "https://git.housh.dev" # NOTE: Do not bind apps to H, J, K, or L! -bind = $mainMod, M, exec, ~/.local/scripts/toggle-waybar +bind = $mainMod, M, exec, $pwa "https://music.apple.com" +bind = $mainMod SHIFT, M, exec, ~/.local/scripts/toggle-waybar bind = $mainMod, N, exec, $terminal -e nvim -bind = $mainMod, P, exec, $pwa "https://pass.proton.me" +bind = $mainMod, P, exec, ~/.local/scripts/proton-pass-manager bind = $mainMod SHIFT, P, pseudo, # dwindle bind = $mainMod SHIFT, R, exec, ~/.local/scripts/waybar-restart bind = $mainMod, Y, exec, $pwa "https://youtube.com" @@ -125,7 +127,7 @@ bind = $mainMod SHIFT, 0, movetoworkspace, 10 # Example special workspace (scratchpad) bind = $mainMod, S, togglespecialworkspace, magic -bind = $mainMod SHIFT, S, movetoworkspace, special:magic +bind = $mainMod SHIFT, S, movetoworkspacesilent, special:magic # Scroll through existing workspaces with mainMod + scroll bind = $mainMod, mouse_down, workspace, e+1 diff --git a/env/.config/hypr/windows.conf b/env/.config/hypr/windows.conf index 21f74e6..19b62f7 100644 --- a/env/.config/hypr/windows.conf +++ b/env/.config/hypr/windows.conf @@ -13,10 +13,15 @@ windowrule = size 800 600, tag:floating-window # Force windows to be a floating window windowrule = tag +floating-window, class:^(blueberry.py|org.gnome.Nautilus|com.ghostty.float)$ +# windowrule = float, class:.*pass.proton.me.* +# windowrule = center, class:.*pass.proton.me.* +# windowrule = size 1200 800, class:.*pass.proton.me.* +# # Force to stay focused when visible. windowrule = stayfocused, class:(blueberry.py) windowrule = stayfocused, class:Pinentry.gtk windowrule = stayfocused, class:com.ghostty.float +# windowrule = stayfocused, class:.*pass.proton.me.* # Clipboard history tui in floating window. windowrule = tag +floating-window, class:.*clipse.* @@ -33,8 +38,5 @@ windowrule = opacity 1.0, class:.*youtube.com.* # Fix some dragging issues with XWayland windowrule = nofocus,class:^$,title:^$,xwayland:1,floating:1,fullscreen:0,pinned:0 -#windowrule = float, class:.*pass.proton.me.* - workspace = special:hidden, invisible - -#windowrule = size 800 600, title:pinentry +workspace = special:pass, class:.*pass.proton.me.* diff --git a/env/.local/scripts/launch-or-focus-webapp b/env/.local/scripts/launch-or-focus-webapp new file mode 100755 index 0000000..14ba846 --- /dev/null +++ b/env/.local/scripts/launch-or-focus-webapp @@ -0,0 +1,34 @@ +#!/usr/bin/env bash + +# Launch a web app or focus if it's already open. + +if [[ $# == 0 ]]; then + echo "Usage: launch-or-focus-webapp " + exit 1 +fi + +SCRIPTS="${SCRIPTS}" + +if [[ -z $SCRIPTS ]]; then + echo "scripts directory not set" + echo "using ~/.local/scripts" + SCRIPTS=~/.local/scripts +fi + +url=$1 + +# parse domain pattern from the url +pattern=${url#https:\/\/} # removing leading 'https://' +pattern=${pattern#http:\/\/} # removing leading 'http://' +pattern=${pattern%%/*} # removing everything after '/' that's left (which should leave us with the domain) + +window=$(hyprctl clients -j | jq -r ".[] | select((.class | contains(\"$pattern\"))) | .address") + +echo "Pattern: \"$pattern\"" +echo "Window: \"$window\"" + +if [[ -n $window ]]; then + hyprctl dispatch focuswindow "address:$window" +else + eval exec "$SCRIPTS/launch-webapp $url" +fi diff --git a/env/.local/scripts/proton-pass-manager b/env/.local/scripts/proton-pass-manager new file mode 100755 index 0000000..17f7001 --- /dev/null +++ b/env/.local/scripts/proton-pass-manager @@ -0,0 +1,30 @@ +#!/usr/bin/env bash + +# Manages the proton pass web application. If the app is not open then +# it will launch the app (which has a workspace rule that put's it into a +# special workspace). If the app is open then it will toggle the special +# workspace. This allows the application to not close and be able to hide +# and show it quickly using the same keybind that would launch it. + +SCRIPTS="${SCRIPTS}" + +if [[ -z $SCRIPTS ]]; then + echo "scripts directory not set" + echo "using ~/.local/scripts" + SCRIPTS=~/.local/scripts +fi + +pattern="pass.proton.me" +url="https://$pattern" + +# Get the window address if it exists. +window_addr=$(hyprctl clients -j | jq -r ".[] | select((.class | contains(\"$pattern\"))) | .address") + +if [[ -z $window_addr ]]; then + echo "No window, launching..." + hyprctl dispatch togglespecialworkspace pass + eval exec $SCRIPTS/launch-webapp $url +else + echo "We have a window, toggling special workspace" + hyprctl dispatch togglespecialworkspace pass +fi diff --git a/env/webapps/applemusic.json b/env/webapps/applemusic.json new file mode 100644 index 0000000..168116d --- /dev/null +++ b/env/webapps/applemusic.json @@ -0,0 +1,6 @@ +{ + "name": "Apple Music", + "url": "https://music.apple.com", + "icon": "https://cdn.jsdelivr.net/gh/homarr-labs/dashboard-icons/png/apple-music.png" +} +