From d160f0f56f03c9a16aa30b1c588245b370f3e06a Mon Sep 17 00:00:00 2001 From: Ray Andrew <4437323+rayandrew@users.noreply.github.com> Date: Fri, 27 Sep 2024 20:43:07 -0500 Subject: [PATCH] stable with bar --- config.def.h | 23 +++++++++++++++++------ dwl.c | 36 ++++++++++++++++++++++++++++++++++-- 2 files changed, 51 insertions(+), 8 deletions(-) diff --git a/config.def.h b/config.def.h index 7a701ba..1613c42 100644 --- a/config.def.h +++ b/config.def.h @@ -9,7 +9,7 @@ static const int bypass_surface_visibility = 0; /* 1 means idle inhibitors will static const int smartgaps = 0; /* 1 means no outer gap when there is only one window */ static const int monoclegaps = 1; /* 1 means outer gaps in monocle layout */ static const unsigned int borderpx = 1; /* border pixel of windows */ -static const int user_bh = 20; /* 0 means that dwl will calculate barheight, >= 1 means dwl will use user_bh as the bar height. */ +static const int user_bh = 0; /* 0 means that dwl will calculate barheight, >= 1 means dwl will use user_bh as the bar height. */ static const unsigned int gappih = 10; /* horiz inner gap between windows */ static const unsigned int gappiv = 10; /* vert inner gap between windows */ static const unsigned int gappoh = 10; /* horiz outer gap between windows and screen edge */ @@ -18,10 +18,17 @@ static const unsigned int gappov = 10; /* vert outer gap between windo // static const float bordercolor[] = COLOR(0x282b2cff); // static const float focuscolor[] = COLOR(0xd1b171ff); // static const float urgentcolor[] = COLOR(0xec6b64ff); -static const int showbar = 1; /* 0 means no bar */ +static const int showbar = 0; /* 0 means no bar */ static const int topbar = 0; /* 0 means bottom bar */ // static const char *fonts[] = {"monospace:size=10"}; -static const char *fonts[] = { "JetBrainsMono Nerd Font Mono:style:medium:size=12", "Iosevka:style:medium:size=12", "monospace:size=10" }; +// static const char *fonts[] = { "JetBrainsMono Nerd Font Mono:style:medium:size=14", "Font Awesome 6 Free Regular:size=14", "Iosevka:style:medium:size=14", "monospace:size=14" }; +static const char *fonts[] = { + "JetBrainsMonoNL Nerd Font:size=20:antialias=true:autohint=true" + // "DejaVu Sans Mono for Powerline:style=Book:size=16", + // "JoyPixels:size=16:antialias=true:autohint=true", + // "Font Awesome 6 Free,Font Awesome 6 Free Regular:style=Regular:size=16:antialias=true:autohint=true" +}; +// static const char *fonts[] = { "JetBrainsMono Nerd Font Mono:style:medium:size=14", "Iosevka:style:medium:size=14", "monospace:size=14" }; /* This conforms to the xdg-protocol. Set the alpha to zero to restore the old behavior */ static const float fullscreen_bg[] = {0.1f, 0.1f, 0.1f, 1.0f}; /* You can also use glsl colors */ // static const float rootcolor[] = COLOR(0x000000ff); @@ -41,7 +48,7 @@ static const float rootcolor[] = COLOR(black); static uint32_t colors[][3] = { /* fg bg border */ [SchemeNorm] = { white, black, gray2 }, - [SchemeSel] = { blue, black, yellow }, + [SchemeSel] = { blue, black, yellow }, [SchemeUrg] = { 0, 0, 0xec6b64ff }, }; @@ -54,7 +61,7 @@ static char *tags[] = { "1", "2", "3", "4", "5", "6", "7", "8", "9", "0" }; #define TAGCOUNT (int) LENGTH(tags) /* logging */ -static int log_level = WLR_ERROR; +static int log_level = WLR_DEBUG; /* Autostart */ static const char *const autostart[] = { @@ -95,7 +102,7 @@ static const Layout layouts[] = { */ /* NOTE: ALWAYS add a fallback rule, even if you are completely sure it won't be used */ static const MonitorRule monrules[] = { - /* name mfact nmaster scale layout rotate/reflect x y */ + /* name mfact nmaster scale layout rotate/reflect x y */ /* example of a HiDPI laptop monitor: */ { "eDP-1", 0.5f, 1, 1.5f, &layouts[0], WL_OUTPUT_TRANSFORM_NORMAL, -1, -1 }, /* defaults */ @@ -204,6 +211,8 @@ static const char *mediaplayprevcmd[] = { "/usr/bin/playerctl", "previous // screenshot #define SCREENSHOTDIR_CMD SHCMD("grim -g \"$(slurp)\" \"$(xdg-user-dir)/Screenshots/$(date +%Y-%m-%d-%H-%M-%S).png\"") #define SCREENSHOTCLIPBOARD_CMD SHCMD("grim -g \"$(slurp)\" -t png - | wl-copy") +// #define KILL_DWL SHCMD("pkill -f sbar-dwl; pkill -f dwl") +// #define KILL_DWL SHCMD("pgrep -f sbar-dwl | xargs kill; pgrep -f dwl | xargs kill") #include "shiftview.c" @@ -254,6 +263,7 @@ static const Key keys[] = { TAGKEYS( XKB_KEY_9, XKB_KEY_parenleft, 8), TAGKEYS( XKB_KEY_0, XKB_KEY_parenright, 9), { MODKEY|WLR_MODIFIER_SHIFT, XKB_KEY_R, quit, {0} }, + // { MODKEY|WLR_MODIFIER_SHIFT, XKB_KEY_R, spawn, KILL_DWL }, { MODKEY|WLR_MODIFIER_SHIFT, XKB_KEY_E, spawn, SHCMD("killall dbus-run-session") }, // gaps @@ -297,6 +307,7 @@ static const Key keys[] = { /* Ctrl-Alt-Backspace and Ctrl-Alt-Fx used to be handled by X server */ { WLR_MODIFIER_CTRL|WLR_MODIFIER_ALT, XKB_KEY_Terminate_Server, quit, {0} }, + // { WLR_MODIFIER_CTRL|WLR_MODIFIER_ALT, XKB_KEY_Terminate_Server, spawn, KILL_DWL }, /* Ctrl-Alt-Fx is used to switch to another VT, if you don't know what a VT is * do not remove them. */ diff --git a/dwl.c b/dwl.c index 1176466..16203c6 100644 --- a/dwl.c +++ b/dwl.c @@ -544,6 +544,7 @@ static uint32_t swipe_fingers = 0; static double swipe_dx = 0; static double swipe_dy = 0; +static int status_fd = -1; static char stext[512]; static struct wl_event_source *status_event_source; @@ -2099,8 +2100,10 @@ drawbar(Monitor *m) return; /* draw status first so it can be overdrawn by tags later */ - if (m == selmon) /* status is only drawn on selected monitor */ + if (m == selmon || 1) /* status is only drawn on selected monitor */ tw = drawstatus(m); + // else + // (void)drawstatus(m); wl_list_for_each(c, &clients, link) { if (c->mon != m) @@ -3183,6 +3186,7 @@ updatebar(Monitor *m) drwl_font_destroy(m->drw->font); snprintf(fontattrs, sizeof(fontattrs), "dpi=%.2f", 96. * m->wlr_output->scale); + wlr_log(WLR_INFO, "fontattrs %s\n", fontattrs); if (!(drwl_font_create(m->drw, LENGTH(fonts), fonts, fontattrs))) die("Could not load font"); @@ -3333,6 +3337,7 @@ run(char *startup_cmd) if ((child_pid = fork()) < 0) die("startup: fork:"); if (child_pid == 0) { + if (status_fd != -1) close(status_fd); close(STDIN_FILENO); setsid(); execl("/bin/sh", "/bin/sh", "-c", startup_cmd, NULL); @@ -3774,8 +3779,27 @@ setup(void) drwl_init(); + // create file descriptor for status input if not already created in XDG_RUNTIME_DIR + const char status_file[256]; + snprintf(status_file, sizeof(status_file), "%s/dwl_status", getenv("XDG_RUNTIME_DIR")); + + FILE* status_f = fopen(status_file, "r"); + if (status_f == NULL) { + status_f = fopen(status_file, "w"); + if (status_f == NULL) { + wlr_log(WLR_ERROR, "Failed to create status file %s\n", status_file); + exit(1); + } + fclose(status_f); + status_f = fopen(status_file, "r"); + } + status_fd = fileno(status_f); + wlr_log(WLR_INFO, "Status file fd %d\n", status_fd); + + // status_event_source = wl_event_loop_add_fd(wl_display_get_event_loop(dpy), + // STDIN_FILENO, WL_EVENT_READABLE, statusin, NULL); status_event_source = wl_event_loop_add_fd(wl_display_get_event_loop(dpy), - STDIN_FILENO, WL_EVENT_READABLE, statusin, NULL); + status_fd, WL_EVENT_READABLE, statusin, NULL); /* Make sure XWayland clients don't connect to the parent X server, * e.g when running in the x11 backend or the wayland backend and the @@ -3801,6 +3825,7 @@ void spawn(const Arg *arg) { if (fork() == 0) { + if (status_fd != -1) close(status_fd); close(STDIN_FILENO); dup2(STDERR_FILENO, STDOUT_FILENO); setsid(); @@ -3823,6 +3848,10 @@ startdrag(struct wl_listener *listener, void *data) int statusin(int fd, unsigned int mask, void *data) { + if (fd == -1) { + return 0; + } + char status[1024]; ssize_t n; @@ -3841,6 +3870,9 @@ statusin(int fd, unsigned int mask, void *data) strncpy(stext, status, sizeof(stext)); drawbars(); + wlr_log(WLR_INFO, "Reading from %d\n", fd); + wlr_log(WLR_INFO, "Status %s\n", stext); + return 0; }