diff options
| author | Gregor Kleen <gkleen@yggdrasil.li> | 2025-09-11 23:17:57 +0200 |
|---|---|---|
| committer | Gregor Kleen <gkleen@yggdrasil.li> | 2025-09-11 23:17:57 +0200 |
| commit | 564853110a6e1367cc379bd8418d874829302d00 (patch) | |
| tree | a6d548f7ae9379810f6d3942b10217364ca54c99 /accounts/gkleen@sif/shell/quickshell | |
| parent | dd2df931a3be1a6518c1e9fbff438de4274456cd (diff) | |
| download | nixos-564853110a6e1367cc379bd8418d874829302d00.tar nixos-564853110a6e1367cc379bd8418d874829302d00.tar.gz nixos-564853110a6e1367cc379bd8418d874829302d00.tar.bz2 nixos-564853110a6e1367cc379bd8418d874829302d00.tar.xz nixos-564853110a6e1367cc379bd8418d874829302d00.zip | |
...
Diffstat (limited to 'accounts/gkleen@sif/shell/quickshell')
5 files changed, 131 insertions, 0 deletions
diff --git a/accounts/gkleen@sif/shell/quickshell/Bar.qml b/accounts/gkleen@sif/shell/quickshell/Bar.qml index 52b9b344..6952c658 100644 --- a/accounts/gkleen@sif/shell/quickshell/Bar.qml +++ b/accounts/gkleen@sif/shell/quickshell/Bar.qml | |||
| @@ -5,6 +5,7 @@ PanelWindow { | |||
| 5 | id: bar | 5 | id: bar |
| 6 | 6 | ||
| 7 | required property var screen | 7 | required property var screen |
| 8 | required property var inhibitorState | ||
| 8 | 9 | ||
| 9 | anchors { | 10 | anchors { |
| 10 | top: true | 11 | top: true |
| @@ -83,6 +84,12 @@ PanelWindow { | |||
| 83 | 84 | ||
| 84 | KeyboardLayout {} | 85 | KeyboardLayout {} |
| 85 | 86 | ||
| 87 | LidSwitchInhibitorWidget {} | ||
| 88 | |||
| 89 | WaylandInhibitorWidget { | ||
| 90 | window: bar | ||
| 91 | } | ||
| 92 | |||
| 86 | Item { | 93 | Item { |
| 87 | height: parent.height | 94 | height: parent.height |
| 88 | width: 8 - 4 | 95 | width: 8 - 4 |
diff --git a/accounts/gkleen@sif/shell/quickshell/LidSwitchInhibitorWidget.qml b/accounts/gkleen@sif/shell/quickshell/LidSwitchInhibitorWidget.qml new file mode 100644 index 00000000..2be0692a --- /dev/null +++ b/accounts/gkleen@sif/shell/quickshell/LidSwitchInhibitorWidget.qml | |||
| @@ -0,0 +1,46 @@ | |||
| 1 | import Quickshell | ||
| 2 | import QtQuick | ||
| 3 | import Quickshell.Widgets | ||
| 4 | import qs.Services | ||
| 5 | |||
| 6 | Item { | ||
| 7 | id: root | ||
| 8 | |||
| 9 | width: icon.width + 8 | ||
| 10 | height: parent.height | ||
| 11 | anchors.verticalCenter: parent.verticalCenter | ||
| 12 | |||
| 13 | WrapperMouseArea { | ||
| 14 | id: widgetMouseArea | ||
| 15 | |||
| 16 | anchors.fill: parent | ||
| 17 | |||
| 18 | hoverEnabled: true | ||
| 19 | |||
| 20 | onClicked: InhibitorState.lidSwitchInhibited = !InhibitorState.lidSwitchInhibited | ||
| 21 | |||
| 22 | Rectangle { | ||
| 23 | anchors.fill: parent | ||
| 24 | color: { | ||
| 25 | if (widgetMouseArea.containsMouse) { | ||
| 26 | return "#33808080"; | ||
| 27 | } | ||
| 28 | return "transparent"; | ||
| 29 | } | ||
| 30 | |||
| 31 | Item { | ||
| 32 | anchors.fill: parent | ||
| 33 | |||
| 34 | MaterialDesignIcon { | ||
| 35 | id: icon | ||
| 36 | |||
| 37 | implicitSize: 14 | ||
| 38 | anchors.centerIn: parent | ||
| 39 | |||
| 40 | icon: InhibitorState.lidSwitchInhibited ? "laptop-off" : "laptop" | ||
| 41 | color: InhibitorState.lidSwitchInhibited ? "#f28a21" : "#555" | ||
| 42 | } | ||
| 43 | } | ||
| 44 | } | ||
| 45 | } | ||
| 46 | } | ||
diff --git a/accounts/gkleen@sif/shell/quickshell/Services/InhibitorState.qml b/accounts/gkleen@sif/shell/quickshell/Services/InhibitorState.qml new file mode 100644 index 00000000..fe48fd7f --- /dev/null +++ b/accounts/gkleen@sif/shell/quickshell/Services/InhibitorState.qml | |||
| @@ -0,0 +1,22 @@ | |||
| 1 | pragma Singleton | ||
| 2 | |||
| 3 | import Quickshell | ||
| 4 | import Custom as Custom | ||
| 5 | |||
| 6 | Singleton { | ||
| 7 | id: inhibitorState | ||
| 8 | |||
| 9 | property bool waylandIdleInhibited: false | ||
| 10 | property alias lidSwitchInhibited: lidSwitchInhibitor.enabled | ||
| 11 | |||
| 12 | Custom.SystemdInhibitor { | ||
| 13 | id: lidSwitchInhibitor | ||
| 14 | |||
| 15 | enabled: false | ||
| 16 | |||
| 17 | what: Custom.SystemdInhibitorParams.HandleLidSwitch | ||
| 18 | who: "quickshell" | ||
| 19 | why: "User request" | ||
| 20 | mode: Custom.SystemdInhibitorParams.BlockWeak | ||
| 21 | } | ||
| 22 | } | ||
diff --git a/accounts/gkleen@sif/shell/quickshell/WaylandInhibitorWidget.qml b/accounts/gkleen@sif/shell/quickshell/WaylandInhibitorWidget.qml new file mode 100644 index 00000000..0633f350 --- /dev/null +++ b/accounts/gkleen@sif/shell/quickshell/WaylandInhibitorWidget.qml | |||
| @@ -0,0 +1,55 @@ | |||
| 1 | import Quickshell | ||
| 2 | import QtQuick | ||
| 3 | import Quickshell.Widgets | ||
| 4 | import Quickshell.Wayland | ||
| 5 | import qs.Services | ||
| 6 | |||
| 7 | Item { | ||
| 8 | id: root | ||
| 9 | |||
| 10 | required property var window | ||
| 11 | |||
| 12 | width: icon.width + 8 | ||
| 13 | height: parent.height | ||
| 14 | anchors.verticalCenter: parent.verticalCenter | ||
| 15 | |||
| 16 | IdleInhibitor { | ||
| 17 | id: inhibitor | ||
| 18 | enabled: InhibitorState.waylandIdleInhibited | ||
| 19 | window: root.window | ||
| 20 | } | ||
| 21 | |||
| 22 | WrapperMouseArea { | ||
| 23 | id: widgetMouseArea | ||
| 24 | |||
| 25 | anchors.fill: parent | ||
| 26 | |||
| 27 | hoverEnabled: true | ||
| 28 | |||
| 29 | onClicked: InhibitorState.waylandIdleInhibited = !InhibitorState.waylandIdleInhibited | ||
| 30 | |||
| 31 | Rectangle { | ||
| 32 | anchors.fill: parent | ||
| 33 | color: { | ||
| 34 | if (widgetMouseArea.containsMouse) { | ||
| 35 | return "#33808080"; | ||
| 36 | } | ||
| 37 | return "transparent"; | ||
| 38 | } | ||
| 39 | |||
| 40 | Item { | ||
| 41 | anchors.fill: parent | ||
| 42 | |||
| 43 | MaterialDesignIcon { | ||
| 44 | id: icon | ||
| 45 | |||
| 46 | implicitSize: 14 | ||
| 47 | anchors.centerIn: parent | ||
| 48 | |||
| 49 | icon: inhibitor.enabled ? "eye" : "eye-off" | ||
| 50 | color: inhibitor.enabled ? "white" : "#555" | ||
| 51 | } | ||
| 52 | } | ||
| 53 | } | ||
| 54 | } | ||
| 55 | } | ||
diff --git a/accounts/gkleen@sif/shell/quickshell/shell.qml b/accounts/gkleen@sif/shell/quickshell/shell.qml index 693d741f..ccb4e82e 100644 --- a/accounts/gkleen@sif/shell/quickshell/shell.qml +++ b/accounts/gkleen@sif/shell/quickshell/shell.qml | |||
| @@ -36,6 +36,7 @@ ShellRoot { | |||
| 36 | 36 | ||
| 37 | Bar { | 37 | Bar { |
| 38 | screen: screenScope.modelData | 38 | screen: screenScope.modelData |
| 39 | inhibitorState: inhibitorState | ||
| 39 | } | 40 | } |
| 40 | } | 41 | } |
| 41 | } | 42 | } |
