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
+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;
}
}