web bookmarks
This commit is contained in:
@@ -32,7 +32,7 @@ static const Rule rules[] = {
|
|||||||
* WM_NAME(STRING) = title
|
* WM_NAME(STRING) = title
|
||||||
*/
|
*/
|
||||||
/* class instance title tags mask isfloating monitor */
|
/* 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 }
|
{ 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){
|
static void webbookmark(const Arg* arg){
|
||||||
const Arg tag = {.ui = 1<<7};
|
const Arg tag = {.ui = 1<<7};
|
||||||
view(&tag);
|
/* view(&tag); */
|
||||||
vene_webbookmark();
|
vene_webbookmark();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -113,7 +113,9 @@ static const Key keys[] = {
|
|||||||
TAGKEYS( XK_5, 4)
|
TAGKEYS( XK_5, 4)
|
||||||
TAGKEYS( XK_6, 5)
|
TAGKEYS( XK_6, 5)
|
||||||
TAGKEYS( XK_7, 6)
|
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)
|
TAGKEYS_NO_MOVE( XK_e, 8)
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -224,7 +224,7 @@ void updatestatus(void);
|
|||||||
static void updatetitle(Client *c);
|
static void updatetitle(Client *c);
|
||||||
static void updatewindowtype(Client *c);
|
static void updatewindowtype(Client *c);
|
||||||
static void updatewmhints(Client *c);
|
static void updatewmhints(Client *c);
|
||||||
static void view(const Arg *arg);
|
void view(const Arg *arg);
|
||||||
static Client *wintoclient(Window w);
|
static Client *wintoclient(Window w);
|
||||||
static Monitor *wintomon(Window w);
|
static Monitor *wintomon(Window w);
|
||||||
static int xerror(Display *dpy, XErrorEvent *ee);
|
static int xerror(Display *dpy, XErrorEvent *ee);
|
||||||
|
|||||||
@@ -4,6 +4,7 @@
|
|||||||
#include <fstream>
|
#include <fstream>
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <chrono>
|
#include <chrono>
|
||||||
|
#include <filesystem>
|
||||||
#include <cppipe/commands.hpp>
|
#include <cppipe/commands.hpp>
|
||||||
// #include "vene.h"
|
// #include "vene.h"
|
||||||
#include "vene_env.h"
|
#include "vene_env.h"
|
||||||
@@ -11,6 +12,7 @@
|
|||||||
using namespace std;
|
using namespace std;
|
||||||
using namespace std::chrono;
|
using namespace std::chrono;
|
||||||
using namespace std::chrono_literals;
|
using namespace std::chrono_literals;
|
||||||
|
namespace fs = std::filesystem;
|
||||||
|
|
||||||
char* HOME;
|
char* HOME;
|
||||||
char SCREEN_CAPS_DIR[64];
|
char SCREEN_CAPS_DIR[64];
|
||||||
@@ -20,6 +22,7 @@ namespace
|
|||||||
time_point<system_clock> next_update;
|
time_point<system_clock> next_update;
|
||||||
bool has_child;
|
bool has_child;
|
||||||
Proc child;
|
Proc child;
|
||||||
|
Proc browser = {.pid = 0};
|
||||||
}
|
}
|
||||||
|
|
||||||
extern "C"
|
extern "C"
|
||||||
@@ -32,6 +35,7 @@ extern "C"
|
|||||||
const void *v;
|
const void *v;
|
||||||
} Arg;
|
} Arg;
|
||||||
void updatestatus();
|
void updatestatus();
|
||||||
|
void view(const Arg* arg);
|
||||||
// end
|
// end
|
||||||
|
|
||||||
void vene_setup()
|
void vene_setup()
|
||||||
@@ -111,38 +115,59 @@ extern "C"
|
|||||||
}
|
}
|
||||||
else if(now > next_update)
|
else if(now > next_update)
|
||||||
{
|
{
|
||||||
// Clean up all zombies
|
|
||||||
while (waitpid(-1, nullptr, WNOHANG) > 0);
|
|
||||||
|
|
||||||
updatestatus();
|
updatestatus();
|
||||||
next_update = now + 10s;
|
next_update = now + 10s;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void vene_webbookmark()
|
void vene_browser(const Arg* arg)
|
||||||
{
|
{
|
||||||
using std::string;
|
if( browser.pid == 0 || check_exited(browser) ) // not running
|
||||||
Cmd dmenu( "dmenu", "-f", "-b", "-l", "30");
|
{
|
||||||
|
browser = Cmd(BROWSER).detach();
|
||||||
|
|
||||||
string bookmark (HOME);
|
// Clean up all zombies
|
||||||
bookmark += "/sync/bookmarks/web/";
|
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");
|
Cmd list_dirs ("ls");
|
||||||
list_dirs += bookmark.c_str();
|
list_dirs += bm_root.c_str();
|
||||||
|
|
||||||
|
while(true)
|
||||||
|
{
|
||||||
// Choose bookmark directory
|
// Choose bookmark directory
|
||||||
bookmark += $(list_dirs | dmenu);
|
string dir = $(list_dirs | dmenu);
|
||||||
bookmark.pop_back(); // remove trailing newline
|
if( dir.empty() )
|
||||||
// Choose bookmark
|
return;
|
||||||
string link =$(dmenu < bookmark.c_str());
|
|
||||||
|
|
||||||
size_t link_begin = link.find('-') + 1;
|
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)
|
if(link_begin != string::npos)
|
||||||
{
|
{
|
||||||
Cmd open_bookmark(BROWSER);
|
Cmd open_bookmark(BROWSER);
|
||||||
link = link.substr(link_begin);
|
link = link.substr(link_begin+1);
|
||||||
open_bookmark += link.c_str();
|
open_bookmark += link.c_str();
|
||||||
open_bookmark.detach();
|
open_bookmark.detach();
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -15,6 +15,7 @@ void vene_setup();
|
|||||||
void vene_updatestatus(char status[]);
|
void vene_updatestatus(char status[]);
|
||||||
void vene_run();
|
void vene_run();
|
||||||
|
|
||||||
|
void vene_browser(const Arg*);
|
||||||
void vene_webbookmark();
|
void vene_webbookmark();
|
||||||
void vene_inc_vol(const Arg*);
|
void vene_inc_vol(const Arg*);
|
||||||
void vene_dec_vol(const Arg*);
|
void vene_dec_vol(const Arg*);
|
||||||
|
|||||||
Reference in New Issue
Block a user