Compare commits
10
Commits
d6202280e9
...
889ecc6eb9
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
889ecc6eb9 | ||
|
|
4a5e539580 | ||
|
|
b275554213 | ||
|
|
07b79c903e | ||
|
|
ef7e66f609 | ||
|
|
a4385c8858 | ||
|
|
efb6df5dc7 | ||
|
|
647cff6727 | ||
|
|
e63ff9f1c4 | ||
|
|
4ad49de088 |
@@ -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 */
|
||||
@@ -72,6 +73,7 @@ static const Layout layouts[] = {
|
||||
// static const char *dmenucmd[] = { "dmenu_run", "-m", dmenumon, "-fn", dmenufont, "-nb", col_gray1, "-nf", col_gray3, "-sb", col_cyan, "-sf", col_gray4, NULL };
|
||||
static const char* dmenucmd[] = { "dmenu_run", "-fn", "monospace:size=14", NULL };
|
||||
static const char* termcmd[] = { "st", NULL };
|
||||
static const char* simulate_mmb[] = { "xdotool", "click", "--delay", "0", "--clearmodifiers", "2", NULL };
|
||||
#if HAS_SW_BACKLIGHT
|
||||
static const char* bright_up[] = { "brightnessctl", "s", "-q", "1%+", NULL };
|
||||
static const char* bright_down[] = { "brightnessctl", "s", "-q", "1%-", NULL };
|
||||
@@ -84,11 +86,14 @@ static void webbookmark(const Arg* unused){
|
||||
static const Key keys[] = {
|
||||
/* modifier key function argument */
|
||||
{ MODKEY|ShiftMask, XK_s, vene_screenshot, {0} }, // Take a screenshot, located in ~/screenshots and in clipboard
|
||||
{ ShiftMask, XK_Insert, vene_paste_sel, {0} }, // Paste what the mouse selection
|
||||
{ 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} },
|
||||
{ 0, XF86XK_AudioMicMute, vene_toggle_mic, {0} },
|
||||
#if HAS_SW_BACKLIGHT
|
||||
{ 0, XF86XK_MonBrightnessUp, spawn, {.v = bright_up } },
|
||||
{ 0, XF86XK_MonBrightnessDown,spawn, {.v = bright_down } },
|
||||
|
||||
@@ -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} -Wall -Ofast -march=native -fno-semantic-interposition -flto ${INCS}
|
||||
CPPFLAGS = -D_DEFAULT_SOURCE -D_BSD_SOURCE -D_XOPEN_SOURCE=700L -DVERSION=\"${VERSION}\" ${XINERAMAFLAGS} -Wall -Ofast -march=native -fno-semantic-interposition -flto=auto ${INCS}
|
||||
#CFLAGS = -g -std=c99 -pedantic -Wall -O0 ${INCS} ${CPPFLAGS}
|
||||
CFLAGS = -std=c99 -pedantic -Wno-deprecated-declarations ${CPPFLAGS}
|
||||
LDFLAGS = -flto -s ${LIBS}
|
||||
LDFLAGS = -flto=auto -s ${LIBS}
|
||||
|
||||
# Solaris
|
||||
#CFLAGS = -fast ${INCS} -DVERSION=\"${VERSION}\"
|
||||
|
||||
@@ -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)
|
||||
{
|
||||
// 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();
|
||||
}
|
||||
@@ -1513,6 +1544,10 @@ setfullscreen(Client *c, int fullscreen)
|
||||
void
|
||||
setlayout(const Arg *arg)
|
||||
{
|
||||
/* Toggle between previous */
|
||||
if(arg && arg->v == selmon->lt[selmon->sellt])
|
||||
arg = NULL;
|
||||
|
||||
if (!arg || !arg->v || arg->v != selmon->lt[selmon->sellt])
|
||||
selmon->sellt ^= 1;
|
||||
if (arg && arg->v)
|
||||
|
||||
@@ -8,15 +8,17 @@
|
||||
#include <cppipe/commands.hpp>
|
||||
#include <X11/X.h>
|
||||
// #include "vene.h"
|
||||
#include "vene_env.h"
|
||||
#include <vene_env.h>
|
||||
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;
|
||||
@@ -28,7 +30,19 @@ namespace
|
||||
bool has_child;
|
||||
Proc child;
|
||||
|
||||
Cmd amixer("amixer");
|
||||
Cmd browser(
|
||||
#if !defined(PULSEAUDIO) && !defined(PIPEWIRE)
|
||||
"apulse",
|
||||
#endif
|
||||
BROWSER);
|
||||
|
||||
Cmd amixer("amixer"
|
||||
#if defined(PULSEAUDIO)
|
||||
,"-Dpulse"
|
||||
#endif
|
||||
);
|
||||
|
||||
Cmd low_battery_notify("notify-send", "--urgency=critical", "Battery Low");
|
||||
}
|
||||
|
||||
extern "C"
|
||||
@@ -176,6 +190,10 @@ extern "C"
|
||||
{
|
||||
new_stat += "🔋";
|
||||
remaining = battery_remaining("BAT0");
|
||||
|
||||
// Low battery warning
|
||||
if(remaining && atoi(charge.c_str()) < 15)
|
||||
run(low_battery_notify); // todo: use lib notify
|
||||
}
|
||||
else
|
||||
new_stat += "🔌";
|
||||
@@ -218,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
|
||||
@@ -248,16 +266,19 @@ 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");
|
||||
// Select a history entry and put to clip
|
||||
Cmd clipmenu("clipmenu", DMENU_ARGS);
|
||||
|
||||
xclip | xdotool;
|
||||
// Paste
|
||||
Cmd xdotool("xdotool", "key", "--delay", "0", "--clearmodifiers", "shift+Insert");
|
||||
|
||||
clipmenu && xdotool;
|
||||
}
|
||||
|
||||
void vene_browser(const Arg* browser_tag)
|
||||
@@ -276,19 +297,17 @@ extern "C"
|
||||
}
|
||||
else // start browser
|
||||
{
|
||||
Cmd(BROWSER).detach();
|
||||
detach(browser);
|
||||
}
|
||||
}
|
||||
|
||||
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)
|
||||
{
|
||||
@@ -299,16 +318,15 @@ extern "C"
|
||||
|
||||
string bm_dir = bm_root + dir;
|
||||
|
||||
// Choose bookmark
|
||||
string link = $(dmenu < bm_dir.c_str());
|
||||
// Read content of bookmarks file and choose
|
||||
string entry = $(dmenu < bm_dir.c_str());
|
||||
|
||||
size_t link_begin = link.find('-');
|
||||
// Extract link
|
||||
size_t link_begin = entry.find('-');
|
||||
if(link_begin != string::npos)
|
||||
{
|
||||
Cmd open_bookmark(BROWSER);
|
||||
link = link.substr(link_begin+1);
|
||||
open_bookmark += link.c_str();
|
||||
open_bookmark.detach();
|
||||
Cmd open_bookmark = browser + (entry.c_str() + link_begin + 1); // skip -
|
||||
detach(open_bookmark);
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -317,21 +335,33 @@ extern "C"
|
||||
void vene_inc_vol(const Arg*)
|
||||
{
|
||||
Cmd inc_vol(amixer + "-q" + "set" + AUDIO_DEV + "3%+");
|
||||
child = inc_vol.detach();
|
||||
child = detach(inc_vol);
|
||||
has_child = true;
|
||||
}
|
||||
|
||||
void vene_dec_vol(const Arg*)
|
||||
{
|
||||
Cmd dec_vol(amixer + "-q" + "set" + AUDIO_DEV + "3%-");
|
||||
child = dec_vol.detach();
|
||||
child = detach(dec_vol);
|
||||
has_child = true;
|
||||
}
|
||||
|
||||
void vene_toggle_vol(const Arg*)
|
||||
{
|
||||
Cmd toggle_vol(amixer + "-q" + "set" + AUDIO_DEV + "toggle");
|
||||
child = toggle_vol.detach();
|
||||
child = detach(toggle_vol);
|
||||
has_child = true;
|
||||
}
|
||||
|
||||
void vene_toggle_mic(const Arg*)
|
||||
{
|
||||
Cmd toggle_mic(amixer + "-q" + "set" + "Capture" + "toggle");
|
||||
child = detach(toggle_mic);
|
||||
has_child = true;
|
||||
}
|
||||
|
||||
void vene_zzz(const Arg*)
|
||||
{
|
||||
ofstream("/sys/power/state") << "mem";
|
||||
}
|
||||
}
|
||||
|
||||
@@ -16,12 +16,14 @@ void vene_updatestatus(char status[]);
|
||||
void vene_run();
|
||||
|
||||
void vene_screenshot(const Arg*);
|
||||
void vene_paste_sel(const Arg*);
|
||||
void vene_clip_history(const Arg*);
|
||||
void vene_browser(const Arg*);
|
||||
void vene_webbookmark();
|
||||
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
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user