blockify icon indicating copy to clipboard operation
blockify copied to clipboard

Add support for Spotify running in a Linux namespace

Open cadaniluk opened this issue 7 years ago • 2 comments

When running blockify without any arguments, I get:

Traceback (most recent call last):
  File "/usr/bin/blockify", line 11, in <module>
    load_entry_point('blockify==3.6.3', 'console_scripts', 'blockify')()
  File "/usr/lib/python3.6/site-packages/blockify/cli.py", line 605, in main
    cli.start()
  File "/usr/lib/python3.6/site-packages/blockify/cli.py", line 225, in start
    self.toggle_mute(2)
  File "/usr/lib/python3.6/site-packages/blockify/cli.py", line 376, in toggle_mute
    self.mutemethod(mode)
  File "/usr/lib/python3.6/site-packages/blockify/cli.py", line 459, in pulsesink_mute
    index, playback_state, muted_value = self.extract_pulse_sink_status(pacmd_out)
  File "/usr/lib/python3.6/site-packages/blockify/cli.py", line 444, in extract_pulse_sink_status
    pid = [k for k in idxd.keys() if k in self.spotify_pids][0]
IndexError: list index out of range

During the run:

idxd.keys() = [2]
self.spotify_pids = [30019, 30006, 29987, 29984]

So obviously, pid is empty and pid[0] is out of bounds, thus the IndexError.

I ran pacmd list-sink-inputs and noticed that application.process.id of Spotify is 2, not the PID of any Spotify-related process.

The problem is that pacmd list-sink-inputs reports the PID from the view of the respective process, Spotify in this case. Since Spotify is put into a separate namespace by flatpak, it reports PID 2, (PID 1 is of the namespace init process, see man 7 pid_namespaces). I don't know whether to consider this a bug in pulseaudio... but certainly, blockify must be PID namespace-aware and use global PIDs instead of namespace-specific ones.

cadaniluk avatar Apr 04 '18 12:04 cadaniluk

I confirm this issue on my machine.

rantonels avatar Jun 08 '18 09:06 rantonels

I confirm as well.

ashwinvis avatar Sep 16 '19 18:09 ashwinvis