The problem#
I make heavy use of virtual desktops, so I use browser windows on multiple desktops. When logging into a site that uses passkeys, KeePassXC pops up a dialog on the desktop its main window is on, which is usually not the desktop my browser window is on. Then I have to switch over to that desktop to interact with the dialog and then back to the desktop I was working on. There is a GitHub issue reporting this, so it may be fixed in a future release.
The solution#
Use the script keepassxc-dialogs-all-desktops.sh:
#!/usr/bin/bash
# Start KeePassXC if it isn't already running.
if ! pgrep 'keepassxc$' >/dev/null 2>/dev/null
then
nohup keepassxc "$@" >/dev/null 2>/dev/null &
fi
pid="$(pgrep 'keepassxc$' | head -1)"
xprop -spy -root _NET_CLIENT_LIST |
while read -r line
do
# If KeePassXC exited, then we're done.
if ! ps -p "$pid" >/dev/null 2>/dev/null
then
exit
fi
# Only look at last window in list.
winid="${line/#*, /}"
if [[ $(xdotool getwindowname "$winid") == \
"KeePassXC - "* ]] && [[ \
$(xdotool getwindowpid "$winid") == "$pid" ]]
then
# Set visible on all desktops.
xdotool set_desktop_for_window "$winid" -1
fi
done
The script will start KeePassXC if it isn't already running, and, until KeePassXC closes, it will watch for dialog windows it opens and set them to be visible on all desktops, so they will appear on the current desktop.