feat(eww): make sliders work

This commit is contained in:
matt1432 2023-07-30 22:15:44 -04:00
commit 30ada01972
4 changed files with 65 additions and 21 deletions
config/eww/scripts

View file

@ -8,17 +8,30 @@ percentage () {
local icon2=$3
local icon3=$4
local icon4=$5
if [ "$val" -le 15 ]; then
echo $icon1
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 $icon2
echo "$icon3"
elif [ "$val" -le 45 ]; then
echo "$icon4"
elif [ "$val" -le 60 ]; then
echo $icon3
echo "$icon5"
elif [ "$val" -le 75 ]; then
echo "$icon6"
elif [ "$val" -le 90 ]; then
echo "$icon7"
else
echo $icon4
echo "$icon8"
fi
}
get_brightness () {
(( br = $(brightnessctl get) * 100 / $(brightnessctl max) ))
echo $br
@ -30,7 +43,7 @@ get_percent () {
get_icon () {
local br=$(get_percent)
echo $(percentage "$br" "" "" "" "")
echo $(percentage "$br" " " " " " " " " " " " " " " " ")
}
if [[ $1 == "br" ]]; then
@ -42,7 +55,10 @@ if [[ $1 == "percent" ]]; then
fi
if [[ $1 == "icon" ]]; then
get_icon
while true; do
sleep 0.2
get_icon
done
fi
if [[ $1 == "set" ]]; then

View file

@ -23,12 +23,11 @@ percentage () {
}
is_muted () {
pacmd list-sinks | awk '/muted/ { print $2 }'
pactl get-sink-mute $SINK | awk '{print $2}'
}
get_percentage () {
local muted=$(is_muted)
if [[ $muted == 'yes' ]]; then
if [[ $(is_muted) == 'yes' ]]; then
echo 0%
else
vol=$(pactl get-sink-volume @DEFAULT_SINK@ | grep Volume | awk '{print $5}' | tr % " ")
@ -39,7 +38,7 @@ get_percentage () {
get_icon () {
local vol=$(get_percentage)
if [[ $vol == "0%" ]]; then
echo "婢"
echo " 婢"
else
echo $(percentage "$vol" "" "" "墳" "")
fi
@ -61,7 +60,10 @@ get_vol () {
}
if [[ $1 == "icon" ]]; then
get_icon
while true; do
sleep 0.2
get_icon
done
fi
if [[ $1 == "class" ]]; then