From b4ec5ed3bfa4e185bbab71c57e6610d6babb0d18 Mon Sep 17 00:00:00 2001 From: Ahurac Date: Tue, 19 Nov 2024 18:36:23 +0100 Subject: [PATCH] =?UTF-8?q?feat:=20bulk=20update=20jsuis=20press=C3=A9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- common/eww/eww.yuck | 83 +++++++++++++++-------------------------- common/eww/listen/audio | 16 ++++++++ common/home.nix | 4 +- 3 files changed, 49 insertions(+), 54 deletions(-) create mode 100755 common/eww/listen/audio diff --git a/common/eww/eww.yuck b/common/eww/eww.yuck index 1e51ac3..57fe8ef 100644 --- a/common/eww/eww.yuck +++ b/common/eww/eww.yuck @@ -12,6 +12,10 @@ "swaync-client --subscribe" ) +(deflisten audio-status + "./listen/audio" +) + (defvar workspaces-icon '{ "admin": "", "everything": "", @@ -24,38 +28,24 @@ "dnd": "" }') -(defvar battery-icon '{ - "Discharging": [ - "󰁹", - "󰂂", - "󰂁", - "󰂀", - "󰁿", - "󰁾", - "󰁽", - "󰁼", - "󰁻", - "󰁺", - "󰂎" - ], - "Charging": [ - "󰂅", - "󰂋", - "󰂊", - "󰢞", - "󰂉", - "󰢝", - "󰂈", - "󰂇", - "󰂆", - "󰢜", - "󰢟" - ], - "Full": [ - "󱟢", - "󱟢" - ] -}') +(defvar battery-icon '[ + { "Discharging": "󰂎", "Charging": "󰢟" }, + { "Discharging": "󰁺", "Charging": "󰢜" }, + { "Discharging": "󰁻", "Charging": "󰂆" }, + { "Discharging": "󰁼", "Charging": "󰂇" }, + { "Discharging": "󰁽", "Charging": "󰂈" }, + { "Discharging": "󰁾", "Charging": "󰢝" }, + { "Discharging": "󰁿", "Charging": "󰂉" }, + { "Discharging": "󰂀", "Charging": "󰢞" }, + { "Discharging": "󰂁", "Charging": "󰂊" }, + { "Discharging": "󰂂", "Charging": "󰂋" }, + { "Discharging": "󰁹", "Charging": "󰂅", "Full": "󱟢" } +]') + +(defvar audio-icon '[ + { "muted": "a", "unmuted": "b" }, + { "muted": "c", "unmuted": "d" } +]') (defwidget workspaces [] (box @@ -109,29 +99,15 @@ )) ) +(defwidget audio [] + (label + :text "" + ) +) + (defwidget battery [] (label - :text "${EWW_BATTERY.BAT0.capacity == 100 - ? "${battery-icon[EWW_BATTERY.BAT0.status][0]}" - : EWW_BATTERY.BAT0.capacity >= 90 - ? "${battery-icon[EWW_BATTERY.BAT0.status][1]}" - : EWW_BATTERY.BAT0.capacity >= 80 - ? "${battery-icon[EWW_BATTERY.BAT0.status][2]}" - : EWW_BATTERY.BAT0.capacity >= 70 - ? "${battery-icon[EWW_BATTERY.BAT0.status][3]}" - : EWW_BATTERY.BAT0.capacity >= 60 - ? "${battery-icon[EWW_BATTERY.BAT0.status][4]}" - : EWW_BATTERY.BAT0.capacity >= 50 - ? "${battery-icon[EWW_BATTERY.BAT0.status][5]}" - : EWW_BATTERY.BAT0.capacity >= 40 - ? "${battery-icon[EWW_BATTERY.BAT0.status][6]}" - : EWW_BATTERY.BAT0.capacity >= 30 - ? "${battery-icon[EWW_BATTERY.BAT0.status][7]}" - : EWW_BATTERY.BAT0.capacity >= 20 - ? "${battery-icon[EWW_BATTERY.BAT0.status][8]}" - : EWW_BATTERY.BAT0.capacity >= 10 - ? "${battery-icon[EWW_BATTERY.BAT0.status][9]}" - : "${battery-icon[EWW_BATTERY.BAT0.status][10]}"} ${EWW_BATTERY.BAT0.capacity}%" + :text "${battery-icon[round((EWW_BATTERY.BAT0.capacity - 5) / 10, 0) - 1][EWW_BATTERY.BAT0.status]} ${EWW_BATTERY.BAT0.capacity}" ) ) @@ -173,6 +149,7 @@ :halign "end" :space-evenly false + (audio) (battery) ) ) diff --git a/common/eww/listen/audio b/common/eww/listen/audio new file mode 100755 index 0000000..c7e1dfb --- /dev/null +++ b/common/eww/listen/audio @@ -0,0 +1,16 @@ +#!/usr/bin/env sh +print_audio_status() { + volume=$(wpctl get-volume @DEFAULT_AUDIO_SINK@) + if echo "$volume" | grep -q 'MUTE'; then + mute=muted + else + mute=unmuted + fi + volume=$(echo "$volume" | awk '{ print $2 }') + printf '{"volume": %s, "status": "%s"}\n' "$volume" "$mute" +} + +print_audio_status +pactl subscribe | grep --line-buffered "'change'" | while read -r _line; do + print_audio_status +done diff --git a/common/home.nix b/common/home.nix index e929ed9..aa90696 100644 --- a/common/home.nix +++ b/common/home.nix @@ -7,6 +7,7 @@ home.stateVersion = "24.05"; home.packages = with pkgs; [ + pulseaudio d2 cargo tinymist @@ -392,7 +393,7 @@ "Mod+WheelScrollUp".action = focus-column-left; "Mod+Shift+WheelScrollDown".action = move-column-right; "Mod+Shift+WheelScrollUp".action = move-column-left; - "Mod+N".action = spawn "swaync" "--toggle-panel"; + "Mod+N".action = spawn "swaync-client" "--toggle-panel"; "Mod+Tab".action = focus-workspace-previous; "Mod+Shift+W".action = maximize-column; "Mod+W".action = switch-preset-column-width; @@ -448,5 +449,6 @@ programs.eww = { enable = true; configDir = ./eww; + package = pkgs.eww-wayland; }; }