Go to file
earnest ma 1f5454956d
nix-shell configuration
2021-08-23 21:28:28 -04:00
.github/workflows Initial commit 2021-04-29 20:05:41 +02:00
src Remove redhook dependency 2021-05-05 11:01:06 +02:00
.envrc nix-shell configuration 2021-08-23 21:28:28 -04:00
.gitignore Initial commit 2021-04-29 20:05:41 +02:00
Cargo.toml Remove redhook dependency 2021-05-05 11:01:06 +02:00
LICENSE Initial commit 2021-04-29 20:05:41 +02:00
Makefile Prefix config file install path with DESTDIR 2021-05-05 11:26:46 +02:00
README.md nix-shell configuration 2021-08-23 21:28:28 -04:00
config.toml Update allowlist 2021-05-05 20:18:50 +02:00
rustfmt.toml Initial commit 2021-04-29 20:05:41 +02:00
shell.nix nix-shell configuration 2021-08-23 21:28:28 -04:00

README.md

earnest's personal clone of spotify-adblock (build helped with Nix) on a foreign system, lol

You should have Spotify installed through the Debian package and probably build-essential and git installed as well.

spotify-adblock

Spotify adblocker for Linux (macOS untested) that works by wrapping getaddrinfo and cef_urlrequest_create. It blocks requests to domains that are not on the allowlist, as well as URLs that are on the denylist.

Notes

  • This does not work with the snap Spotify package.
  • This might not work with the Flatpak Spotify package, depending on your system's shared libraries' versions.
  • On Debian-based distributions (e.g. Ubuntu), the Debian Spotify package can be installed by following the instructions at the bottom of this page. (recommended)

Build

Prerequisites:

  • Git
  • Make
  • Rust
$ git clone https://github.com/abba23/spotify-adblock.git
$ cd spotify-adblock
$ make

Install

$ sudo make install

Flatpak

$ mkdir -p ~/.spotify-adblock && cp target/release/libspotifyadblock.so ~/.spotify-adblock/spotify-adblock.so
$ mkdir -p ~/.config/spotify-adblock && cp config.toml ~/.config/spotify-adblock
$ flatpak override --user --filesystem="~/.spotify-adblock/spotify-adblock.so" --filesystem="~/.config/spotify-adblock/config.toml" com.spotify.Client

Usage

Command-line

$ LD_PRELOAD=/usr/local/lib/spotify-adblock.so spotify

Flatpak

$ flatpak run --command=sh com.spotify.Client -c 'eval "$(sed s#LD_PRELOAD=#LD_PRELOAD=$HOME/.spotify-adblock/spotify-adblock.so:#g /app/bin/spotify)"'

Desktop file

You can integrate it with your desktop environment by creating a .desktop file (e.g. spotify-adblock.desktop) in ~/.local/share/applications. This lets you easily run it from an application launcher without opening a terminal.

Examples:

Debian Package

[Desktop Entry]
Type=Application
Name=Spotify (adblock)
GenericName=Music Player
Icon=spotify-client
TryExec=spotify
Exec=env LD_PRELOAD=/usr/local/lib/spotify-adblock.so spotify %U
Terminal=false
MimeType=x-scheme-handler/spotify;
Categories=Audio;Music;Player;AudioVideo;
StartupWMClass=spotify

Flatpak

[Desktop Entry]
Type=Application
Name=Spotify (adblock)
GenericName=Music Player
Icon=com.spotify.Client
Exec=flatpak run --file-forwarding --command=sh com.spotify.Client -c 'eval "$(sed s#LD_PRELOAD=#LD_PRELOAD=$HOME/.spotify-adblock/spotify-adblock.so:#g /app/bin/spotify)"' @@u %U @@
Terminal=false
MimeType=x-scheme-handler/spotify;
Categories=Audio;Music;Player;AudioVideo;
StartupWMClass=spotify

Uninstall

$ sudo make uninstall

Flatpak

$ rm -r ~/.spotify-adblock ~/.config/spotify-adblock
$ flatpak override --user --reset com.spotify.Client

Configuration

The allowlist and denylist can be configured in a config file located at (in ascending order of precedence):

  • /etc/spotify-adblock/config.toml (default)
  • ~/.config/spotify-adblock/config.toml (default for Flatpak)
  • config.toml in the working directory