Wednesday 23 March 2011

Disabling Adverts in Spotify on Ubuntu Linux

Ok .. this is completely unrelated to my Solr stuff.
But - I wanted to share this useful snippet.

(NB)

* This does not actually disable the adverts - it simply mutes the volume for approximately the same time as a spotify ad lasts.
* Its not an automatic solution - Its only really useful if you are listening to spotify whilst you are sitting at the keyboard.
* It works for me!

The reason I wrote this is because some of the Spotify adverts were

* Not relevant to me ( I am most definitely not interested in Tiny Tempah )
* Really irritating (Go Compare / Compare the Meerkat)

So I could have ponied up and gone for the subscription , However there are a few reasons for this.

* My spotify usage is not really very high. (I have my entire CD collection already ripped and sitting locally)
* The Linux version is not up to scratch i use the Windows version through Wine.

I might re-evaluate this at some point in the future - this is how it is now.

So heres how it works

I created a small Shell script to mute the volume for 45seconds , and then bring it back up again.
The script for ubuntu is as follows.


#!/bin/bash

pactl set-sink-mute 0 yes
sleep 45
pactl set-sink-mute 0 no


Save this script somewhere ( eg ~/mute.sh )
make it executable
#> chmod u+x ~/mute.sh
Now you are going to create a custom keybinding in Ubuntu
Go to 
System -> Preferences -> Keyboard Shortcuts
Click "Add"
you will get a pop-up window asking for an name and command
Call it  "MuteVol1Min"
and set the command to "~/mute.sh" (or wherever you saved the script)
Click Apply
Finally you need to bind it to a key combo.
click on the "shortcut" column next to the custom shortcut you just created.
I bound mine to the windows key + pause/break key - that comes up as Mod4+Pause.
You could choose the same combination - or try something different.
To use it - as soon as you notice that an advert comes up hit the key combo - sound will mute and come back up 45seconds later after the advert is finished.
Its not perfect but it works well for me as im usually listening and coding at the same time.
Hope this helps someone
N...

3 comments:

  1. This comment has been removed by the author.

    ReplyDelete
  2. An important note is that this script requires the package "pactl" to be installed, pulseaudio-utils

    (tested on Linux mint Debian) and it works if i install that package, too bad my wine and pulseaudio dosent like eachother so i couldnt try it out so much thanks though for the tip!

    ReplyDelete
  3. I've created an automated solution, see: https://gist.github.com/3198763

    ReplyDelete