added failsafe to choice script so that no error occurs when closing dmenu without a choice

This commit is contained in:
Solomon Laing 2021-03-23 23:07:02 +10:30
parent cfd82b29cf
commit 654d7cf14f

View File

@ -2,6 +2,10 @@
choice=$(pactl list short sinks | awk '{print $2}' | dmenu -i -p "which sink should be default?") choice=$(pactl list short sinks | awk '{print $2}' | dmenu -i -p "which sink should be default?")
if [ $choice=="" ] ; then
exit 0;
fi
rm /tmp/pactl-default-sink --force # to ignore if it isn't there rm /tmp/pactl-default-sink --force # to ignore if it isn't there
echo "$choice" >> /tmp/pactl-default-sink echo "$choice" >> /tmp/pactl-default-sink
pactl set-default-sink $choice # make sure that the chosen sink is the pactl set-default-sink $choice # make sure that the chosen sink is the