This commit is contained in:
Linus Nuber committed 2026-10-20 22:41:25 +02:00
1 parent 5ab26951d2
commit b6669d0c4c
1 file changed
+30 -18
+30 -18
View File
@@ -1,59 +1,71 @@
#!/bin/bash
statedir="/tmp/keepassxc"
mkdir -p "$statedir"
pidfile="$statedir/pid"
fifo="$statedir/fifo"
errfile="$statedir/error.log"
exec 2> "$errfile"
#exec 2> "$statedir/error.log"
CNTR=0
RUNTIME=10 # Sekunden
keepass_running()
{
test -e "$pidfile" && {
KPID="$(<$pidfile)"
if ps -q "$KPID" >/dev/null 2>&1; then
# zenity --info --text "Keepass läuft schon unter pid $KPID"
return 0
fi
rm "$pidfile"
}
return 1
pgrep -x keepassxc > /dev/null
}
start_keepass()
{
CNTR=$(($RUNTIME * 4))
if ! keepass_running; then
flatpak run org.keepassxc.KeePassXC --pw-stdin "$@" \
~/Nextcloud/data/Gemeinsam/keepass/LinusKeyPass.kdbx \
< ~/.local/share/keepass &> /dev/null &
echo "$!" > "$pidfile"
< ~/.local/share/keepass >/dev/null 2>&1 &
return 0
fi
return 1
}
tick()
{
echo "tick" > "$fifo"
#echo "tick"
}
mkdir -p "$statedir"
test -e "$fifo" || mkfifo "$fifo"
tick &
while true; do
read l < "$fifo"
set -- $l
case "$1" in
tick)
#echo "tack $CNTR"
if [ $CNTR -ge 1 ]; then
((CNTR = CNTR - 1))
if [ $CNTR -eq 0 ]; then
killall keepassxc
fi
fi
sleep 0.25
;;
start-keepass)
#echo "keepass"
shift
start_keepass "$@"
;;
start-browser)
#echo "browser"
shift
start_keepass --minimized
/usr/bin/brave-browser-stable "$@"
/usr/bin/brave-browser-stable "$@" &
;;
done)
#echo "done"
rm "$fifo"
exit 0
;;
esac
tick &
done