Sat 6 Jul 00:48:20 CEST 2024

This commit is contained in:
Thomas Avé 2024-07-06 00:48:20 +02:00
parent 302b53d8e2
commit 38266ed3e9
1 changed files with 30 additions and 26 deletions

View File

@ -18,25 +18,6 @@ const batteryIndicator = Widget.Box({
self.tooltip_text = `Battery ${battery.percent}%` self.tooltip_text = `Battery ${battery.percent}%`
self.class_name = "blue battery-item"; self.class_name = "blue battery-item";
}), }),
Widget.Button({
class_name: "item",
child: Widget.Label({
label: powerProfiles.bind('active_profile'),
}),
on_clicked: () => {
switch (powerProfiles.active_profile) {
case 'balanced':
powerProfiles.active_profile = 'performance';
break;
case 'performance':
powerProfiles.active_profile = 'power-saver';
break;
default:
powerProfiles.active_profile = 'balanced';
break;
};
},
})
]: [] ]: []
}) })
@ -157,8 +138,6 @@ function Center() {
}) })
} }
const divide = ([total, free]) => free / total
function Right() { function Right() {
return Widget.Box({ return Widget.Box({
hpack: "end", hpack: "end",
@ -175,7 +154,7 @@ function Right() {
vexpand: false, vexpand: false,
size: 16, size: 16,
icon: "speedometer", icon: "speedometer",
css: "margin-right: 1em;", css: "margin-right: 0.7em;",
}), }),
Widget.Label({ Widget.Label({
label: Variable("", { label: Variable("", {
@ -188,16 +167,41 @@ function Right() {
]}), ]}),
Widget.Label({ Widget.Label({
class_name: "item blue", class_name: "item blue",
label: Variable("", { poll: [5000, 'bash -c "cat /proc/cpuinfo | grep \\"MHz\\" | awk \'{print \\$4}\' | sort -n | tail -1 | awk \'{printf \\"%.2fGHz\\", \\$1/1000}\'"'] }).bind(),
}),
Widget.Label({
class_name: "item",
label: Variable("", { label: Variable("", {
poll: [2000, 'free', out => (out.split('\n') poll: [2000, 'free', out => (out.split('\n')
.find(line => line.includes('Mem:')) .find(line => line.includes('Mem:'))
.split(/\s+/)[2] / 1000000).toFixed(2) + "GB"], .split(/\s+/)[2] / 1000000).toFixed(2) + "GB"],
}).bind(), }).bind(),
}), }),
Widget.Button({
class_name: "item",
child: Widget.Box({
children: [
Widget.Icon({
vexpand: false,
size: 16,
icon: powerProfiles.bind('active_profile').as(profile => `power-profile-${profile}-symbolic`),
css: "margin-right: 0.7em;",
}),
Widget.Label({
label: Variable("", { poll: [5000, 'bash -c "cat /proc/cpuinfo | grep \\"MHz\\" | awk \'{print \\$4}\' | sort -n | tail -1 | awk \'{printf \\"%.2fGHz\\", \\$1/1000}\'"'] }).bind(),
}),
]
}),
on_clicked: () => {
switch (powerProfiles.active_profile) {
case 'balanced':
powerProfiles.active_profile = 'performance';
break;
case 'performance':
powerProfiles.active_profile = 'power-saver';
break;
default:
powerProfiles.active_profile = 'balanced';
break;
};
},
}),
Widget.Label({ Widget.Label({
class_name: "item blue", class_name: "item blue",
label: Variable("", { poll: [5000, settings["temperature-cmd"] ] }).bind(), label: Variable("", { poll: [5000, settings["temperature-cmd"] ] }).bind(),