From 54233a6690e961a750ecf0750832eb17922622d0 Mon Sep 17 00:00:00 2001 From: matt1432 Date: Fri, 4 Aug 2023 23:01:46 -0400 Subject: [PATCH] feat: adjust eww var timings and add dynamic mic icon --- config/eww/quick-settings/quick-settings.yuck | 4 +-- config/eww/scripts/brightness.sh | 3 +- config/eww/scripts/mic.sh | 30 +++++++++++++++++++ config/eww/scripts/notif.sh | 2 +- config/eww/scripts/volume.sh | 2 +- config/eww/variables.yuck | 1 + 6 files changed, 37 insertions(+), 5 deletions(-) create mode 100755 config/eww/scripts/mic.sh diff --git a/config/eww/quick-settings/quick-settings.yuck b/config/eww/quick-settings/quick-settings.yuck index 87203f12..9b343bc1 100644 --- a/config/eww/quick-settings/quick-settings.yuck +++ b/config/eww/quick-settings/quick-settings.yuck @@ -194,9 +194,9 @@ (eventbox :class "left-part" :cursor "pointer" - :onclick "swayosd --input-volume mute-toggle" + :onclick "$EWW_PATH/mic.sh toggle-muted" - (label :text " 󰍬 " + (label :text " ${mic_icon} " :class "grid-label" ) ) diff --git a/config/eww/scripts/brightness.sh b/config/eww/scripts/brightness.sh index 8152eea2..f68f01ed 100755 --- a/config/eww/scripts/brightness.sh +++ b/config/eww/scripts/brightness.sh @@ -56,11 +56,12 @@ fi if [[ $1 == "icon" ]]; then while true; do - sleep 0.2 + sleep 0.01 get_icon done fi if [[ $1 == "set" ]]; then + eww update br=$2 brightnessctl set $2% fi diff --git a/config/eww/scripts/mic.sh b/config/eww/scripts/mic.sh new file mode 100755 index 00000000..d235e415 --- /dev/null +++ b/config/eww/scripts/mic.sh @@ -0,0 +1,30 @@ +#!/usr/bin/env bash + +SOURCE="@DEFAULT_SOURCE@" + +is_muted () { + pactl get-source-mute $SOURCE | awk '{print $2}' +} + +get_icon () { + if [[ $(is_muted) == "yes" ]]; then + echo " 󰍭" + else + echo " 󰍬" + fi +} + +if [[ $1 == "icon" ]]; then + while true; do + sleep 0.01 + get_icon + done +fi + +if [[ $1 == "muted" ]]; then + is_muted +fi + +if [[ $1 == "toggle-muted" ]]; then + swayosd --input-volume mute-toggle +fi diff --git a/config/eww/scripts/notif.sh b/config/eww/scripts/notif.sh index 4e850b8a..5526f299 100755 --- a/config/eww/scripts/notif.sh +++ b/config/eww/scripts/notif.sh @@ -23,7 +23,7 @@ icon () { if [[ $1 == "icon" ]]; then while true; do - sleep 0.2 + sleep 0.01 icon done fi diff --git a/config/eww/scripts/volume.sh b/config/eww/scripts/volume.sh index 94f9de6d..70cffe93 100755 --- a/config/eww/scripts/volume.sh +++ b/config/eww/scripts/volume.sh @@ -61,7 +61,7 @@ get_vol () { if [[ $1 == "icon" ]]; then while true; do - sleep 0.2 + sleep 0.01 get_icon done fi diff --git a/config/eww/variables.yuck b/config/eww/variables.yuck index 696337d1..f2f3a53c 100644 --- a/config/eww/variables.yuck +++ b/config/eww/variables.yuck @@ -1,5 +1,6 @@ (deflisten notif_icon "$EWW_PATH/notif.sh icon") (deflisten heart_icon "tail -f $HOME/.config/.heart") +(deflisten mic_icon "$EWW_PATH/mic.sh icon") (deflisten volume_icon "$EWW_PATH/volume.sh icon") (defpoll volume :interval "1s" "$EWW_PATH/volume.sh percentage")