diff options
author | Alex Kelly <kellya@arachnitech.com> | 2022-06-26 23:17:54 -0400 |
---|---|---|
committer | Alex Kelly <kellya@arachnitech.com> | 2022-06-26 23:17:54 -0400 |
commit | 06fd86bf78406d9eaca7426853e3a2b45fcdd119 (patch) | |
tree | 16c5e376be476078b7aef915737c90aa9e4fb048 /rofi-sound-output-chooser | |
parent | ff1970404996968bcfd8f9f388921686edd8d805 (diff) | |
download | rofi-sound-06fd86bf78406d9eaca7426853e3a2b45fcdd119.tar.gz |
initial checkin
Diffstat (limited to 'rofi-sound-output-chooser')
-rwxr-xr-x | rofi-sound-output-chooser | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/rofi-sound-output-chooser b/rofi-sound-output-chooser new file mode 100755 index 0000000..d51c71d --- /dev/null +++ b/rofi-sound-output-chooser @@ -0,0 +1,38 @@ +#!/usr/bin/env bash +# Outputs have spaces in them, so let's make \n the IFS +IFS=$'\n' + +# Menu will have a quit option, though you could just escape +if [ "$*" = "quit" ] +then + exit 0 +fi + + +# An option was passed, so let's check it +if [ "$@" ] +then + # 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 "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 + dunstify -t 2000 -r 2 -u low "Activated: $desc" + else + # didn't work, critically alert the user + dunstify -t 2000 -r 2 -u critical "Error activating $desc" + 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) + 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 + echo "quit" +fi |