Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update usage instructions for Flatpak #184

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
71 changes: 32 additions & 39 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ Spotify adblocker for Linux (macOS untested) that works by wrapping `getaddrinfo

### 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](https://www.spotify.com/us/download/linux/). *(recommended)*

## Build
Expand All @@ -14,32 +13,44 @@ Prerequisites:
* [Cargo](https://doc.rust-lang.org/cargo/)

```bash
$ git clone https://github.com/abba23/spotify-adblock.git
$ cd spotify-adblock
$ make
git clone https://github.com/abba23/spotify-adblock.git
cd spotify-adblock
make
```

## Install
#### Build (Flatpak)

You only need `git` and `podman` (or `docker`) installed:

```bash
$ sudo make install
git clone https://github.com/abba23/spotify-adblock.git
cd spotify-adblock
# This is a Docker-compatible command
podman run -it --rm -v $(pwd):/src:Z ubuntu:24.10 sh -c 'apt update && apt install -y --no-install-recommends ca-certificates cargo make && make -C /src'
```

#### Flatpak
## Install
```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
sudo make install
```

## Usage
### Command-line
#### Install (Flatpak)
```bash
$ LD_PRELOAD=/usr/local/lib/spotify-adblock.so spotify
mkdir -p ~/.var/app/com.spotify.Client/config/spotify-adblock
cp target/release/libspotifyadblock.so ~/.var/app/com.spotify.Client
cp config.toml ~/.var/app/com.spotify.Client/config/spotify-adblock
flatpak --user override "--env=LD_PRELOAD=$HOME/.var/app/com.spotify.Client/libspotifyadblock.so" com.spotify.Client
```

#### Flatpak
## Usage

### Flatpak

No extra configuration needed, just launch the app.

### Command-line
```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)"'
LD_PRELOAD=/usr/local/lib/spotify-adblock.so spotify
```

### Desktop file
Expand All @@ -51,7 +62,7 @@ Examples:
<summary>Debian Package</summary>
<p>

```
```ini
[Desktop Entry]
Type=Application
Name=Spotify (adblock)
Expand All @@ -67,39 +78,21 @@ StartupWMClass=spotify
</p>
</details>

<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>

## Uninstall
```bash
$ sudo make uninstall
sudo make uninstall
```

#### Flatpak
#### Uninstall (Flatpak)
```bash
$ rm -r ~/.spotify-adblock ~/.config/spotify-adblock
$ flatpak override --user --reset com.spotify.Client
flatpak --user override --unset-env=LD_PRELOAD com.spotify.Client
rm -rv ~/.var/app/com.spotify.Client/{config/spotify-adblock,libspotifyadblock.so}
```

## Configuration
The allowlist and denylist can be configured in a config file located at (in descending order of precedence):
* `config.toml` in the working directory
* `$XDG_CONFIG_HOME/spotify-adblock/config.toml`
* `~/.config/spotify-adblock/config.toml`
* `~/.var/app/com.spotify.Client/config/spotify-adblock/config.toml` *(Flatpak)*
* `/etc/spotify-adblock/config.toml` *(default)*