diff --git a/quickshell/Modals/Spotlight/SpotlightContent.qml b/quickshell/Modals/Spotlight/SpotlightContent.qml index 5e566f6f..959956ee 100644 --- a/quickshell/Modals/Spotlight/SpotlightContent.qml +++ b/quickshell/Modals/Spotlight/SpotlightContent.qml @@ -467,6 +467,7 @@ Item { Item { width: parent.width height: parent.height - y + opacity: parentModal?.isClosing ? 0 : 1 SpotlightResults { id: resultsView diff --git a/quickshell/Modals/Spotlight/SpotlightModal.qml b/quickshell/Modals/Spotlight/SpotlightModal.qml index 9fef779b..2c12f221 100644 --- a/quickshell/Modals/Spotlight/SpotlightModal.qml +++ b/quickshell/Modals/Spotlight/SpotlightModal.qml @@ -3,7 +3,6 @@ import Quickshell.Hyprland import Quickshell.Io import qs.Common import qs.Modals.Common -import qs.Services DankModal { id: spotlightModal @@ -18,62 +17,69 @@ DankModal { property bool spotlightOpen: false property alias spotlightContent: spotlightContentInstance property bool openedFromOverview: false + property bool isClosing: false + + function resetContent() { + if (!spotlightContent) + return; + if (spotlightContent.appLauncher) { + spotlightContent.appLauncher.searchQuery = ""; + spotlightContent.appLauncher.selectedIndex = 0; + spotlightContent.appLauncher.setCategory(I18n.tr("All")); + } + if (spotlightContent.fileSearchController) + spotlightContent.fileSearchController.reset(); + if (spotlightContent.resetScroll) + spotlightContent.resetScroll(); + if (spotlightContent.searchField) + spotlightContent.searchField.text = ""; + spotlightContent.searchMode = "apps"; + } function show() { openedFromOverview = false; + isClosing = false; + resetContent(); spotlightOpen = true; + if (spotlightContent?.appLauncher) + spotlightContent.appLauncher.ensureInitialized(); open(); Qt.callLater(() => { - if (spotlightContent && spotlightContent.searchField) { + if (spotlightContent?.searchField) spotlightContent.searchField.forceActiveFocus(); - } }); } function showWithQuery(query) { - if (spotlightContent) { - if (spotlightContent.appLauncher) { - spotlightContent.appLauncher.searchQuery = query; - } - if (spotlightContent.searchField) { - spotlightContent.searchField.text = query; - } - } - + openedFromOverview = false; + isClosing = false; + resetContent(); spotlightOpen = true; + if (spotlightContent?.appLauncher) { + spotlightContent.appLauncher.ensureInitialized(); + spotlightContent.appLauncher.searchQuery = query; + } + if (spotlightContent?.searchField) + spotlightContent.searchField.text = query; open(); Qt.callLater(() => { - if (spotlightContent && spotlightContent.searchField) { + if (spotlightContent?.searchField) spotlightContent.searchField.forceActiveFocus(); - } }); } function hide() { openedFromOverview = false; + isClosing = true; spotlightOpen = false; close(); } onDialogClosed: { - if (spotlightContent) { - if (spotlightContent.appLauncher) { - spotlightContent.appLauncher.searchQuery = ""; - spotlightContent.appLauncher.selectedIndex = 0; - spotlightContent.appLauncher.setCategory(I18n.tr("All")); - } - if (spotlightContent.fileSearchController) { - spotlightContent.fileSearchController.reset(); - } - if (spotlightContent.resetScroll) { - spotlightContent.resetScroll(); - } - if (spotlightContent.searchField) { - spotlightContent.searchField.text = ""; - } - } + isClosing = false; + resetContent(); } function toggle() { diff --git a/quickshell/Modules/AppDrawer/AppDrawerPopout.qml b/quickshell/Modules/AppDrawer/AppDrawerPopout.qml index 29bff7e8..e908e304 100644 --- a/quickshell/Modules/AppDrawer/AppDrawerPopout.qml +++ b/quickshell/Modules/AppDrawer/AppDrawerPopout.qml @@ -52,6 +52,7 @@ DankPopout { onOpened: { searchMode = "apps"; + appLauncher.ensureInitialized(); appLauncher.searchQuery = ""; appLauncher.selectedIndex = 0; appLauncher.setCategory(I18n.tr("All")); @@ -344,7 +345,7 @@ DankPopout { width: parent.width - Theme.spacingS * 2 height: 40 anchors.horizontalCenter: parent.horizontalCenter - visible: searchField.text.length === 0 && appDrawerPopout.searchMode === "apps" + visible: appDrawerPopout.searchMode === "apps" Rectangle { width: 180 @@ -404,7 +405,7 @@ DankPopout { height: { let usedHeight = 40 + Theme.spacingS; usedHeight += 52 + Theme.spacingS; - usedHeight += (searchField.text.length === 0 && appDrawerPopout.searchMode === "apps" ? 40 : 0); + usedHeight += appDrawerPopout.searchMode === "apps" ? 40 : 0; return parent.height - usedHeight; } radius: Theme.cornerRadius diff --git a/quickshell/Modules/AppDrawer/AppLauncher.qml b/quickshell/Modules/AppDrawer/AppLauncher.qml index 189cef96..8b9eeb06 100644 --- a/quickshell/Modules/AppDrawer/AppLauncher.qml +++ b/quickshell/Modules/AppDrawer/AppLauncher.qml @@ -1,9 +1,7 @@ import QtQuick -import QtQuick.Controls import Quickshell import qs.Common import qs.Services -import qs.Widgets Item { id: root @@ -23,15 +21,15 @@ Item { property bool keyboardNavigationActive: false property bool suppressUpdatesWhileLaunching: false property var categories: { - const allCategories = AppSearchService.getAllCategories().filter(cat => cat !== "Education" && cat !== "Science") - const result = [I18n.tr("All")] - return result.concat(allCategories.filter(cat => cat !== I18n.tr("All"))) + const allCategories = AppSearchService.getAllCategories().filter(cat => cat !== "Education" && cat !== "Science"); + const result = [I18n.tr("All")]; + return result.concat(allCategories.filter(cat => cat !== I18n.tr("All"))); } readonly property var categoryIcons: categories.map(category => AppSearchService.getCategoryIcon(category)) property var appUsageRanking: AppUsageHistoryData.appUsageRanking || {} property alias model: filteredModel - property var _watchApplications: AppSearchService.applications property var _uniqueApps: [] + property bool _initialized: false property bool _isTriggered: false property string _triggeredCategory: "" property bool _updatingFromTrigger: false @@ -40,98 +38,109 @@ Item { signal categorySelected(string category) signal viewModeSelected(string mode) + function ensureInitialized() { + if (_initialized) + return; + _initialized = true; + updateFilteredModel(); + } + function updateCategories() { - const allCategories = AppSearchService.getAllCategories().filter(cat => cat !== "Education" && cat !== "Science") - const result = [I18n.tr("All")] - categories = result.concat(allCategories.filter(cat => cat !== I18n.tr("All"))) + const allCategories = AppSearchService.getAllCategories().filter(cat => cat !== "Education" && cat !== "Science"); + const result = [I18n.tr("All")]; + categories = result.concat(allCategories.filter(cat => cat !== I18n.tr("All"))); } Connections { target: PluginService - function onPluginLoaded() { updateCategories() } - function onPluginUnloaded() { updateCategories() } - function onPluginListUpdated() { updateCategories() } + function onPluginLoaded() { + updateCategories(); + } + function onPluginUnloaded() { + updateCategories(); + } + function onPluginListUpdated() { + updateCategories(); + } function onRequestLauncherUpdate(pluginId) { // Only update if we are actually looking at this plugin or in All category - updateFilteredModel() + updateFilteredModel(); } } Connections { target: SettingsData function onSortAppsAlphabeticallyChanged() { - updateFilteredModel() + updateFilteredModel(); } } - - function updateFilteredModel() { if (suppressUpdatesWhileLaunching) { - suppressUpdatesWhileLaunching = false - return + suppressUpdatesWhileLaunching = false; + return; } - filteredModel.clear() - selectedIndex = 0 - keyboardNavigationActive = false + filteredModel.clear(); + selectedIndex = 0; + keyboardNavigationActive = false; - const triggerResult = checkPluginTriggers(searchQuery) + const triggerResult = checkPluginTriggers(searchQuery); if (triggerResult.triggered) { - console.log("AppLauncher: Plugin trigger detected:", triggerResult.trigger, "for plugin:", triggerResult.pluginId) + console.log("AppLauncher: Plugin trigger detected:", triggerResult.trigger, "for plugin:", triggerResult.pluginId); } - let apps = [] - const allCategory = I18n.tr("All") - const emptyTriggerPlugins = typeof PluginService !== "undefined" ? PluginService.getPluginsWithEmptyTrigger() : [] + let apps = []; + const allCategory = I18n.tr("All"); + const emptyTriggerPlugins = typeof PluginService !== "undefined" ? PluginService.getPluginsWithEmptyTrigger() : []; if (triggerResult.triggered) { - _isTriggered = true - _triggeredCategory = triggerResult.pluginCategory - _updatingFromTrigger = true - selectedCategory = triggerResult.pluginCategory - _updatingFromTrigger = false - apps = AppSearchService.getPluginItems(triggerResult.pluginCategory, triggerResult.query) + _isTriggered = true; + _triggeredCategory = triggerResult.pluginCategory; + _updatingFromTrigger = true; + selectedCategory = triggerResult.pluginCategory; + _updatingFromTrigger = false; + apps = AppSearchService.getPluginItems(triggerResult.pluginCategory, triggerResult.query); } else { if (_isTriggered) { - _updatingFromTrigger = true - selectedCategory = allCategory - _updatingFromTrigger = false - _isTriggered = false - _triggeredCategory = "" + _updatingFromTrigger = true; + selectedCategory = allCategory; + _updatingFromTrigger = false; + _isTriggered = false; + _triggeredCategory = ""; } if (searchQuery.length === 0) { if (selectedCategory === allCategory) { - let emptyTriggerItems = [] + let emptyTriggerItems = []; emptyTriggerPlugins.forEach(pluginId => { - const plugin = PluginService.getLauncherPlugin(pluginId) - const pluginCategory = plugin.name || pluginId - const items = AppSearchService.getPluginItems(pluginCategory, "") - emptyTriggerItems = emptyTriggerItems.concat(items) - }) - apps = AppSearchService.applications.concat(emptyTriggerItems) + const plugin = PluginService.getLauncherPlugin(pluginId); + const pluginCategory = plugin.name || pluginId; + const items = AppSearchService.getPluginItems(pluginCategory, ""); + emptyTriggerItems = emptyTriggerItems.concat(items); + }); + apps = AppSearchService.applications.concat(emptyTriggerItems); } else { - apps = AppSearchService.getAppsInCategory(selectedCategory).slice(0, maxResults) + apps = AppSearchService.getAppsInCategory(selectedCategory).slice(0, maxResults); } } else { if (selectedCategory === allCategory) { - apps = AppSearchService.searchApplications(searchQuery) + apps = AppSearchService.searchApplications(searchQuery); - let emptyTriggerItems = [] + let emptyTriggerItems = []; emptyTriggerPlugins.forEach(pluginId => { - const plugin = PluginService.getLauncherPlugin(pluginId) - const pluginCategory = plugin.name || pluginId - const items = AppSearchService.getPluginItems(pluginCategory, searchQuery) - emptyTriggerItems = emptyTriggerItems.concat(items) - }) - apps = apps.concat(emptyTriggerItems) + const plugin = PluginService.getLauncherPlugin(pluginId); + const pluginCategory = plugin.name || pluginId; + const items = AppSearchService.getPluginItems(pluginCategory, searchQuery); + emptyTriggerItems = emptyTriggerItems.concat(items); + }); + apps = apps.concat(emptyTriggerItems); } else { - const categoryApps = AppSearchService.getAppsInCategory(selectedCategory) + const categoryApps = AppSearchService.getAppsInCategory(selectedCategory); if (categoryApps.length > 0) { - const allSearchResults = AppSearchService.searchApplications(searchQuery) - const categoryNames = new Set(categoryApps.map(app => app.name)) - apps = allSearchResults.filter(searchApp => categoryNames.has(searchApp.name)).slice(0, maxResults) + const allSearchResults = AppSearchService.searchApplications(searchQuery); + const categoryNames = new Set(categoryApps.map(app => app.name)); + apps = allSearchResults.filter(searchApp => categoryNames.has(searchApp.name)).slice(0, maxResults); } else { - apps = [] + apps = []; } } } @@ -140,138 +149,150 @@ Item { if (searchQuery.length === 0) { if (SettingsData.sortAppsAlphabetically) { apps = apps.sort((a, b) => { - return (a.name || "").localeCompare(b.name || "") - }) + return (a.name || "").localeCompare(b.name || ""); + }); } else { apps = apps.sort((a, b) => { - const aId = a.id || a.execString || a.exec || "" - const bId = b.id || b.execString || b.exec || "" - const aUsage = appUsageRanking[aId] ? appUsageRanking[aId].usageCount : 0 - const bUsage = appUsageRanking[bId] ? appUsageRanking[bId].usageCount : 0 - if (aUsage !== bUsage) { - return bUsage - aUsage - } - return (a.name || "").localeCompare(b.name || "") - }) + const aId = a.id || a.execString || a.exec || ""; + const bId = b.id || b.execString || b.exec || ""; + const aUsage = appUsageRanking[aId] ? appUsageRanking[aId].usageCount : 0; + const bUsage = appUsageRanking[bId] ? appUsageRanking[bId].usageCount : 0; + if (aUsage !== bUsage) { + return bUsage - aUsage; + } + return (a.name || "").localeCompare(b.name || ""); + }); } } - const seenNames = new Set() - const uniqueApps = [] + const seenNames = new Set(); + const uniqueApps = []; apps.forEach(app => { - if (app) { - const itemKey = app.name + "|" + (app.execString || app.exec || app.action || "") - if (seenNames.has(itemKey)) { - return - } - seenNames.add(itemKey) - uniqueApps.push(app) + if (app) { + const itemKey = app.name + "|" + (app.execString || app.exec || app.action || ""); + if (seenNames.has(itemKey)) { + return; + } + seenNames.add(itemKey); + uniqueApps.push(app); - const isPluginItem = app.action !== undefined - filteredModel.append({ - "name": app.name || "", - "exec": app.execString || app.exec || app.action || "", - "icon": app.icon !== undefined ? app.icon : (isPluginItem ? "" : "application-x-executable"), - "comment": app.comment || "", - "categories": app.categories || [], - "isPlugin": isPluginItem, - "appIndex": uniqueApps.length - 1 - }) - } - }) + const isPluginItem = app.action !== undefined; + filteredModel.append({ + "name": app.name || "", + "exec": app.execString || app.exec || app.action || "", + "icon": app.icon !== undefined ? app.icon : (isPluginItem ? "" : "application-x-executable"), + "comment": app.comment || "", + "categories": app.categories || [], + "isPlugin": isPluginItem, + "appIndex": uniqueApps.length - 1 + }); + } + }); - root._uniqueApps = uniqueApps + root._uniqueApps = uniqueApps; } function selectNext() { if (filteredModel.count === 0) { - return + return; } - keyboardNavigationActive = true - selectedIndex = viewMode === "grid" ? Math.min(selectedIndex + gridColumns, filteredModel.count - 1) : Math.min(selectedIndex + 1, filteredModel.count - 1) + keyboardNavigationActive = true; + selectedIndex = viewMode === "grid" ? Math.min(selectedIndex + gridColumns, filteredModel.count - 1) : Math.min(selectedIndex + 1, filteredModel.count - 1); } function selectPrevious() { if (filteredModel.count === 0) { - return + return; } - keyboardNavigationActive = true - selectedIndex = viewMode === "grid" ? Math.max(selectedIndex - gridColumns, 0) : Math.max(selectedIndex - 1, 0) + keyboardNavigationActive = true; + selectedIndex = viewMode === "grid" ? Math.max(selectedIndex - gridColumns, 0) : Math.max(selectedIndex - 1, 0); } function selectNextInRow() { if (filteredModel.count === 0 || viewMode !== "grid") { - return + return; } - keyboardNavigationActive = true - selectedIndex = Math.min(selectedIndex + 1, filteredModel.count - 1) + keyboardNavigationActive = true; + selectedIndex = Math.min(selectedIndex + 1, filteredModel.count - 1); } function selectPreviousInRow() { if (filteredModel.count === 0 || viewMode !== "grid") { - return + return; } - keyboardNavigationActive = true - selectedIndex = Math.max(selectedIndex - 1, 0) + keyboardNavigationActive = true; + selectedIndex = Math.max(selectedIndex - 1, 0); } function launchSelected() { if (filteredModel.count === 0 || selectedIndex < 0 || selectedIndex >= filteredModel.count) { - return + return; } - const selectedApp = filteredModel.get(selectedIndex) - launchApp(selectedApp) + const selectedApp = filteredModel.get(selectedIndex); + launchApp(selectedApp); } function launchApp(appData) { if (!appData || typeof appData.appIndex === "undefined" || appData.appIndex < 0 || appData.appIndex >= _uniqueApps.length) { - return + return; } - suppressUpdatesWhileLaunching = true + suppressUpdatesWhileLaunching = true; - const actualApp = _uniqueApps[appData.appIndex] + const actualApp = _uniqueApps[appData.appIndex]; if (appData.isPlugin) { - const pluginId = getPluginIdForItem(actualApp) + const pluginId = getPluginIdForItem(actualApp); if (pluginId) { - AppSearchService.executePluginItem(actualApp, pluginId) - appLaunched(appData) - return + AppSearchService.executePluginItem(actualApp, pluginId); + appLaunched(appData); + return; } } else { - SessionService.launchDesktopEntry(actualApp) - appLaunched(appData) - AppUsageHistoryData.addAppUsage(actualApp) + SessionService.launchDesktopEntry(actualApp); + appLaunched(appData); + AppUsageHistoryData.addAppUsage(actualApp); } } function setCategory(category) { - selectedCategory = category - categorySelected(category) + selectedCategory = category; + categorySelected(category); } function setViewMode(mode) { - viewMode = mode - viewModeSelected(mode) + viewMode = mode; + viewModeSelected(mode); } onSearchQueryChanged: { + if (!_initialized) + return; if (debounceSearch) { - searchDebounceTimer.restart() + searchDebounceTimer.restart(); } else { - updateFilteredModel() + updateFilteredModel(); } } + onSelectedCategoryChanged: { - if (_updatingFromTrigger) { - return - } - updateFilteredModel() + if (_updatingFromTrigger || !_initialized) + return; + updateFilteredModel(); } - onAppUsageRankingChanged: updateFilteredModel() - on_WatchApplicationsChanged: updateFilteredModel() - Component.onCompleted: { - updateFilteredModel() + + onAppUsageRankingChanged: { + if (_initialized) + updateFilteredModel(); + } + + Connections { + target: DesktopEntries + function onApplicationsChanged() { + if (!root._initialized) + return; + root.updateCategories(); + root.updateFilteredModel(); + } } ListModel { @@ -289,59 +310,67 @@ Item { // Plugin trigger system functions function checkPluginTriggers(query) { if (!query || typeof PluginService === "undefined") { - return { triggered: false, pluginCategory: "", query: "" } + return { + triggered: false, + pluginCategory: "", + query: "" + }; } - const triggers = PluginService.getAllPluginTriggers() + const triggers = PluginService.getAllPluginTriggers(); for (const trigger in triggers) { if (query.startsWith(trigger)) { - const pluginId = triggers[trigger] - const plugin = PluginService.getLauncherPlugin(pluginId) + const pluginId = triggers[trigger]; + const plugin = PluginService.getLauncherPlugin(pluginId); if (plugin) { - const remainingQuery = query.substring(trigger.length).trim() + const remainingQuery = query.substring(trigger.length).trim(); const result = { triggered: true, pluginId: pluginId, pluginCategory: plugin.name || pluginId, query: remainingQuery, trigger: trigger - } - return result + }; + return result; } } } - return { triggered: false, pluginCategory: "", query: "" } + return { + triggered: false, + pluginCategory: "", + query: "" + }; } function getPluginIdForItem(item) { if (!item || !item.categories || typeof PluginService === "undefined") { - return null + return null; } - const launchers = PluginService.getLauncherPlugins() + const launchers = PluginService.getLauncherPlugins(); for (const pluginId in launchers) { - const plugin = launchers[pluginId] - const pluginCategory = plugin.name || pluginId + const plugin = launchers[pluginId]; + const pluginCategory = plugin.name || pluginId; - let hasCategory = false + let hasCategory = false; if (Array.isArray(item.categories)) { - hasCategory = item.categories.includes(pluginCategory) + hasCategory = item.categories.includes(pluginCategory); } else if (item.categories && typeof item.categories.count !== "undefined") { for (let i = 0; i < item.categories.count; i++) { if (item.categories.get(i) === pluginCategory) { - hasCategory = true - break + hasCategory = true; + break; } } } if (hasCategory) { - return pluginId + return pluginId; } } - return null + return null; } } diff --git a/quickshell/Modules/WorkspaceOverlays/NiriOverviewOverlay.qml b/quickshell/Modules/WorkspaceOverlays/NiriOverviewOverlay.qml index 0d0b558e..6b3eff3f 100644 --- a/quickshell/Modules/WorkspaceOverlays/NiriOverviewOverlay.qml +++ b/quickshell/Modules/WorkspaceOverlays/NiriOverviewOverlay.qml @@ -125,7 +125,12 @@ Scope { } onShouldShowSpotlightChanged: { - if (shouldShowSpotlight || !isActiveScreen) + if (shouldShowSpotlight) { + if (spotlightContent?.appLauncher) + spotlightContent.appLauncher.ensureInitialized(); + return; + } + if (!isActiveScreen) return; Qt.callLater(() => keyboardFocusScope.forceActiveFocus()); } diff --git a/quickshell/Services/AppSearchService.qml b/quickshell/Services/AppSearchService.qml index d4593dc9..86ea5056 100644 --- a/quickshell/Services/AppSearchService.qml +++ b/quickshell/Services/AppSearchService.qml @@ -8,7 +8,8 @@ import qs.Common Singleton { id: root - property var applications: DesktopEntries.applications.values.filter(app => !app.noDisplay) + property var applications: [] + property var _cachedCategories: null readonly property int maxResults: 10 readonly property int frecencySampleSize: 10 @@ -36,6 +37,20 @@ Singleton { } ] + function refreshApplications() { + applications = DesktopEntries.applications.values; + _cachedCategories = null; + } + + Connections { + target: DesktopEntries + function onApplicationsChanged() { + root.refreshApplications(); + } + } + + Component.onCompleted: refreshApplications() + function tokenize(text) { return text.toLowerCase().trim().split(/[\s\-_]+/).filter(w => w.length > 0); } @@ -316,19 +331,20 @@ Singleton { } function getAllCategories() { - const categories = new Set([I18n.tr("All")]); + if (_cachedCategories) + return _cachedCategories; + const categories = new Set([I18n.tr("All")]); for (const app of applications) { const appCategories = getCategoriesForApp(app); appCategories.forEach(cat => categories.add(cat)); } - // Add plugin categories const pluginCategories = getPluginCategories(); pluginCategories.forEach(cat => categories.add(cat)); - const result = Array.from(categories).sort(); - return result; + _cachedCategories = Array.from(categories).sort(); + return _cachedCategories; } function getAppsInCategory(category) { diff --git a/quickshell/matugen/dynamic-base16-dankshell.vsix b/quickshell/matugen/dynamic-base16-dankshell.vsix index 42e1d10e..fe8c43cd 100644 Binary files a/quickshell/matugen/dynamic-base16-dankshell.vsix and b/quickshell/matugen/dynamic-base16-dankshell.vsix differ diff --git a/quickshell/matugen/vsix-build/extension.js b/quickshell/matugen/vsix-build/extension.js deleted file mode 100644 index cb5ef0e4..00000000 --- a/quickshell/matugen/vsix-build/extension.js +++ /dev/null @@ -1,86 +0,0 @@ -const vscode = require("vscode"); -const path = require("path"); -const fs = require("fs"); - -let watcher = null; -let reloadTimeout = null; - -function activate(context) { - const themesDir = path.join(context.extensionPath, "themes"); - - try { - watcher = vscode.workspace.createFileSystemWatcher( - new vscode.RelativePattern(themesDir, "*.json") - ); - } catch (e) { - return; - } - - if (!watcher) return; - - const reloadTheme = () => { - if (reloadTimeout) clearTimeout(reloadTimeout); - - reloadTimeout = setTimeout(async () => { - const config = vscode.workspace.getConfiguration("workbench"); - const currentTheme = config.get("colorTheme"); - - if (!currentTheme?.includes("DankShell")) return; - - let themeFile; - switch (true) { - case currentTheme.includes("Light"): - themeFile = path.join(themesDir, "dankshell-light.json"); - break; - case currentTheme.includes("Dark"): - themeFile = path.join(themesDir, "dankshell-dark.json"); - break; - default: - themeFile = path.join(themesDir, "dankshell-default.json"); - } - - let themeData; - try { - const content = fs.readFileSync(themeFile, "utf8"); - themeData = JSON.parse(content); - } catch (e) { - return; - } - - const themeKey = `[${currentTheme}]`; - - if (themeData.colors) { - const colorConfig = config.get("colorCustomizations") || {}; - colorConfig[themeKey] = themeData.colors; - await config.update( - "colorCustomizations", - colorConfig, - vscode.ConfigurationTarget.Global - ); - } - - if (themeData.tokenColors) { - const editorConfig = vscode.workspace.getConfiguration("editor"); - const tokenConfig = editorConfig.get("tokenColorCustomizations") || {}; - tokenConfig[themeKey] = { textMateRules: themeData.tokenColors }; - await editorConfig.update( - "tokenColorCustomizations", - tokenConfig, - vscode.ConfigurationTarget.Global - ); - } - }, 150); - }; - - watcher.onDidChange(reloadTheme); - watcher.onDidCreate(reloadTheme); - - context.subscriptions.push(watcher); -} - -function deactivate() { - if (reloadTimeout) clearTimeout(reloadTimeout); - if (watcher) watcher.dispose(); -} - -module.exports = { activate, deactivate }; diff --git a/quickshell/matugen/vsix-build/package.json b/quickshell/matugen/vsix-build/package.json index a7d8112b..e17af035 100644 --- a/quickshell/matugen/vsix-build/package.json +++ b/quickshell/matugen/vsix-build/package.json @@ -7,10 +7,6 @@ "engines": { "vscode": "^1.70.0" }, - "main": "./extension.js", - "activationEvents": [ - "onStartupFinished" - ], "categories": [ "Themes" ], @@ -31,17 +27,20 @@ { "label": "Dynamic Base16 DankShell", "uiTheme": "vs-dark", - "path": "./themes/dankshell-default.json" + "path": "./themes/dankshell-default.json", + "_watch": true }, { "label": "Dynamic Base16 DankShell (Dark)", "uiTheme": "vs-dark", - "path": "./themes/dankshell-dark.json" + "path": "./themes/dankshell-dark.json", + "_watch": true }, { "label": "Dynamic Base16 DankShell (Light)", "uiTheme": "vs", - "path": "./themes/dankshell-light.json" + "path": "./themes/dankshell-light.json", + "_watch": true } ] }