summaryrefslogtreecommitdiff
path: root/.config
diff options
context:
space:
mode:
authorA Farzat <a@farzat.xyz>2024-10-13 11:46:44 +0900
committerA Farzat <a@farzat.xyz>2024-10-20 11:46:44 +0900
commit726bc6f623b4e765f923bf10267fa4a1d66b0097 (patch)
tree50b7cd071546b519710a5062b4987b663b4860ab /.config
parent002727a501aaa74d2eb60cc0475d746a668a9cd0 (diff)
downloaddotfiles-726bc6f623b4e765f923bf10267fa4a1d66b0097.tar.gz
dotfiles-726bc6f623b4e765f923bf10267fa4a1d66b0097.zip
Add mpv audio_setter script
Diffstat (limited to '.config')
-rw-r--r--.config/mpv/.luarc.json3
-rw-r--r--.config/mpv/scripts/audio_setter.lua14
2 files changed, 17 insertions, 0 deletions
diff --git a/.config/mpv/.luarc.json b/.config/mpv/.luarc.json
new file mode 100644
index 0000000..82edb9f
--- /dev/null
+++ b/.config/mpv/.luarc.json
@@ -0,0 +1,3 @@
+{
+ "diagnostics.globals": ["mp"]
+}
diff --git a/.config/mpv/scripts/audio_setter.lua b/.config/mpv/scripts/audio_setter.lua
new file mode 100644
index 0000000..12981f1
--- /dev/null
+++ b/.config/mpv/scripts/audio_setter.lua
@@ -0,0 +1,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)