Compare commits
12
Commits
d6202280e9
...
local
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
71ee58ed76 | ||
|
|
9dc4646559 | ||
|
|
889ecc6eb9 | ||
|
|
4a5e539580 | ||
|
|
b275554213 | ||
|
|
07b79c903e | ||
|
|
ef7e66f609 | ||
|
|
a4385c8858 | ||
|
|
efb6df5dc7 | ||
|
|
647cff6727 | ||
|
|
e63ff9f1c4 | ||
|
|
4ad49de088 |
@@ -36,6 +36,9 @@ static const Rule rules[] = {
|
||||
{ "LibreWolf", NULL, NULL, 1<<7, 0, -1 },
|
||||
{ NULL, "emacs", NULL, 1<<8, 0, -1 },
|
||||
{ "dlt-viewer", NULL, NULL, 1<<5, 0, -1 },
|
||||
{ "Emulator", NULL, "", 1<<9, 1, -1 },
|
||||
{ "Emulator", NULL, "Android Emulator - MB_V530E_MB.EA-M_14_0_CID_Central_Information_Display:5554", 1<<5, 1, -1 },
|
||||
|
||||
|
||||
};
|
||||
|
||||
@@ -44,6 +47,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 +76,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 };
|
||||
@@ -83,12 +88,16 @@ 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 } },
|
||||
|
||||
@@ -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} -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,9 @@ namespace
|
||||
bool has_child;
|
||||
Proc child;
|
||||
|
||||
Cmd amixer("amixer");
|
||||
Cmd browser(BROWSER);
|
||||
|
||||
Cmd low_battery_notify("notify-send", "--urgency=critical", "Battery Low");
|
||||
}
|
||||
|
||||
extern "C"
|
||||
@@ -176,6 +180,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 += "🔌";
|
||||
@@ -191,19 +199,23 @@ extern "C"
|
||||
catch(...){ cerr << "EXCEPT\n"; }
|
||||
|
||||
// Volume
|
||||
string amix_out = $(amixer + "get" + AUDIO_DEV);
|
||||
size_t vol_bracket = amix_out.find('[');
|
||||
string vol_out = $({"wpctl", "get-volume", "@DEFAULT_AUDIO_SINK@"});
|
||||
size_t vol_begin = vol_out.find(' ');
|
||||
|
||||
if(vol_bracket != string::npos)
|
||||
if(vol_begin != string::npos)
|
||||
{
|
||||
bool is_muted = amix_out.find("[on]") == string::npos;
|
||||
bool is_muted = vol_out.find("[MUTED]") != string::npos;
|
||||
new_stat += is_muted ? "🔇" : "🔉";
|
||||
|
||||
size_t first_digit = vol_bracket + 1;
|
||||
size_t close_bracket = amix_out.find(']', first_digit);
|
||||
new_stat.append(amix_out, first_digit, close_bracket - first_digit);
|
||||
size_t first_digit = vol_begin + 1;
|
||||
size_t vol_end = vol_out.find(' ', first_digit);
|
||||
|
||||
new_stat += ' ';
|
||||
if(vol_end == string::npos)
|
||||
vol_end = vol_out.size() + 1;
|
||||
|
||||
float vol = stof( vol_out.substr(first_digit, vol_end - first_digit) );
|
||||
|
||||
new_stat += to_string(int(vol * 100)) + "% ";
|
||||
}
|
||||
|
||||
// Time
|
||||
@@ -218,7 +230,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 +260,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,62 +291,74 @@ 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());
|
||||
|
||||
// Initial bookmark directory
|
||||
string dir = "Luxoft";
|
||||
|
||||
while(true)
|
||||
{
|
||||
// Choose bookmark directory
|
||||
string dir = $(list_dirs | dmenu);
|
||||
if( dir.empty() )
|
||||
return;
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
// Choose bookmark directory
|
||||
dir = $(list_dirs | dmenu);
|
||||
if( dir.empty() )
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
void vene_inc_vol(const Arg*)
|
||||
{
|
||||
Cmd inc_vol(amixer + "-q" + "set" + AUDIO_DEV + "3%+");
|
||||
child = inc_vol.detach();
|
||||
Cmd inc_vol("wpctl", "set-volume", "@DEFAULT_AUDIO_SINK@", "3%+");
|
||||
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();
|
||||
Cmd dec_vol("wpctl", "set-volume", "@DEFAULT_AUDIO_SINK@", "3%-");
|
||||
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();
|
||||
Cmd toggle_vol("wpctl", "set-mute", "@DEFAULT_AUDIO_SINK@", "toggle");
|
||||
child = detach(toggle_vol);
|
||||
has_child = true;
|
||||
}
|
||||
|
||||
void vene_toggle_mic(const Arg*)
|
||||
{
|
||||
Cmd toggle_mic("wpctl", "set-mute", "@DEFAULT_AUDIO_SOURCE@", "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