bkbilly / lnxlink

🖥 Effortlessly manage your Linux machine using MQTT.

Home Page:https://bkbilly.gitbook.io/lnxlink

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Getting and using bash command response data

Iceman248 opened this issue · comments

Describe the solution you'd like

I wanted to auto lower volume of a particular app's volume while TTS is playing for announcements that I setup. I was able to get this working using "pactl set-sink-input-volume <Sink Input #> 50%". I then followed it up after the TTS with 100% to turn it back up. It has worked great so far, except the Sink Input # keeps changing often for some reason for my web browser.

I tried using name of it which stays the same, but nothing I used worked, so I had to use the number, so unless I am missing something with the name, I was going to see about how I could get the number from the response to "pactl list sink-inputs" which is how I learn it each time it changes. Below is the response to this command. You can see the data I want is in multiple places, starting at the beginning.

Edit:
"pactl list short sink-inputs" returns something shorter, first thing is also what I am looking for, perhaps a bit easier.

1804387 47 1804386 PipeWire float32le 2ch 48000Hz

Sink Input #1804387
        Driver: PipeWire
        Owner Module: n/a
        Client: 1804386
        Sink: 47
        Sample Specification: float32le 2ch 48000Hz
        Channel Map: front-left,front-right
        Format: pcm, format.sample_format = "\"float32le\""  format.rate = "48000"  format.channels = "2"  format.channel_map = "\"front-left,front-right\""
        Corked: no
        Mute: no
        Volume: front-left: 65536 / 100% / 0.00 dB,   front-right: 65536 / 100% / 0.00 dB
                balance 0.00
        Buffer Latency: 0 usec
        Sink Latency: 0 usec
        Resample method: PipeWire
        Properties:
                client.api = "pipewire-pulse"
                pulse.server.type = "unix"
                application.name = "Chromium"
                application.process.id = "3794856"
                application.process.user = "iceman"
                application.process.host = "iceman-linux"
                application.process.binary = "vivaldi-bin"
                application.language = "en_US.UTF-8"
                window.x11.display = ":0"
                application.process.machine_id = "ce0311944aa84849940ccd5d3d4a4432"
                application.process.session_id = "2"
                application.icon_name = "chromium-browser"
                media.name = "Playback"
                node.rate = "1/48000"
                node.latency = "1024/48000"
                stream.is-live = "true"
                node.name = "Chromium"
                node.autoconnect = "true"
                node.want-driver = "true"
                media.class = "Stream/Output/Audio"
                adapt.follower.spa-node = ""
                object.register = "false"
                factory.id = "6"
                clock.quantum-limit = "8192"
                factory.mode = "split"
                audio.adapt.follower = ""
                library.name = "audioconvert/libspa-audioconvert"
                client.id = "73"
                object.id = "61"
                object.serial = "1804387"
                pulse.attr.maxlength = "4194304"
                pulse.attr.tlength = "16384"
                pulse.attr.prebuf = "12296"
                pulse.attr.minreq = "4096"
                module-stream-restore.id = "sink-input-by-application-name:Chromium"

Additional context

No response

I don't fully understand what you want to do, but it's a good idea to return the result of the bash command to a new MQTT topic.
You could create an automation that subscribes to that topic and get the result you want from that.
I'll try to implement it for the next release.

Okay, thanks. I just want to be able to read data from a bash command result since what am looking for keeps changing and that is the only way I see to accomplish what I want.

I've just added the option for the bash command to publish the results on a new topic.
You can use MQTT explorer to find the exact topic you will have to subscribe to get the data.

For now you can only use it if you install lnxlink as a development platform.

This should work fine on the latest release 2023.8.0.