From a009bbe470005bd3e3558ee0091a0169d9d8128f Mon Sep 17 00:00:00 2001 From: elkowar <5300871+elkowar@users.noreply.github.com> Date: Tue, 10 Aug 2021 19:52:35 +0200 Subject: [PATCH] Some cleanup in bar --- eww-bar/.config/eww-bar/audio.sh | 31 +++++++++++++++++++++------ eww-bar/.config/eww-bar/eww.yuck | 18 ++++++---------- eww-bar/.config/eww-bar/workspaces.sh | 9 ++++++-- 3 files changed, 38 insertions(+), 20 deletions(-) mode change 100644 => 100755 eww-bar/.config/eww-bar/audio.sh diff --git a/eww-bar/.config/eww-bar/audio.sh b/eww-bar/.config/eww-bar/audio.sh old mode 100644 new mode 100755 index 2b9fc13..ff86694 --- a/eww-bar/.config/eww-bar/audio.sh +++ b/eww-bar/.config/eww-bar/audio.sh @@ -1,10 +1,27 @@ #!/usr/bin/env bash - - -speaker_sink_id=$(pamixer --list-sinks | grep "Komplete_Audio_6" | awk '{print $1}') -game_sink_id=$(pamixer --list-sinks | grep "stereo-game" | awk '{print $1}') - -volume=$(pamixer --get-volume) - +case "$1" in + "symbol") + pactl subscribe | grep --line-buffered "Event 'change' on client" | while read -r; do + case "$(pactl get-default-sink)" in + *Arctis_9*) echo "🎧";; + *) echo "📢";; + esac + done + ;; + "volume") + pamixer --get-volume; + pactl subscribe | grep --line-buffered "Event 'change' on sink " | while read -r evt; + do pamixer --get-volume; + done + ;; + "toggle") + speaker_sink_id=$(pamixer --list-sinks | grep "Komplete_Audio_6" | awk '{print $1}') + game_sink_id=$(pamixer --list-sinks | grep "stereo-game" | awk '{print $1}') + case "$(pactl get-default-sink)" in + *Arctis_9*) pactl set-default-sink $speaker_sink_id;; + *) pactl set-default-sink $game_sink_id ;; + esac + ;; +esac diff --git a/eww-bar/.config/eww-bar/eww.yuck b/eww-bar/.config/eww-bar/eww.yuck index 93cc10b..f5152ec 100644 --- a/eww-bar/.config/eww-bar/eww.yuck +++ b/eww-bar/.config/eww-bar/eww.yuck @@ -14,8 +14,6 @@ :class "segment-bottom" (bottom))))) - - (defwidget top [] (workspaces :wsp_yuck {screen == 0 ? workspaces_0_yuck : screen == 1 ? workspaces_1_yuck : workspaces_2_yuck})) @@ -57,8 +55,10 @@ (box :orientation "v" :valign "fill" :vexpand true - (large-sym :sym "🎧") - "${volume}%"))) + (button :onclick "./audio.sh toggle" + (large-sym :sym audio_sink)) + (button :onclick "pavucontrol &" + "${volume}%")))) (defwidget large-sym [sym] @@ -69,18 +69,14 @@ :halign "center" day_word day month year)) -(deflisten volume - ` - pamixer --get-volume; - pactl subscribe | grep --line-buffered "Event 'change' on sink " | while read -r evt; - do pamixer --get-volume; - done`) +(deflisten audio_sink "./audio.sh symbol") +(deflisten volume :initial "0" "./audio.sh volume") (defpoll hour :interval "1s" "date +%H") (defpoll min :interval "1s" "date +%M") (defpoll sec :interval "1s" "date +%S") -(defpoll day_word :interval "10m" "date +%a") +(defpoll day_word :interval "10m" "date +%a | tr [:upper:] [:lower:]") (defpoll day :interval "10m" "date +%d") (defpoll month :interval "1h" "date +%m") (defpoll year :interval "1h" "date +%y") diff --git a/eww-bar/.config/eww-bar/workspaces.sh b/eww-bar/.config/eww-bar/workspaces.sh index 71c1478..a568158 100755 --- a/eww-bar/.config/eww-bar/workspaces.sh +++ b/eww-bar/.config/eww-bar/workspaces.sh @@ -10,6 +10,7 @@ gib_workspace_names() { } gib_workspace_yuck() { + buffered="" gib_workspace_names | while read -r id active name; do name="${name#*_}" if [ "$active" == '*' ]; then @@ -25,10 +26,14 @@ gib_workspace_yuck() { button_class="empty" button_name="◇" fi - echo -n '(button :class "'$button_class' '$active_class'" :onclick "wmctrl -s '$id'" "'$button_name'")' + buffered+="(button :class \"$button_class $active_class\" :onclick \"wmctrl -s $id\" \"$button_name\")" + if [ $button_class = "occupied" -o $active_class = "active" ]; then + echo -n "$buffered" + buffered="" + fi done } xprop -spy -root _NET_CURRENT_DESKTOP | while read -r; do - echo '(box :orientation "v" :class "workspaces" :space-evenly true :halign "start" :valign "center" :vexpand true '"$(gib_workspace_yuck)"')' + echo '(box :orientation "v" :class "workspaces" :space-evenly true :halign "center" :valign "center" :vexpand true '"$(gib_workspace_yuck)"')' done