Add DMS plugins for rbw lock and wvkbd toggle

- Introduced new DMS plugins: `rbw-lock-toggle` for managing Bitwarden vault state and `wvkbd-toggle` for showing/hiding the on-screen keyboard.
- Updated `flake.lock` and `flake.nix` to include the new plugins and their configurations.
- Removed legacy options and files related to the rbw lock toggle, streamlining the DMS configuration.
- Enhanced the home-manager module to support the new plugins and their integration into the DMS environment.
This commit is contained in:
2026-06-22 12:26:25 -03:00
parent 662d24a89c
commit 1524100ff5
16 changed files with 155 additions and 305 deletions
@@ -0,0 +1,44 @@
# Builds matugen config.toml text for DMS dynamic theming.
{
lib,
home,
hyprlandEnabled,
ohMyPoshEnabled,
discordEnabled,
obsidianSnippetDirs,
}:
let
templateBlock = name: input: output: ''
[templates.${name}]
input_path = '${input}'
output_path = '${output}'
'';
in
''
[config]
''
+ lib.optionalString hyprlandEnabled (
templateBlock "hyprland"
"${home}/.config/matugen/templates/hyprland-colors.conf"
"${home}/.config/hypr/colors.conf"
)
+ lib.optionalString ohMyPoshEnabled (
templateBlock "ohmyposh"
"${home}/.config/matugen/templates/ohmyposh-theme.omp.json"
"${home}/.config/oh-my-posh/theme.omp.json"
)
+ lib.optionalString discordEnabled (
templateBlock "dank-discord"
"${home}/.config/matugen/templates/dank-discord.css"
"${home}/.config/vesktop/themes/dank-discord.css"
)
+ lib.optionalString (obsidianSnippetDirs != [ ]) (
lib.concatStringsSep "\n" (
lib.lists.imap0 (i: snippetDir:
templateBlock "Obsidian${toString i}"
"${home}/.config/matugen/templates/obsidian-minimal-matugen-colors.css"
"${snippetDir}/matugen.css"
) obsidianSnippetDirs
)
)
+2 -7
View File
@@ -17,12 +17,6 @@
default = [ ];
description = "Extra right-bar widgets merged into the first-run DMS settings seed.";
};
enableWvkbdToggle = lib.mkEnableOption ''
wvkbd DMS plugin + bar toggle (touch / uConsole).
'';
enableRbwLockToggle = lib.mkEnableOption ''
rbw vault lock/unlock button in the DMS bar (Bitwarden CLI via rbw).
'';
rebuildCommand = lib.mkOption {
type = lib.types.nullOr (lib.types.listOf lib.types.str);
default = null;
@@ -44,7 +38,8 @@
type = lib.types.bool;
default = true;
description = ''
Install bundled third-party DMS plugins from flake inputs on all DMS hosts.
Install bundled DMS plugins from flake inputs (third-party + chiasson).
Disable individual plugins in DMS settings; set this to false to skip all bundled plugins.
'';
};
};
@@ -14,14 +14,6 @@
discordEnabled = lib.attrByPath [ "chiasson" "home" "apps" "discord" "enable" ] false config;
ohMyPoshEnabled = config.programs.oh-my-posh.enable or false;
obsidianSnippetDirs = map (v: v + "/snippets") (dmsOs.obsidianVaults or [ ]);
seedBarWidgets =
lib.optionals (dmsOs.enableWvkbdToggle or false) [
{ id = "wvkbdToggle"; enabled = true; }
]
++ lib.optionals (dmsOs.enableRbwLockToggle or false) [
{ id = "rbwLockToggle"; enabled = true; }
]
++ (dmsOs.extraRightBarWidgets or [ ]);
matugenOutputDirs =
lib.optionals hyprlandEnabled [ "${home}/.config/hypr" ]
++ lib.optionals ohMyPoshEnabled [ "${home}/.config/oh-my-posh" ]
@@ -30,10 +22,9 @@
"${home}/.config/qt6ct/colors"
"${home}/.config/qt5ct/colors"
];
ensureMatugenOutputDirsScript = pkgs.writeShellScript "dms-ensure-matugen-output-dirs" ''
set -euo pipefail
${lib.concatStringsSep "\n" (map (dir: "mkdir -p ${lib.escapeShellArg dir}") matugenOutputDirs)}
${lib.concatStringsSep "\n" (map (dir: ''
ensureMatugenBody =
lib.concatStringsSep "\n" (map (dir: "mkdir -p ${lib.escapeShellArg dir}") matugenOutputDirs)
+ lib.concatStringsSep "\n" (map (dir: ''
snippetDir=${lib.escapeShellArg dir}
parentDir="$(dirname "$snippetDir")"
if [ -d "$snippetDir" ]; then
@@ -43,8 +34,8 @@
else
mkdir -p "$snippetDir"
fi
'') obsidianSnippetDirs)}
${lib.optionalString ohMyPoshEnabled ''
'') obsidianSnippetDirs)
+ lib.optionalString ohMyPoshEnabled ''
dest="$HOME/.config/oh-my-posh/theme.omp.json"
template="$HOME/.config/matugen/templates/ohmyposh-theme.omp.json"
if [ -L "$dest" ] || { [ -e "$dest" ] && ! [ -f "$dest" ]; }; then
@@ -53,19 +44,21 @@
if [ ! -f "$dest" ]; then
cp -L "$template" "$dest"
fi
''}
'';
ensureMatugenOutputDirsScript = pkgs.writeShellScript "dms-ensure-matugen-output-dirs" ''
set -euo pipefail
${ensureMatugenBody}
'';
# Clears Quickshell QML bytecode cache so bar plugins reload (stale *.qmlc keeps old UI).
dmsRestartOnceScript = pkgs.writeShellScript "dms-rbw-plugin-restart-once" ''
set -euo pipefail
rt="''${XDG_RUNTIME_DIR:-/run/user/$(id -u)}"
exec 9>"$rt/dms-rbw-plugin-restart.lock"
${pkgs.util-linux}/bin/flock -n 9 || exit 0
cache="''${XDG_CACHE_HOME:-''$HOME/.cache}/quickshell/qmlcache"
rm -rf "$cache"
${pkgs.systemd}/bin/systemctl --user try-restart dms.service 2>/dev/null || true
'';
dmsRestartOnceScript = pkgs.writeShellScript "dms-plugin-restart-once" (
builtins.replaceStrings
[ "@FLOCK@" "@SYSTEMCTL@" ]
[
"${pkgs.util-linux}/bin/flock"
"${pkgs.systemd}/bin/systemctl"
]
(builtins.readFile ./scripts/dms-restart-once.sh)
);
jsonFormat = pkgs.formats.json { };
dmsConfigDir = "${config.xdg.configHome}/DankMaterialShell";
@@ -84,11 +77,45 @@
"settings.json" = jsonFormat.generate "dms-settings-seed.json" (
import ../_private/default-settings.nix {
inherit lib gpuTempEnabled;
extraRightBarWidgets = seedBarWidgets;
extraRightBarWidgets = dmsOs.extraRightBarWidgets or [ ];
}
);
};
dmsSeedBody = lib.concatMapStringsSep "\n" (
fileName:
let
dest = "${dmsConfigDir}/${fileName}";
src = dmsSeedSources.${fileName};
in
''
dest=${lib.escapeShellArg dest}
mkdir -p "$(dirname "$dest")"
if [ -L "$dest" ]; then
${pkgs.coreutils}/bin/cp --remove-destination -L "$dest" "$dest"
fi
if [ ! -e "$dest" ]; then
${pkgs.coreutils}/bin/cp ${lib.escapeShellArg src} "$dest"
chmod u+w "$dest"
fi
''
) (lib.attrNames dmsSeedSources);
dmsSeedConfigScript = pkgs.writeShellScript "dms-seed-config" ''
set -euo pipefail
${dmsSeedBody}
'';
matugenConfigText = import ../_private/matugen-config.nix {
inherit
lib
home
hyprlandEnabled
ohMyPoshEnabled
discordEnabled
obsidianSnippetDirs
;
};
# Directory name must match each plugin's `id` in plugin.json.
thirdPartyPlugins = {
dankVault = inputs.dms-plugin-dank-vault;
@@ -107,6 +134,8 @@
wallpaperCarousel = inputs.dms-plugin-wallpaper-carousel;
ephemera = inputs.dms-plugin-ephemera;
appShortcut = inputs.dms-plugin-app-shortcut;
wvkbdToggle = inputs.dms-plugin-wvkbd-toggle;
rbwLockToggle = inputs.dms-plugin-rbw-lock-toggle;
};
shipThirdPartyPlugin =
@@ -123,29 +152,6 @@ in {
];
config = lib.mkIf dmsEnabled (lib.mkMerge [
(lib.mkIf (dmsOs.enableWvkbdToggle or false) {
xdg.configFile."DankMaterialShell/plugins/wvkbd-toggle/plugin.json".source =
../plugins/wvkbd-toggle/plugin.json;
xdg.configFile."DankMaterialShell/plugins/wvkbd-toggle/WvkbdToggle.qml".source =
../plugins/wvkbd-toggle/WvkbdToggle.qml;
xdg.configFile."DankMaterialShell/plugins/wvkbd-toggle/WvkbdToggleSettings.qml".source =
../plugins/wvkbd-toggle/WvkbdToggleSettings.qml;
})
(lib.mkIf (dmsOs.enableRbwLockToggle or false) {
# Directory name matches plugin id (same idea as NixMonitor / ideapad wvkbdToggle).
xdg.configFile."DankMaterialShell/plugins/rbwLockToggle/plugin.json" = {
source = ../plugins/rbw-lock-toggle/plugin.json;
onChange = "${dmsRestartOnceScript}";
};
xdg.configFile."DankMaterialShell/plugins/rbwLockToggle/RbwLockToggleSettings.qml" = {
source = ../plugins/rbw-lock-toggle/RbwLockToggleSettings.qml;
onChange = "${dmsRestartOnceScript}";
};
xdg.configFile."DankMaterialShell/plugins/rbwLockToggle/RbwLockToggle.qml" = {
source = ../plugins/rbw-lock-toggle/RbwLockToggle.qml;
onChange = "${dmsRestartOnceScript}";
};
})
(lib.mkIf (dmsOs.bundleThirdPartyPlugins or true) {
xdg.configFile =
lib.mapAttrs (id: src: shipThirdPartyPlugin id src) thirdPartyPlugins;
@@ -211,25 +217,7 @@ in {
};
# Detach store symlinks so UI edits survive rebuilds; seed defaults only on a fresh profile.
home.activation.dmsSeedConfig = lib.hm.dag.entryAfter [ "writeBoundary" ] ''
${lib.concatMapStringsSep "\n" (
fileName:
let
dest = "${dmsConfigDir}/${fileName}";
src = dmsSeedSources.${fileName};
in ''
dest=${lib.escapeShellArg dest}
mkdir -p "$(dirname "$dest")"
if [ -L "$dest" ]; then
${pkgs.coreutils}/bin/cp --remove-destination -L "$dest" "$dest"
fi
if [ ! -e "$dest" ]; then
${pkgs.coreutils}/bin/cp ${lib.escapeShellArg src} "$dest"
chmod u+w "$dest"
fi
''
) (lib.attrNames dmsSeedSources)}
'';
home.activation.dmsSeedConfig = lib.hm.dag.entryAfter [ "writeBoundary" ] "${dmsSeedConfigScript}";
# matugen won't create missing output_path parents; run before DMS theme generation.
systemd.user.services.dms.serviceConfig.ExecStartPre =
@@ -238,38 +226,7 @@ in {
# DMS / matugen custom templates.
#
# DMS docs (custom templates): https://danklinux.com/docs/dankmaterialshell/application-themes#custom-matugen-templates
xdg.configFile."matugen/config.toml".text =
''
[config]
''
+ lib.optionalString hyprlandEnabled ''
[templates.hyprland]
input_path = '${home}/.config/matugen/templates/hyprland-colors.conf'
output_path = '${home}/.config/hypr/colors.conf'
''
+ lib.optionalString ohMyPoshEnabled ''
[templates.ohmyposh]
input_path = '${home}/.config/matugen/templates/ohmyposh-theme.omp.json'
output_path = '${home}/.config/oh-my-posh/theme.omp.json'
''
+ lib.optionalString discordEnabled ''
[templates.dank-discord]
input_path = '${home}/.config/matugen/templates/dank-discord.css'
output_path = '${home}/.config/vesktop/themes/dank-discord.css'
''
+ lib.optionalString (obsidianSnippetDirs != []) (
lib.concatStringsSep "\n" (
lib.lists.imap0 (i: snippetDir: ''
[templates.Obsidian${toString i}]
input_path = '${home}/.config/matugen/templates/obsidian-minimal-matugen-colors.css'
output_path = '${snippetDir}/matugen.css'
'') obsidianSnippetDirs
)
)
;
xdg.configFile."matugen/config.toml".text = matugenConfigText;
xdg.configFile."matugen/templates/dank-discord.css".source = ../templates/dank-discord.css;
xdg.configFile."matugen/templates/hyprland-colors.conf".source = ../templates/hyprland-colors.conf;
@@ -0,0 +1,8 @@
#!/usr/bin/env bash
set -euo pipefail
rt="${XDG_RUNTIME_DIR:-/run/user/$(id -u)}"
exec 9>"$rt/dms-plugin-restart.lock"
@FLOCK@ -n 9 || exit 0
cache="${XDG_CACHE_HOME:-$HOME/.cache}/quickshell/qmlcache"
rm -rf "$cache"
@SYSTEMCTL@ --user try-restart dms.service 2>/dev/null || true
@@ -1,80 +0,0 @@
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
}
}
}
}
@@ -1,16 +0,0 @@
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
}
}
@@ -1,13 +0,0 @@
{
"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"]
}
@@ -1,51 +0,0 @@
import QtQuick
import Quickshell
import qs.Common
import qs.Services
import qs.Widgets
import qs.Modules.Plugins
PluginComponent {
id: root
function toggleKeyboard() {
Quickshell.execDetached(["sh", "-c", "pkill -SIGRTMIN -x wvkbd-mobintl"]);
}
pillClickAction: () => root.toggleKeyboard()
horizontalBarPill: Component {
MouseArea {
implicitWidth: icon.implicitWidth
implicitHeight: icon.implicitHeight
hoverEnabled: true
cursorShape: Qt.PointingHandCursor
onClicked: root.toggleKeyboard()
DankIcon {
id: icon
name: "keyboard"
size: Theme.iconSize
color: parent.containsMouse ? Theme.primary : Theme.surfaceText
}
}
}
verticalBarPill: Component {
MouseArea {
implicitWidth: iconV.implicitWidth
implicitHeight: iconV.implicitHeight
hoverEnabled: true
cursorShape: Qt.PointingHandCursor
onClicked: root.toggleKeyboard()
DankIcon {
id: iconV
name: "keyboard"
size: Theme.iconSize
color: parent.containsMouse ? Theme.primary : Theme.surfaceText
anchors.horizontalCenter: parent.horizontalCenter
}
}
}
}
@@ -1,16 +0,0 @@
import QtQuick
import qs.Common
import qs.Modules.Plugins
PluginSettings {
id: root
pluginId: "wvkbdToggle"
StyledText {
width: parent.width
text: "Click the keyboard icon in the bar to show or hide the on-screen keyboard (wvkbd)."
font.pixelSize: Theme.fontSizeSmall
color: Theme.surfaceVariantText
wrapMode: Text.WordWrap
}
}
@@ -1,13 +0,0 @@
{
"id": "wvkbdToggle",
"name": "Virtual Keyboard Toggle",
"description": "Bar button to show/hide the wvkbd on-screen keyboard (for touch/tablet)",
"version": "1.0.0",
"author": "chiasson.cloud",
"type": "widget",
"capabilities": ["dankbar-widget"],
"component": "./WvkbdToggle.qml",
"settings": "./WvkbdToggleSettings.qml",
"icon": "keyboard",
"permissions": ["settings_read"]
}