From 59bb4a9fb7cdafb8f642a38a625dc79fd64db637 Mon Sep 17 00:00:00 2001 From: Daniel Flanagan Date: Thu, 28 Mar 2024 10:47:17 -0500 Subject: [PATCH] Batterytime --- modules/home-manager/eww.nix | 10 ---------- modules/home-manager/eww/eww.yuck | 5 +++-- modules/home-manager/eww/scripts/battery-time.bash | 3 +++ modules/nixos/ewwbar.nix | 2 +- 4 files changed, 7 insertions(+), 13 deletions(-) delete mode 100644 modules/home-manager/eww.nix create mode 100755 modules/home-manager/eww/scripts/battery-time.bash diff --git a/modules/home-manager/eww.nix b/modules/home-manager/eww.nix deleted file mode 100644 index 871a6ae..0000000 --- a/modules/home-manager/eww.nix +++ /dev/null @@ -1,10 +0,0 @@ -{ - programs.eww = { - enable = true; - }; - - home.file.".config/eww/eww.yuck" = { - enable = true; - text = builtins.readFile ./eww/eww.yuck; - }; -} diff --git a/modules/home-manager/eww/eww.yuck b/modules/home-manager/eww/eww.yuck index 266ac31..21e99de 100644 --- a/modules/home-manager/eww/eww.yuck +++ b/modules/home-manager/eww/eww.yuck @@ -76,8 +76,7 @@ (deflisten micMuted :initial "false" "pamixer --default-source --get-mute; pactl subscribe | grep source --line-buffered | while read i; do pamixer --default-source --get-mute; done") -(deflisten batteryTime :initial "unknown" - "upower -d | rg '\\s*(time to empty|time to full):\\s*(\\d.*)\$' -r '\$2'; upower --monitor-detail | rg '\\s*(time to empty|time to full):\\s*(\\d.*)\$' -r '\$2'") + ; "upower -d | rg '\\s*(time to empty|time to full):\\s*(\\d.*)\$' -r '\$2'; upower --monitor-detail | rg '\\s*(time to empty|time to full):\\s*(\\d.*)\$' -r '\$2'") ; (deflisten batteryTime :initial "unknown" ; "upower -d | rg '\s*time to empty:\s*(\d.*)\$' -r '\$1'; upower --monitor-detail | rg '\\s*time to empty:\\s*(\\d.*)\$' -r '\$1'") @@ -96,5 +95,7 @@ (defpoll brightness :interval "10s" "echo $(((100 * $(brightnessctl get)) / $(brightnessctl max)))") +(deflisten batteryTime :initial "unknown" "scripts/battery-time.bash") + (deflisten workspace "scripts/hypr-workspaces.bash") (defwidget workspaces [] (literal :content workspace)) diff --git a/modules/home-manager/eww/scripts/battery-time.bash b/modules/home-manager/eww/scripts/battery-time.bash new file mode 100755 index 0000000..28c307b --- /dev/null +++ b/modules/home-manager/eww/scripts/battery-time.bash @@ -0,0 +1,3 @@ +#!/usr/bin/env bash +{ upower -d; upower --monitor-detail; } \ + | rg '\s*time to.*:\s*(\d.*)\s*$' -r '$1' diff --git a/modules/nixos/ewwbar.nix b/modules/nixos/ewwbar.nix index cd26cf9..500ef10 100644 --- a/modules/nixos/ewwbar.nix +++ b/modules/nixos/ewwbar.nix @@ -1,3 +1,3 @@ {pkgs, ...}: { - environment.systemPackages = [pkgs.eww]; + environment.systemPackages = with pkgs; [eww upower]; }