web bookmarks

This commit is contained in:
vrd
2026-07-30 11:54:49 +03:00
committed by Venelin Dechkov
parent 491e29fefa
commit 5b8797bccd
4 changed files with 53 additions and 25 deletions
+5 -3
View File
@@ -32,7 +32,7 @@ static const Rule rules[] = {
* WM_NAME(STRING) = title
*/
/* class instance title tags mask isfloating monitor */
{ NULL, BROWSER, NULL, 1<<7, 0, -1 },
{ BROWSER, NULL, NULL, 1<<7, 0, -1 },
{ NULL, "emacs", NULL, 1<<8, 0, -1 }
};
@@ -72,7 +72,7 @@ static const char* screenshot [] = { "scrot", "-s", SCREEN_CAPS_DIR, NULL };
static void webbookmark(const Arg* arg){
const Arg tag = {.ui = 1<<7};
view(&tag);
/* view(&tag); */
vene_webbookmark();
}
@@ -113,7 +113,9 @@ static const Key keys[] = {
TAGKEYS( XK_5, 4)
TAGKEYS( XK_6, 5)
TAGKEYS( XK_7, 6)
TAGKEYS_NO_MOVE( XK_b, 7)
{ MODKEY, XK_b, vene_browser, {.ui = 1 << 7} },
{ MODKEY|ControlMask, XK_b, toggleview, {.ui = 1 << 7} },
{ MODKEY|ControlMask|ShiftMask, XK_b, toggletag, {.ui = 1 << 7} },
TAGKEYS_NO_MOVE( XK_e, 8)
};
+1 -1
View File
@@ -224,7 +224,7 @@ void updatestatus(void);
static void updatetitle(Client *c);
static void updatewindowtype(Client *c);
static void updatewmhints(Client *c);
static void view(const Arg *arg);
void view(const Arg *arg);
static Client *wintoclient(Window w);
static Monitor *wintomon(Window w);
static int xerror(Display *dpy, XErrorEvent *ee);
+46 -21
View File
@@ -4,6 +4,7 @@
#include <fstream>
#include <string>
#include <chrono>
#include <filesystem>
#include <cppipe/commands.hpp>
// #include "vene.h"
#include "vene_env.h"
@@ -11,6 +12,7 @@
using namespace std;
using namespace std::chrono;
using namespace std::chrono_literals;
namespace fs = std::filesystem;
char* HOME;
char SCREEN_CAPS_DIR[64];
@@ -20,6 +22,7 @@ namespace
time_point<system_clock> next_update;
bool has_child;
Proc child;
Proc browser = {.pid = 0};
}
extern "C"
@@ -32,6 +35,7 @@ extern "C"
const void *v;
} Arg;
void updatestatus();
void view(const Arg* arg);
// end
void vene_setup()
@@ -111,38 +115,59 @@ extern "C"
}
else if(now > next_update)
{
// Clean up all zombies
while (waitpid(-1, nullptr, WNOHANG) > 0);
updatestatus();
next_update = now + 10s;
}
}
void vene_webbookmark()
void vene_browser(const Arg* arg)
{
using std::string;
Cmd dmenu( "dmenu", "-f", "-b", "-l", "30");
if( browser.pid == 0 || check_exited(browser) ) // not running
{
browser = Cmd(BROWSER).detach();
string bookmark (HOME);
bookmark += "/sync/bookmarks/web/";
// Clean up all zombies
while (waitpid(-1, nullptr, WNOHANG) > 0);
}
else // running, view it
{
view(arg);
}
}
void vene_webbookmark() // todo: cppipe exceptions
{
Cmd dmenu( "dmenu", "-b", "-f", "-i", "-l", "30");
string bm_root (HOME);
bm_root += "/sync/bookmarks/web/";
Cmd list_dirs ("ls");
list_dirs += bookmark.c_str();
list_dirs += bm_root.c_str();
// Choose bookmark directory
bookmark += $(list_dirs | dmenu);
bookmark.pop_back(); // remove trailing newline
// Choose bookmark
string link =$(dmenu < bookmark.c_str());
size_t link_begin = link.find('-') + 1;
if(link_begin != string::npos)
while(true)
{
Cmd open_bookmark(BROWSER);
link = link.substr(link_begin);
open_bookmark += link.c_str();
open_bookmark.detach();
// Choose bookmark directory
string dir = $(list_dirs | dmenu);
if( dir.empty() )
return;
string bm_dir = bm_root;
bm_dir += dir;
bm_dir.pop_back(); // remove trailing newline
// Choose bookmark
string link = $(dmenu < bm_dir.c_str());
size_t link_begin = link.find('-');
if(link_begin != string::npos)
{
Cmd open_bookmark(BROWSER);
link = link.substr(link_begin+1);
open_bookmark += link.c_str();
open_bookmark.detach();
break;
}
}
}
+1
View File
@@ -15,6 +15,7 @@ void vene_setup();
void vene_updatestatus(char status[]);
void vene_run();
void vene_browser(const Arg*);
void vene_webbookmark();
void vene_inc_vol(const Arg*);
void vene_dec_vol(const Arg*);