Compare commits

..
12 Commits
Author SHA1 Message Date
Venelin Dechkov 71ee58ed76 VENE_LOCAL 2026-07-30 13:03:29 +03:00
Venelin Dechkov 9dc4646559 alsa -> pipewire 2026-07-30 13:03:12 +03:00
Venelin Dechkov 889ecc6eb9 pipewire support 2026-07-30 11:54:49 +03:00
Venelin Dechkov 4a5e539580 update time every min 2026-07-30 11:54:49 +03:00
Venelin Dechkov b275554213 fix bookmarks 2026-07-30 11:54:49 +03:00
Venelin Dechkov 07b79c903e toggle layouts 2026-07-30 11:54:49 +03:00
Venelin Dechkov ef7e66f609 clip history 2026-07-30 11:54:49 +03:00
Venelin Dechkov a4385c8858 browser depends on config 2026-07-30 11:54:49 +03:00
vrdandVenelin Dechkov efb6df5dc7 fix warning 2026-07-30 11:54:49 +03:00
vrdandVenelin Dechkov 647cff6727 toggle mic 2026-07-30 11:54:49 +03:00
vrdandVenelin Dechkov e63ff9f1c4 fix firefox mic on alsa 2026-07-30 11:54:49 +03:00
Venelin Dechkov 4ad49de088 fix low battery 2026-07-30 11:54:49 +03:00
5 changed files with 126 additions and 53 deletions
+12 -3
View File
@@ -36,6 +36,9 @@ static const Rule rules[] = {
{ "LibreWolf", NULL, NULL, 1<<7, 0, -1 }, { "LibreWolf", NULL, NULL, 1<<7, 0, -1 },
{ NULL, "emacs", NULL, 1<<8, 0, -1 }, { NULL, "emacs", NULL, 1<<8, 0, -1 },
{ "dlt-viewer", NULL, NULL, 1<<5, 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 nmaster = 1; /* number of clients in master area */
static const int resizehints = 0; /* 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 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[] = { static const Layout layouts[] = {
/* symbol arrange function */ /* 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", "-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* dmenucmd[] = { "dmenu_run", "-fn", "monospace:size=14", NULL };
static const char* termcmd[] = { "st", NULL }; static const char* termcmd[] = { "st", NULL };
static const char* simulate_mmb[] = { "xdotool", "click", "--delay", "0", "--clearmodifiers", "2", NULL };
#if HAS_SW_BACKLIGHT #if HAS_SW_BACKLIGHT
static const char* bright_up[] = { "brightnessctl", "s", "-q", "1%+", NULL }; static const char* bright_up[] = { "brightnessctl", "s", "-q", "1%+", NULL };
static const char* bright_down[] = { "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[] = { static const Key keys[] = {
/* modifier key function argument */ /* 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|ShiftMask, XK_s, vene_screenshot, {0} }, // Take a screenshot, located in ~/screenshots and in clipboard
{ MODKEY|ShiftMask, XK_b, webbookmark, {0} }, // Open a web bookmark { 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_AudioRaiseVolume, vene_inc_vol, {0} },
{ 0, XF86XK_AudioLowerVolume, vene_dec_vol, {0} }, { 0, XF86XK_AudioLowerVolume, vene_dec_vol, {0} },
{ 0, XF86XK_AudioMute, vene_toggle_vol, {0} }, { 0, XF86XK_AudioMute, vene_toggle_vol, {0} },
{ 0, XF86XK_AudioMicMute, vene_toggle_mic, {0} },
#if HAS_SW_BACKLIGHT #if HAS_SW_BACKLIGHT
{ 0, XF86XK_MonBrightnessUp, spawn, {.v = bright_up } }, { 0, XF86XK_MonBrightnessUp, spawn, {.v = bright_up } },
{ 0, XF86XK_MonBrightnessDown,spawn, {.v = bright_down } }, { 0, XF86XK_MonBrightnessDown,spawn, {.v = bright_down } },
+4 -4
View File
@@ -11,8 +11,8 @@ X11INC = /usr/X11R6/include
X11LIB = /usr/X11R6/lib X11LIB = /usr/X11R6/lib
# Xinerama, comment if you don't want it # Xinerama, comment if you don't want it
# XINERAMALIBS = -lXinerama XINERAMALIBS = -lXinerama
# XINERAMAFLAGS = -DXINERAMA XINERAMAFLAGS = -DXINERAMA
# freetype # freetype
FREETYPELIBS = -lfontconfig -lXft FREETYPELIBS = -lfontconfig -lXft
@@ -26,10 +26,10 @@ INCS = -I${X11INC} -I${FREETYPEINC}
LIBS = -L${X11LIB} -lX11 ${XINERAMALIBS} ${FREETYPELIBS} LIBS = -L${X11LIB} -lX11 ${XINERAMALIBS} ${FREETYPELIBS}
# flags # 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 = -g -std=c99 -pedantic -Wall -O0 ${INCS} ${CPPFLAGS}
CFLAGS = -std=c99 -pedantic -Wno-deprecated-declarations ${CPPFLAGS} CFLAGS = -std=c99 -pedantic -Wno-deprecated-declarations ${CPPFLAGS}
LDFLAGS = -flto -s ${LIBS} LDFLAGS = -flto=auto -s ${LIBS}
# Solaris # Solaris
#CFLAGS = -fast ${INCS} -DVERSION=\"${VERSION}\" #CFLAGS = -fast ${INCS} -DVERSION=\"${VERSION}\"
+38 -3
View File
@@ -1384,10 +1384,41 @@ run(void)
XEvent ev; XEvent ev;
/* main event loop */ /* main event loop */
XSync(dpy, False); XSync(dpy, False);
while (!XNextEvent(dpy, &ev))
int display_fd = ConnectionNumber(dpy);
while (1)
{ {
if (handler[ev.type]) // Wait until there is an XEvent
handler[ev.type](&ev); /* call handler */ 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(); vene_run();
} }
@@ -1513,6 +1544,10 @@ setfullscreen(Client *c, int fullscreen)
void void
setlayout(const Arg *arg) 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]) if (!arg || !arg->v || arg->v != selmon->lt[selmon->sellt])
selmon->sellt ^= 1; selmon->sellt ^= 1;
if (arg && arg->v) if (arg && arg->v)
+69 -42
View File
@@ -8,15 +8,17 @@
#include <cppipe/commands.hpp> #include <cppipe/commands.hpp>
#include <X11/X.h> #include <X11/X.h>
// #include "vene.h" // #include "vene.h"
#include "vene_env.h" #include <vene_env.h>
extern "C" extern "C"
{ {
#include "slstatus/slstatus.h" #include "slstatus/slstatus.h"
} }
#define DMENU_ARGS "-b", "-f", "-i", "-l", "30", "-fn", "monospace:size=14"
using namespace std; using namespace std;
using namespace std::chrono; using namespace std::chrono;
using namespace std::chrono_literals; using namespace std::literals;
namespace fs = std::filesystem; namespace fs = std::filesystem;
char* HOME; char* HOME;
@@ -28,7 +30,9 @@ namespace
bool has_child; bool has_child;
Proc child; Proc child;
Cmd amixer("amixer"); Cmd browser(BROWSER);
Cmd low_battery_notify("notify-send", "--urgency=critical", "Battery Low");
} }
extern "C" extern "C"
@@ -176,6 +180,10 @@ extern "C"
{ {
new_stat += "🔋"; new_stat += "🔋";
remaining = battery_remaining("BAT0"); remaining = battery_remaining("BAT0");
// Low battery warning
if(remaining && atoi(charge.c_str()) < 15)
run(low_battery_notify); // todo: use lib notify
} }
else else
new_stat += "🔌"; new_stat += "🔌";
@@ -191,19 +199,23 @@ extern "C"
catch(...){ cerr << "EXCEPT\n"; } catch(...){ cerr << "EXCEPT\n"; }
// Volume // Volume
string amix_out = $(amixer + "get" + AUDIO_DEV); string vol_out = $({"wpctl", "get-volume", "@DEFAULT_AUDIO_SINK@"});
size_t vol_bracket = amix_out.find('['); 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 ? "🔇" : "🔉"; new_stat += is_muted ? "🔇" : "🔉";
size_t first_digit = vol_bracket + 1; size_t first_digit = vol_begin + 1;
size_t close_bracket = amix_out.find(']', first_digit); size_t vol_end = vol_out.find(' ', first_digit);
new_stat.append(amix_out, first_digit, close_bracket - 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 // Time
@@ -218,7 +230,7 @@ extern "C"
new_stat += (timeinfo->tm_min/10) + '0'; new_stat += (timeinfo->tm_min/10) + '0';
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 void vene_run() // update status bar every 5 sec
@@ -248,16 +260,19 @@ extern "C"
{ {
Cmd scrot("scrot", "-s", "-"); Cmd scrot("scrot", "-s", "-");
Cmd tee("tee", SCREEN_CAPS_DIR); Cmd tee("tee", SCREEN_CAPS_DIR);
Cmd xclip("xclip", "-selection", "clipboard", "-t", "image/png"); Cmd to_clip("xclip", "-selection", "clipboard", "-t", "image/png");
scrot | tee | xclip; // todo: cppipe < string 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"); // Select a history entry and put to clip
Cmd xdotool("xdotool", "click", "--delay", "0", "--clearmodifiers", "2"); 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) void vene_browser(const Arg* browser_tag)
@@ -276,62 +291,74 @@ extern "C"
} }
else // start browser else // start browser
{ {
Cmd(BROWSER).detach(); detach(browser);
} }
} }
void vene_webbookmark() // todo: cppipe exceptions 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); string bm_root = HOME + "/sync/bookmarks/web/"s;
bm_root += "/sync/bookmarks/web/";
Cmd list_dirs ("ls"); Cmd list_dirs ("ls", bm_root.c_str());
list_dirs += bm_root.c_str();
// Initial bookmark directory
string dir = "Luxoft";
while(true) while(true)
{ {
// Choose bookmark directory
string dir = $(list_dirs | dmenu);
if( dir.empty() )
return;
string bm_dir = bm_root + dir; string bm_dir = bm_root + dir;
// Choose bookmark // Read content of bookmarks file and choose
string link = $(dmenu < bm_dir.c_str()); 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) if(link_begin != string::npos)
{ {
Cmd open_bookmark(BROWSER); Cmd open_bookmark = browser + (entry.c_str() + link_begin + 1); // skip -
link = link.substr(link_begin+1); detach(open_bookmark);
open_bookmark += link.c_str();
open_bookmark.detach();
break; break;
} }
// Choose bookmark directory
dir = $(list_dirs | dmenu);
if( dir.empty() )
return;
} }
} }
void vene_inc_vol(const Arg*) void vene_inc_vol(const Arg*)
{ {
Cmd inc_vol(amixer + "-q" + "set" + AUDIO_DEV + "3%+"); Cmd inc_vol("wpctl", "set-volume", "@DEFAULT_AUDIO_SINK@", "3%+");
child = inc_vol.detach(); child = detach(inc_vol);
has_child = true; has_child = true;
} }
void vene_dec_vol(const Arg*) void vene_dec_vol(const Arg*)
{ {
Cmd dec_vol(amixer + "-q" + "set" + AUDIO_DEV + "3%-"); Cmd dec_vol("wpctl", "set-volume", "@DEFAULT_AUDIO_SINK@", "3%-");
child = dec_vol.detach(); child = detach(dec_vol);
has_child = true; has_child = true;
} }
void vene_toggle_vol(const Arg*) void vene_toggle_vol(const Arg*)
{ {
Cmd toggle_vol(amixer + "-q" + "set" + AUDIO_DEV + "toggle"); Cmd toggle_vol("wpctl", "set-mute", "@DEFAULT_AUDIO_SINK@", "toggle");
child = toggle_vol.detach(); child = detach(toggle_vol);
has_child = true; 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";
}
} }
+3 -1
View File
@@ -16,12 +16,14 @@ void vene_updatestatus(char status[]);
void vene_run(); void vene_run();
void vene_screenshot(const Arg*); void vene_screenshot(const Arg*);
void vene_paste_sel(const Arg*); void vene_clip_history(const Arg*);
void vene_browser(const Arg*); 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*);
void vene_toggle_vol(const Arg*); void vene_toggle_vol(const Arg*);
void vene_toggle_mic(const Arg*);
void vene_zzz(const Arg*);
#ifdef __cplusplus #ifdef __cplusplus
} }