2021-04-29 14:05:41 -04:00
# spotify-adblock
2021-05-01 09:17:58 -04:00
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.
2021-04-29 14:05:41 -04:00
### Notes
2021-05-04 11:45:48 -04:00
* 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.
2021-05-04 13:08:27 -04:00
* On Debian-based distributions (e.g. Ubuntu), the Debian Spotify package can be installed by following the instructions at the bottom of [this page ](https://www.spotify.com/us/download/linux/ ). *(recommended)*
2021-04-29 14:05:41 -04:00
## Build
Prerequisites:
* Git
* Make
* Rust
2021-05-04 11:45:48 -04:00
```bash
$ git clone https://github.com/abba23/spotify-adblock.git
$ cd spotify-adblock
$ make
```
2021-04-29 14:05:41 -04:00
## Install
2021-05-04 11:45:48 -04:00
```bash
$ sudo make install
```
2021-04-29 14:05:41 -04:00
2021-05-04 11:45:48 -04:00
#### Flatpak
```bash
$ 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
```
2021-04-29 14:05:41 -04:00
2021-05-04 11:45:48 -04:00
## Usage
2021-04-29 14:05:41 -04:00
### Command-line
2021-05-04 11:45:48 -04:00
```bash
$ LD_PRELOAD=/usr/local/lib/spotify-adblock.so spotify
```
#### Flatpak
```bash
$ 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)"'
```
2021-04-29 14:05:41 -04:00
### 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.
2021-05-04 11:45:48 -04:00
Examples:
2021-04-29 14:05:41 -04:00
< details >
2021-05-04 11:45:48 -04:00
< summary > Debian Package< / summary >
2021-04-29 14:05:41 -04:00
< p >
```
[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
```
< / p >
< / details >
2021-05-04 11:45:48 -04:00
< details >
< summary > Flatpak< / summary >
< p >
```
[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
```
< / p >
< / details >
2021-04-29 14:05:41 -04:00
## Uninstall
2021-05-04 11:45:48 -04:00
```bash
$ sudo make uninstall
```
2021-04-29 14:05:41 -04:00
2021-05-04 11:45:48 -04:00
#### Flatpak
```bash
$ rm -r ~/.spotify-adblock ~/.config/spotify-adblock
$ flatpak override --user --reset com.spotify.Client
```
2021-04-29 14:05:41 -04:00
## Configuration
2021-05-04 11:45:48 -04:00
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)*
2021-04-29 14:05:41 -04:00
* `config.toml` in the working directory