logo

dotfiles

My dotfiles, one branch per machine, rebased on base git clone https://anongit.hacktivis.me/git/dotfiles.git/

append.lua (883B)


  1. -- Copyright © 2023 Haelwenn (lanodan) Monnier <contact+dotfiles@hacktivis.me>
  2. -- SPDX-License-Identifier: MIT
  3. local utils = require 'mp.utils'
  4. local msg = require 'mp.msg'
  5. function get_clipboard(primary)
  6. local args = {'wl-paste'}
  7. local res = utils.subprocess({ args = args, cancellable = false })
  8. if not res.error and res.status == 0 then
  9. return res.stdout
  10. else
  11. msg.error("Error grabbing clipboard:")
  12. msg.error(" Status: "..(res.status or ""))
  13. msg.error(" Error: "..(res.error or ""))
  14. msg.error(" stdout: "..(res.stdout or ""))
  15. msg.error("args: "..utils.to_string(args))
  16. return nil
  17. end
  18. end
  19. function append()
  20. local clipboard = get_clipboard()
  21. if clipboard then
  22. mp.commandv("loadfile", clipboard, "append-play")
  23. mp.osd_message("append-play: "..clipboard)
  24. msg.info("append-play: "..clipboard)
  25. end
  26. end
  27. mp.add_key_binding("ctrl+v", "append", append)