bakkeby / patches

Collection of patches for dwm, st and dmenu
286 stars 30 forks source link

splitmonstatus? #48

Closed apprehensions closed 2 years ago

apprehensions commented 2 years ago

to put it simply. having a specific status for each monitor. much like splitstatus splits for center, it splits for monitors

my only usecase for this is to ONLY tell the time. (i could just launch a terminal or set a hotkey for this but why even bother?) i use a custom dwm build with holdbar to save some screen estate. but i would like to know the time as i have a second monitor.

i can use staticstatus but my current status-bar configuration is quite large and doesn't fit on my secondary display.

offtopic question: just as a question, is it even appropriate for ask for patch requests here? and, why aren't some of your patches on the dwm.suckless.org patches?

bakkeby commented 2 years ago

to put it simply. having a specific status for each monitor. much like splitstatus splits for center, it splits for monitors

At this level of personalised customisation you would kind of be expected to figure things out on your own because it is quite far into the tinkering realm. At some point

The splitstatus patch does in principle what you suggest, just that it shows all the statuses on the same monitor. All you need is to change if statements around to control which monitor what is drawn on. E.g. if (m->num == 1) { to only do something when on the second monitor.

just as a question, is it even appropriate for ask for patch requests here?

Appropriate I don't know, maybe it is :)

and, why aren't some of your patches on the dwm.suckless.org patches?

I did answer this in some other issue, but I can't find that at the moment. The gist of it is that:

I suppose that I will contribute my patches to the public domain (suckless.org) when the time comes that I am no longer planning on maintaining them (and I go back to Windows or something).

apprehensions commented 2 years ago

At this level of personalised customisation you would kind of be expected to figure things out on your own because it is quite far into the tinkering realm. At some point

MY FACE WHEN I HAVE THOUSAND PATCHES ON DWM BUT I DONT KNOW HOW TO CODE IN C.

The splitstatus patch does in principle what you suggest, just that it shows all the statuses on the same monitor. All you need is to change if statements around to control which monitor what is drawn on. E.g. if (m->num == 1) { to only do something when on the second monitor.

true, but how would it even be controlled?

apprehensions commented 2 years ago
diff --git a/config.h b/config.h
index 4ec03fc..9352d4a 100644
--- a/config.h
+++ b/config.h
@@ -13,6 +13,8 @@ static const int systraypinningfailfirst = 1;   /* 1: if pinning fails, display
 static int showsystray        = 0;        /* 0 means no systray */
 static const int showbar            = 1;        /* 0 means no bar */
 static const int topbar             = 0;        /* 0 means bottom bar */
+static const int splitstatus        = 1;        /* 1 for split status items */
+static const char *splitdelim        = ";";       /* Character used for separating status */
 static const int horizpadbar        = 4;        /* horizontal padding for statusbar */
 static const int vertpadbar         = 8;        /* vertical padding for statusbar */
 static const char *fonts[]          = { "monospace:size=10:Medium" };
diff --git a/dwm.c b/dwm.c
index 3e73cdc..3100d2e 100644
--- a/dwm.c
+++ b/dwm.c
@@ -948,6 +948,8 @@ drawbar(Monitor *m)
    int x, w, tw = 0, stw = 0;
    int boxs = drw->fonts->h / 9;
    int boxw = drw->fonts->h / 6 + 2;
+   char *mstext;
+   char *rstext;
    unsigned int i, occ = 0, urg = 0;
    Client *c;

@@ -958,8 +960,13 @@ drawbar(Monitor *m)
        stw = getsystraywidth();

    /* draw status first so it can be overdrawn by tags later */
-   if (m == selmon) { /* status is only drawn on selected monitor */
-       tw = statusw = m->ww - drawstatusbar(m, bh, stext) - stw ;
+   rstext = strdup(stext);
+   mstext = strsep(&rstext, splitdelim);
+   if (m->num == 0) { /* status is only drawn on selected monitor */
+       tw = statusw = m->ww - drawstatusbar(m, bh, mstext) - stw ;
+   }
+   if (m->num == 1) { /* status is only drawn on selected monitor */
+       tw = statusw = m->ww - drawstatusbar(m, bh, rstext) - stw ;
    }

    resizebarwin(m);

is this good? i love this working for 2 minutes but segmentation faulted now

bakkeby commented 2 years ago

I don't see anything obviously wrong with it. Segmentation faults are always fun. I'd recommend trying things out in Xephyr first, it generally saves a lot of time.

apprehensions commented 2 years ago

keeping it closed as i did find a solution anyway.