From cf75c1aad0c2e5e4c1f5be404d52f7fab6079ad3 Mon Sep 17 00:00:00 2001 From: bbedward Date: Thu, 13 Nov 2025 10:23:14 -0500 Subject: [PATCH] show a power profile OSD --- quickshell/Common/OSDManager.qml | 24 +++++++++++++ quickshell/DMSShell.qml | 8 +++++ quickshell/Modules/OSD/PowerProfileOSD.qml | 40 ++++++++++++++++++++++ quickshell/Widgets/DankOSD.qml | 1 + 4 files changed, 73 insertions(+) create mode 100644 quickshell/Common/OSDManager.qml create mode 100644 quickshell/Modules/OSD/PowerProfileOSD.qml diff --git a/quickshell/Common/OSDManager.qml b/quickshell/Common/OSDManager.qml new file mode 100644 index 00000000..24a9a7cf --- /dev/null +++ b/quickshell/Common/OSDManager.qml @@ -0,0 +1,24 @@ +pragma Singleton + +import Quickshell +import QtQuick + +Singleton { + id: osdManager + + property var currentOSDsByScreen: ({}) + + function showOSD(osd) { + if (!osd || !osd.screen) + return + + const screenName = osd.screen.name + const currentOSD = currentOSDsByScreen[screenName] + + if (currentOSD && currentOSD !== osd) { + currentOSD.hide() + } + + currentOSDsByScreen[screenName] = osd + } +} diff --git a/quickshell/DMSShell.qml b/quickshell/DMSShell.qml index 7259e5da..f9d2f81d 100644 --- a/quickshell/DMSShell.qml +++ b/quickshell/DMSShell.qml @@ -578,6 +578,14 @@ Item { } } + Variants { + model: SettingsData.getFilteredScreens("osd") + + delegate: PowerProfileOSD { + modelData: item + } + } + LazyLoader { id: hyprlandOverviewLoader active: CompositorService.isHyprland diff --git a/quickshell/Modules/OSD/PowerProfileOSD.qml b/quickshell/Modules/OSD/PowerProfileOSD.qml new file mode 100644 index 00000000..96304710 --- /dev/null +++ b/quickshell/Modules/OSD/PowerProfileOSD.qml @@ -0,0 +1,40 @@ +import QtQuick +import Quickshell.Services.UPower +import qs.Common +import qs.Services +import qs.Widgets + +DankOSD { + id: root + + osdWidth: Theme.iconSize + Theme.spacingS * 2 + osdHeight: Theme.iconSize + Theme.spacingS * 2 + autoHideInterval: 2000 + enableMouseInteraction: false + + property int lastProfile: -1 + + Connections { + target: typeof PowerProfiles !== "undefined" ? PowerProfiles : null + + function onProfileChanged() { + if (lastProfile !== -1 && lastProfile !== PowerProfiles.profile) { + root.show() + } + lastProfile = PowerProfiles.profile + } + } + + Component.onCompleted: { + if (typeof PowerProfiles !== "undefined") { + lastProfile = PowerProfiles.profile + } + } + + content: DankIcon { + anchors.centerIn: parent + name: typeof PowerProfiles !== "undefined" ? Theme.getPowerProfileIcon(PowerProfiles.profile) : "settings" + size: Theme.iconSize + color: Theme.primary + } +} diff --git a/quickshell/Widgets/DankOSD.qml b/quickshell/Widgets/DankOSD.qml index 4368f21d..0239d312 100644 --- a/quickshell/Widgets/DankOSD.qml +++ b/quickshell/Widgets/DankOSD.qml @@ -27,6 +27,7 @@ PanelWindow { signal osdHidden function show() { + OSDManager.showOSD(root) closeTimer.stop() shouldBeVisible = true visible = true