feat(eww): make some performance improvements

This commit is contained in:
matt1432 2023-08-20 00:01:31 -04:00
parent 98cc247ed4
commit e283d15a24
4 changed files with 44 additions and 56 deletions

View file

@ -311,7 +311,7 @@
(scale :value br (scale :value br
:onchange "$EWW_PATH/brightness.sh set {}" :onchange "$EWW_PATH/brightness.sh set {}"
:min 0 :min 0
:max 101 :max 256
:height 0 :height 0
:width 0 :width 0
) )

View file

@ -12,18 +12,23 @@ get_device() {
get_state() { get_state() {
if [[ "$(rfkill list | grep -A 1 hci0 | grep -o no)" == "no" ]]; then if [[ "$(rfkill list | grep -A 1 hci0 | grep -o no)" == "no" ]]; then
eww update bluetooth_icon=" 󰂯 "
echo " 󰂯 " > "$FILE" echo " 󰂯 " > "$FILE"
else else
eww update bluetooth_icon=" 󰂲 "
echo " 󰂲 " > "$FILE" echo " 󰂲 " > "$FILE"
fi fi
} }
[[ "$1" == "device" ]] && get_device [[ "$1" == "device" ]] && get_device
[[ "$1" == "toggle" ]] && rfkill toggle bluetooth if [[ "$1" == "toggle" ]]; then
rfkill toggle bluetooth
get_state
fi
if [[ $1 == "icon" ]]; then if [[ $1 == "icon" ]]; then
while true; do while true; do
sleep 0.1 sleep 1
get_state get_state
tail "$FILE" tail "$FILE"
done done

View file

@ -1,67 +1,46 @@
#!/usr/bin/env bash #!/usr/bin/env bash
# @requires: brightnessctl get_icon () {
val=$(brightnessctl get)
if [ "$val" -le 3 ]; then
eww update br_icon=" "
elif [ "$val" -le 38 ]; then
eww update br_icon=" "
elif [ "$val" -le 77 ]; then
eww update br_icon=" "
elif [ "$val" -le 115 ]; then
eww update br_icon=" "
elif [ "$val" -le 153 ]; then
eww update br_icon=" "
elif [ "$val" -le 191 ]; then
eww update br_icon=" "
elif [ "$val" -le 230 ]; then
eww update br_icon=" "
percentage () {
local val=$(echo $1 | tr '%' ' ' | awk '{print $1}')
local icon1=$2
local icon2=$3
local icon3=$4
local icon4=$5
local icon5=$6
local icon6=$7
local icon7=$8
local icon8=$9
if [ "$val" -le 1 ]; then
echo "$icon1"
elif [ "$val" -le 15 ]; then
echo "$icon2"
elif [ "$val" -le 30 ]; then
echo "$icon3"
elif [ "$val" -le 45 ]; then
echo "$icon4"
elif [ "$val" -le 60 ]; then
echo "$icon5"
elif [ "$val" -le 75 ]; then
echo "$icon6"
elif [ "$val" -le 90 ]; then
echo "$icon7"
else else
echo "$icon8" eww update br_icon=" "
fi fi
} }
get_brightness () {
(( br = $(brightnessctl get) * 100 / $(brightnessctl max) ))
echo $br
}
get_percent () {
echo $(get_brightness)%
}
get_icon () {
local br=$(get_percent)
echo $(percentage "$br" " " " " " " " " " " " " " " " ")
}
if [[ $1 == "br" ]]; then if [[ $1 == "br" ]]; then
get_brightness brightnessctl get
fi
if [[ $1 == "percent" ]]; then
get_percent
fi fi
if [[ $1 == "icon" ]]; then if [[ $1 == "icon" ]]; then
while true; do while true; do
sleep 0.01 sleep 1
get_icon get_icon
done done
fi fi
if [[ $1 == "set" ]]; then if [[ $1 == "set" ]]; then
eww update br=$2 brightnessctl set "$2"
brightnessctl set $2% get_icon
fi fi

View file

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