feat(eww): add dyna icons for bluet and wifi

This commit is contained in:
matt1432 2023-08-07 20:37:41 -04:00
parent 117899ed59
commit 57b75324d4
5 changed files with 54 additions and 8 deletions

View file

@ -58,7 +58,7 @@
margin-top: -10px; margin-top: -10px;
margin-left: -10px; margin-left: -10px;
margin-bottom: 10px; margin-bottom: 10px;
padding: 6px; padding: 3px;
border: 2px solid $contrastbg; border: 2px solid $contrastbg;
border-top-right-radius: 20px; border-top-right-radius: 20px;
border-top-left-radius: 10px; border-top-left-radius: 10px;

View file

@ -92,8 +92,8 @@
(eventbox :class "left-part" (eventbox :class "left-part"
:cursor "pointer" :cursor "pointer"
:onclick "rfkill toggle wlan" :onclick "$EWW_PATH/network.sh toggle"
(label :text " 󰖩 " (label :text " ${network_icon} "
:class "grid-label" :class "grid-label"
) )
) )
@ -113,9 +113,9 @@
(eventbox :class "left-part" (eventbox :class "left-part"
:cursor "pointer" :cursor "pointer"
:onclick "rfkill toggle bluetooth" :onclick "$EWW_PATH/bluetooth.sh toggle"
(label :text " 󰂯 " (label :text " ${bluetooth_icon} "
:class "grid-label" :class "grid-label"
) )
) )
@ -156,7 +156,7 @@
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(box :orientation "h" (box :orientation "h"
:space-evenly true :space-evenly true
:spacing 54 :spacing 60
:width 0 :width 0
:height 0 :height 0
:halign "center" :halign "center"
@ -169,7 +169,7 @@
:limit-width 10 :limit-width 10
) )
(label :text "todo" (label :text "${bluetooth_dev}"
:class "sub-label" :class "sub-label"
:width 0 :width 0
:height 0 :height 0

27
config/eww/scripts/bluetooth.sh Executable file
View file

@ -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

View file

@ -8,4 +8,20 @@ get_ssid() {
fi fi
} }
get_state() {
if [[ "$(rfkill list | grep -A 1 LAN | grep -o no)" == "no" ]]; then
echo " 󰖩 "
else
echo " 󰖪 "
fi
}
[[ "$1" == "ssid" ]] && get_ssid [[ "$1" == "ssid" ]] && get_ssid
[[ "$1" == "toggle" ]] && rfkill toggle wlan
if [[ $1 == "icon" ]]; then
while true; do
sleep 0.1
get_state
done
fi

View file

@ -2,8 +2,11 @@
(deflisten heart_icon "tail -f $HOME/.config/.heart") (deflisten heart_icon "tail -f $HOME/.config/.heart")
(deflisten mic_icon "$EWW_PATH/mic.sh icon") (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") (deflisten volume_icon "$EWW_PATH/volume.sh icon")
(defpoll volume :interval "1s" "$EWW_PATH/volume.sh percentage") (defpoll volume :interval "1s" "$EWW_PATH/volume.sh percentage")