aboutsummaryrefslogtreecommitdiff
path: root/quickshell
diff options
context:
space:
mode:
authorAargh Rai <aargh.rai+git@gmail.com>2025-12-27 11:24:35 +0530
committerAargh Rai <aargh.rai+git@gmail.com>2025-12-27 11:24:35 +0530
commitd8209b7f2b293fbcfcaef00a568e032c93fbe5ea (patch)
treeaac6bd66f65472c4572d648790c2ea5c5d54fd7c /quickshell
parenta99b01b32a5c768abac9d8e020f87d8203fe6a09 (diff)
powerprofilesctl control from quickshell + my eyes are cooked, so blink reminders
Diffstat (limited to 'quickshell')
-rw-r--r--quickshell/BatteryModeConfig.qml110
-rw-r--r--quickshell/items/Electrons.qml4
-rw-r--r--quickshell/items/Radio.qml9
-rw-r--r--quickshell/shell.qml97
4 files changed, 215 insertions, 5 deletions
diff --git a/quickshell/BatteryModeConfig.qml b/quickshell/BatteryModeConfig.qml
new file mode 100644
index 0000000..0945888
--- /dev/null
+++ b/quickshell/BatteryModeConfig.qml
@@ -0,0 +1,110 @@
+import QtQuick
+import QtQuick.Layouts
+import Quickshell
+import Quickshell.Io
+
+Rectangle {
+ id: batteryModeConfigRect
+
+ width: 200
+ height: 50
+ Layout.fillWidth: true
+ Layout.fillHeight: true
+ color: shellRoot.black
+ antialiasing: true
+ bottomLeftRadius: 10
+ bottomRightRadius: 10
+ property int current: 1
+
+ Timer {
+ interval: 0
+ running: true
+ repeat: false
+ onTriggered: {
+ fetchProc.running = true;
+ }
+ }
+
+ signal requestClose()
+ focus: true
+ Keys.onEscapePressed: requestClose()
+
+ Process {
+ id: fetchProc
+ command: ["sh", "-c", "powerprofilesctl get"]
+
+ stdout: SplitParser {
+ onRead: data => {
+ const p = data.trim();
+ if (p == "power-saver") current = 0;
+ else if (p == "balanced") current = 1;
+ else if (p == "performance") current = 2;
+ else current = 3;
+ }
+ }
+ Component.onCompleted: running = true
+ }
+
+ Process {
+ id: saverProc
+ command: ["sh", "-c", "powerprofilesctl set power-saver"]
+ Component.onCompleted: running = false
+ }
+ Process {
+ id: balancedProc
+ command: ["sh", "-c", "powerprofilesctl set balanced"]
+ Component.onCompleted: running = false
+ }
+ Process {
+ id: perfProc
+ command: ["sh", "-c", "powerprofilesctl set performance"]
+ Component.onCompleted: running = false
+ }
+
+ RowLayout {
+ anchors.centerIn: parent
+ spacing: 40
+ Text {
+ text: "󰌪"
+ font.family: shellRoot.fontFamily
+ font.pixelSize: batteryModeConfigRect.current == 0 ? 40 : 20
+ font.weight: Font.Medium
+ color: batteryModeConfigRect.current == 0 ? shellRoot.green : shellRoot.white
+ MouseArea {
+ anchors.fill: parent
+ onClicked: {
+ saverProc.running = true;
+ current = 0;
+ }
+ }
+ }
+ Text {
+ text: ""
+ font.family: shellRoot.fontFamily
+ font.pixelSize: batteryModeConfigRect.current == 1 ? 40 : 20
+ font.weight: Font.Medium
+ color: batteryModeConfigRect.current == 1 ? shellRoot.green : shellRoot.white
+ MouseArea {
+ anchors.fill: parent
+ onClicked: {
+ balancedProc.running = true;
+ current = 1;
+ }
+ }
+ }
+ Text {
+ text: "󰠠"
+ font.family: shellRoot.fontFamily
+ font.pixelSize: batteryModeConfigRect.current == 2 ? 40 : 20
+ font.weight: Font.Medium
+ color: batteryModeConfigRect.current == 2 ? shellRoot.green : shellRoot.white
+ MouseArea {
+ anchors.fill: parent
+ onClicked: {
+ perfProc.running = true;
+ current = 2;
+ }
+ }
+ }
+ }
+}
diff --git a/quickshell/items/Electrons.qml b/quickshell/items/Electrons.qml
index 769eda8..b507509 100644
--- a/quickshell/items/Electrons.qml
+++ b/quickshell/items/Electrons.qml
@@ -20,4 +20,8 @@ RowLayout {
bold: true
}
}
+ MouseArea {
+ anchors.fill: parent
+ onClicked: shellRoot.batteryModeConfig = !shellRoot.batteryModeConfig
+ }
}
diff --git a/quickshell/items/Radio.qml b/quickshell/items/Radio.qml
index b3ee8e6..2e33dec 100644
--- a/quickshell/items/Radio.qml
+++ b/quickshell/items/Radio.qml
@@ -19,10 +19,9 @@ RowLayout {
pixelSize: shellRoot.fontSize
bold: true
}
-
- MouseArea {
- anchors.fill: parent
- onClicked: networkManagerProc.running = true
- }
+ }
+ MouseArea {
+ anchors.fill: parent
+ onClicked: networkManagerProc.running = true
}
}
diff --git a/quickshell/shell.qml b/quickshell/shell.qml
index f860d74..eb595e8 100644
--- a/quickshell/shell.qml
+++ b/quickshell/shell.qml
@@ -26,6 +26,8 @@ ShellRoot {
property bool appLauncherVisible: false
property bool calendarVisible: false
+ property bool batteryModeConfig: false
+ property bool blink: false
GlobalShortcut {
id: launcherShortcut
@@ -229,4 +231,99 @@ ShellRoot {
}
}
}
+
+ Variants {
+ model: Quickshell.screens
+
+ PanelWindow {
+ visible: shellRoot.batteryModeConfig
+
+ anchors {
+ top: true
+ left: true
+ }
+
+ margins {
+ top: 0
+ left: Screen.width / 2 - 100
+ }
+
+ implicitWidth: 200
+ implicitHeight: 50
+
+ color: "transparent"
+ exclusiveZone: 0
+
+ WlrLayershell.layer: WlrLayer.Overlay
+ WlrLayershell.keyboardFocus: WlrKeyboardFocus.OnDemand
+
+ Behavior on height {
+ NumberAnimation { duration: 200; easing.type: Easing.OutCubic }
+ }
+
+ BatteryModeConfig {
+ onRequestClose: {
+ shellRoot.batteryModeConfig = false
+ }
+ }
+ }
+ }
+
+ Timer {
+ interval: 1000 * 60 * 30
+ running: true
+ repeat: true
+ onTriggered: {
+ shellRoot.blink = true;
+ }
+ }
+
+ Variants {
+ model: Quickshell.screens
+
+ PanelWindow {
+ visible: shellRoot.blink
+
+ margins {
+ top: 0
+ left: 0
+ }
+
+ implicitWidth: 800
+ implicitHeight: 400
+
+ color: "transparent"
+ exclusiveZone: 0
+
+ WlrLayershell.layer: WlrLayer.Overlay
+ WlrLayershell.keyboardFocus: WlrKeyboardFocus.OnDemand
+
+ Behavior on height {
+ NumberAnimation { duration: 200; easing.type: Easing.OutCubic }
+ }
+
+ Rectangle {
+ id: batteryModeConfigRect
+
+ width: 800
+ height: 400
+ Layout.fillWidth: true
+ Layout.fillHeight: true
+ color: shellRoot.black
+ antialiasing: true
+ radius: 10
+ focus: true
+ Keys.onEscapePressed: shellRoot.blink = false;
+
+ Text {
+ anchors.centerIn: parent
+ text: "BLINK"
+ font.family: shellRoot.fontFamily
+ font.weight: 800
+ font.pixelSize: 200
+ color: shellRoot.white
+ }
+ }
+ }
+ }
}