vene files and dwm changes
This commit is contained in:
@@ -16,8 +16,9 @@ ${OBJ}: config.h config.mk
|
||||
config.h:
|
||||
cp config.def.h $@
|
||||
|
||||
dwm: ${OBJ}
|
||||
${CC} -o $@ ${OBJ} ${LDFLAGS}
|
||||
dwm: ${OBJ} vene.cpp
|
||||
c++ -c ${CPPFLAGS} -std=c++17 vene.cpp
|
||||
${CC} -o $@ ${OBJ} vene.o ${LDFLAGS} -lstdc++
|
||||
|
||||
clean:
|
||||
rm -f dwm ${OBJ} dwm-${VERSION}.tar.gz
|
||||
|
||||
@@ -7,7 +7,7 @@ static const unsigned int borderpx = 1; /* border pixel of windows */
|
||||
static const unsigned int snap = 32; /* snap pixel */
|
||||
static const int showbar = 1; /* 0 means no bar */
|
||||
static const int topbar = 1; /* 0 means bottom bar */
|
||||
static const char* fonts[] = { "monospace:size=10" }; //todo:, "NotoColorEmoji:pixelsize=10:antialias=true:autohint=true"
|
||||
static const char* fonts[] = { "monospace:size=13" }; //todo:, "NotoColorEmoji:pixelsize=10:antialias=true:autohint=true"
|
||||
//static const char* fonts[] = { "monospace:size=10", "NotoColorEmoji:pixelsize=10:antialias=true:autohint=true" };
|
||||
//static const char* fonts[] = { "monospace:size=10", "NotoColorEmoji:pixelsize=10:autohint=true" };
|
||||
/* static const char dmenufont[] = "monospace:size=10"; */
|
||||
@@ -39,7 +39,7 @@ static const Rule rules[] = {
|
||||
/* layout(s) */
|
||||
static const float mfact = 0.55; /* factor of master area size [0.05..0.95] */
|
||||
static const int nmaster = 1; /* number of clients in master area */
|
||||
static const int resizehints = 1; /* 1 means respect size hints in tiled resizals */
|
||||
static const int resizehints = 0; /* 1 means respect size hints in tiled resizals */
|
||||
static const int lockfullscreen = 1; /* 1 will force focus on the fullscreen window */
|
||||
|
||||
static const Layout layouts[] = {
|
||||
@@ -69,9 +69,6 @@ static const Layout layouts[] = {
|
||||
static const char* dmenucmd[] = { "dmenu_run", NULL };
|
||||
static const char* termcmd[] = { "st", NULL };
|
||||
static const char* screenshot [] = { "scrot", "-s", SCREEN_CAPS_DIR, NULL };
|
||||
static const char* inc_vol [] = { "amixer", "set", "Master", "3%+", NULL };
|
||||
static const char* dec_vol [] = { "amixer", "set", "Master", "3%-", NULL };
|
||||
static const char* mute_vol[] = { "amixer", "set", "Master", "toggle", NULL };
|
||||
|
||||
static void webbookmark(const Arg* arg){
|
||||
const Arg tag = {.ui = 1<<7};
|
||||
@@ -79,18 +76,16 @@ static void webbookmark(const Arg* arg){
|
||||
vene_webbookmark();
|
||||
}
|
||||
|
||||
|
||||
static const Key keys[] = {
|
||||
/* modifier key function argument */
|
||||
// { MODKEY|ShiftMask, XK_b, spawn, {.v = browser } }, //Open browser
|
||||
{ MODKEY|ShiftMask, XK_s, spawn, {.v = screenshot } }, //Take a screenshot
|
||||
{ MODKEY|ShiftMask, XK_b, webbookmark, {0} }, //Open a web bookmark
|
||||
{ 0, XF86XK_AudioRaiseVolume, spawn, {.v = inc_vol } },
|
||||
{ 0, XF86XK_AudioLowerVolume, spawn, {.v = dec_vol } },
|
||||
{ 0, XF86XK_AudioMute, spawn, {.v = mute_vol } },
|
||||
{ 0, XF86XK_AudioRaiseVolume, vene_inc_vol, {0 } },
|
||||
{ 0, XF86XK_AudioLowerVolume, vene_dec_vol, {0 } },
|
||||
{ 0, XF86XK_AudioMute, vene_toggle_vol, {0 } },
|
||||
{ MODKEY, XK_p, spawn, {.v = dmenucmd } },
|
||||
{ MODKEY|ShiftMask, XK_Return, spawn, {.v = termcmd } },
|
||||
{ MODKEY, XK_s, togglebar, {0} }, //Togglebar
|
||||
{ MODKEY, XK_s, togglebar, {0} },
|
||||
{ MODKEY, XK_j, focusstack, {.i = +1 } },
|
||||
{ MODKEY, XK_k, focusstack, {.i = -1 } },
|
||||
{ MODKEY, XK_i, incnmaster, {.i = +1 } },
|
||||
@@ -120,7 +115,6 @@ static const Key keys[] = {
|
||||
TAGKEYS( XK_7, 6)
|
||||
TAGKEYS_NO_MOVE( XK_b, 7)
|
||||
TAGKEYS_NO_MOVE( XK_e, 8)
|
||||
{ MODKEY|ShiftMask, XK_q, quit, {0} },
|
||||
};
|
||||
|
||||
/* button definitions */
|
||||
|
||||
@@ -11,8 +11,8 @@ X11INC = /usr/X11R6/include
|
||||
X11LIB = /usr/X11R6/lib
|
||||
|
||||
# Xinerama, comment if you don't want it
|
||||
XINERAMALIBS = -lXinerama
|
||||
XINERAMAFLAGS = -DXINERAMA
|
||||
# XINERAMALIBS = -lXinerama
|
||||
# XINERAMAFLAGS = -DXINERAMA
|
||||
|
||||
# freetype
|
||||
FREETYPELIBS = -lfontconfig -lXft
|
||||
@@ -26,10 +26,10 @@ INCS = -I${X11INC} -I${FREETYPEINC}
|
||||
LIBS = -L${X11LIB} -lX11 ${XINERAMALIBS} ${FREETYPELIBS}
|
||||
|
||||
# flags
|
||||
CPPFLAGS = -D_DEFAULT_SOURCE -D_BSD_SOURCE -D_XOPEN_SOURCE=700L -DVERSION=\"${VERSION}\" ${XINERAMAFLAGS}
|
||||
CPPFLAGS = -D_DEFAULT_SOURCE -D_BSD_SOURCE -D_XOPEN_SOURCE=700L -DVERSION=\"${VERSION}\" ${XINERAMAFLAGS} -Wall -Ofast -march=native -fno-semantic-interposition -flto
|
||||
#CFLAGS = -g -std=c99 -pedantic -Wall -O0 ${INCS} ${CPPFLAGS}
|
||||
CFLAGS = -std=c99 -pedantic -Wall -Wno-deprecated-declarations -Os ${INCS} ${CPPFLAGS}
|
||||
LDFLAGS = ${LIBS}
|
||||
CFLAGS = -std=c99 -pedantic -Wno-deprecated-declarations ${INCS} ${CPPFLAGS}
|
||||
LDFLAGS = -flto -s ${LIBS}
|
||||
|
||||
# Solaris
|
||||
#CFLAGS = -fast ${INCS} -DVERSION=\"${VERSION}\"
|
||||
|
||||
@@ -186,7 +186,6 @@ static void movemouse(const Arg *arg);
|
||||
static Client *nexttiled(Client *c);
|
||||
static void pop(Client *c);
|
||||
static void propertynotify(XEvent *e);
|
||||
static void quit(const Arg *arg);
|
||||
static Monitor *recttomon(int x, int y, int w, int h);
|
||||
static void resize(Client *c, int x, int y, int w, int h, int interact);
|
||||
static void resizeclient(Client *c, int x, int y, int w, int h);
|
||||
@@ -221,11 +220,11 @@ static void updateclientlist(void);
|
||||
static int updategeom(void);
|
||||
static void updatenumlockmask(void);
|
||||
static void updatesizehints(Client *c);
|
||||
static void updatestatus(void);
|
||||
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);
|
||||
@@ -259,7 +258,6 @@ static void (*handler[LASTEvent]) (XEvent *) = {
|
||||
[UnmapNotify] = unmapnotify
|
||||
};
|
||||
static Atom wmatom[WMLast], netatom[NetLast];
|
||||
static int running = 1;
|
||||
static Cur *cursor[CurLast];
|
||||
static Clr **scheme;
|
||||
static Display *dpy;
|
||||
@@ -268,6 +266,7 @@ static Monitor *mons, *selmon;
|
||||
static Window root, wmcheckwin;
|
||||
|
||||
/* configuration, allows nested code to access above variables */
|
||||
#include "vene.h"
|
||||
#include "config.h"
|
||||
|
||||
/* compile-time check if all tags fit into an unsigned int bit array. */
|
||||
@@ -527,6 +526,9 @@ clientmessage(XEvent *e)
|
||||
} else if (cme->message_type == netatom[NetActiveWindow]) {
|
||||
if (c != selmon->sel && !c->isurgent)
|
||||
seturgent(c, 1);
|
||||
|
||||
const Arg tag = {.ui = c->tags}; /* switch to show highlighted window*/
|
||||
view(&tag);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1225,9 +1227,8 @@ propertynotify(XEvent *e)
|
||||
Window trans;
|
||||
XPropertyEvent *ev = &e->xproperty;
|
||||
|
||||
if ((ev->window == root) && (ev->atom == XA_WM_NAME))
|
||||
updatestatus();
|
||||
else if (ev->state == PropertyDelete)
|
||||
|
||||
if (ev->state == PropertyDelete)
|
||||
return; /* ignore */
|
||||
else if ((c = wintoclient(ev->window))) {
|
||||
switch(ev->atom) {
|
||||
@@ -1255,12 +1256,6 @@ propertynotify(XEvent *e)
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
quit(const Arg *arg)
|
||||
{
|
||||
running = 0;
|
||||
}
|
||||
|
||||
Monitor *
|
||||
recttomon(int x, int y, int w, int h)
|
||||
{
|
||||
@@ -1385,9 +1380,13 @@ run(void)
|
||||
XEvent ev;
|
||||
/* main event loop */
|
||||
XSync(dpy, False);
|
||||
while (running && !XNextEvent(dpy, &ev))
|
||||
while (!XNextEvent(dpy, &ev))
|
||||
{
|
||||
if (handler[ev.type])
|
||||
handler[ev.type](&ev); /* call handler */
|
||||
|
||||
vene_run();
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
@@ -1539,6 +1538,8 @@ setmfact(const Arg *arg)
|
||||
void
|
||||
setup(void)
|
||||
{
|
||||
vene_setup();
|
||||
|
||||
int i;
|
||||
XSetWindowAttributes wa;
|
||||
Atom utf8string;
|
||||
@@ -1649,8 +1650,6 @@ spawn(const Arg *arg)
|
||||
{
|
||||
struct sigaction sa;
|
||||
|
||||
if (arg->v == dmenucmd)
|
||||
dmenumon[0] = '0' + selmon->num;
|
||||
if (fork() == 0) {
|
||||
if (dpy)
|
||||
close(ConnectionNumber(dpy));
|
||||
@@ -1662,7 +1661,6 @@ spawn(const Arg *arg)
|
||||
sigaction(SIGCHLD, &sa, NULL);
|
||||
|
||||
execvp(((char **)arg->v)[0], (char **)arg->v);
|
||||
die("dwm: execvp '%s' failed:", ((char **)arg->v)[0]);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2005,8 +2003,8 @@ updatesizehints(Client *c)
|
||||
void
|
||||
updatestatus(void)
|
||||
{
|
||||
if (!gettextprop(root, XA_WM_NAME, stext, sizeof(stext)))
|
||||
strcpy(stext, "dwm-"VERSION);
|
||||
vene_updatestatus(stext);
|
||||
|
||||
drawbar(selmon);
|
||||
}
|
||||
|
||||
@@ -2143,10 +2141,6 @@ zoom(const Arg *arg)
|
||||
int
|
||||
main(int argc, char *argv[])
|
||||
{
|
||||
if (argc == 2 && !strcmp("-v", argv[1]))
|
||||
die("dwm-"VERSION);
|
||||
else if (argc != 1)
|
||||
die("usage: dwm [-v]");
|
||||
if (!setlocale(LC_CTYPE, "") || !XSupportsLocale())
|
||||
fputs("warning: no locale support\n", stderr);
|
||||
if (!(dpy = XOpenDisplay(NULL)))
|
||||
|
||||
@@ -0,0 +1,161 @@
|
||||
#include <time.h>
|
||||
#include <cstring>
|
||||
#include <cstdlib>
|
||||
#include <string>
|
||||
#include <chrono>
|
||||
#include <cppipe/commands.hpp>
|
||||
// #include "vene.h"
|
||||
#include "vene_env.h"
|
||||
|
||||
using namespace std;
|
||||
using namespace std::chrono;
|
||||
using namespace std::chrono_literals;
|
||||
|
||||
char* HOME;
|
||||
char SCREEN_CAPS_DIR[64];
|
||||
|
||||
namespace
|
||||
{
|
||||
time_point<system_clock> next_update;
|
||||
void schedule_update()
|
||||
{
|
||||
next_update = system_clock::now() + 100ms;
|
||||
}
|
||||
}
|
||||
|
||||
extern "C"
|
||||
{
|
||||
// from dwm
|
||||
typedef union {
|
||||
int i;
|
||||
unsigned int ui;
|
||||
float f;
|
||||
const void *v;
|
||||
} Arg;
|
||||
void updatestatus();
|
||||
// end
|
||||
|
||||
void vene_setup()
|
||||
{
|
||||
// Init vars
|
||||
HOME = getenv("HOME");
|
||||
|
||||
strcpy(SCREEN_CAPS_DIR, HOME);
|
||||
strcat(SCREEN_CAPS_DIR, "/screen_caps/");
|
||||
|
||||
// Signal handlers
|
||||
// signal(SIGRTMIN, goto_tag);
|
||||
|
||||
// strcpy(BOOKMARK_DIR, HOME);
|
||||
// strcat(BOOKMARK_DIR, "/notes/bookmarks/web");
|
||||
|
||||
// sprintf(OPEN_BOOKMARK_CMD, "xdg-open $(dmenumap ~/notes/bookmarks/web/$(ls %s | dmenu "DMENU_OPTS") "DMENU_OPTS")", BOOKMARK_DIR);
|
||||
// strcpy(OPEN_BOOKMARK_CMD, "xdg-open $(dmenumap "DMENU_OPTS" ~/notes/bookmarks/web/$(ls ");
|
||||
// strcat(OPEN_BOOKMARK_CMD, BOOKMARK_DIR);
|
||||
// strcat(OPEN_BOOKMARK_CMD, " | dmenu "DMENU_OPTS);
|
||||
|
||||
}
|
||||
|
||||
void vene_updatestatus(char status[])
|
||||
{
|
||||
using std::string;
|
||||
static string new_stat;
|
||||
new_stat.clear();
|
||||
|
||||
// Volume
|
||||
string amix_out = $(Cmd("amixer", "get", AUDIO_DEV));
|
||||
size_t bracket = amix_out.find('[');
|
||||
|
||||
if(bracket != string::npos)
|
||||
{
|
||||
bool is_muted = amix_out.find("[on]") == string::npos;
|
||||
new_stat += is_muted ? "🔇" : "🔉";
|
||||
|
||||
new_stat += amix_out[bracket+1];
|
||||
if(char second = amix_out[bracket+2]; second != '%')
|
||||
new_stat += second;
|
||||
if(char third = amix_out[bracket+3]; third != '%')
|
||||
new_stat += third;
|
||||
|
||||
new_stat += '%';
|
||||
|
||||
}
|
||||
new_stat += ' ';
|
||||
|
||||
// Time
|
||||
time_t rawtime;
|
||||
struct tm * timeinfo;
|
||||
time ( &rawtime );
|
||||
timeinfo = localtime ( &rawtime );
|
||||
|
||||
new_stat += (timeinfo->tm_hour/10) + '0';
|
||||
new_stat += (timeinfo->tm_hour%10) + '0';
|
||||
new_stat += ':';
|
||||
new_stat += (timeinfo->tm_min/10) + '0';
|
||||
new_stat += (timeinfo->tm_min%10) + '0';
|
||||
|
||||
strcpy(status, new_stat.c_str());
|
||||
}
|
||||
|
||||
void vene_run() // update status bar every 5 sec
|
||||
{
|
||||
|
||||
time_point<system_clock> now = system_clock::now();
|
||||
if(now > next_update)
|
||||
{
|
||||
next_update = now + 5s;
|
||||
updatestatus();
|
||||
}
|
||||
}
|
||||
|
||||
void vene_webbookmark()
|
||||
{
|
||||
using std::string;
|
||||
Cmd dmenu( "dmenu", "-f", "-b", "-l", "30");
|
||||
|
||||
string bookmark (HOME);
|
||||
bookmark += "/sync/bookmarks/web/";
|
||||
|
||||
Cmd list_dirs ("ls");
|
||||
list_dirs += bookmark.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)
|
||||
{
|
||||
Cmd open_bookmark(BROWSER);
|
||||
link = link.substr(link_begin);
|
||||
open_bookmark += link.c_str();
|
||||
open_bookmark.detach();
|
||||
}
|
||||
}
|
||||
|
||||
void vene_inc_vol(const Arg*)
|
||||
{
|
||||
Cmd inc_vol("amixer", "set", AUDIO_DEV, "3%+");
|
||||
inc_vol.detach();
|
||||
|
||||
schedule_update();
|
||||
}
|
||||
|
||||
void vene_dec_vol(const Arg*)
|
||||
{
|
||||
Cmd dec_vol("amixer", "set", AUDIO_DEV, "3%-");
|
||||
dec_vol.detach();
|
||||
|
||||
schedule_update();
|
||||
}
|
||||
|
||||
void vene_toggle_vol(const Arg*)
|
||||
{
|
||||
Cmd toggle_vol("amixer", "set", AUDIO_DEV, "toggle");
|
||||
toggle_vol.detach();
|
||||
|
||||
schedule_update();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
#pragma once
|
||||
// Vene stuff used by dwm
|
||||
|
||||
// extern char* HOME;
|
||||
extern char SCREEN_CAPS_DIR[64];
|
||||
// extern char BOOKMARK_DIR[64];
|
||||
// extern char OPEN_BOOKMARK_CMD[128];
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
{
|
||||
#endif
|
||||
|
||||
void vene_setup();
|
||||
void vene_updatestatus(char status[]);
|
||||
void vene_run();
|
||||
|
||||
void vene_webbookmark();
|
||||
void vene_inc_vol(const Arg*);
|
||||
void vene_dec_vol(const Arg*);
|
||||
void vene_toggle_vol(const Arg*);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
Reference in New Issue
Block a user