I have a dumb work related chrome thing, i’d like to make it so that when a certain notification sound plays in chromium, my computer does a few things automatically for me

Does anyone know a good way to make this happen?

I imagine it’d have to be setup like:

when chrome starts playing audio && check if that audio matches soundfile.ogg && myscript.sh, but I don’t know any good cli utilities that could get something like that done, and if there are any better ideas!

  • bloodfart@lemmy.ml
    link
    fedilink
    arrow-up
    1
    ·
    3 months ago

    My assumption is that you don’t care if your notification gets spoofed, ex. Someone rings a little bell and the script deletes all cookies from porn websites as if the little bell notification played.

    So I think the hardest and best way to do this is to have the script run on a separate device than the sound plays on.

    First record the sound you want to trigger with. Use the script executing device with the microphone and interface you’ll be using in production set up in the location of production to make it easier on yourself.

    Now reduce the bitrate of the target sound a lot. No, more than that, keep going, a little more, that’s perfect.

    Now write something that will capture the last target_sound_length seconds of audio and compare it with the bitcrushed version. Depending on your device, there may be a buffer object in the adc you can interface with, although if it’s running a normal operating system you won’t be able to just get to it without going through the os first.

    If you can go through the chrome notificationing machine, figure out the hook used to trigger the notification you want to respond to and intercept and perform the script. No nyquist needed!