clip history

This commit is contained in:
Venelin Dechkov
2026-07-30 11:54:49 +03:00
parent a4385c8858
commit ef7e66f609
3 changed files with 28 additions and 22 deletions
+5 -3
View File
@@ -72,6 +72,7 @@ static const Layout layouts[] = {
// static const char *dmenucmd[] = { "dmenu_run", "-m", dmenumon, "-fn", dmenufont, "-nb", col_gray1, "-nf", col_gray3, "-sb", col_cyan, "-sf", col_gray4, NULL };
static const char* dmenucmd[] = { "dmenu_run", "-fn", "monospace:size=14", NULL };
static const char* termcmd[] = { "st", NULL };
static const char* simulate_mmb[] = { "xdotool", "click", "--delay", "0", "--clearmodifiers", "2", NULL };
#if HAS_SW_BACKLIGHT
static const char* bright_up[] = { "brightnessctl", "s", "-q", "1%+", NULL };
static const char* bright_down[] = { "brightnessctl", "s", "-q", "1%-", NULL };
@@ -83,9 +84,10 @@ static void webbookmark(const Arg* unused){
static const Key keys[] = {
/* modifier key function argument */
{ MODKEY|ShiftMask, XK_s, vene_screenshot, {0} }, // Take a screenshot, located in ~/screenshots and in clipboard
{ ShiftMask, XK_Insert, vene_paste_sel, {0} }, // Paste what the mouse selection
{ 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, XK_v, vene_clip_history,{0} }, // Clip history
{ ShiftMask, XK_Insert, spawn, { .v = simulate_mmb } }, // Paste what the mouse selection by simulating a MMB click
{ 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} },
+22 -18
View File
@@ -14,9 +14,11 @@ extern "C"
#include "slstatus/slstatus.h"
}
#define DMENU_ARGS "-b", "-f", "-i", "-l", "30", "-fn", "monospace:size=14"
using namespace std;
using namespace std::chrono;
using namespace std::chrono_literals;
using namespace std::literals;
namespace fs = std::filesystem;
char* HOME;
@@ -234,7 +236,7 @@ extern "C"
new_stat += (timeinfo->tm_min/10) + '0';
new_stat += (timeinfo->tm_min%10) + '0';
strcpy(status, new_stat.c_str());
strcpy(status, new_stat.c_str()); // todo: write directly to status
}
void vene_run() // update status bar every 5 sec
@@ -264,16 +266,21 @@ extern "C"
{
Cmd scrot("scrot", "-s", "-");
Cmd tee("tee", SCREEN_CAPS_DIR);
Cmd xclip("xclip", "-selection", "clipboard", "-t", "image/png");
scrot | tee | xclip; // todo: cppipe < string
Cmd to_clip("xclip", "-selection", "clipboard", "-t", "image/png");
scrot | tee | to_clip; // todo: cppipe < string
}
void vene_paste_sel(const Arg*)
void vene_clip_history(const Arg*)
{
Cmd xclip("xclip", "-selection", "primary", "-o");
Cmd xdotool("xdotool", "click", "--delay", "0", "--clearmodifiers", "2");
Cmd clipmenu("clipmenu", DMENU_ARGS);
Cmd get_clip("xclip", "-o");
Cmd xdotool("xdotool", "type", "--delay", "0", "--clearmodifiers");
xclip | xdotool;
// Select a history entry and put to clip
clipmenu();
// Simulate keyboard input
run(xdotool + $(get_clip).c_str());
}
void vene_browser(const Arg* browser_tag)
@@ -298,13 +305,11 @@ extern "C"
void vene_webbookmark() // todo: cppipe exceptions
{
Cmd dmenu( "dmenu", "-b", "-f", "-i", "-l", "30", "-fn", "monospace:size=14");
Cmd dmenu( "dmenu", DMENU_ARGS);
string bm_root (HOME);
bm_root += "/sync/bookmarks/web/";
string bm_root = HOME + "/sync/bookmarks/web/"s;
Cmd list_dirs ("ls");
list_dirs += bm_root.c_str();
Cmd list_dirs ("ls", bm_root.c_str());
while(true)
{
@@ -315,17 +320,16 @@ extern "C"
string bm_dir = bm_root + dir;
// Choose bookmark
// Read content of bookmarks file and choose
string link = $(dmenu < bm_dir.c_str());
// Extract link
size_t link_begin = link.find('-');
if(link_begin != string::npos)
{
// Extract link
Cmd open_bookmark("apulse", BROWSER);
link = link.substr(link_begin+1);
open_bookmark += link.c_str();
detach(open_bookmark);
detach(open_bookmark +
(link.c_str() + 1)); // skip -
break;
}
}
+1 -1
View File
@@ -16,7 +16,7 @@ void vene_updatestatus(char status[]);
void vene_run();
void vene_screenshot(const Arg*);
void vene_paste_sel(const Arg*);
void vene_clip_history(const Arg*);
void vene_browser(const Arg*);
void vene_webbookmark();
void vene_inc_vol(const Arg*);