From f2af11c5973f10c1a55f817061da06779058aa38 Mon Sep 17 00:00:00 2001 From: Rudis Muiznieks Date: Wed, 20 Nov 2024 08:08:55 -0600 Subject: [PATCH] fuzzel audio chooser script --- mako/config | 1 + scripts/choose-audio | 48 ++++++++++++++++++++++++++++++++++++ sway/config.d/03-keybindings | 1 + zsh/zalias-borges | 3 ++- 4 files changed, 52 insertions(+), 1 deletion(-) create mode 100755 scripts/choose-audio diff --git a/mako/config b/mako/config index 1376602..64e6061 100644 --- a/mako/config +++ b/mako/config @@ -1,5 +1,6 @@ font=monospace 14 default-timeout=30000 +anchor=bottom-right # Colors diff --git a/scripts/choose-audio b/scripts/choose-audio new file mode 100755 index 0000000..e7f7723 --- /dev/null +++ b/scripts/choose-audio @@ -0,0 +1,48 @@ +#!/usr/bin/env bash +SELF="$(dirname "$0")/$(basename "$0")" +LANG="en_US.utf8" +# Outputs have spaces in them, so let's make \n the IFS +IFS=$'\n' + +# Make script independent on particular implementation of send client +if command -v notify-send > /dev/null 2>&1; then + SEND="notify-send" +elif command -v dunstify > /dev/null 2>&1; then + SEND="dunstify" +else + SEND="/bin/false" +fi + +# An option was passed, so let's check it +if [ "$@" ] +then + if [ "$1" = "-select" ]; then + choice="$("$SELF" | fuzzel --dmenu)" + if [ -n "$choice" ]; then + "$SELF" "$choice" + fi + else + # the output from the selection will be the desciption. Save that for alerts + desc="$*" + # Figure out what the device name is based on the description passed + device=$(pactl list sinks|grep -C2 -F "Description: $desc"|grep Name|cut -d: -f2|xargs) + # Try to set the default to the device chosen + if pactl set-default-sink "$device" + then + # if it worked, alert the user + $SEND -t 2000 -r 2 -u low "Activated: $desc" + else + # didn't work, critically alert the user + $SEND -t 2000 -r 2 -u critical "Error activating $desc" + fi + fi +else + #echo -en "\x00prompt\x1fSelect Output\n" + # Get the list of outputs based on the description, which is what makes sense to a human + # and is what we want to show in the menu + for x in $(pactl list sinks | grep -ie "description:"|cut -d: -f2|sort) + do + # outputs with cut may have spaces, so use empty xargs to remove them, and output that to the rofi list + echo "$x"|xargs + done +fi diff --git a/sway/config.d/03-keybindings b/sway/config.d/03-keybindings index 0f4225c..6b1e7bd 100644 --- a/sway/config.d/03-keybindings +++ b/sway/config.d/03-keybindings @@ -48,3 +48,4 @@ bindsym XF86AudioPlay exec playerctl play-pause bindsym Print exec grim -g "$(slurp)" - | swappy -f - bindsym $mod+c exec clipman pick --tool=CUSTOM --tool-args="fuzzel -d" +bindsym $mod+a exec /home/rudism/skynet/scripts/choose-audio -select diff --git a/zsh/zalias-borges b/zsh/zalias-borges index 77807e7..8f29425 100644 --- a/zsh/zalias-borges +++ b/zsh/zalias-borges @@ -17,12 +17,13 @@ hash -d c=/mnt/constantmown alias nasavpn='/home/rudism/src/nasavpn/nasavpn' alias dockerrm='docker stop $(docker ps -aq); docker rm $(docker ps -aq); docker system prune -f' alias webcamfix='sudo modprobe v4l2loopback devices=1 video_nr=9 card_label=VirtualCam exclusive_caps=1 && ffmpeg -f video4linux2 -framerate 25 -video_size 1280x720 -input_format mjpeg -i /dev/video0 -f v4l2 -pix_fmt yuv420p /dev/video9; sudo rmmod v4l2loopback' -alias syncmusic='rsync -av --size-only --ignore-times --no-perms --no-owner --no-group --delete /mnt/agrajag/music/ /mnt/usb/Music' +alias syncmusic='rsync -av --size-only --times --no-perms --no-owner --no-group --delete /mnt/agrajag/music/ /mnt/usb/Music' alias watchsync='watch -d grep -e Dirty: -e Writeback: /proc/meminfo' alias localai='COMPOSE_FILE=~/.local/share/local-ai/docker-compose.yaml docker compose up -d --force-recreate' alias win='dbus-run-session sway --unsupported-gpu' alias transcrilium='/home/rudism/src/transcrilium/transcrilium /mnt/usb/PRIVATE/SONY/REC_FILE/Voice\ Notes01' alias clearb="printf '\033[2J\033[3J\033[1;1H'" +alias airplay="pactl unload-module module-raop-discover; pactl load-module module-raop-discover" # llm aliases that use aichat if command -v aichat >/dev/null; then