#!/bin/sh

# Simple dmenu script to ask for keepassxc database password, and get the password of asked account

. ~/.config/dmenu/config

db=$(grep database ~/.config/dmenu-keepassxc/config | cut -d: -f 2)

kf=$(grep keyfile ~/.config/dmenu-keepassxc/config | cut -d: -f 2)

if [ "$2" = copy ]; then
	$DMENU -P -p "Enter KeePassXC database password" | keepassxc-cli show -sa password -k $kf $db "$1" | xclip -sel c && quick-notify "Dmenu-KeePassXC" "Password Copied"
else
	$DMENU -P -p "Enter KeePassXC database password" | keepassxc-cli show -sa password -k $kf $db "$1"
fi