logo

dotfiles

My dotfiles, one branch per machine, rebased on base git clone https://hacktivis.me/git/dotfiles.git
commit: 2c25ef48c13ca3cbf15bfadb4cd38900077ff5a3
parent 08798ceaaa253c0197868c4e9fd85864fbc96ffe
Author: Haelwenn (lanodan) Monnier <contact@hacktivis.me>
Date:   Tue,  7 Nov 2023 04:07:59 +0100

mpv/scripts/append.lua: New script

Diffstat:

A.config/mpv/scripts/append.lua32++++++++++++++++++++++++++++++++
1 file changed, 32 insertions(+), 0 deletions(-)

diff --git a/.config/mpv/scripts/append.lua b/.config/mpv/scripts/append.lua @@ -0,0 +1,32 @@ +-- Copyright © 2023 Haelwenn (lanodan) Monnier <contact+dotfiles@hacktivis.me> +-- SPDX-License-Identifier: MIT + +local utils = require 'mp.utils' +local msg = require 'mp.msg' + +function get_clipboard(primary) + local args = {'wl-paste'} + local res = utils.subprocess({ args = args, cancellable = false }) + + if not res.error and res.status == 0 then + return res.stdout + else + msg.error("Error grabbing clipboard:") + msg.error(" Status: "..(res.status or "")) + msg.error(" Error: "..(res.error or "")) + msg.error(" stdout: "..(res.stdout or "")) + msg.error("args: "..utils.to_string(args)) + return nil + end +end + +function append() + local clipboard = get_clipboard() + if clipboard then + mp.commandv("loadfile", clipboard, "append-play") + mp.osd_message("append-play: "..clipboard) + msg.info("append-play: "..clipboard) + end +end + +mp.add_key_binding("ctrl+v", "append", append)