Some cleanup in bar

This commit is contained in:
elkowar 2021-08-10 19:52:35 +02:00
parent 48850415d8
commit a009bbe470
No known key found for this signature in database
GPG key ID: E321AD71B1D1F27F
3 changed files with 38 additions and 20 deletions

31
eww-bar/.config/eww-bar/audio.sh Normal file → Executable file
View file

@ -1,10 +1,27 @@
#!/usr/bin/env bash #!/usr/bin/env bash
case "$1" in
"symbol")
speaker_sink_id=$(pamixer --list-sinks | grep "Komplete_Audio_6" | awk '{print $1}') pactl subscribe | grep --line-buffered "Event 'change' on client" | while read -r; do
game_sink_id=$(pamixer --list-sinks | grep "stereo-game" | awk '{print $1}') case "$(pactl get-default-sink)" in
*Arctis_9*) echo "🎧";;
volume=$(pamixer --get-volume) *) 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

View file

@ -14,8 +14,6 @@
:class "segment-bottom" :class "segment-bottom"
(bottom))))) (bottom)))))
(defwidget top [] (defwidget top []
(workspaces :wsp_yuck {screen == 0 ? workspaces_0_yuck : screen == 1 ? workspaces_1_yuck : workspaces_2_yuck})) (workspaces :wsp_yuck {screen == 0 ? workspaces_0_yuck : screen == 1 ? workspaces_1_yuck : workspaces_2_yuck}))
@ -57,8 +55,10 @@
(box :orientation "v" (box :orientation "v"
:valign "fill" :valign "fill"
:vexpand true :vexpand true
(large-sym :sym "🎧") (button :onclick "./audio.sh toggle"
"${volume}%"))) (large-sym :sym audio_sink))
(button :onclick "pavucontrol &"
"${volume}%"))))
(defwidget large-sym [sym] (defwidget large-sym [sym]
@ -69,18 +69,14 @@
:halign "center" :halign "center"
day_word day month year)) day_word day month year))
(deflisten volume (deflisten audio_sink "./audio.sh symbol")
` (deflisten volume :initial "0" "./audio.sh volume")
pamixer --get-volume;
pactl subscribe | grep --line-buffered "Event 'change' on sink " | while read -r evt;
do pamixer --get-volume;
done`)
(defpoll hour :interval "1s" "date +%H") (defpoll hour :interval "1s" "date +%H")
(defpoll min :interval "1s" "date +%M") (defpoll min :interval "1s" "date +%M")
(defpoll sec :interval "1s" "date +%S") (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 day :interval "10m" "date +%d")
(defpoll month :interval "1h" "date +%m") (defpoll month :interval "1h" "date +%m")
(defpoll year :interval "1h" "date +%y") (defpoll year :interval "1h" "date +%y")

View file

@ -10,6 +10,7 @@ gib_workspace_names() {
} }
gib_workspace_yuck() { gib_workspace_yuck() {
buffered=""
gib_workspace_names | while read -r id active name; do gib_workspace_names | while read -r id active name; do
name="${name#*_}" name="${name#*_}"
if [ "$active" == '*' ]; then if [ "$active" == '*' ]; then
@ -25,10 +26,14 @@ gib_workspace_yuck() {
button_class="empty" button_class="empty"
button_name="◇" button_name="◇"
fi 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 done
} }
xprop -spy -root _NET_CURRENT_DESKTOP | while read -r; do 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 done