From d367e7e71bd92c19e9d63d8fd01fc0579b6e25d7 Mon Sep 17 00:00:00 2001 From: purian23 Date: Fri, 30 Oct 2026 00:12:12 -0400 Subject: [PATCH] feat(clock): clock: per-widget click action w/overview as optional Fixes 3993 Port 2.0 --- .../Common/settings/BarWidgetDefaults.js | 4 +++- .../BarWidgetOptions/ClockOptions.qml | 21 +++++++++++++++++ .../SurfaceWidgets/SurfaceWidgetFactory.qml | 23 +++++++++++++++++-- .../translations/settings_search_index.json | 18 ++++++++++++++- 4 files changed, 62 insertions(+), 4 deletions(-) diff --git a/quickshell/Common/settings/BarWidgetDefaults.js b/quickshell/Common/settings/BarWidgetDefaults.js index faf97357f..d76b240ad 100644 --- a/quickshell/Common/settings/BarWidgetDefaults.js +++ b/quickshell/Common/settings/BarWidgetDefaults.js @@ -132,7 +132,9 @@ var DEFAULTS = { clock: { clockCompactMode: false, clockDateOrder: "timeFirst", - clockNotificationBadge: false + clockNotificationBadge: false, + clockClickAction: "dash", + clockClickCommand: "" }, music: { mediaStyle: "controls", diff --git a/quickshell/Modules/Settings/BarWidgetOptions/ClockOptions.qml b/quickshell/Modules/Settings/BarWidgetOptions/ClockOptions.qml index 1fcf808cb..ff382c706 100644 --- a/quickshell/Modules/Settings/BarWidgetOptions/ClockOptions.qml +++ b/quickshell/Modules/Settings/BarWidgetOptions/ClockOptions.qml @@ -39,6 +39,27 @@ Column { onToggled: checked => root.page.set("clockNotificationBadge", checked) } + SettingsDropdownRow { + readonly property var actions: ["dash", "settings", "command", "none"] + + resetStore: root.page + resetKeys: ["clockClickAction"] + text: I18n.tr("Click action", "clock widget option: what clicking the clock opens") + options: [I18n.tr("Dashboard"), I18n.tr("Time & weather"), I18n.tr("Custom command"), I18n.tr("None", "bar click action")] + currentValue: options[actions.indexOf(root.page.value("clockClickAction"))] ?? options[0] + onValueChanged: value => root.page.set("clockClickAction", actions[options.indexOf(value)] ?? "dash") + } + + SettingsTextFieldRow { + resetStore: root.page + resetKeys: ["clockClickCommand"] + text: I18n.tr("Custom command") + visible: root.page.value("clockClickAction") === "command" + placeholderText: "gnome-clocks" + value: root.page.value("clockClickCommand") + onEditingFinished: value => root.page.set("clockClickCommand", value.trim()) + } + SettingsNavRow { iconName: "schedule" title: I18n.tr("Time & weather") diff --git a/quickshell/Modules/SurfaceWidgets/SurfaceWidgetFactory.qml b/quickshell/Modules/SurfaceWidgets/SurfaceWidgetFactory.qml index 057b93028..e778551ef 100644 --- a/quickshell/Modules/SurfaceWidgets/SurfaceWidgetFactory.qml +++ b/quickshell/Modules/SurfaceWidgets/SurfaceWidgetFactory.qml @@ -1,9 +1,11 @@ pragma ComponentBehavior: Bound import QtQuick +import Quickshell import Quickshell.Services.SystemTray import qs.Common import qs.Services import qs.Modules.DBar.Widgets +import qs.Modules.DDash import "../DBar/WidgetModel.js" as WidgetModel Item { @@ -393,15 +395,32 @@ Item { } onClockClicked: { + const action = SettingsData.widgetOption("clock", clockWidget.widgetData, "clockClickAction"); + if (action === "none") + return; + if (action === "settings") { + PopoutService.focusOrToggleSettingsWithTab("time_weather"); + return; + } + if (action === "command") { + const command = SettingsData.widgetOption("clock", clockWidget.widgetData, "clockClickCommand"); + if (command) + Quickshell.execDetached(["sh", "-c", command]); + return; + } + // requestTab would still show a disabled Overview as a detail page. + const tabId = DashRegistry.isSelectable(DashRegistry.overviewId) ? DashRegistry.overviewId : DashRegistry.defaultTabId; + if (!tabId) + return; const section = root.getWidgetSection(parent) || "center"; root.openWidgetPopout({ loader: PopoutService.dankDashPopoutLoader, widgetItem: clockWidget, section, useCenterSection: true, - triggerSource: root._dashTriggerSource(section, "overview"), + triggerSource: root._dashTriggerSource(section, tabId), islandActivity: "home", - prepare: popout => popout.requestTab("overview"), + prepare: popout => popout.requestTab(tabId), mode: "click", setTriggerScreen: true }); diff --git a/quickshell/translations/settings_search_index.json b/quickshell/translations/settings_search_index.json index abba72ef6..ed8fc4b33 100644 --- a/quickshell/translations/settings_search_index.json +++ b/quickshell/translations/settings_search_index.json @@ -10148,6 +10148,14 @@ "runtimeType": "barWidgetOption", "optionFile": "IslandOptions.qml" }, + { + "section": "barWidgetOption:ClockOptions.qml:4", + "label": "Click action", + "tabIndex": 22, + "keywords": [], + "runtimeType": "barWidgetOption", + "optionFile": "ClockOptions.qml" + }, { "section": "barWidgetOption:IslandOptions.qml:12", "label": "Clipboard", @@ -10324,6 +10332,14 @@ "runtimeType": "barWidgetOption", "optionFile": "AppsDockOptions.qml" }, + { + "section": "barWidgetOption:ClockOptions.qml:5", + "label": "Custom command", + "tabIndex": 22, + "keywords": [], + "runtimeType": "barWidgetOption", + "optionFile": "ClockOptions.qml" + }, { "section": "barWidgetOption:IslandOptions.qml:14", "label": "Dashboard", @@ -11061,7 +11077,7 @@ "optionFile": "IslandOptions.qml" }, { - "section": "barWidgetOption:ClockOptions.qml:4", + "section": "barWidgetOption:ClockOptions.qml:6", "label": "Time & weather", "tabIndex": 22, "keywords": [],