diff options
Diffstat (limited to 'mac/.config/sketchybar.mon/plugins/volume_click.sh')
| -rwxr-xr-x | mac/.config/sketchybar.mon/plugins/volume_click.sh | 57 |
1 files changed, 57 insertions, 0 deletions
diff --git a/mac/.config/sketchybar.mon/plugins/volume_click.sh b/mac/.config/sketchybar.mon/plugins/volume_click.sh new file mode 100755 index 0000000..e05c0d8 --- /dev/null +++ b/mac/.config/sketchybar.mon/plugins/volume_click.sh @@ -0,0 +1,57 @@ +#!/bin/bash + +WIDTH=100 + +detail_on() { + sketchybar --animate tanh 30 --set volume slider.width=$WIDTH +} + +detail_off() { + sketchybar --animate tanh 30 --set volume slider.width=0 +} + +toggle_detail() { + INITIAL_WIDTH=$(sketchybar --query volume | jq -r ".slider.width") + if [ "$INITIAL_WIDTH" -eq "0" ]; then + detail_on + else + detail_off + fi +} + +toggle_devices() { + which SwitchAudioSource >/dev/null || exit 0 + source "$CONFIG_DIR/colors.sh" + source "$CONFIG_DIR/globalstyles.sh" + + args=(--remove '/volume.device\.*/' --set "$NAME" popup.drawing=toggle "${menu_defaults[@]}") + COUNTER=0 + CURRENT="$(SwitchAudioSource -t output -c)" + while IFS= read -r device; do + COLOR=$WHITE + ICON= + ICON_COLOR=$TRANSPARENT + if [ "${device}" = "$CURRENT" ]; then + COLOR=$HIGHLIGHT + ICON= + ICON_COLOR=$COLOR + fi + + args+=(--add item volume.device.$COUNTER popup."$NAME" \ + --set volume.device.$COUNTER label="${device}" \ + label.color="$COLOR" \ + icon=$ICON \ + icon.color=$ICON_COLOR \ + "${menu_item_defaults[@]}" \ + click_script="SwitchAudioSource -s \"${device}\" && sketchybar --set /volume.device\.*/ label.color=$GREY --set \$NAME label.color=$WHITE --set $NAME popup.drawing=off") + COUNTER=$((COUNTER+1)) + done <<< "$(SwitchAudioSource -a -t output)" + + sketchybar -m "${args[@]}" > /dev/null +} + +if [ "$BUTTON" = "left" ] || [ "$MODIFIER" = "shift" ]; then + toggle_devices +else + toggle_detail +fi
\ No newline at end of file |
