From 57b75324d490c95a8cb3f2798b14050cde25218f Mon Sep 17 00:00:00 2001 From: matt1432 Date: Mon, 7 Aug 2023 20:37:41 -0400 Subject: [PATCH] feat(eww): add dyna icons for bluet and wifi --- config/eww/quick-settings/quick-settings.scss | 2 +- config/eww/quick-settings/quick-settings.yuck | 12 ++++----- config/eww/scripts/bluetooth.sh | 27 +++++++++++++++++++ config/eww/scripts/network.sh | 16 +++++++++++ config/eww/variables.yuck | 5 +++- 5 files changed, 54 insertions(+), 8 deletions(-) create mode 100755 config/eww/scripts/bluetooth.sh diff --git a/config/eww/quick-settings/quick-settings.scss b/config/eww/quick-settings/quick-settings.scss index 4c1b8873..4497b913 100644 --- a/config/eww/quick-settings/quick-settings.scss +++ b/config/eww/quick-settings/quick-settings.scss @@ -58,7 +58,7 @@ margin-top: -10px; margin-left: -10px; margin-bottom: 10px; - padding: 6px; + padding: 3px; border: 2px solid $contrastbg; border-top-right-radius: 20px; border-top-left-radius: 10px; diff --git a/config/eww/quick-settings/quick-settings.yuck b/config/eww/quick-settings/quick-settings.yuck index b79c67fd..f5bbeea1 100644 --- a/config/eww/quick-settings/quick-settings.yuck +++ b/config/eww/quick-settings/quick-settings.yuck @@ -92,8 +92,8 @@ (eventbox :class "left-part" :cursor "pointer" - :onclick "rfkill toggle wlan" - (label :text " 󰖩 " + :onclick "$EWW_PATH/network.sh toggle" + (label :text " ${network_icon} " :class "grid-label" ) ) @@ -113,9 +113,9 @@ (eventbox :class "left-part" :cursor "pointer" - :onclick "rfkill toggle bluetooth" + :onclick "$EWW_PATH/bluetooth.sh toggle" - (label :text " 󰂯 " + (label :text " ${bluetooth_icon} " :class "grid-label" ) ) @@ -156,7 +156,7 @@ ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; (box :orientation "h" :space-evenly true - :spacing 54 + :spacing 60 :width 0 :height 0 :halign "center" @@ -169,7 +169,7 @@ :limit-width 10 ) - (label :text "todo" + (label :text "${bluetooth_dev}" :class "sub-label" :width 0 :height 0 diff --git a/config/eww/scripts/bluetooth.sh b/config/eww/scripts/bluetooth.sh new file mode 100755 index 00000000..b000c9bb --- /dev/null +++ b/config/eww/scripts/bluetooth.sh @@ -0,0 +1,27 @@ +#!/usr/bin/env bash + +get_device() { + if [[ $(bluetoothctl devices Connected) != "" ]]; then + bluetoothctl devices Connected | awk '{ for (i = 3; i <= NF; i++) { printf("%s ", $i) } printf("\n") }' + else + echo "Disconnected" + fi +} + +get_state() { + if [[ "$(rfkill list | grep -A 1 hci0 | grep -o no)" == "no" ]]; then + echo " 󰂯 " + else + echo " 󰂲 " + fi +} + +[[ "$1" == "device" ]] && get_device +[[ "$1" == "toggle" ]] && rfkill toggle bluetooth + +if [[ $1 == "icon" ]]; then + while true; do + sleep 0.1 + get_state + done +fi diff --git a/config/eww/scripts/network.sh b/config/eww/scripts/network.sh index 7589e18b..8f518d87 100755 --- a/config/eww/scripts/network.sh +++ b/config/eww/scripts/network.sh @@ -8,4 +8,20 @@ get_ssid() { fi } +get_state() { + if [[ "$(rfkill list | grep -A 1 LAN | grep -o no)" == "no" ]]; then + echo " 󰖩 " + else + echo " 󰖪 " + fi +} + [[ "$1" == "ssid" ]] && get_ssid +[[ "$1" == "toggle" ]] && rfkill toggle wlan + +if [[ $1 == "icon" ]]; then + while true; do + sleep 0.1 + get_state + done +fi diff --git a/config/eww/variables.yuck b/config/eww/variables.yuck index 9a76dd69..fc7e30ab 100644 --- a/config/eww/variables.yuck +++ b/config/eww/variables.yuck @@ -2,8 +2,11 @@ (deflisten heart_icon "tail -f $HOME/.config/.heart") (deflisten mic_icon "$EWW_PATH/mic.sh icon") -(deflisten network_ssid "zscroll -l 10 -u true \"$EWW_PATH/network.sh ssid\"") +(deflisten network_ssid "zscroll -d 0.7 -l 10 -p '. ' -u true \"$EWW_PATH/network.sh ssid\"") +(deflisten network_icon "$EWW_PATH/network.sh icon") +(deflisten bluetooth_dev "zscroll -d 0.7 -l 10 -p '. ' -u true \"$EWW_PATH/bluetooth.sh device\"") +(deflisten bluetooth_icon "$EWW_PATH/bluetooth.sh icon") (deflisten volume_icon "$EWW_PATH/volume.sh icon") (defpoll volume :interval "1s" "$EWW_PATH/volume.sh percentage")