Sat 6 Jul 00:01:45 CEST 2024

This commit is contained in:
Thomas Avé 2024-07-06 00:01:45 +02:00
parent f945ad5112
commit 8238826e66
5 changed files with 38 additions and 21 deletions

View File

@ -25,6 +25,7 @@
}; };
home.file."${config.xdg.configHome}/ags/settings.json".text = builtins.toJSON { home.file."${config.xdg.configHome}/ags/settings.json".text = builtins.toJSON {
temperature-cmd = "bash -c 'sensors | grep Tctl | cut -c16-22'"; temperature-cmd = "bash -c 'sensors | grep Tctl | cut -c16-22'";
enable-battery = false;
}; };
home.file."${config.xdg.configHome}/ags/style.css".text = pkgs.lib.mkAfter '' home.file."${config.xdg.configHome}/ags/style.css".text = pkgs.lib.mkAfter ''
window.bar { window.bar {

View File

@ -19,6 +19,7 @@
}; };
home.file."${config.xdg.configHome}/ags/settings.json".text = pkgs.lib.mkDefault (builtins.toJSON { home.file."${config.xdg.configHome}/ags/settings.json".text = pkgs.lib.mkDefault (builtins.toJSON {
temperature-cmd = "bash -c 'sensors | grep Package | cut -c17-23'"; temperature-cmd = "bash -c 'sensors | grep Package | cut -c17-23'";
enable-battery = true;
}); });
home.file."${config.xdg.configHome}/ags/style.css".text = '' home.file."${config.xdg.configHome}/ags/style.css".text = ''
window.bar { window.bar {

View File

@ -3,27 +3,41 @@ const audio = await Service.import("audio")
const systemtray = await Service.import("systemtray") const systemtray = await Service.import("systemtray")
import { getIconName } from "./utils.js" import { getIconName } from "./utils.js"
import { NotificationPopups } from "./notificationPopups.js" import { NotificationPopups } from "./notificationPopups.js"
const battery = await Service.import('battery') const battery = await Service.import('battery')
const powerProfiles = await Service.import('powerprofiles')
const settings = JSON.parse(Utils.readFile(App.configDir + '/settings.json')) const settings = JSON.parse(Utils.readFile(App.configDir + '/settings.json'))
const batteryIndicator = Widget.Box({ const batteryIndicator = Widget.Box({
children: [ children: settings["enable-battery"]? [
Widget.Icon().hook(battery, self => { Widget.Icon().hook(battery, self => {
const icon = [ const thresholds = [...Array(11).keys()].map( i => i * 10);
[101, 'full'], const icon = thresholds.find(threshold => threshold >= battery.percent)
[67, 'good'], self.icon = battery.charging? `battery-level-${icon}-charging-symbolic` : `battery-level-${icon}-symbolic`
[34, 'low'], self.tooltip_text = `Battery ${battery.percent}%`
[1, 'caution'], self.class_name = "blue systray-item";
[0, 'empty'], }),
].find(([threshold]) => threshold <= battery.percentage)?.[1] Widget.Button({
self.icon = `battery-${icon}-symbolic` class_name: "item",
}), child: Widget.Label({
Widget.Label().hook(battery, self => { label: powerProfiles.bind('active_profile'),
self.label = `${battery.percentage}%` }),
self.css = "margin-left: 0.7em;" 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;
};
},
})
]: []
}) })
@ -43,7 +57,7 @@ const volumeIndicator = Widget.Button({
].find(([threshold]) => threshold <= vol)?.[1] ].find(([threshold]) => threshold <= vol)?.[1]
self.icon = `audio-volume-${icon}-symbolic` self.icon = `audio-volume-${icon}-symbolic`
self.tooltip_text = `Volume ${Math.floor(vol)}%` self.tooltip_text = `Volume ${Math.floor(vol)}%`
}), }),
Widget.Label().hook(audio.speaker, self => { Widget.Label().hook(audio.speaker, self => {
const label = `${Math.floor(audio.speaker.volume * 100)}%` const label = `${Math.floor(audio.speaker.volume * 100)}%`

View File

@ -35,6 +35,7 @@
fileSystems."/home/server".device = pkgs.lib.mkForce "10.0.0.1:/home/server"; fileSystems."/home/server".device = pkgs.lib.mkForce "10.0.0.1:/home/server";
services.upower.enable = true; services.upower.enable = true;
services.power-profiles-daemon.enable = true;
networking.wireless.iwd.enable = true; networking.wireless.iwd.enable = true;
networking.wireless.iwd.settings = { networking.wireless.iwd.settings = {
IPv6 = { IPv6 = {

View File

@ -47,10 +47,10 @@
}; };
}; };
# services.resolved = { services.resolved = {
# enable = true; enable = true;
# fallbackDns = [ "1.1.1.1" "1.0.0.1" ]; fallbackDns = [ "1.1.1.1" "1.0.0.1" ];
# }; };
fileSystems."/home/server" = { fileSystems."/home/server" = {
device = "192.168.1.2:/home/server"; device = "192.168.1.2:/home/server";