diff --git a/config.h b/config.h index bcef069..a0d9032 100644 --- a/config.h +++ b/config.h @@ -44,6 +44,7 @@ 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 = 0; /* 1 means respect size hints in tiled resizals */ static const int lockfullscreen = 1; /* 1 will force focus on the fullscreen window */ +static const int refreshrate = 60; /* refresh rate (per second) for client move/resize */ static const Layout layouts[] = { /* symbol arrange function */ @@ -88,6 +89,7 @@ static const Key keys[] = { { 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 + { MODKEY, XK_z, vene_zzz, {0} }, // Sleep { 0, XF86XK_AudioRaiseVolume, vene_inc_vol, {0} }, { 0, XF86XK_AudioLowerVolume, vene_dec_vol, {0} }, { 0, XF86XK_AudioMute, vene_toggle_vol, {0} }, diff --git a/dwm.c b/dwm.c index feaf4e0..3f9115d 100644 --- a/dwm.c +++ b/dwm.c @@ -1384,10 +1384,41 @@ run(void) XEvent ev; /* main event loop */ XSync(dpy, False); - while (!XNextEvent(dpy, &ev)) + + int display_fd = ConnectionNumber(dpy); + + while (1) { - if (handler[ev.type]) - handler[ev.type](&ev); /* call handler */ + // Wait until there is an XEvent + fd_set waited_read_fds; + FD_ZERO(&waited_read_fds); + FD_SET(display_fd, &waited_read_fds); + + struct timeval tv; + tv.tv_sec = 60; + tv.tv_usec = 0; + + int fds_ready_count = select(display_fd + 1, &waited_read_fds, NULL, NULL, &tv); + + if(fds_ready_count > 0) + { + // Event pending + while(XPending(dpy)) + { + XNextEvent(dpy, &ev); + + if (handler[ev.type]) + handler[ev.type](&ev); /* call handler */ + } + } + else if(fds_ready_count == 0) + { + // timeout + } + else + { + // error + } vene_run(); } diff --git a/vene.cpp b/vene.cpp index 8964365..8050282 100644 --- a/vene.cpp +++ b/vene.cpp @@ -8,7 +8,7 @@ #include #include // #include "vene.h" -#include "vene_env.h" +#include extern "C" { #include "slstatus/slstatus.h" @@ -272,15 +272,13 @@ extern "C" void vene_clip_history(const Arg*) { - Cmd clipmenu("clipmenu", DMENU_ARGS); - Cmd get_clip("xclip", "-o"); - Cmd xdotool("xdotool", "type", "--delay", "0", "--clearmodifiers"); - // Select a history entry and put to clip - clipmenu(); + Cmd clipmenu("clipmenu", DMENU_ARGS); - // Simulate keyboard input - run(xdotool + $(get_clip).c_str()); + // Paste + Cmd xdotool("xdotool", "key", "--delay", "0", "--clearmodifiers", "shift+Insert"); + + clipmenu && xdotool; } void vene_browser(const Arg* browser_tag) @@ -362,4 +360,9 @@ extern "C" child = detach(toggle_mic); has_child = true; } + + void vene_zzz(const Arg*) + { + ofstream("/sys/power/state") << "mem"; + } } diff --git a/vene.h b/vene.h index 8631288..fce1bb7 100644 --- a/vene.h +++ b/vene.h @@ -23,6 +23,7 @@ void vene_inc_vol(const Arg*); void vene_dec_vol(const Arg*); void vene_toggle_vol(const Arg*); void vene_toggle_mic(const Arg*); +void vene_zzz(const Arg*); #ifdef __cplusplus }