pablodz / pipewire_python

Python controller, player and recorder via pipewire's commands
https://pablodz.github.io/pipewire_python/html/
MIT License
22 stars 7 forks source link

get list of applications? #8

Closed carlocastoldi closed 2 years ago

carlocastoldi commented 3 years ago

Hey! I am sorry if I am coming here asking questions that may not be related, but do you perhaps intend to support a way to get the list of source & sink applications, along with their properties?

I am interested because I want to contribute in caffeine-ng for supporting PipeWire. At the momeny they are using pulsectl, but I think it no longer works with PipeWire, and the repository is dead.

If you can't / won't for some time, can you perhaps point me to a solution for getting a list of the application that are currently playing or recording?

Thank you! ^^

pablodz commented 3 years ago

I am sorry if I am coming here asking questions that may not be related, but do you perhaps intend to support a way to get the list of source & sink applications, along with their properties?

If it's possible to execute with pipewire command line, it's easy to handle. If not, It's necessary to write a C++ API to connect with Python control that would take months to develop

carlocastoldi commented 3 years ago

If it's possible to execute with pipewire command line, it's easy to handle.

I know pw-cli ls Client exists. Other then that, tho, I don't know if/how I can know whether an application is active or not. Do you?

The output is something like:

    id 58, type PipeWire:Interface:Client/3
                module.id = "2"
                pipewire.protocol = "protocol-native"
                pipewire.sec.pid = "961"
                pipewire.sec.uid = "1000"
                pipewire.sec.gid = "1000"
                pipewire.access = "unrestricted"
                application.name = "Firefox"

Additionally: if you require a PipeWire command line, does it mean you do polling rather then being notified of any changes?

carlocastoldi commented 3 years ago

Additional infos can be retrieved with pw-cli i <id>:

        id: 58
        permissions: rwxm
        type: PipeWire:Interface:Client/3
*       properties:
*               pipewire.protocol = "protocol-native"
*               pipewire.sec.pid = "961"
*               pipewire.sec.uid = "1000"
*               pipewire.sec.gid = "1000"
*               module.id = "2"
*               object.id = "58"
*               client.api = "pipewire-pulse"
*               pulse.server.type = "unix"
*               application.name = "Firefox"
*               application.process.id = "978"
*               application.process.user = "carlo"
*               application.process.host = "carlo-manjaro"
*               application.process.binary = "firefox"
*               application.language = "it_IT.UTF-8"
*               window.x11.display = ":0"
*               application.process.machine-id = "7e563f70bed3423b862cf285a8cb2985"
*               application.process.session-id = "1"
*               config.name = "pipewire-pulse.conf"
*               cpu.max-align = "32"
*               default.clock.rate = "48000"
*               default.clock.allowed-rates = "[ 48000 ]"
*               default.clock.quantum = "1024"
*               default.clock.min-quantum = "32"
*               default.clock.max-quantum = "8192"
*               default.video.width = "640"
*               default.video.height = "480"
*               default.video.rate.num = "25"
*               default.video.rate.denom = "1"
*               log.level = "2"
*               clock.power-of-two-quantum = "true"
*               link.max-buffers = "64"
*               mem.warn-mlock = "false"
*               mem.allow-mlock = "true"
*               core.version = "0.3.35"
*               core.name = "pipewire-carlo-961"
*               pipewire.access = "unrestricted"
pablodz commented 3 years ago

Additionally: if you require a PipeWire command line, does it mean you do polling rather than be notified of any changes?

Exactly, by now is just polling from the command line, but I want to create the whole custom python controller. Is that useful for your work? Thanks for the command

carlocastoldi commented 3 years ago

Exactly, by now is just polling from the command line, but I want to create the whole custom python controller.

Oh I see. That is awesome, good luck!

Is that useful for your work?

I don't know yet... What I am interested in doing is doing a program that, if any sound is being played (or recorded) prevents the computer from suspending. At the moment caffeine-ng works, but relies on PulseAudio. On PipeWire it fails because it's using an old pa binding, i think

pablodz commented 3 years ago

@carlocastoldi please validate to close, check instructs here https://github.com/pablodz/pipewire_python#get-interfaces Interface type Link is not yet supported, indentation is wrong for that types. For Client is working as expected

    id: 60
    permissions: rwx
    type: PipeWire:Interface:Link/3
    output-node-id: 57
    output-port-id: 58
    input-node-id: 49
    input-port-id: 51
*   state: "invalid-state"
*   format:
   audio/dsp
             format : (Id) F32P
*   properties:
*       link.output.node = "57"
*       link.input.node = "49"
*       link.passive = "false"
*       link.output.port = "58"
*       link.input.port = "51"
*       factory.id = "20"
*       client.id = "33"
*       object.id = "60"
pablodz commented 3 years ago

don't forget to pip install --force-reinstall pipewire_python