lock: also unlock keyring on unlock

This commit is contained in:
end-4
2025-09-30 23:07:04 +02:00
parent 599055b49f
commit 3c00805763
3 changed files with 37 additions and 0 deletions
@@ -268,6 +268,7 @@ Singleton {
}
property bool centerClock: true
property bool showLockedText: true
property bool unlockKeyring: true
}
property JsonObject media: JsonObject {
@@ -1,4 +1,5 @@
import qs
import qs.modules.common
import QtQuick
import Quickshell
import Quickshell.Services.Pam
@@ -55,6 +56,7 @@ Scope {
onCompleted: result => {
if (result == PamResult.Success) {
root.unlocked();
if (Config.options.lock.unlockKeyring) root.unlockKeyring();
} else {
root.showFailure = true;
GlobalStates.screenUnlockFailed = true;
@@ -64,4 +66,13 @@ Scope {
root.unlockInProgress = false;
}
}
function unlockKeyring() {
Quickshell.execDetached({
environment: ({
UNLOCK_PASSWORD: root.currentText
}),
command: ["bash", "-c", Quickshell.shellPath("scripts/keyring/unlock.sh")]
})
}
}
+25
View File
@@ -0,0 +1,25 @@
#!/usr/bin/env bash
# Based on https://unix.stackexchange.com/a/602935
# Skip if already unlocked
locked_state=$(busctl --user get-property org.freedesktop.secrets \
/org/freedesktop/secrets/collection/login \
org.freedesktop.Secret.Collection Locked)
if [[ "${locked_state}" == "b false" ]]; then
echo 'Keyring is already unlocked.' >&2
exit 1
fi
# Prompt for password if not provided
if [[ -z "${UNLOCK_PASSWORD}" ]]; then
echo -n 'Login password: ' >&2
read -s UNLOCK_PASSWORD || return
fi
# Unlock
killall -q -u "$(whoami)" gnome-keyring-daemon
eval $(echo -n "${UNLOCK_PASSWORD}" \
| gnome-keyring-daemon --daemonize --login \
| sed -e 's/^/export /')
unset UNLOCK_PASSWORD
echo '' >&2