aboutsummaryrefslogtreecommitdiff
path: root/.config/eww
diff options
context:
space:
mode:
Diffstat (limited to '.config/eww')
-rw-r--r--.config/eww/eww.yuck8
-rwxr-xr-x.config/eww/scripts/volumecontrol124
2 files changed, 4 insertions, 128 deletions
diff --git a/.config/eww/eww.yuck b/.config/eww/eww.yuck
index 201abee..1a7ccdf 100644
--- a/.config/eww/eww.yuck
+++ b/.config/eww/eww.yuck
@@ -70,9 +70,9 @@
:spacing 10
(button
:class ""
- :onclick "scripts/volumecontrol down"
- :onmiddleclick "scripts/volumecontrol mute"
- :onrightclick "scripts/volumecontrol up"
+ :onclick "scripts/volumecontrol.sh down"
+ :onmiddleclick "scripts/volumecontrol.sh mute"
+ :onrightclick "scripts/volumecontrol.sh up"
volume)
))
@@ -157,7 +157,7 @@
"scripts/freebsd-updates.sh")
(defpoll volume :interval "1s"
- "scripts/volumecontrol")
+ "scripts/volumecontrol.sh")
(defpoll brightness :interval "1s"
"scripts/brightnesscontrol.sh")
diff --git a/.config/eww/scripts/volumecontrol b/.config/eww/scripts/volumecontrol
deleted file mode 100755
index 8134d00..0000000
--- a/.config/eww/scripts/volumecontrol
+++ /dev/null
@@ -1,124 +0,0 @@
-#!/usr/bin/env bash
-
-# You can call this script like this:
-# volumecontrol up
-# volumecontrol down
-# volumecontrol mute
-
-function get_volume {
- # pactl get-sink-volume @DEFAULT_SINK@ | grep '%' | cut -d '%' -f 1 | cut -d ' ' -f 6
- echo "scale=1; $(mixer vol | grep 'vol.volume=' | cut -d '=' -f 2 | cut -d ':' -f 1)*100" | bc | cut -d '.' -f 1
-}
-
-function is_mute {
- # pactl get-sink-mute @DEFAULT_SINK@ | grep 'Mute: yes' >> /dev/null
- mixer vol | grep 'vol.mute=on' >> /dev/null
-}
-
-function send_notification {
- volume=$(get_volume)
- # Make the bar with the special character ─ (it's not dash -)
- # https://en.wikipedia.org/wiki/Box-drawing_character
- if [[ $volume == "100" ]]; then
- icon=""
- elif [[ $volume -ge "89" && $volume -le "100" ]]; then
- icon=""
- elif [[ $volume -ge "79" && $volume -le "90" ]]; then
- icon=""
- elif [[ $volume -ge "69" && $volume -le "80" ]]; then
- icon=""
- elif [[ $volume -ge "59" && $volume -le "70" ]]; then
- icon=""
- elif [[ $volume -ge "49" && $volume -le "60" ]]; then
- icon=""
- elif [[ $volume -ge "39" && $volume -le "50" ]]; then
- icon=""
- elif [[ $volume -ge "29" && $volume -le "40" ]]; then
- icon=""
- elif [[ $volume -ge "19" && $volume -le "30" ]]; then
- icon=""
- elif [[ $volume -ge "9" && $volume -le "20" ]]; then
- icon=""
- elif [[ $volume -gt "0" && $volume -le "10" ]]; then
- icon=""
- elif [[ $volume -eq "0" ]]; then
- icon=""
- # volume="M "
- fi
-bar=$(seq -s "─" $(($volume/5)) | sed 's/[0-9]//g')
-# Send the notification
-fyi --hint=string:x-canonical-private-synchronous:volumecontrol -u normal "$icon $bar $volume"
-}
-
-case $1 in
- up)
- # pactl set-sink-mute @DEFAULT_SINK@ 0
- mixer vol.mute=off
- # Up the volume (+ 2%)
- # pactl set-sink-volume @DEFAULT_SINK@ +2%
- mixer vol.volume=+2%
- mixer vol > ~/.cache/audio-volume
- send_notification
- # canberra-gtk-play -i audio-volume-change
- ;;
- down)
- # pactl set-sink-mute @DEFAULT_SINK@ 0
- mixer vol.mute=off
- # pactl set-sink-volume @DEFAULT_SINK@ -2%
- mixer vol.volume=-2%
- mixer vol > ~/.cache/audio-volume
- send_notification
- # canberra-gtk-play -i audio-volume-change
- ;;
- mute)
- # Toggle mute
- # pactl set-sink-mute @DEFAULT_SINK@ toggle
- mixer vol.mute=toggle
- mixer vol > ~/.cache/audio-volume
- if is_mute ; then
- icon="󰝟"
- fyi --hint=string:x-canonical-private-synchronous:volumecontrol -u normal "$icon Audio Muted"
- else
- send_notification
- # canberra-gtk-play -i audio-volume-change
- fi
- ;;
- *)
- volume="$(get_volume)"
-
- if [[ $volume == "100" ]]; then
- icon=""
- elif [[ $volume -ge "89" && $volume -le "100" ]]; then
- icon=""
- elif [[ $volume -ge "79" && $volume -le "90" ]]; then
- icon=""
- elif [[ $volume -ge "69" && $volume -le "80" ]]; then
- icon=""
- elif [[ $volume -ge "59" && $volume -le "70" ]]; then
- icon=""
- elif [[ $volume -ge "49" && $volume -le "60" ]]; then
- icon=""
- elif [[ $volume -ge "39" && $volume -le "50" ]]; then
- icon=""
- elif [[ $volume -ge "29" && $volume -le "40" ]]; then
- icon=""
- elif [[ $volume -ge "19" && $volume -le "30" ]]; then
- icon=""
- elif [[ $volume -ge "9" && $volume -le "20" ]]; then
- icon=""
- elif [[ $volume -gt "0" && $volume -le "10" ]]; then
- icon=""
- elif [[ $volume -eq "0" ]]; then
- icon="󰝟"
- volume="M "
- fi
-
-
-if is_mute; then
- icon="󰝟"
- volume="M "
-fi
-
-printf "%s" "$icon $volume%"
- ;;
-esac