Skip to content

Do something after screenshot #15971

Closed Answered by barraIhsan
barraIhsan asked this question in Q&A
Discussion options

You must be logged in to vote

And now it's on lua

require("mp")

local function screenshot(flag)
	return function()
		-- take a screenshot based on the flags
		-- and store the path into a variable
		local filename = mp.command_native({ "screenshot", flag }).filename
		mp.osd_message("Screenshot (" .. flag .. ") taken")

		-- do the following action only if the platform is linux
		-- 1. copy to clipboard using wl-copy or xclip
		-- 2. add xattr to the file ("mpv" tag, where and when the
		-- screenshot was taken in the comment)
		if mp.get_property("platform") == "linux" then
			-- copy to clipboard
			if os.getenv("XDG_SESSION_TYPE") == "wayland" then
				os.execute("wl-copy < " .. filename)
			else
				os.execute("x…

Replies: 2 comments 9 replies

Comment options

You must be logged in to vote
8 replies
@barraIhsan
Comment options

@kasper93
Comment options

kasper93 Mar 4, 2025
Collaborator

@barraIhsan
Comment options

@kasper93
Comment options

kasper93 Mar 4, 2025
Collaborator

@barraIhsan
Comment options

Comment options

You must be logged in to vote
1 reply
@barraIhsan
Comment options

Answer selected by barraIhsan
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
4 participants