feat(eww): make sliders work

This commit is contained in:
matt1432 2023-07-30 22:15:44 -04:00
parent 082485d7a5
commit 30ada01972
4 changed files with 65 additions and 21 deletions

View file

@ -92,7 +92,7 @@
(eventbox :class "left-part" (eventbox :class "left-part"
:cursor "pointer" :cursor "pointer"
:onclick "notify-send 'set this up moron'" :onclick "rfkill toggle wlan"
(label :text " 󰖩 " (label :text " 󰖩 "
:class "grid-label" :class "grid-label"
@ -114,12 +114,16 @@
(eventbox :class "left-part" (eventbox :class "left-part"
:cursor "pointer" :cursor "pointer"
:onclick "rfkill toggle bluetooth"
(label :text " 󰂯 " (label :text " 󰂯 "
:class "grid-label" :class "grid-label"
) )
) )
(eventbox :class "right-part" (eventbox :class "right-part"
:cursor "pointer" :cursor "pointer"
:onclick "blueberry &"
(label :text " " :class "grid-chev") (label :text " " :class "grid-chev")
) )
) )
@ -132,13 +136,19 @@
(eventbox :class "left-part" (eventbox :class "left-part"
:cursor "pointer" :cursor "pointer"
:onclick "notify-send 'set this up moron'"
(label :text " 󰌾 " (label :text " 󰌾 "
:class "grid-label" :class "grid-label"
) )
) )
(eventbox :class "right-part" (eventbox :class "right-part"
:cursor "pointer" :cursor "pointer"
(label :text " " :class "grid-chev") :onclick "notify-send 'set this up moron'"
(label :text " "
:class "grid-chev"
)
) )
) )
) )
@ -162,12 +172,16 @@
(eventbox :class "left-part" (eventbox :class "left-part"
:cursor "pointer" :cursor "pointer"
(label :text " 󰕾 " :onclick "swayosd --output-volume mute-toggle"
(label :text " ${volume_icon} "
:class "grid-label" :class "grid-label"
) )
) )
(eventbox :class "right-part" (eventbox :class "right-part"
:cursor "pointer" :cursor "pointer"
:onclick "pavucontrol &"
(label :text " " :class "grid-chev") (label :text " " :class "grid-chev")
) )
) )
@ -180,12 +194,16 @@
(eventbox :class "left-part" (eventbox :class "left-part"
:cursor "pointer" :cursor "pointer"
:onclick "swayosd --input-volume mute-toggle"
(label :text " 󰍬 " (label :text " 󰍬 "
:class "grid-label" :class "grid-label"
) )
) )
(eventbox :class "right-part" (eventbox :class "right-part"
:cursor "pointer" :cursor "pointer"
:onclick "pavucontrol &"
(label :text " " :class "grid-chev") (label :text " " :class "grid-chev")
) )
) )
@ -198,12 +216,16 @@
(eventbox :class "left-part" (eventbox :class "left-part"
:cursor "pointer" :cursor "pointer"
:onclick "notify-send 'set this up moron'"
(label :text " 󰍃 " (label :text " 󰍃 "
:class "grid-label" :class "grid-label"
) )
) )
(eventbox :class "right-part" (eventbox :class "right-part"
:cursor "pointer" :cursor "pointer"
:onclick "notify-send 'set this up moron'"
(label :text " " :class "grid-chev") (label :text " " :class "grid-chev")
) )
) )
@ -226,9 +248,10 @@
:height 0 :height 0
:space-evenly false :space-evenly false
(label :text "󰕾 " :class "slider-label") (label :text "${volume_icon}" :class "slider-label")
(scale :value 0 (scale :value volume_value
:onchange "$EWW_PATH/volume.sh set {}"
:min 0 :min 0
:max 101 :max 101
:height 0 :height 0
@ -243,9 +266,11 @@
:height 0 :height 0
:space-evenly false :space-evenly false
(label :text "󰃟 " :class "slider-label") (label :text " ${br_icon} " :class "slider-label" :style "margin-left: 6px;
margin-right: -6px")
(scale :value 0 (scale :value br
:onchange "$EWW_PATH/brightness.sh set {}"
:min 0 :min 0
:max 101 :max 101
:height 0 :height 0
@ -253,6 +278,7 @@
) )
) )
) )
) )
) )
(defwindow quick-settings-reveal (defwindow quick-settings-reveal

View file

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

View file

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

View file

@ -1,12 +1,12 @@
(deflisten notif_icon "$EWW_PATH/notif.sh icon") (deflisten notif_icon "$EWW_PATH/notif.sh icon")
(deflisten heart_icon "tail -f $HOME/.config/.heart") (deflisten heart_icon "tail -f $HOME/.config/.heart")
(defpoll volume_icon :interval "1s" "$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")
(defpoll volume_value :interval "1s" "$EWW_PATH/volume.sh vol") (defpoll volume_value :interval "1s" "$EWW_PATH/volume.sh vol")
(defpoll is_muted :interval "1s" "$EWW_PATH/volume.sh muted") (defpoll is_muted :interval "1s" "$EWW_PATH/volume.sh muted")
(defpoll br_icon :interval "1s" "$EWW_PATH/brightness.sh icon") (deflisten br_icon "$EWW_PATH/brightness.sh icon")
(defpoll br :interval "1s" "$EWW_PATH/brightness.sh br") (defpoll br :interval "1s" "$EWW_PATH/brightness.sh br")
(defpoll completeday :interval "1h" "date '+%A, %d %B'") (defpoll completeday :interval "1h" "date '+%A, %d %B'")