1
0
mirror of https://github.com/AvengeMedia/DankMaterialShell.git synced 2026-05-12 23:32:50 -04:00

feat: consolidate plugin directory management into a single dynamic button (#2400)

* feat: add Open Dir button to Plugins settings

* feat: consolidate plugin directory management into a single dynamic button
This commit is contained in:
Huỳnh Thiện Lộc
2026-05-12 20:29:17 +07:00
committed by GitHub
parent 9b68fc8213
commit 4bc62cc6ec
2 changed files with 31 additions and 12 deletions
+8 -4
View File
@@ -250,11 +250,15 @@ FocusScope {
} }
DankButton { DankButton {
text: I18n.tr("Create Dir") text: PluginService.pluginDirectoryExists ? I18n.tr("Open Dir") : I18n.tr("Create Dir")
iconName: "create_new_folder" iconName: PluginService.pluginDirectoryExists ? "folder_open" : "create_new_folder"
onClicked: { onClicked: {
PluginService.createPluginDirectory(); if (PluginService.pluginDirectoryExists) {
ToastService.showInfo("Created plugin directory: " + PluginService.pluginDirectory); PluginService.openPluginDirectory();
} else {
PluginService.createPluginDirectory();
ToastService.showInfo("Created plugin directory: " + PluginService.pluginDirectory);
}
} }
} }
} }
+23 -8
View File
@@ -20,14 +20,9 @@ Singleton {
property var pluginLauncherComponents: ({}) property var pluginLauncherComponents: ({})
property var pluginDesktopComponents: ({}) property var pluginDesktopComponents: ({})
property var availablePluginsList: [] property var availablePluginsList: []
property string pluginDirectory: { readonly property string pluginDirectory: Paths.strip(Paths.config) + "/plugins"
var configDir = StandardPaths.writableLocation(StandardPaths.ConfigLocation);
var configDirStr = configDir.toString(); property bool pluginDirectoryExists: false
if (configDirStr.startsWith("file://")) {
configDirStr = configDirStr.substring(7);
}
return configDirStr + "/DankMaterialShell/plugins";
}
property string systemPluginDirectory: "/etc/xdg/quickshell/dms-plugins" property string systemPluginDirectory: "/etc/xdg/quickshell/dms-plugins"
property var knownManifests: ({}) property var knownManifests: ({})
@@ -64,10 +59,23 @@ Singleton {
onTriggered: root._flushDirtyStates() onTriggered: root._flushDirtyStates()
} }
Process {
id: directoryCheckProcess
command: ["test", "-d", root.pluginDirectory]
onExited: (exitCode) => {
root.pluginDirectoryExists = (exitCode === 0);
}
}
function checkPluginDirectoryExists() {
directoryCheckProcess.running = true;
}
Component.onCompleted: { Component.onCompleted: {
userWatcher.folder = Paths.toFileUrl(root.pluginDirectory); userWatcher.folder = Paths.toFileUrl(root.pluginDirectory);
systemWatcher.folder = Paths.toFileUrl(root.systemPluginDirectory); systemWatcher.folder = Paths.toFileUrl(root.systemPluginDirectory);
Qt.callLater(resyncAll); Qt.callLater(resyncAll);
Qt.callLater(checkPluginDirectoryExists);
} }
FolderListModel { FolderListModel {
@@ -758,6 +766,7 @@ Singleton {
systemWatcher.folder = ""; systemWatcher.folder = "";
systemWatcher.folder = systemUrl; systemWatcher.folder = systemUrl;
resyncDebounce.restart(); resyncDebounce.restart();
checkPluginDirectoryExists();
} }
function forceRescanPlugin(pluginId) { function forceRescanPlugin(pluginId) {
@@ -775,6 +784,12 @@ Singleton {
function createPluginDirectory() { function createPluginDirectory() {
Quickshell.execDetached(["mkdir", "-p", pluginDirectory]); Quickshell.execDetached(["mkdir", "-p", pluginDirectory]);
Qt.callLater(checkPluginDirectoryExists);
return true;
}
function openPluginDirectory() {
Qt.openUrlExternally(Paths.toFileUrl(pluginDirectory));
return true; return true;
} }