From f602df31706cde2176053faa284f8a2cecdd10ce Mon Sep 17 00:00:00 2001 From: OlivierChiasson Date: Sun, 21 Jun 2026 17:56:33 -0300 Subject: [PATCH] Initial commit --- README.md | 5 +++ RbwLockToggle.qml | 80 +++++++++++++++++++++++++++++++++++++++ RbwLockToggleSettings.qml | 16 ++++++++ plugin.json | 13 +++++++ 4 files changed, 114 insertions(+) create mode 100644 README.md create mode 100644 RbwLockToggle.qml create mode 100644 RbwLockToggleSettings.qml create mode 100644 plugin.json diff --git a/README.md b/README.md new file mode 100644 index 0000000..db3d1ac --- /dev/null +++ b/README.md @@ -0,0 +1,5 @@ +# rbwLockToggle — DMS bar plugin + +Bar widget for [DankMaterialShell](https://github.com/AvengeMedia/DankMaterialShell): shows Bitwarden vault lock state via [rbw](https://github.com/doy/rbw) and toggles lock/unlock on click. + +Requires `rbw` and a working pinentry on PATH in the DMS session. diff --git a/RbwLockToggle.qml b/RbwLockToggle.qml new file mode 100644 index 0000000..c36bc2d --- /dev/null +++ b/RbwLockToggle.qml @@ -0,0 +1,80 @@ +import QtQuick +import Quickshell +import Quickshell.Io +import qs.Common +import qs.Services +import qs.Widgets +import qs.Modules.Plugins + +PluginComponent { + id: root + + property bool vaultUnlocked: false + + function refreshLockState() { + if (!statusProcess.running) + statusProcess.exec(["rbw", "unlocked"]); + } + + function toggleLock() { + if (root.vaultUnlocked) { + Quickshell.execDetached(["rbw", "lock"]); + } else { + Quickshell.execDetached(["rbw", "unlock"]); + } + } + + pillClickAction: () => root.toggleLock() + + Component.onCompleted: refreshLockState() + + Timer { + interval: 2500 + repeat: true + running: true + onTriggered: root.refreshLockState() + } + + Process { + id: statusProcess + command: ["rbw", "unlocked"] + onExited: (exitCode, _exitStatus) => { + root.vaultUnlocked = exitCode === 0; + } + } + + horizontalBarPill: Component { + MouseArea { + implicitWidth: iconH.implicitWidth + implicitHeight: iconH.implicitHeight + hoverEnabled: true + cursorShape: Qt.PointingHandCursor + onClicked: root.toggleLock() + + DankIcon { + id: iconH + name: root.vaultUnlocked ? "lock_open_right" : "lock" + size: root.iconSize + color: parent.containsMouse ? Theme.primary : Theme.surfaceText + } + } + } + + verticalBarPill: Component { + MouseArea { + implicitWidth: iconV.implicitWidth + implicitHeight: iconV.implicitHeight + hoverEnabled: true + cursorShape: Qt.PointingHandCursor + onClicked: root.toggleLock() + + DankIcon { + id: iconV + name: root.vaultUnlocked ? "lock_open_right" : "lock" + size: root.iconSize + color: parent.containsMouse ? Theme.primary : Theme.surfaceText + anchors.horizontalCenter: parent.horizontalCenter + } + } + } +} diff --git a/RbwLockToggleSettings.qml b/RbwLockToggleSettings.qml new file mode 100644 index 0000000..6e879e0 --- /dev/null +++ b/RbwLockToggleSettings.qml @@ -0,0 +1,16 @@ +import QtQuick +import qs.Common +import qs.Modules.Plugins + +PluginSettings { + id: root + pluginId: "rbwLockToggle" + + StyledText { + width: parent.width + text: "Shows rbw vault state with a closed lock (locked) or open lock (unlocked). Click to run `rbw unlock` (pinentry) or `rbw lock`. Requires `rbw` on PATH in the DMS session and a working pinentry." + font.pixelSize: Theme.fontSizeSmall + color: Theme.surfaceVariantText + wrapMode: Text.WordWrap + } +} diff --git a/plugin.json b/plugin.json new file mode 100644 index 0000000..c951ded --- /dev/null +++ b/plugin.json @@ -0,0 +1,13 @@ +{ + "id": "rbwLockToggle", + "name": "Bitwarden (rbw) lock", + "description": "Bar control for rbw vault: locked/unlocked padlock; click to unlock or lock", + "version": "1.0.0", + "author": "chiasson.cloud", + "type": "widget", + "capabilities": ["dankbar-widget"], + "component": "./RbwLockToggle.qml", + "settings": "./RbwLockToggleSettings.qml", + "icon": "lock_open", + "permissions": ["settings_read"] +}