KeepassXC and Qutebrowser
I wanted to try this browser for a while, having got used to Aerc for email I thought this would be the perfect companion.
My issue, as always, is passwords, and using the wealth of information stored in KeepassXC with whatever browser I choose.
I checked this one and there are two userscripts which say it can work. I had no success with either one. I don't use GPG which broke one of them and the second has dependencies outside the capabilities of both Pacman and Auracle.
So I scripted a way to get the URL from the browser, find this domain in the password list. Then get confirmation which entry to use and copy the username to the clipboard.
Then ask to continue and copy the password to the clipboard. After confirmation the clipboard is wiped.
This is then bound to a Niri key bind and it works perfectly. At first I thought it was clunky but, I can edit any part of this as I go, so if the URL has changed it doesn't matter.
This script is keepass-fetch.sh
#!/bin/bash
while true; do
# 1. Check if the window exists
KPW=$(niri msg --json windows | jq -r '.[] | select(.app_id | ascii_downcase | contains("keepassxc")) | .id' | head -n 1)
# 2. If found, break out of the loop
if [[ -n $KPW ]]; then
break
fi
# 3. If not found, prompt the user
QT_QPA_PLATFORM=wayland zenity --question \
--title="KeePassXC Error" \
--text="The window cannot be found,\nPlease open Keepassxc and continue" \
--ok-label="Done" \
--cancel-label="Cancel"
# 4. If the user clicks "Cancel" (exit code non-zero), exit the script entirely
if [[ $? -ne 0 ]]; then
echo "Operation canceled by user."
exit 1
fi
done
APPID=$(niri msg --json windows | jq -r '.[] | select(.app_id | ascii_downcase | contains("qutebrowser")) | .id' |
head -n 1)
sleep 1
niri msg action focus-window --id $APPID
# --- STEP 1: Extract URL from Active qutebrowser ---
echo "key esc" | DOTOOL_XKB_LAYOUT=es dotool
sleep 0.1
echo "type yy" | DOTOOL_XKB_LAYOUT=es dotool
sleep 0.25
# --- STEP 2: Extract Clean Domain ---
URL=$(wl-paste)
DOMAIN=$(echo "$URL" | sed -E 's|https?://(www\.)?||' | cut -d'/' -f1)
if [ -z "$DOMAIN" ]; then
# yy-send "KeePassXC Error" "Clipboard is empty or could not parse domain."
exit 1
fi
# --- STEP 3: Focus KeePassXC Window ---
KEEPASS_ID=$(niri msg --json windows | jq -r '.[] | select(.app_id | ascii_downcase | contains("keepassxc")) | .id' | head -n 1)
if [ -z "$KEEPASS_ID" ]; then
# notify-send "KeePassXC Error" "KeePassXC window is not open on any workspace."
exit 1
fi
niri msg action focus-window --id "$KEEPASS_ID"
sleep 0.2
# --- STEP 4: Activate Search & Type Domain ---
echo "key esc" | DOTOOL_XKB_LAYOUT=es dotool
sleep 0.1
echo "key ctrl+f" | DOTOOL_XKB_LAYOUT=es dotool
sleep 0.1
echo "type $DOMAIN" | DOTOOL_XKB_LAYOUT=es dotool
sleep 0.1
# --- STEP 5: Manual Intermission (Select Your Entry) ---
QT_QPA_PLATFORM=wayland zenity --question \
--title="KeePassXC Pipeline" \
--text="Domain searched!\n\n1. Select the correct entry row in KeePassXC.\n2. Click 'Get Username' to proceed." \
--ok-label="Get Username" --cancel-label="Cancel"
if [ $? -ne 0 ]; then
wl-copy -c
exit 0
fi
# Refocus KeePassXC in case Zenity took focus away
niri msg action focus-window --id "$KEEPASS_ID"
sleep 0.1
# --- STEP 6 & 7: Copy Username (Ctrl+B) & Notify ---
echo "key ctrl+b" | DOTOOL_XKB_LAYOUT=es dotool
sleep 0.1
# notify-send "KeePassXC" "Username copied! Ready to paste."
# --- STEP 8: Prompt to Paste Username ---
QT_QPA_PLATFORM=wayland zenity --question \
--title="KeePassXC Pipeline" \
--text="Username is in your clipboard.\n\nPaste it into your browser field, then click OK to fetch Password." \
--ok-label="Get Password" --cancel-label="Cancel"
if [ $? -ne 0 ]; then
wl-copy -c
exit 0
fi
# --- STEP 9 & 10: Refocus KeePassXC & Copy Password (Ctrl+C) ---
niri msg action focus-window --id "$KEEPASS_ID"
sleep 0.2
echo "key ctrl+c" | DOTOOL_XKB_LAYOUT=es dotool
sleep 0.1
# notify-send "KeePassXC" "Password copied!"
# --- STEP 11: Final Clear Clipboard Prompt ---
QT_QPA_PLATFORM=wayland zenity --info \
--title="KeePassXC Pipeline" \
--text="Password is in your clipboard.\n\nPaste it, then click OK to securely clear the clipboard." \
--ok-label="Clear Clipboard"
# Wipe clipboard securely
wl-copy -c
# notify-send "KeePassXC" "Clipboard safely cleared."
Although it is fairly simple it relies on the wayland copy and paste tools to work.
The extra benefit is this works with any browser as long as niri can find the correct app_id.
Posted
14:56 04/06/2026