aboutsummaryrefslogtreecommitdiff
path: root/quickshell
diff options
context:
space:
mode:
authorAargh Rai <aargh.rai+git@gmail.com>2026-05-10 14:57:19 +0530
committerAargh Rai <aargh.rai+git@gmail.com>2026-05-10 14:57:19 +0530
commitce5908ed1c96ac3e8cf9e9aa471441a1d653ab3b (patch)
tree8d7202ffcabeafb700562ea122b500e26d7af68c /quickshell
parent8c1a8c052568c6f3fd9a76d01fc6bf694b85ff6e (diff)
switched from power-profiles-daemon to tlp & removed the option to manually change the power mode, tlp does it automatically now!
Diffstat (limited to 'quickshell')
-rw-r--r--quickshell/BatteryInfo.qml139
-rw-r--r--quickshell/BatteryModeConfig.qml110
-rw-r--r--quickshell/items/Electrons.qml2
-rw-r--r--quickshell/scripts/battery-info.py39
-rwxr-xr-xquickshell/scripts/battery-info.sh17
-rw-r--r--quickshell/shell.qml12
6 files changed, 202 insertions, 117 deletions
diff --git a/quickshell/BatteryInfo.qml b/quickshell/BatteryInfo.qml
new file mode 100644
index 0000000..e879d94
--- /dev/null
+++ b/quickshell/BatteryInfo.qml
@@ -0,0 +1,139 @@
+import QtQuick
+import QtQuick.Layouts
+import Quickshell
+import Quickshell.Io
+
+Rectangle {
+ id: batteryInfoRect
+
+ width: 300
+ height: 120
+ Layout.fillWidth: true
+ Layout.fillHeight: true
+ color: shellRoot.black
+ antialiasing: true
+ topLeftRadius: 10
+ topRightRadius: 10
+ property var energy: ""
+ property var voltage: ""
+ property var capacity: ""
+
+ Timer {
+ interval: 0
+ running: true
+ repeat: false
+ onTriggered: {
+ fetchProc.running = true;
+ }
+ }
+
+ signal requestClose()
+ focus: true
+ Keys.onEscapePressed: requestClose()
+
+ Process {
+ id: fetchProc
+ command: ["sh", "-c", "~/.config/quickshell/scripts/battery-info.sh"]
+
+ stdout: SplitParser {
+ onRead: data => {
+ if (data.includes("energy")) {
+ energy = data.split(":")[1]
+ return
+ }
+ if (data.includes("voltage")) {
+ voltage = data.split(":")[1]
+ return
+ }
+ if (data.includes("capacity")) {
+ capacity = data.split(":")[1]
+ return
+ }
+ }
+
+ }
+ Component.onCompleted: running = true
+ }
+
+ RowLayout {
+ anchors.centerIn: parent
+ ColumnLayout {
+ anchors.left: parent
+ Text {
+ text: "Energy"
+ font.family: shellRoot.fontFamily
+ font.pixelSize: 20
+ font.weight: Font.Medium
+ color: shellRoot.green
+ MouseArea {
+ anchors.fill: parent
+ onClicked: {
+ }
+ }
+ }
+ Text {
+ text: "Capacity"
+ font.family: shellRoot.fontFamily
+ font.pixelSize: 20
+ font.weight: Font.Medium
+ color: shellRoot.green
+ MouseArea {
+ anchors.fill: parent
+ onClicked: {
+ }
+ }
+ }
+ Text {
+ text: "Voltage"
+ font.family: shellRoot.fontFamily
+ font.pixelSize: 20
+ font.weight: Font.Medium
+ color: shellRoot.green
+ MouseArea {
+ anchors.fill: parent
+ onClicked: {
+ }
+ }
+ }
+ }
+ ColumnLayout {
+ anchors.right: parent
+ Text {
+ text: energy
+ font.family: shellRoot.fontFamily
+ font.pixelSize: 20
+ font.weight: Font.Medium
+ color: shellRoot.white
+ MouseArea {
+ anchors.fill: parent
+ onClicked: {
+ }
+ }
+ }
+ Text {
+ text: capacity
+ font.family: shellRoot.fontFamily
+ font.pixelSize: 20
+ font.weight: Font.Medium
+ color: shellRoot.white
+ MouseArea {
+ anchors.fill: parent
+ onClicked: {
+ }
+ }
+ }
+ Text {
+ text: voltage
+ font.family: shellRoot.fontFamily
+ font.pixelSize: 20
+ font.weight: Font.Medium
+ color: shellRoot.white
+ MouseArea {
+ anchors.fill: parent
+ onClicked: {
+ }
+ }
+ }
+ }
+ }
+}
diff --git a/quickshell/BatteryModeConfig.qml b/quickshell/BatteryModeConfig.qml
deleted file mode 100644
index 4ef80c5..0000000
--- a/quickshell/BatteryModeConfig.qml
+++ /dev/null
@@ -1,110 +0,0 @@
-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
- topLeftRadius: 10
- topRightRadius: 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 b507509..f75c126 100644
--- a/quickshell/items/Electrons.qml
+++ b/quickshell/items/Electrons.qml
@@ -22,6 +22,6 @@ RowLayout {
}
MouseArea {
anchors.fill: parent
- onClicked: shellRoot.batteryModeConfig = !shellRoot.batteryModeConfig
+ onClicked: shellRoot.batteryInfo = !shellRoot.batteryModeConfig
}
}
diff --git a/quickshell/scripts/battery-info.py b/quickshell/scripts/battery-info.py
new file mode 100644
index 0000000..c3958f7
--- /dev/null
+++ b/quickshell/scripts/battery-info.py
@@ -0,0 +1,39 @@
+# this script was used to generate the battery-info.sh via chatgpt
+
+import subprocess
+
+output = subprocess.run(
+ ["upower", "--enumerate"],
+ capture_output=True
+).stdout.decode('utf-8')
+
+target = None
+
+for line in output.split("\n"):
+ if "BAT" not in line:
+ continue
+ target = line
+ break
+
+print(line)
+
+output = subprocess.run(
+ ["upower", "-i", line],
+ capture_output=True
+).stdout.decode('utf-8')
+
+energy = None
+voltage = None
+capacity = None
+
+for line in output.split("\n"):
+ if energy is None and "energy:" in line:
+ energy = line.split(":")[1].strip()
+ if voltage is None and "voltage:" in line:
+ voltage = line.split(":")[1].strip()
+ if capacity is None and "capacity:" in line:
+ capacity = line.split(":")[1].strip()
+
+print("energy:", energy)
+print("voltage:", voltage)
+print("capacity:", capacity)
diff --git a/quickshell/scripts/battery-info.sh b/quickshell/scripts/battery-info.sh
new file mode 100755
index 0000000..414d168
--- /dev/null
+++ b/quickshell/scripts/battery-info.sh
@@ -0,0 +1,17 @@
+#!/usr/bin/env bash
+
+target=$(upower --enumerate | awk '/BAT/ { print; exit }')
+
+upower -i "$target" | awk -F: '
+/energy:/ && !e { e=$2 }
+/voltage:/ && !v { v=$2 }
+/capacity:/ && !c { c=$2 }
+END {
+ gsub(/^[ \t]+/, "", e)
+ gsub(/^[ \t]+/, "", v)
+ gsub(/^[ \t]+/, "", c)
+
+ print "energy:", e
+ print "voltage:", v
+ print "capacity:", c
+}'
diff --git a/quickshell/shell.qml b/quickshell/shell.qml
index cab8d77..2664ac3 100644
--- a/quickshell/shell.qml
+++ b/quickshell/shell.qml
@@ -26,7 +26,7 @@ ShellRoot {
property bool appLauncherVisible: false
property bool calendarVisible: false
- property bool batteryModeConfig: false
+ property bool batteryInfo: false
property bool blink: false
GlobalShortcut {
@@ -178,7 +178,7 @@ ShellRoot {
model: Quickshell.screens
PanelWindow {
- visible: shellRoot.batteryModeConfig
+ visible: shellRoot.batteryInfo
anchors {
bottom: true
@@ -190,8 +190,8 @@ ShellRoot {
left: Screen.width / 2 - 100
}
- implicitWidth: 200
- implicitHeight: 50
+ implicitWidth: 300
+ implicitHeight: 120
color: "transparent"
exclusiveZone: 0
@@ -203,9 +203,9 @@ ShellRoot {
NumberAnimation { duration: 200; easing.type: Easing.OutCubic }
}
- BatteryModeConfig {
+ BatteryInfo {
onRequestClose: {
- shellRoot.batteryModeConfig = false
+ shellRoot.batteryInfo = false
}
}
}