dwm-script_tags-6.2.diff (4925B)
1 diff --color -r -u dwm-6.2/config.def.h dwm_patched/config.def.h 2 --- dwm-6.2/config.def.h 2019-02-02 13:55:28.000000000 +0100 3 +++ dwm_patched/config.def.h 2020-07-30 17:23:53.470898016 +0200 4 @@ -3,6 +3,9 @@ 5 /* appearance */ 6 static const unsigned int borderpx = 1; /* border pixel of windows */ 7 static const unsigned int snap = 32; /* snap pixel */ 8 +static const char *tagfifo = "/tmp/dwm_tags"; /*fifo of bar information */ 9 +static const int barheight = 25; /*height of bar*/ 10 +static const char *sepchar = ":"; 11 static const int showbar = 1; /* 0 means no bar */ 12 static const int topbar = 1; /* 0 means bottom bar */ 13 static const char *fonts[] = { "monospace:size=10" }; 14 Only in dwm_patched: drw.o 15 diff --color -r -u dwm-6.2/dwm.c dwm_patched/dwm.c 16 --- dwm-6.2/dwm.c 2019-02-02 13:55:28.000000000 +0100 17 +++ dwm_patched/dwm.c 2020-07-30 17:27:29.083891791 +0200 18 @@ -28,6 +28,7 @@ 19 #include <stdlib.h> 20 #include <string.h> 21 #include <unistd.h> 22 +#include <fcntl.h> 23 #include <sys/types.h> 24 #include <sys/wait.h> 25 #include <X11/cursorfont.h> 26 @@ -387,8 +388,11 @@ 27 if (m) { 28 arrangemon(m); 29 restack(m); 30 - } else for (m = mons; m; m = m->next) 31 + } else for (m = mons; m; m = m->next){ 32 arrangemon(m); 33 + } 34 + 35 + 36 } 37 38 void 39 @@ -695,51 +699,55 @@ 40 void 41 drawbar(Monitor *m) 42 { 43 - int x, w, sw = 0; 44 - int boxs = drw->fonts->h / 9; 45 - int boxw = drw->fonts->h / 6 + 2; 46 unsigned int i, occ = 0, urg = 0; 47 + int fd; 48 Client *c; 49 + char str[1000]=""; 50 51 - /* draw status first so it can be overdrawn by tags later */ 52 - if (m == selmon) { /* status is only drawn on selected monitor */ 53 - drw_setscheme(drw, scheme[SchemeNorm]); 54 - sw = TEXTW(stext) - lrpad + 2; /* 2px right padding */ 55 - drw_text(drw, m->ww - sw, 0, sw, bh, 0, stext, 0); 56 - } 57 + 58 + mkfifo(tagfifo, 0666); 59 + fd = open(tagfifo,O_WRONLY); 60 61 for (c = m->clients; c; c = c->next) { 62 occ |= c->tags; 63 if (c->isurgent) 64 urg |= c->tags; 65 } 66 - x = 0; 67 for (i = 0; i < LENGTH(tags); i++) { 68 - w = TEXTW(tags[i]); 69 - drw_setscheme(drw, scheme[m->tagset[m->seltags] & 1 << i ? SchemeSel : SchemeNorm]); 70 - drw_text(drw, x, 0, w, bh, lrpad / 2, tags[i], urg & 1 << i); 71 - if (occ & 1 << i) 72 - drw_rect(drw, x + boxs, boxs, boxw, boxw, 73 - m == selmon && selmon->sel && selmon->sel->tags & 1 << i, 74 - urg & 1 << i); 75 - x += w; 76 - } 77 - w = blw = TEXTW(m->ltsymbol); 78 - drw_setscheme(drw, scheme[SchemeNorm]); 79 - x = drw_text(drw, x, 0, w, bh, lrpad / 2, m->ltsymbol, 0); 80 - 81 - if ((w = m->ww - sw - x) > bh) { 82 - if (m->sel) { 83 - drw_setscheme(drw, scheme[m == selmon ? SchemeSel : SchemeNorm]); 84 - drw_text(drw, x, 0, w, bh, lrpad / 2, m->sel->name, 0); 85 - if (m->sel->isfloating) 86 - drw_rect(drw, x + boxs, boxs, boxw, boxw, m->sel->isfixed, 0); 87 - } else { 88 - drw_setscheme(drw, scheme[SchemeNorm]); 89 - drw_rect(drw, x, 0, w, bh, 1, 1); 90 + strcat(str,sepchar); 91 + 92 + // Occupied and focused 93 + if ( occ & 1 << i && m->tagset[m->seltags] & 1 << i ) { 94 + /*fprintf(fd,"%%C %s %%f",tags[i]);*/ 95 + strcat(str,"%O "); 96 + strcat(str,tags[i]); 97 + strcat(str," %f"); 98 + //not occupied but still focused 99 + } else if ( !( occ & 1 << i )&& m->tagset[m->seltags] & 1 << i ) { 100 + strcat(str,"%E "); 101 + strcat(str,tags[i]); 102 + strcat(str," %f"); 103 + } else if ( occ & 1 << i && !( m->tagset[m->seltags] & 1 << i ) ) { 104 + //occupied but not focused 105 + strcat(str,"%o "); 106 + strcat(str,tags[i]); 107 + strcat(str," %f"); 108 + } else { 109 + //not occupied not focused 110 + strcat(str,"%e "); 111 + strcat(str,tags[i]); 112 + strcat(str," %f"); 113 } 114 - } 115 - drw_map(drw, m->barwin, 0, 0, m->ww, bh); 116 + } 117 + strcat(str,sepchar); 118 + strcat(str,m->ltsymbol); 119 + if(m->sel){ 120 + strcat(str,sepchar); 121 + strcat(str,m->sel->name); 122 + } 123 + strcat(str,"\n"); 124 + write(fd,&str,strlen(str)+1); 125 + close(fd); 126 } 127 128 void 129 @@ -1351,7 +1359,7 @@ 130 XEvent ev; 131 XWindowChanges wc; 132 133 - drawbar(m); 134 + /*drawbar(m);*/ 135 if (!m->sel) 136 return; 137 if (m->sel->isfloating || !m->lt[m->sellt]->arrange) 138 @@ -1545,7 +1553,7 @@ 139 if (!drw_fontset_create(drw, fonts, LENGTH(fonts))) 140 die("no fonts could be loaded."); 141 lrpad = drw->fonts->h; 142 - bh = drw->fonts->h + 2; 143 + bh = barheight; 144 updategeom(); 145 /* init atoms */ 146 utf8string = XInternAtom(dpy, "UTF8_STRING", False); 147 @@ -1802,18 +1810,10 @@ 148 updatebars(void) 149 { 150 Monitor *m; 151 - XSetWindowAttributes wa = { 152 - .override_redirect = True, 153 - .background_pixmap = ParentRelative, 154 - .event_mask = ButtonPressMask|ExposureMask 155 - }; 156 XClassHint ch = {"dwm", "dwm"}; 157 for (m = mons; m; m = m->next) { 158 if (m->barwin) 159 continue; 160 - m->barwin = XCreateWindow(dpy, root, m->wx, m->by, m->ww, bh, 0, DefaultDepth(dpy, screen), 161 - CopyFromParent, DefaultVisual(dpy, screen), 162 - CWOverrideRedirect|CWBackPixmap|CWEventMask, &wa); 163 XDefineCursor(dpy, m->barwin, cursor[CurNormal]->cursor); 164 XMapRaised(dpy, m->barwin); 165 XSetClassHint(dpy, m->barwin, &ch);