SpottyMute/cscnp.sh

60 lines
1.7 KiB
Bash
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#!/bin/bash
## ~/.local/bin/5nowplaying.sh ##
ad(){ #is spotify trying to sell me something and calling it a song?
local SONG=$( eval spotifycli --song )
test
[[ $SONG == "Advertisement" ]]
}
checkmute(){ # am I muted already? returns 1 if unmuted. !checkmute means muted
test
[[ $( eval amixer -D pulse sget Master | grep -F [on] ) ]]
}
ifad(){ #prints now playing for clementine, "muted," and cmus
local C=$( np -n )
local M="MUTED ·"
local CMUS=$( tail -n 1 ~/.cmus/now-playing )
echo -n $C $M $CMUS
}
ifnoad(){ #prints now playing for clementine, spotify, and cmus
local C=$( np -n )
local S=$( spotifycli --status )
local CMUS=$( tail -n 1 ~/.cmus/now-playing )
echo -n $C $S $CMUS
}
if ad ; then ifad ;
elif ! ad ; then ifnoad;
else ifnoad ; fi #something's gone wrong
while ad && checkmute ; #if there's an ad and alsa is unmuted, runs fuckads.sh
do
# fuckads.sh #
toggle(){ #flip the switch
amixer -q -D pulse sset Master toggle
}
if ad ; then #yea spotify is trying to sell me something
while ad ; #right now?
do
if checkmute ; #am I muted yet?
then
toggle && notify-send "🔇FUCKADS🔇 MUTING THAT SHIT" ; #mute
sleep 30 #each ad is like 30 secs
fi; continue; # another one ??
done;
while ! ad ; #ok spotify isn't trying to sell me something
do
if ! checkmute ; #am I still muted?
then
toggle && notify-send "✅FUCKADS✅ MUTED THAT SHIT" ; #unmute
sleep 30 #wait to check for another ad
fi
done
fi
break; sleep 30 ; done #waits 30 seconds before checking and unmuting