blob: 09458888c2603a1c3ff25f14005c06c25ffe4db4 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
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;
}
}
}
}
}
|