[hackers] [dwm] [PATCH] layouts added to fullgaps patch

2019-04-09 Thread Aaron Duxler
Hi all,

I just edited the layouts gaplesgrid, bstack, bstackhoriz, fibonacci(spiral, 
dwindle), centeredfloatingmaster, centeredfloatingmaster
to work with fullgaps. Gaps are removed when only one client is visible.

If it is used in combination with the noborders patch, this patch results in a 
similar behaviour as the uselessgap patch, 
but with keybindings to change gaps during runtime.

---
 config.def.h  |  29 ++-
 dwm.c | 223 --
 fibonacci.c   |  71 
 gaplessgrid.c |  40 +
 4 files changed, 351 insertions(+), 12 deletions(-)
 create mode 100644 fibonacci.c
 create mode 100644 gaplessgrid.c

diff --git a/config.def.h b/config.def.h
index 1c0b587..7672129 100644
--- a/config.def.h
+++ b/config.def.h
@@ -2,6 +2,7 @@
 
 /* appearance */
 static const unsigned int borderpx  = 1;/* border pixel of windows */
+static const unsigned int gappx = 5;/* gaps between windows */
 static const unsigned int snap  = 32;   /* snap pixel */
 static const int showbar= 1;/* 0 means no bar */
 static const int topbar = 1;/* 0 means bottom bar */
@@ -36,11 +37,21 @@ 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 resizehints = 1;/* 1 means respect size hints in tiled 
resizals */
 
+#include "fibonacci.c"
+#include "gaplessgrid.c"
 static const Layout layouts[] = {
/* symbol arrange function */
-   { "[]=",  tile },/* first entry is default */
-   { "><>",  NULL },/* no layout function means floating behavior 
*/
+   { "[]=",  tile },   /* first entry is default */ 
+   { "###",  gaplessgrid },
+   { "[@]",  spiral }, 
+   { "[\\]", dwindle },
+   { "|M|",  centeredmaster },
+   { ">M>",  centeredfloatingmaster },
+   { "TTT",  bstack },
+   { "===",  bstackhoriz },
{ "[M]",  monocle },
+   { "><>",  NULL },/* no layout function means floating behavior 
*/
+   { NULL,   NULL },
 };
 
 /* key definitions */
@@ -74,8 +85,15 @@ static Key keys[] = {
{ MODKEY,   XK_Tab,view,   {0} },
{ MODKEY|ShiftMask, XK_c,  killclient, {0} },
{ MODKEY,   XK_t,  setlayout,  {.v = 
&layouts[0]} },
-   { MODKEY,   XK_f,  setlayout,  {.v = 
&layouts[1]} },
-   { MODKEY,   XK_m,  setlayout,  {.v = 
&layouts[2]} },
+   { MODKEY,   XK_g,  setlayout,  {.v = 
&layouts[1]} },
+   { MODKEY,   XK_q,  setlayout,  {.v = 
&layouts[2]} },
+   { MODKEY,   XK_a,  setlayout,  {.v = 
&layouts[3]} },
+   { MODKEY,   XK_u,  setlayout,  {.v = 
&layouts[4]} },
+   { MODKEY,   XK_o,  setlayout,  {.v = 
&layouts[5]} },
+   { MODKEY,   XK_x,  setlayout,  {.v = 
&layouts[6]} },
+   { MODKEY,   XK_y,  setlayout,  {.v = 
&layouts[7]} },
+   { MODKEY,   XK_m,  setlayout,  {.v = 
&layouts[8]} },
+   { MODKEY,   XK_f,  setlayout,  {.v = 
&layouts[9]} },
{ MODKEY,   XK_space,  setlayout,  {0} },
{ MODKEY|ShiftMask, XK_space,  togglefloating, {0} },
{ MODKEY,   XK_0,  view,   {.ui = ~0 } 
},
@@ -84,6 +102,9 @@ static Key keys[] = {
{ MODKEY,   XK_period, focusmon,   {.i = +1 } },
{ MODKEY|ShiftMask, XK_comma,  tagmon, {.i = -1 } },
{ MODKEY|ShiftMask, XK_period, tagmon, {.i = +1 } },
+   { MODKEY,   XK_minus,  setgaps,{.i = -1 } },
+   { MODKEY,   XK_equal,  setgaps,{.i = +1 } },
+   { MODKEY|ShiftMask, XK_equal,  setgaps,{.i = 0  } },
TAGKEYS(XK_1,  0)
TAGKEYS(XK_2,  1)
TAGKEYS(XK_3,  2)
diff --git a/dwm.c b/dwm.c
index 4465af1..9f06978 100644
--- a/dwm.c
+++ b/dwm.c
@@ -119,6 +119,7 @@ struct Monitor {
int by;   /* bar geometry */
int mx, my, mw, mh;   /* screen size */
int wx, wy, ww, wh;   /* window area  */
+   int gappx;/* gaps between windows */
unsigned int seltags;
unsigned int sellt;
unsigned int tagset[2];
@@ -199,6 +200,7 @@ static void sendmon(Client *c, Monitor *m);
 static void setclientstate(Client *c, long state

[hackers] [st][PATCH] Change background transparency on the fly

2019-04-09 Thread Bakar Chargeishvili
Hi,

This is modified version of st-alpha-0.8.2 patch. New function is added
to control background transparency using key bindings. This is
particularly useful when multiple terminal windows cover each other
(e.g. in the monocle layout of dwm) and lines on the background window
disturb to focus on the main window. In this case one can easily adjust
transparency of the front window and keep working.

Cheers,
Bakar

---
 config.def.h |  8 ++-
 config.mk|  2 +-
 st.c |  2 +-
 st.h |  1 +
 win.h|  2 +-
 x.c  | 59 +---
 6 files changed, 58 insertions(+), 16 deletions(-)

diff --git a/config.def.h b/config.def.h
index 482901e..bcbbb38 100644
--- a/config.def.h
+++ b/config.def.h
@@ -82,6 +82,9 @@ char *termname = "st-256color";
  */
 unsigned int tabspaces = 8;

+/* bg opacity */
+float alpha = 0.8;
+
 /* Terminal colors (16 first used in escape sequence) */
 static const char *colorname[] = {
/* 8 normal colors */
@@ -109,6 +112,7 @@ static const char *colorname[] = {
/* more colors can be added after 255 to use with DefaultXX */
"#cc",
"#55",
+   "black",
 };


@@ -117,7 +121,7 @@ static const char *colorname[] = {
  * foreground, background, cursor, reverse cursor
  */
 unsigned int defaultfg = 7;
-unsigned int defaultbg = 0;
+unsigned int defaultbg = 258;
 static unsigned int defaultcs = 256;
 static unsigned int defaultrcs = 257;

@@ -178,6 +182,8 @@ static Shortcut shortcuts[] = {
{ TERMMOD,  XK_Y,   selpaste,   {.i =  0} },
{ ShiftMask,XK_Insert,  selpaste,   {.i =  0} },
{ TERMMOD,  XK_Num_Lock,numlock,{.i =  0} },
+   { TERMMOD,  XK_A,   chalpha,{.f = +0.1} },
+   { TERMMOD,  XK_D,   chalpha,{.f = -0.1} },
 };

 /*
diff --git a/config.mk b/config.mk
index 0cbb002..1d2f0e2 100644
--- a/config.mk
+++ b/config.mk
@@ -16,7 +16,7 @@ PKG_CONFIG = pkg-config
 INCS = -I$(X11INC) \
`$(PKG_CONFIG) --cflags fontconfig` \
`$(PKG_CONFIG) --cflags freetype2`
-LIBS = -L$(X11LIB) -lm -lrt -lX11 -lutil -lXft \
+LIBS = -L$(X11LIB) -lm -lrt -lX11 -lutil -lXft -lXrender\
`$(PKG_CONFIG) --libs fontconfig` \
`$(PKG_CONFIG) --libs freetype2`

diff --git a/st.c b/st.c
index 8e6ccb5..c3975f7 100644
--- a/st.c
+++ b/st.c
@@ -2251,7 +2251,7 @@ eschandle(uchar ascii)
case 'c': /* RIS -- Reset to initial state */
treset();
resettitle();
-   xloadcols();
+   xloadcols(alpha);
break;
case '=': /* DECPAM -- Application keypad */
xsetmode(1, MODE_APPKEYPAD);
diff --git a/st.h b/st.h
index 4da3051..6799ef6 100644
--- a/st.h
+++ b/st.h
@@ -120,3 +120,4 @@ extern char *termname;
 extern unsigned int tabspaces;
 extern unsigned int defaultfg;
 extern unsigned int defaultbg;
+extern float alpha;
diff --git a/win.h b/win.h
index a6ef1b9..13fdb0b 100644
--- a/win.h
+++ b/win.h
@@ -28,7 +28,7 @@ void xclipcopy(void);
 void xdrawcursor(int, int, Glyph, int, int, Glyph);
 void xdrawline(Line, int, int, int);
 void xfinishdraw(void);
-void xloadcols(void);
+void xloadcols(float);
 int xsetcolorname(int, const char *);
 void xsettitle(char *);
 int xsetcursor(int);
diff --git a/x.c b/x.c
index 5828a3b..7a06d38 100644
--- a/x.c
+++ b/x.c
@@ -53,6 +53,7 @@ static void clipcopy(const Arg *);
 static void clippaste(const Arg *);
 static void numlock(const Arg *);
 static void selpaste(const Arg *);
+static void chalpha(const Arg *);
 static void zoom(const Arg *);
 static void zoomabs(const Arg *);
 static void zoomreset(const Arg *);
@@ -98,6 +99,7 @@ typedef struct {
XSetWindowAttributes attrs;
int scr;
int isfixed; /* is fixed geometry? */
+   int depth; /* bit depth */
int l, t; /* left and top offset */
int gm; /* geometry mask */
 } XWindow;
@@ -233,6 +235,7 @@ static char *usedfont = NULL;
 static double usedfontsize = 0;
 static double defaultfontsize = 0;

+static char *opt_alpha = NULL;
 static char *opt_class = NULL;
 static char **opt_cmd  = NULL;
 static char *opt_embed = NULL;
@@ -282,6 +285,19 @@ numlock(const Arg *dummy)
win.mode ^= MODE_NUMLOCK;
 }

+void
+chalpha(const Arg *arg)
+{
+   alpha += arg->f;
+   if (alpha > 1)
+   alpha = 0;
+   if (alpha < 0)
+   alpha = 1;
+
+   xloadcols(alpha);
+   redraw();
+}
+
 void
 zoom(const Arg *arg)
 {
@@ -692,7 +708,7 @@ xresize(int col, int row)

XFreePixmap(xw.dpy, xw.buf);
xw.buf = XCreatePixmap(xw.dpy, xw.win, win.w, win.h,
-   DefaultDepth(xw.dpy, xw.scr));
+   xw.depth);
XftDrawChange(xw.draw, xw.buf);
xclear(0, 0, win.w, win.h);

@@ -731,7 +747,7 @@ xloadcolor(int i, const char *name, Color *ncolor)
 }

 v

[hackers] [dwm][PATCH] Make monocle-layout symbol static

2019-04-09 Thread aleks
dwm only uses the monocle-layout symbol, which is defined in the
config.h, when no clients are open. Otherwise, dwm prints the number
of opened clients. This patch makes dwm use the symbol as defined by
the user in the config.h regardless of how many clients are open.

I created this patch because I find an icon as a symbol aesthetically
more pleasant than numbers and because I don't need to know the exact
number of opened clients all the time. Additionally, this patch makes
the code simpler because it only removes code.
---
 dwm.c | 6 --
 1 file changed, 6 deletions(-)

diff --git a/dwm.c b/dwm.c
index 4465af1..3b98778 100644
--- a/dwm.c
+++ b/dwm.c
@@ -1103,14 +1103,8 @@ maprequest(XEvent *e)
 void
 monocle(Monitor *m)
 {
-   unsigned int n = 0;
Client *c;
 
-   for (c = m->clients; c; c = c->next)
-   if (ISVISIBLE(c))
-   n++;
-   if (n > 0) /* override layout symbol */
-   snprintf(m->ltsymbol, sizeof m->ltsymbol, "[%d]", n);
for (c = nexttiled(m->clients); c; c = nexttiled(c->next))
resize(c, m->wx, m->wy, m->ww - 2 * c->bw, m->wh - 2 * c->bw, 
0);
 }
-- 
2.21.0