abba23 / spotify-adblock

Adblocker for Spotify
https://github.com/abba23/spotify-adblock
1.82k stars 88 forks source link

Spotify flatpak fix #112

Open pizzadude opened 2 years ago

pizzadude commented 2 years ago

The actual spotify binary is in a different folder, so people may need to run spotify flatpak with something like this:

flatpak run --command=/app/extra/share/spotify/spotify --env="LD_PRELOAD=/home/user/.spotify-adblock/spotify-adblock.so" com.spotify.Client

nullndvoid commented 1 year ago

--env="LD_PRELOAD=/path/to/adblock.so" might work also?

1RandomDev commented 1 year ago

This doesn't load the adblocker since you set the command directly to the spotify binary. --command has to be set to sh in order for the -c '...' in the end to be executed. And if set correctly it still can't start.

For me the fix was to download the prebuilt binary instead of building it myself.

pizzadude commented 1 year ago

Yeah, maybe I got it wrong.

flatpak run --command=/app/extra/share/spotify/spotify --env="LD_PRELOAD=/home/user/.spotify-adblock/spotify-adblock.so" com.spotify.Client seems to work, but I built the library in an Ubuntu distrobox container.

abba23 commented 1 year ago

I don't use Flatpak, so I can't test this. Can someone confirm that the path has changed, the current instructions in the README are broken and

flatpak run --command=/app/extra/share/spotify/spotify --env="LD_PRELOAD=/home/user/.spotify-adblock/spotify-adblock.so" com.spotify.Client

definitely works without breaking anything else (e.g. by overriding LD_PRELOAD like that)?

Rand-o commented 1 year ago

@abba23 Hey I did test it out on 2 of my Fedora computers running flatpak and it runs fine but doesnt block ads

alsoGAMER commented 1 year ago

same here on archlinux

commandline: flatpak run --command=/app/extra/share/spotify/spotify --file-forwarding --env="LD_PRELOAD=/home/alsog/.spotify-adblock/spotify-adblock.so" com.spotify.Client --no-sandbox --no-zygote

ERROR: ld.so: object '/home/alsog/.spotify-adblock/spotify-adblock.so' from LD_PRELOAD cannot be preloaded (cannot open shared object file): ignored.

pizzadude commented 1 year ago

You need to whitelist ~/.spotify-adblock with flatseal

alsoGAMER commented 1 year ago

@pizzadude thanks! seems to be working fine now

Rand-o commented 1 year ago

@pizzadude that was it :) thanks!

axelsimon commented 11 months ago

I'm only managing to start from the command line (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)"') and not from the GNOME integrated .desktop file.

As Spotify is installed as a system-wide flatpak, I've tried patching both /var/lib/flatpak/app/com.spotify.Client/x86_64/stable/active/export/share/applications/com.spotify.Client.desktop and /var/lib/flatpak/app/com.spotify.Client/x86_64/stable/active/files/share/applications/com.spotify.Client.desktop but no luck.

So which even is the right .desktop file to patch? And are the instructions on the README still valid?

Regarding this:

You need to whitelist ~/.spotify-adblock with flatseal

you can also use the commands mentioned in the README if you don't want to bother with Flatseal (which is a great app, in any case): flatpak override --user --filesystem="~/.spotify-adblock/spotify-adblock.so" --filesystem="~/.config/spotify-adblock/config.toml" com.spotify.Client

They do the same thing.

Motzumoto commented 5 months ago

You need to whitelist ~/.spotify-adblock with flatseal

Hey can you go into further details as to how to do this? This is what i see with flatseal image

I'm not sure how to whitelist a specific path, if thats possible.

axelsimon commented 5 months ago

It would look like this in Flatseal: image

then enter the path: image

Done.

Otherwise open a terminal and run: flatpak override --user --filesystem="~/.spotify-adblock/spotify-adblock.so" --filesystem="~/.config/spotify-adblock/config.toml" com.spotify.Client which does the same thing, it allows the flatpak to access the two files in ~/.config/spotify-adblock. In the above screenshots you can see that those two files are already visible in Flatseal, because i ran that command.

Motzumoto commented 5 months ago

It would look like this in Flatseal: ![image](https://private-user-images.githubusercontent.com/

I greatly appreciate it!

pyro12 commented 4 months ago

I don't use Flatpak, so I can't test this. Can someone confirm that the path has changed, the current instructions in the README are broken and

flatpak run --command=/app/extra/share/spotify/spotify --env="LD_PRELOAD=/home/user/.spotify-adblock/spotify-adblock.so" com.spotify.Client

definitely works without breaking anything else (e.g. by overriding LD_PRELOAD like that)?

One year after you asked, on a fresh Arch install, this command is working for me while the one in the readme gave "command not found". Unlike the other poster, I am not seeing ads.

pyro12 commented 4 months ago

Don't know what happened, but I had to change it to

flatpak run --command=/app/extra/share/spotify/spotify --env="LD_PRELOAD=/home/$USER/.spotify-adblock/spotify-adblock.so" com.spotify.Client

to get it working again. Haven't used it in a couple weeks so I can't say when the issue first occurred. Other than a couple system updates (pacman -Syu), I haven't changed anything. I guess I did install STEAM flatpak which is currently running if that matters.

I was getting the same error as @alsoGAMER and also running Arch.