# We make sure that Snap and flatpak versions are uninstalled
sudo snap remove spotify 2> /dev/null
sudo flatpak uninstall com.spotify.Client 2> /dev/null
# We install the version from the official website
which curl &> /dev/null || sudo apt update && sudo apt install curl -y # Install curl if not already installed
curl -sS https://download.spotify.com/debian/pubkey_0D811D58.gpg | sudo apt-key add -
echo "deb http://repository.spotify.com stable non-free" | sudo tee /etc/apt/sources.list.d/spotify.list
sudo apt update
sudo apt install spotify-client -y
# We install the prerequisites to build and install the patch (Git and Rust will be installed and not removed)
sudo apt install git make build-essential -y
which rustc &> /dev/null || curl https://sh.rustup.rs -sSf | ( sh -s -- -y; source $HOME/.cargo/env ) # Install rust if not already installed
# Download and build the patch
git clone https://github.com/abba23/spotify-adblock.git
cd spotify-adblock
make
# Install the patch
sudo make install
# Removing sourcecode folder
cd ..
rm -rf spotify-adblock
# We replace the Ubuntu desktop shortcut
if [ -f /usr/share/applications/spotify.desktop ] ; then
sudo sed -i "7s#.*#Exec=env LD_PRELOAD=/usr/local/lib/spotify-adblock.so spotify %U#" /usr/share/applications/spotify.desktop
fi