vene signal changes in dwm and status bar upgrades

This commit is contained in:
vrd
2026-07-30 11:54:49 +03:00
committed by Venelin Dechkov
parent 336575522b
commit e81536b695
2 changed files with 42 additions and 30 deletions
+6 -2
View File
@@ -1547,8 +1547,9 @@ setup(void)
/* do not transform children into zombies when they terminate */ /* do not transform children into zombies when they terminate */
sigemptyset(&sa.sa_mask); sigemptyset(&sa.sa_mask);
sa.sa_flags = SA_NOCLDSTOP | SA_NOCLDWAIT | SA_RESTART; sa.sa_flags = SA_NOCLDSTOP | SA_RESTART;
sa.sa_handler = SIG_IGN; /* IGN -> DFL for cppipe so that waitpid works */
sa.sa_handler = SIG_DFL;
sigaction(SIGCHLD, &sa, NULL); sigaction(SIGCHLD, &sa, NULL);
/* clean up any zombies (inherited from .xinitrc etc) immediately */ /* clean up any zombies (inherited from .xinitrc etc) immediately */
@@ -1653,8 +1654,11 @@ spawn(const Arg *arg)
if (fork() == 0) { if (fork() == 0) {
if (dpy) if (dpy)
close(ConnectionNumber(dpy)); close(ConnectionNumber(dpy));
/* Child starts a new session */
setsid(); setsid();
/* Don't inherit dwm's sigaction from setup */
sigemptyset(&sa.sa_mask); sigemptyset(&sa.sa_mask);
sa.sa_flags = 0; sa.sa_flags = 0;
sa.sa_handler = SIG_DFL; sa.sa_handler = SIG_DFL;
+36 -28
View File
@@ -1,6 +1,7 @@
#include <time.h> #include <time.h>
#include <cstring> #include <cstring>
#include <cstdlib> #include <cstdlib>
#include <fstream>
#include <string> #include <string>
#include <chrono> #include <chrono>
#include <cppipe/commands.hpp> #include <cppipe/commands.hpp>
@@ -17,10 +18,8 @@ char SCREEN_CAPS_DIR[64];
namespace namespace
{ {
time_point<system_clock> next_update; time_point<system_clock> next_update;
void schedule_update() bool has_child;
{ Proc child;
next_update = system_clock::now() + 100ms;
}
} }
extern "C" extern "C"
@@ -62,25 +61,28 @@ extern "C"
static string new_stat; static string new_stat;
new_stat.clear(); new_stat.clear();
// Net
string eth_state;
ifstream("/sys/class/net/eth0/operstate") >> eth_state;
if(eth_state == "up")
new_stat += "🌐 ";
// Volume // Volume
string amix_out = $(Cmd("amixer", "get", AUDIO_DEV)); string amix_out = $(Cmd("amixer", "get", AUDIO_DEV));
size_t bracket = amix_out.find('['); size_t vol_bracket = amix_out.find('[');
if(bracket != string::npos) if(vol_bracket != string::npos)
{ {
bool is_muted = amix_out.find("[on]") == string::npos; bool is_muted = amix_out.find("[on]") == string::npos;
new_stat += is_muted ? "🔇" : "🔉"; new_stat += is_muted ? "🔇" : "🔉";
new_stat += amix_out[bracket+1]; size_t first_digit = vol_bracket + 1;
if(char second = amix_out[bracket+2]; second != '%') size_t close_bracket = amix_out.find(']', first_digit);
new_stat += second; new_stat.append(amix_out, first_digit, close_bracket - first_digit);
if(char third = amix_out[bracket+3]; third != '%')
new_stat += third;
new_stat += '%';
new_stat += ' ';
} }
new_stat += ' ';
// Time // Time
time_t rawtime; time_t rawtime;
@@ -101,10 +103,19 @@ extern "C"
{ {
time_point<system_clock> now = system_clock::now(); time_point<system_clock> now = system_clock::now();
if(now > next_update) if(has_child && check_exited(child))
{ {
next_update = now + 5s; // Clean up all zombies
while (waitpid(-1, nullptr, WNOHANG) > 0);
has_child = false;
updatestatus(); updatestatus();
next_update = now + 5s;
}
else if(now > next_update)
{
updatestatus();
next_update = now + 5s;
} }
} }
@@ -137,25 +148,22 @@ extern "C"
void vene_inc_vol(const Arg*) void vene_inc_vol(const Arg*)
{ {
Cmd inc_vol("amixer", "set", AUDIO_DEV, "3%+"); Cmd inc_vol("amixer", "-q", "set", AUDIO_DEV, "3%+");
inc_vol.detach(); child = inc_vol.detach();
has_child = true;
schedule_update();
} }
void vene_dec_vol(const Arg*) void vene_dec_vol(const Arg*)
{ {
Cmd dec_vol("amixer", "set", AUDIO_DEV, "3%-"); Cmd dec_vol("amixer", "-q", "set", AUDIO_DEV, "3%-");
dec_vol.detach(); child = dec_vol.detach();
has_child = true;
schedule_update();
} }
void vene_toggle_vol(const Arg*) void vene_toggle_vol(const Arg*)
{ {
Cmd toggle_vol("amixer", "set", AUDIO_DEV, "toggle"); Cmd toggle_vol("amixer", "-q", "set", AUDIO_DEV, "toggle");
toggle_vol.detach(); child = toggle_vol.detach();
has_child = true;
schedule_update();
} }
} }