From 14c115f80a42d4a51dc8b7b860a08c4a30e2d886 Mon Sep 17 00:00:00 2001 From: end-4 <97237370+end-4@users.noreply.github.com> Date: Sun, 9 Nov 2025 13:57:29 +0100 Subject: [PATCH] background: add option to only show clock when locked (#2387) --- dots/.config/quickshell/ii/modules/common/Config.qml | 1 + .../modules/ii/background/widgets/clock/ClockWidget.qml | 9 +++++---- .../quickshell/ii/modules/settings/BackgroundConfig.qml | 9 +++++++++ 3 files changed, 15 insertions(+), 4 deletions(-) diff --git a/dots/.config/quickshell/ii/modules/common/Config.qml b/dots/.config/quickshell/ii/modules/common/Config.qml index 5e6a2afae..f2d058a18 100644 --- a/dots/.config/quickshell/ii/modules/common/Config.qml +++ b/dots/.config/quickshell/ii/modules/common/Config.qml @@ -148,6 +148,7 @@ Singleton { property JsonObject widgets: JsonObject { property JsonObject clock: JsonObject { property bool enable: true + property bool showOnlyWhenLocked: false property string placementStrategy: "leastBusy" // "free", "leastBusy", "mostBusy" property real x: 100 property real y: 100 diff --git a/dots/.config/quickshell/ii/modules/ii/background/widgets/clock/ClockWidget.qml b/dots/.config/quickshell/ii/modules/ii/background/widgets/clock/ClockWidget.qml index 149ce169e..cf8c739e0 100644 --- a/dots/.config/quickshell/ii/modules/ii/background/widgets/clock/ClockWidget.qml +++ b/dots/.config/quickshell/ii/modules/ii/background/widgets/clock/ClockWidget.qml @@ -16,8 +16,9 @@ AbstractBackgroundWidget { implicitHeight: contentColumn.implicitHeight implicitWidth: contentColumn.implicitWidth - property string clockStyle: Config.options.background.widgets.clock.style - property bool forceCenter: (GlobalStates.screenLocked && Config.options.lock.centerClock) + readonly property string clockStyle: Config.options.background.widgets.clock.style + readonly property bool forceCenter: (GlobalStates.screenLocked && Config.options.lock.centerClock) + readonly property bool shouldShow: (!Config.options.background.widgets.clock.showOnlyWhenLocked || GlobalStates.screenLocked) property bool wallpaperSafetyTriggered: false needsColText: clockStyle === "digital" x: forceCenter ? ((root.screenWidth - root.width) / 2) : targetX @@ -42,7 +43,7 @@ AbstractBackgroundWidget { FadeLoader { id: cookieClockLoader anchors.horizontalCenter: parent.horizontalCenter - shown: root.clockStyle === "cookie" + shown: root.clockStyle === "cookie" && (root.shouldShow) sourceComponent: Column { CookieClock { anchors.horizontalCenter: parent.horizontalCenter @@ -58,7 +59,7 @@ AbstractBackgroundWidget { FadeLoader { id: digitalClockLoader anchors.horizontalCenter: parent.horizontalCenter - shown: root.clockStyle === "digital" + shown: root.clockStyle === "digital" && (root.shouldShow) sourceComponent: ColumnLayout { id: clockColumn spacing: 6 diff --git a/dots/.config/quickshell/ii/modules/settings/BackgroundConfig.qml b/dots/.config/quickshell/ii/modules/settings/BackgroundConfig.qml index 3b388583f..ec9dc320d 100644 --- a/dots/.config/quickshell/ii/modules/settings/BackgroundConfig.qml +++ b/dots/.config/quickshell/ii/modules/settings/BackgroundConfig.qml @@ -97,6 +97,15 @@ ContentPage { } } + ConfigSwitch { + buttonIcon: "lock_clock" + text: Translation.tr("Show only when locked") + checked: Config.options.background.widgets.clock.showOnlyWhenLocked + onCheckedChanged: { + Config.options.background.widgets.clock.showOnlyWhenLocked = checked; + } + } + ContentSubsection { title: Translation.tr("Clock style") ConfigSelectionArray {