Skip to content

Commit

Permalink
Merge pull request #2 from smarkoco/main
Browse files Browse the repository at this point in the history
Added */ad/* url match and added option to run in a background tmux process, for status checking
  • Loading branch information
nisiddharth authored Mar 10, 2023
2 parents f388629 + e9e32ea commit d74265e
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 6 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ Mutes and unmutes Spotify within 5 seconds of start and end of Ads.

### Usage:

To use just run `mute_spotify_timer.sh` either using terminal or Alt + F2 launcher or just add it to list of system Startup Applications.
To use just run `mute_spotify_timer.sh` either using terminal or Alt + F2 launcher or just add it to list of system Startup Applications. To allow monitoring the ongoing status, run `adfree.sh` as a Startup Application. It creates a new background tmux session called `adfree`, which can be connected to with `tmux a -t adfree`.

### Maintenance:

Expand Down
3 changes: 3 additions & 0 deletions adfree.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#!/bin/bash
tmux new-session -d -s adfree
tmux send-keys '~/spotify-muter-linux/mute_spotify_timer.sh' C-m # C-m sends ENTER keystroke
10 changes: 5 additions & 5 deletions mute_spotify_timer.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,16 @@
while true; do
# get Spotify playing song name
name=`dbus-send --print-reply --dest=org.mpris.MediaPlayer2.spotify /org/mpris/MediaPlayer2 org.freedesktop.DBus.Properties.Get string:org.mpris.MediaPlayer2.Player string:Metadata | sed -n '/title/{n;p}' | cut -d '"' -f 2`

url=`dbus-send --print-reply --dest=org.mpris.MediaPlayer2.spotify /org/mpris/MediaPlayer2 org.freedesktop.DBus.Properties.Get string:org.mpris.MediaPlayer2.Player string:Metadata | sed -n '/url/{n;p}' | cut -d '"' -f 2`
echo $name

if [[ "$name" = *"Advertisement"* || "$name" = *"Spotify"* ]]; then
if [[ "$name" = *"Advertisement"* || "$name" = *"Spotify"* ]] || [[ $url == *"/ad/"* ]]; then
echo "Muting"
~/spotify-muter-linux/mute_app.sh spotify mute
sleep 25
sleep 5
else
echo "Unmuting"
~/spotify-muter-linux/mute_app.sh spotify unmute
fi
sleep 5
sleep 1
done

0 comments on commit d74265e

Please sign in to comment.