Files
dotfiles/env/.local/scripts/proton-pass-manager

31 lines
983 B
Bash
Executable File

#!/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