From 3bdc58986d2e141a1016a728749551c4e19acaf7 Mon Sep 17 00:00:00 2001 From: Yingjie Wang Date: Mon, 27 Jul 2026 16:34:53 -0400 Subject: [PATCH] new: add screenshot bind --- lua/binds/init.lua | 1 + lua/binds/screenshot.lua | 37 +++++++++++++++++++++++++++++++++++++ 2 files changed, 38 insertions(+) create mode 100644 lua/binds/screenshot.lua diff --git a/lua/binds/init.lua b/lua/binds/init.lua index d0f4405..41b60ce 100644 --- a/lua/binds/init.lua +++ b/lua/binds/init.lua @@ -7,6 +7,7 @@ local pieces = { "window", "workspace", "passthrough", + "screenshot", } M.binds = {} diff --git a/lua/binds/screenshot.lua b/lua/binds/screenshot.lua new file mode 100644 index 0000000..fc388f1 --- /dev/null +++ b/lua/binds/screenshot.lua @@ -0,0 +1,37 @@ +local bind = require("lua.lib.bind") + +local M = {} + +local function screenshot_fullscreen() + local home = os.getenv("HOME") + local dir = home .. "/Pictures/screenshots/" + local name = "screenshot_" .. os.date("%Y%d%m_%H%M%S") .. ".png" + local file = dir .. name + + local monitor = hl.get_active_monitor() + if monitor == nil then + return + end + + hl.exec_cmd( + string.format( + "grim -o %q %q && " .. "wl-copy --type image/png < %q && " .. "notify-send %q %q && " .. "swappy -f %q", + monitor.name, + file, + file, + "Screenshot created and copied to clipboard", + "Mode: Fullscreen", + file + ) + ) +end + +M.binds = { + { + keys = bind.with_leader("SHIFT + Print"), + dispatcher = screenshot_fullscreen, + desc = "Make fullscreen screenshot", + }, +} + +return M