local mp = require "mp" local nextfile = require "nextfile" local prevfile = require "prevfile" local config = { directory = "/home/viciouscirce/pix/testshots/" -- Change this to your target directory } local function get_output_filename(prompt) local prev = prevfile.prevfile(config.directory) mp.osd_message(prev) local suggested_filename = nextfile.nextfile(config.directory, "jpg") if not prompt then return config.directory .. suggested_filename end local cmd = "echo " .. suggested_filename .. " | dmenu -p Filename:" local name = string.gsub(io.popen(cmd):read('*a'), '\n$', '') if name == nil or #name == 0 then return config.directory .. suggested_filename end return config.directory .. name end local function clip(prompt) local output_filename = get_output_filename(prompt) mp.commandv("screenshot-to-file", output_filename) end local function clip_prompt() clip(true) end local function clip_noprompt() clip(false) end mp.add_key_binding("Alt+S", clip_prompt) mp.add_key_binding("Alt+s", clip_noprompt)