From 47306a4169b1cb10aee30f610571abd8fe239653 Mon Sep 17 00:00:00 2001 From: Venelin Date: Sat, 7 Sep 2024 12:10:38 +0300 Subject: [PATCH] screenshot to clip --- config.h | 5 ++--- vene.cpp | 8 ++++++++ vene.h | 1 + 3 files changed, 11 insertions(+), 3 deletions(-) diff --git a/config.h b/config.h index 6a17ee4..8c71a69 100644 --- a/config.h +++ b/config.h @@ -68,7 +68,6 @@ static const Layout layouts[] = { // static const char* dmenucmd[] = { "dmenu_run", "-fn", dmenufont, "-nb", col_gray1, "-nf", col_gray3, "-sb", col_cyan, "-sf", col_gray4, NULL }; static const char* dmenucmd[] = { "dmenu_run", NULL }; static const char* termcmd[] = { "st", NULL }; -static const char* screenshot [] = { "scrot", "-s", SCREEN_CAPS_DIR, NULL }; #if HAS_SW_BACKLIGHT static const char* bright_up[] = { "brightnessctl", "s", "-q", "3%+", NULL }; static const char* bright_down[] = { "brightnessctl", "s", "-q", "3%-", NULL }; @@ -80,8 +79,8 @@ static void webbookmark(const Arg* unused){ static const Key keys[] = { /* modifier key function argument */ - { MODKEY|ShiftMask, XK_s, spawn, {.v = screenshot } }, //Take a screenshot - { MODKEY|ShiftMask, XK_b, webbookmark, {0} }, //Open a web bookmark + { MODKEY|ShiftMask, XK_s, vene_screenshot, {0} }, // Take a screenshot, located in ~/screenshots and in clipboard + { MODKEY|ShiftMask, XK_b, webbookmark, {0} }, // Open a web bookmark { 0, XF86XK_AudioRaiseVolume, vene_inc_vol, {0} }, { 0, XF86XK_AudioLowerVolume, vene_dec_vol, {0} }, { 0, XF86XK_AudioMute, vene_toggle_vol, {0} }, diff --git a/vene.cpp b/vene.cpp index 69181ee..1065d66 100644 --- a/vene.cpp +++ b/vene.cpp @@ -248,6 +248,14 @@ extern "C" } } + void vene_screenshot(const Arg*) + { + Cmd scrot("scrot", "-s"); + Cmd tee("tee", SCREEN_CAPS_DIR); + Cmd xclip("xclip", "-selection", "clipboard", "-t", "image/png"); + scrot | tee | xclip; // todo: cppipe < string + } + void vene_browser(const Arg* browser_tag) { bool browser_tag_used = false; diff --git a/vene.h b/vene.h index 46daaf7..4912ed1 100644 --- a/vene.h +++ b/vene.h @@ -15,6 +15,7 @@ void vene_setup(); void vene_updatestatus(char status[]); void vene_run(); +void vene_screenshot(const Arg*); void vene_browser(const Arg*); void vene_webbookmark(); void vene_inc_vol(const Arg*);