summaryrefslogtreecommitdiff
path: root/.config/mpv/scripts/audio_setter.lua
blob: 12981f12a5de5cad987a53b58bc7e66e110d6949 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
local function change_audio()
    local r = mp.command_native({
            name = "subprocess",
            capture_stdout = true,
            args = {'sh', '-c', "mpv --audio-device=help | tail -n+2 | fzf-tmux -p | awk '{printf $1}'"},
            playback_only = false,
        })

    if r.status == 0 and r.stdout ~= "" then
        mp.set_property("audio-device", string.sub(r.stdout, 2, -2))
    end
end

mp.add_key_binding("alt+a", "SetAudioDevice", change_audio)