From 151d695212fbfc4f790c261542bf0b89f65c28ba Mon Sep 17 00:00:00 2001 From: bbedward Date: Sun, 4 Jan 2026 11:49:05 -0500 Subject: [PATCH] launcher: optimize bindings and filters --- .../Modals/Spotlight/SpotlightContent.qml | 1 + .../Modals/Spotlight/SpotlightModal.qml | 66 ++-- .../Modules/AppDrawer/AppDrawerPopout.qml | 5 +- quickshell/Modules/AppDrawer/AppLauncher.qml | 325 ++++++++++-------- .../WorkspaceOverlays/NiriOverviewOverlay.qml | 7 +- quickshell/Services/AppSearchService.qml | 26 +- .../matugen/dynamic-base16-dankshell.vsix | Bin 5967 -> 5003 bytes quickshell/matugen/vsix-build/extension.js | 86 ----- quickshell/matugen/vsix-build/package.json | 13 +- 9 files changed, 250 insertions(+), 279 deletions(-) delete mode 100644 quickshell/matugen/vsix-build/extension.js 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 42e1d10e0ab0ab8ca36c06f4139e310e7b620741..fe8c43cd1e393cd612efe014c1f4e9f8df04f4a2 100644 GIT binary patch delta 1129 zcmX@F*R9SM;LXe;!oa}5!SE|qC1xU@2K)AzQJFwI(e^S6NNBPMqc%)zvm4`GMu@07 zvph_6vM;j~L@=8fu6^??<}^kwE}+Q_V3Q|@aKMe3+{WR|3o?7-mDnS_j0_B}ldo|o z)k7`LEUn;XU}Sm0%)kI9woW?eci4cZ?R|CE3iS!s%62zwk$Uca4rg=BLcQ?3kr~U-n(sjo_bSX=m6s^9}m&hr)VeXMhrLvN$+L6Il z*S(}qCmoZ0b;Gpj70c;c7t$mCX@|M|(J6CGci6NLyMYOJW*KR@|e zeU^E~U8c4b`#X{=_H-nBGxu&2+L~#)KjwmQ0uK zTk5ZxdELNvos!sxQ*#eJIeY1EpI2O&OmTe6F-KE<`DObHPM(|gK zOQ^66MBN-=U2N*!2*b2P)h!f}V*0}}d9R2pOu0J3Sa@;;dP|H!0-UyizGPU^Sjx&U z`3{F98!H3MT5C`^fK@;VL8t}>1_6e*jzR1U45<|*sd>ej`FZ*!8L7Fc#rmNkaQ!I0 z*&r&#G?#ty8Bsl$qmcb7D<;L{&k2;3n;b623sa$na5i#msG>Og9~V%Y?BoMt{8+Rp xFuctuV`5;?0{Rx_c#v;f8rShm<`b9D1m#z>yc*!m$_DZ;HxRM`_2u(}cmT6clePc= delta 2073 zcmeBHKd;9Z;LXe;!oa}5!SG_w#OR598tf&l&Y3_w(e^S6NNBPMqc%)zvm4`GMu@07 zvph_6vM;j~L@=8fu6^??<}}87gvooqF!%jpVqkc{!N4HKAj6PaQIeWhoSC1e4`=CR z6^Dj!GB86OkXc&6%>cBGnSlXJ%ngmszhxj&_dLAfqTHlT*V~7etXy%MIb(8JcyuOz z=+aqFSYmqS{tP;%@xON8k%Mfj;wIEHs6LmhFz6u*=XeZ^2A9lwd+VnL4{jA*_pjRTU?uQ1&fdNy;bZ)4~>cOd~? z76VbgM~1o%^FrqoJ>-eJaPz4u->(Rvu)x^nGn+Znx<6Y6%o6oH_vU!ntks>mX%`g2 zkAymM-W5NTd00p&Q}Cp@(d^Z0EMCsN$Y=iY&<^IT#XeD~>sRu=|CK0`=;OOw*R4Ou z;9%0n8pf@i^>s7$x3Oifn&_=xLv^JNTPw?!YDY#Ad=7~!hYyN6%(t3YY zB5v)h?;kU(GK9ZB{qwwk(^03g@9e?Wmh8?m_>zV7J8mAHdFChdroC4yOrOwp> z-oEO`-+Qu8=JijR>&tJCSUT^N*Mw^)b)$8kSKbI+ ze9-LHUDGeOZ;St1`TC^$mu`a$841CMZRJ zy_+s~Q)phwp2xd|CAwPTjTf4ltJKT3ezcwS!rS%GZIdgTexI{y;r&zWbI3la&){zK za^dw-(kN7Az^?oZwjn|1{qoXaz-V)vhfXPuvq*6$G1=UemZQ>BmL7fYGi zBkPv$kFHuIEgM<4b@IOLh1++3ey5HW>j~^?n8ogDb{m-B=6CGb&=NY9(-Mm)54RN- z(LFqHV>iF#nZyJs&g=QjK!x#SK4BS%zzu#&sDKz3Qc^S#&_z|(A^_Lu07{prg}($i z5d)Jc!;;27EDSiS0#;zi@Px?Ru#TbyS*bl66;B}0C zL1J=tVtOjDuF1~}4MA9;hVT#Ac~C+SY7_&50K;3yU0jnl3QEB2g@nl)K`ACyZlJjE z { - 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 } ] }