From 8238826e66a3f0fae023a47c87a702ca89f02a63 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thomas=20Av=C3=A9?= Date: Sat, 6 Jul 2024 00:01:45 +0200 Subject: [PATCH] Sat 6 Jul 00:01:45 CEST 2024 --- home/Kell.nix | 1 + home/ags/default.nix | 1 + home/ags/files/config.js | 48 ++++++++++++++++++++++++++-------------- hosts/Aloria/default.nix | 1 + hosts/Common/default.nix | 8 +++---- 5 files changed, 38 insertions(+), 21 deletions(-) diff --git a/home/Kell.nix b/home/Kell.nix index 0c2c726..8b1dd89 100644 --- a/home/Kell.nix +++ b/home/Kell.nix @@ -25,6 +25,7 @@ }; home.file."${config.xdg.configHome}/ags/settings.json".text = builtins.toJSON { 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 '' window.bar { diff --git a/home/ags/default.nix b/home/ags/default.nix index 572f67b..911cfc3 100644 --- a/home/ags/default.nix +++ b/home/ags/default.nix @@ -19,6 +19,7 @@ }; home.file."${config.xdg.configHome}/ags/settings.json".text = pkgs.lib.mkDefault (builtins.toJSON { temperature-cmd = "bash -c 'sensors | grep Package | cut -c17-23'"; + enable-battery = true; }); home.file."${config.xdg.configHome}/ags/style.css".text = '' window.bar { diff --git a/home/ags/files/config.js b/home/ags/files/config.js index 049dc14..06ba904 100644 --- a/home/ags/files/config.js +++ b/home/ags/files/config.js @@ -3,27 +3,41 @@ const audio = await Service.import("audio") const systemtray = await Service.import("systemtray") import { getIconName } from "./utils.js" import { NotificationPopups } from "./notificationPopups.js" + const battery = await Service.import('battery') +const powerProfiles = await Service.import('powerprofiles') const settings = JSON.parse(Utils.readFile(App.configDir + '/settings.json')) const batteryIndicator = Widget.Box({ - children: [ - Widget.Icon().hook(battery, self => { - const icon = [ - [101, 'full'], - [67, 'good'], - [34, 'low'], - [1, 'caution'], - [0, 'empty'], - ].find(([threshold]) => threshold <= battery.percentage)?.[1] - self.icon = `battery-${icon}-symbolic` - }), - Widget.Label().hook(battery, self => { - self.label = `${battery.percentage}%` - self.css = "margin-left: 0.7em;" - }) - ] + children: settings["enable-battery"]? [ + Widget.Icon().hook(battery, self => { + const thresholds = [...Array(11).keys()].map( i => i * 10); + const icon = thresholds.find(threshold => threshold >= battery.percent) + self.icon = battery.charging? `battery-level-${icon}-charging-symbolic` : `battery-level-${icon}-symbolic` + self.tooltip_text = `Battery ${battery.percent}%` + self.class_name = "blue systray-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; + }; + }, + }) + ]: [] }) @@ -43,7 +57,7 @@ const volumeIndicator = Widget.Button({ ].find(([threshold]) => threshold <= vol)?.[1] 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 => { const label = `${Math.floor(audio.speaker.volume * 100)}%` diff --git a/hosts/Aloria/default.nix b/hosts/Aloria/default.nix index 5dcc766..8457a22 100644 --- a/hosts/Aloria/default.nix +++ b/hosts/Aloria/default.nix @@ -35,6 +35,7 @@ fileSystems."/home/server".device = pkgs.lib.mkForce "10.0.0.1:/home/server"; services.upower.enable = true; + services.power-profiles-daemon.enable = true; networking.wireless.iwd.enable = true; networking.wireless.iwd.settings = { IPv6 = { diff --git a/hosts/Common/default.nix b/hosts/Common/default.nix index 618da07..1df181c 100644 --- a/hosts/Common/default.nix +++ b/hosts/Common/default.nix @@ -47,10 +47,10 @@ }; }; - # services.resolved = { - # enable = true; - # fallbackDns = [ "1.1.1.1" "1.0.0.1" ]; - # }; + services.resolved = { + enable = true; + fallbackDns = [ "1.1.1.1" "1.0.0.1" ]; + }; fileSystems."/home/server" = { device = "192.168.1.2:/home/server";