New theme + kb
This commit is contained in:
		
							parent
							
								
									9d72348d46
								
							
						
					
					
						commit
						37d3482e82
					
				
							
								
								
									
										5
									
								
								Makefile
									
									
									
									
									
								
							
							
						
						
									
										5
									
								
								Makefile
									
									
									
									
									
								
							| 
						 | 
				
			
			@ -12,11 +12,6 @@ build/obj/%.c.o: %.c
 | 
			
		|||
	mkdir -p $(dir $@)
 | 
			
		||||
	${CC} -c ${CFLAGS} -o $@ $<
 | 
			
		||||
 | 
			
		||||
${OBJ}: config.h config.mk
 | 
			
		||||
 | 
			
		||||
config.h:
 | 
			
		||||
	cp config.def.h $@
 | 
			
		||||
 | 
			
		||||
build/dwm: ${OBJ}
 | 
			
		||||
	${CC} -o $@ ${OBJ} ${LDFLAGS}
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
							
								
								
									
										149
									
								
								config.def.h
									
									
									
									
									
								
							
							
						
						
									
										149
									
								
								config.def.h
									
									
									
									
									
								
							| 
						 | 
				
			
			@ -1,149 +0,0 @@
 | 
			
		|||
/* See LICENSE file for copyright and license details. */
 | 
			
		||||
#ifndef _H_DWM_CONF
 | 
			
		||||
#define _H_DWM_CONF
 | 
			
		||||
 | 
			
		||||
#include "dwm.h"
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
/* appearance */
 | 
			
		||||
const unsigned int borderpx  = 1;        /* border pixel of windows */
 | 
			
		||||
const int startwithgaps[]    = { 1 };	/* 1 means gaps are used by default, this can be customized for each tag */
 | 
			
		||||
const unsigned int gappx[]   = { 10 };   /* default gap between windows in pixels, this can be customized for each tag */
 | 
			
		||||
const unsigned int snap      = 32;       /* snap pixel */
 | 
			
		||||
const int showbar            = 1;        /* 0 means no bar */
 | 
			
		||||
const int topbar             = 0;        /* 0 means bottom bar */
 | 
			
		||||
const char *fonts[]          = { "monospace:size=10" };
 | 
			
		||||
const char dmenufont[]       = "monospace:size=10";
 | 
			
		||||
const char col_gray1[]       = "#222222";
 | 
			
		||||
const char col_gray2[]       = "#444444";
 | 
			
		||||
const char col_gray3[]       = "#bbbbbb";
 | 
			
		||||
const char col_gray4[]       = "#eeeeee";
 | 
			
		||||
const char col_cyan[]        = "#005577";
 | 
			
		||||
const char *colors[][3]      = {
 | 
			
		||||
	/*               fg         bg         border   */
 | 
			
		||||
	[SchemeNorm] = { col_gray3, col_gray1, col_gray2 },
 | 
			
		||||
	[SchemeSel]  = { col_gray4, col_cyan,  col_cyan  },
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
/* tagging */
 | 
			
		||||
const char *tags[] = { "1", "2", "3", "4", "5", "6", "7", "8", "9" };
 | 
			
		||||
 | 
			
		||||
const Rule rules[] = {
 | 
			
		||||
	/* xprop(1):
 | 
			
		||||
	 *	WM_CLASS(STRING) = instance, class
 | 
			
		||||
	 *	WM_NAME(STRING) = title
 | 
			
		||||
	 */
 | 
			
		||||
	/* class      instance    title       tags mask     isfloating   monitor */
 | 
			
		||||
	{ "Gimp",     NULL,       NULL,       0,            1,           -1 },
 | 
			
		||||
	{ "Firefox",  NULL,       NULL,       1 << 2,       0,           -1 },
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
/* layout(s) */
 | 
			
		||||
const float mfact     = 0.55; /* factor of master area size [0.05..0.95] */
 | 
			
		||||
const int nmaster     = 1;    /* number of clients in master area */
 | 
			
		||||
const int resizehints = 1;    /* 1 means respect size hints in tiled resizals */
 | 
			
		||||
const int lockfullscreen = 1; /* 1 will force focus on the fullscreen window */
 | 
			
		||||
 | 
			
		||||
const Layout layouts[] = {
 | 
			
		||||
	/* symbol     arrange function */
 | 
			
		||||
	{ "[T]",      tile },    /* first entry is default */
 | 
			
		||||
	{ "[F]",      NULL },    /* no layout function means floating behavior */
 | 
			
		||||
	{ "[M]",      monocle },
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
/* key definitions */
 | 
			
		||||
#define MODKEY Mod4Mask
 | 
			
		||||
#define TAGKEYS(KEY,TAG) \
 | 
			
		||||
	{ MODKEY,                       KEY,      view,           {.ui = 1 << TAG} }, \
 | 
			
		||||
	{ MODKEY|ControlMask,           KEY,      toggleview,     {.ui = 1 << TAG} }, \
 | 
			
		||||
	{ MODKEY|ShiftMask,             KEY,      tag,            {.ui = 1 << TAG} }, \
 | 
			
		||||
	{ MODKEY|ControlMask|ShiftMask, KEY,      toggletag,      {.ui = 1 << TAG} },
 | 
			
		||||
 | 
			
		||||
/* helper for spawning shell commands in the pre dwm-5.0 fashion */
 | 
			
		||||
#define SHCMD(cmd) { .v = (const char*[]){ "/bin/bash", "-c", cmd, NULL } }
 | 
			
		||||
 | 
			
		||||
const char* upvol[]      = { "/usr/bin/pactl", "set-sink-volume", "@DEFAULT_SINK@", "+5%",    NULL };
 | 
			
		||||
const char* downvol[]    = { "/usr/bin/pactl", "set-sink-volume", "@DEFAULT_SINK@", "-5%",    NULL };
 | 
			
		||||
const char* mutevol[]    = { "/usr/bin/pactl", "set-sink-mute",   "@DEFAULT_SINK@", "toggle", NULL };
 | 
			
		||||
const char* light_up[]   = { "/usr/bin/light", "-A", "5", NULL };
 | 
			
		||||
const char* light_down[] = { "/usr/bin/light", "-U", "5", NULL };
 | 
			
		||||
const char* rofi[]       = { "rofi", "-modi", "drun", "-show", "drun", "-config", "~/.config/rofi/rofidmenu.rasi", NULL };
 | 
			
		||||
 | 
			
		||||
const Key keys[] = {
 | 
			
		||||
	/* modifier                     key        function        argument */
 | 
			
		||||
 | 
			
		||||
	{ MODKEY,                       XK_w,                     spawn,          { .v = (const char*[]){"firefox",                 NULL} }    }, 
 | 
			
		||||
	{ MODKEY,                       XK_n,                     spawn,          { .v = (const char*[]){"thunar",                  NULL} }    }, 
 | 
			
		||||
	{ MODKEY,                       XK_Return,                spawn,          { .v = (const char*[]){"alacritty",               NULL} }    }, 
 | 
			
		||||
    { 0,                            XF86XK_AudioPlay,         spawn,          { .v = (const char*[]){"firefox",                 NULL} }    },
 | 
			
		||||
	{ 0,                            XK_Print,                 spawn,          { .v = (const char*[]){"flameshot", "gui",        NULL} }    }, 
 | 
			
		||||
    { 0,                            XF86XK_AudioStop,         spawn,          { .v = (const char*[]){"playerctl", "play-pause", NULL} }    },
 | 
			
		||||
    { 0,                            XF86XK_AudioNext,         spawn,          { .v = (const char*[]){"playerctl", "next",       NULL} }    },
 | 
			
		||||
    { 0,                            XF86XK_AudioPrev,         spawn,          { .v = (const char*[]){"playerctl", "previous",   NULL} }    },
 | 
			
		||||
    { MODKEY,                       XK_d,                     spawn,          { .v = rofi      }                                           },
 | 
			
		||||
    { 0,                            XF86XK_AudioRaiseVolume,  spawn,          { .v = upvol     }                                           },
 | 
			
		||||
    { 0,                            XF86XK_AudioLowerVolume,  spawn,          { .v = downvol   }                                           },
 | 
			
		||||
    { 0,                            XF86XK_AudioMute,         spawn,          { .v = mutevol   }                                           },
 | 
			
		||||
    { 0,                            XF86XK_MonBrightnessUp,   spawn,          { .v = light_up  }                                           },
 | 
			
		||||
    { 0,                            XF86XK_MonBrightnessDown, spawn,          { .v = light_down}                                           },
 | 
			
		||||
	{ MODKEY,                       XK_j,                     focusstack,     {.i = +1 }                                                   },
 | 
			
		||||
	{ MODKEY,                       XK_k,                     focusstack,     {.i = -1 }                                                   },
 | 
			
		||||
	{ MODKEY,                       XK_i,                     incnmaster,     {.i = +1 }                                                   },
 | 
			
		||||
	{ MODKEY,                       XK_h,                     setmfact,       {.f = -0.05}                                                 },
 | 
			
		||||
	{ MODKEY,                       XK_l,                     setmfact,       {.f = +0.05}                                                 }, 
 | 
			
		||||
	{ MODKEY,                       XK_f,                     togglefullscr,  {0}                                                          },
 | 
			
		||||
	{ MODKEY,                       XK_Tab,                   view,           {0}                                                          }, // Switch windows
 | 
			
		||||
    { MODKEY,                       XK_q,                     killclient,     {0}                                                          }, // Kill prog
 | 
			
		||||
    { MODKEY,                       XK_t,                     setlayout,      {.v = &layouts[0]}                                           },
 | 
			
		||||
	{ MODKEY,                       XK_f,                     setlayout,      {.v = &layouts[1]}                                           },
 | 
			
		||||
    { MODKEY,                       XK_s,                     setlayout,      {.v = &layouts[2]}                                           },
 | 
			
		||||
	{ MODKEY,                       XK_space,                 setlayout,      {0}                                                          },
 | 
			
		||||
	{ MODKEY|ShiftMask,             XK_space,                 togglefloating, {0}                                                          },
 | 
			
		||||
	{ MODKEY,                       XK_0,                     view,           {.ui = ~0 }                                                  },
 | 
			
		||||
    { MODKEY|ShiftMask,             XK_0,                     tag,            {.ui = ~0 }                                                  },
 | 
			
		||||
    TAGKEYS(                        XK_1,                      0)
 | 
			
		||||
	TAGKEYS(                        XK_2,                      1)
 | 
			
		||||
	TAGKEYS(                        XK_3,                      2)
 | 
			
		||||
	TAGKEYS(                        XK_4,                      3)
 | 
			
		||||
	TAGKEYS(                        XK_5,                      4)
 | 
			
		||||
	TAGKEYS(                        XK_6,                      5)
 | 
			
		||||
	TAGKEYS(                        XK_7,                      6)
 | 
			
		||||
	TAGKEYS(                        XK_8,                      7)
 | 
			
		||||
	TAGKEYS(                        XK_9,                      8)
 | 
			
		||||
	{ MODKEY|ShiftMask,             XK_e,      spawn,        {0}},
 | 
			
		||||
 | 
			
		||||
    // { MODKEY,                       XK_minus,  setgaps,        {.i = -5 } },
 | 
			
		||||
    // { MODKEY,                       XK_equal,  setgaps,        {.i = +5 } },
 | 
			
		||||
    // { MODKEY|ShiftMask,             XK_minus,  setgaps,        {.i = GAP_RESET } },
 | 
			
		||||
    // { MODKEY|ShiftMask,             XK_equal,  setgaps,        {.i = GAP_TOGGLE} },
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
    // ????????????????????????????//
 | 
			
		||||
	// { MODKEY,                       XK_comma,  focusmon,       {.i = -1 } },
 | 
			
		||||
	// { MODKEY,                       XK_period, focusmon,       {.i = +1 } },
 | 
			
		||||
	// { MODKEY|ShiftMask,             XK_comma,  tagmon,         {.i = -1 } },
 | 
			
		||||
	// { MODKEY|ShiftMask,             XK_period, tagmon,         {.i = +1 } },
 | 
			
		||||
 | 
			
		||||
	// { MODKEY,                       XK_b,      togglebar,      {0} }, // stupid
 | 
			
		||||
	// { MODKEY,                       XK_Return, zoom,           {0} },
 | 
			
		||||
	// { MODKEY,                       XK_d,      incnmaster,     {.i = -1 } },
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
/* button definitions */
 | 
			
		||||
/* click can be ClkTagBar, ClkLtSymbol, ClkStatusText, ClkWinTitle, ClkClientWin, or ClkRootWin */
 | 
			
		||||
const Button buttons[] = {
 | 
			
		||||
	/* click                event mask      button          function        argument */
 | 
			
		||||
	{ ClkLtSymbol,          0,              Button1,        setlayout,      {0} },
 | 
			
		||||
	{ ClkLtSymbol,          0,              Button3,        setlayout,      {.v = &layouts[2]} },
 | 
			
		||||
	{ ClkWinTitle,          0,              Button2,        zoom,           {0} },
 | 
			
		||||
	// { ClkStatusText,        0,              Button2,        spawn,          {.v = termcmd } },
 | 
			
		||||
	{ ClkClientWin,         MODKEY,         Button1,        movemouse,      {0} },
 | 
			
		||||
	{ ClkClientWin,         MODKEY,         Button2,        togglefloating, {0} },
 | 
			
		||||
	{ ClkClientWin,         MODKEY,         Button3,        resizemouse,    {0} },
 | 
			
		||||
	{ ClkTagBar,            0,              Button1,        view,           {0} },
 | 
			
		||||
	{ ClkTagBar,            0,              Button3,        toggleview,     {0} },
 | 
			
		||||
	{ ClkTagBar,            MODKEY,         Button1,        tag,            {0} },
 | 
			
		||||
	{ ClkTagBar,            MODKEY,         Button3,        toggletag,      {0} },
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
#endif
 | 
			
		||||
							
								
								
									
										35
									
								
								config.h
									
									
									
									
									
								
							
							
						
						
									
										35
									
								
								config.h
									
									
									
									
									
								
							| 
						 | 
				
			
			@ -14,17 +14,22 @@ const int showbar            = 1;        /* 0 means no bar */
 | 
			
		|||
const int topbar             = 0;        /* 0 means bottom bar */
 | 
			
		||||
const char *fonts[]          = { "monospace:size=10" };
 | 
			
		||||
const char dmenufont[]       = "monospace:size=10";
 | 
			
		||||
const char col_gray1[]       = "#222222";
 | 
			
		||||
const char col_gray2[]       = "#444444";
 | 
			
		||||
const char col_gray3[]       = "#bbbbbb";
 | 
			
		||||
const char col_gray4[]       = "#eeeeee";
 | 
			
		||||
const char col_cyan[]        = "#005577";
 | 
			
		||||
const char *colors[][3]      = {
 | 
			
		||||
	/*               fg         bg         border   */
 | 
			
		||||
	[SchemeNorm] = { col_gray3, col_gray1, col_gray2 },
 | 
			
		||||
	[SchemeSel]  = { col_gray4, col_cyan,  col_cyan  },
 | 
			
		||||
 | 
			
		||||
const char* THEME_BW[][3] = {
 | 
			
		||||
    [SchemeNorm] = {"#aaaaaa", "#181818", "#181818"},
 | 
			
		||||
    [SchemeSel]  = {"#aaaaaa", "#3f3f3f", "#3f3f3f"},
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
const char* THEME_DEFAULT[][3] = {
 | 
			
		||||
	/*               text       inactive tag/status bar  border   */
 | 
			
		||||
	[SchemeNorm] = { "#bbbbbb", "#222222",               "#444444" },
 | 
			
		||||
    /*               text       active tag/middle bar    border*/
 | 
			
		||||
	[SchemeSel]  = { "#eeeeee", "#005577",               "#005577"  },
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
#define colors THEME_BW
 | 
			
		||||
 | 
			
		||||
/* tagging */
 | 
			
		||||
const char *tags[] = { "1", "2", "3", "4", "5", "6", "7", "8", "9" };
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -69,6 +74,12 @@ const char* light_up[]   = { "/usr/bin/light", "-A", "5", NULL };
 | 
			
		|||
const char* light_down[] = { "/usr/bin/light", "-U", "5", NULL };
 | 
			
		||||
const char* rofi[]       = { "rofi", "-modi", "drun", "-show", "drun", "-config", "~/.config/rofi/rofidmenu.rasi", NULL };
 | 
			
		||||
 | 
			
		||||
/* commands spawned when clicking statusbar, the mouse button pressed is exported as BUTTON */
 | 
			
		||||
const StatusCmd statuscmds[] = {
 | 
			
		||||
    { "notify-send Mouse$BUTTON", 1 },
 | 
			
		||||
};
 | 
			
		||||
const char *statuscmd[] = { "/bin/sh", "-c", NULL, NULL };
 | 
			
		||||
 | 
			
		||||
const Key keys[] = {
 | 
			
		||||
	/* modifier                     key        function        argument */
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -101,6 +112,7 @@ const Key keys[] = {
 | 
			
		|||
	{ MODKEY|ShiftMask,             XK_space,                 togglefloating, {0}                                                          },
 | 
			
		||||
	{ MODKEY,                       XK_0,                     view,           {.ui = ~0 }                                                  },
 | 
			
		||||
    { MODKEY|ShiftMask,             XK_0,                     tag,            {.ui = ~0 }                                                  },
 | 
			
		||||
	{ MODKEY|ShiftMask,             XK_e,                      quit,          {0}},
 | 
			
		||||
    TAGKEYS(                        XK_1,                      0)
 | 
			
		||||
	TAGKEYS(                        XK_2,                      1)
 | 
			
		||||
	TAGKEYS(                        XK_3,                      2)
 | 
			
		||||
| 
						 | 
				
			
			@ -110,7 +122,6 @@ const Key keys[] = {
 | 
			
		|||
	TAGKEYS(                        XK_7,                      6)
 | 
			
		||||
	TAGKEYS(                        XK_8,                      7)
 | 
			
		||||
	TAGKEYS(                        XK_9,                      8)
 | 
			
		||||
	{ MODKEY|ShiftMask,             XK_e,      quit,         {0}},
 | 
			
		||||
 | 
			
		||||
    // { MODKEY,                       XK_minus,  setgaps,        {.i = -5 } },
 | 
			
		||||
    // { MODKEY,                       XK_equal,  setgaps,        {.i = +5 } },
 | 
			
		||||
| 
						 | 
				
			
			@ -136,7 +147,9 @@ const Button buttons[] = {
 | 
			
		|||
	{ ClkLtSymbol,          0,              Button1,        setlayout,      {0} },
 | 
			
		||||
	{ ClkLtSymbol,          0,              Button3,        setlayout,      {.v = &layouts[2]} },
 | 
			
		||||
	{ ClkWinTitle,          0,              Button2,        zoom,           {0} },
 | 
			
		||||
	// { ClkStatusText,        0,              Button2,        spawn,          {.v = termcmd } },
 | 
			
		||||
	{ ClkStatusText,        0,              Button1,        spawn,          {.v = statuscmd } },
 | 
			
		||||
	{ ClkStatusText,        0,              Button2,        spawn,          {.v = statuscmd } },
 | 
			
		||||
	{ ClkStatusText,        0,              Button3,        spawn,          {.v = statuscmd } },
 | 
			
		||||
	{ ClkClientWin,         MODKEY,         Button1,        movemouse,      {0} },
 | 
			
		||||
	{ ClkClientWin,         MODKEY,         Button2,        togglefloating, {0} },
 | 
			
		||||
	{ ClkClientWin,         MODKEY,         Button3,        resizemouse,    {0} },
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
							
								
								
									
										68
									
								
								dwm.c
									
									
									
									
									
								
							
							
						
						
									
										68
									
								
								dwm.c
									
									
									
									
									
								
							| 
						 | 
				
			
			@ -214,8 +214,27 @@ buttonpress(XEvent *e)
 | 
			
		|||
			arg.ui = 1 << i;
 | 
			
		||||
		} else if (ev->x < x + TEXTW(selmon->ltsymbol))
 | 
			
		||||
			click = ClkLtSymbol;
 | 
			
		||||
		else if (ev->x > selmon->ww - (int)TEXTW(stext))
 | 
			
		||||
		else if (ev->x > selmon->ww - statusw) {
 | 
			
		||||
			char *text, *s, ch;
 | 
			
		||||
			*lastbutton = '0' + ev->button;
 | 
			
		||||
 | 
			
		||||
			x = selmon->ww - statusw;
 | 
			
		||||
			click = ClkStatusText;
 | 
			
		||||
 | 
			
		||||
			statuscmdn = 0;
 | 
			
		||||
			for (text = s = stext; *s && x <= ev->x; s++) {
 | 
			
		||||
				if ((unsigned char)(*s) < ' ') {
 | 
			
		||||
					ch = *s;
 | 
			
		||||
					*s = '\0';
 | 
			
		||||
					x += TEXTW(text) - lrpad;
 | 
			
		||||
					*s = ch;
 | 
			
		||||
					text = s + 1;
 | 
			
		||||
					if (x >= ev->x)
 | 
			
		||||
						break;
 | 
			
		||||
					statuscmdn = ch;
 | 
			
		||||
				}
 | 
			
		||||
			}
 | 
			
		||||
		}
 | 
			
		||||
		else
 | 
			
		||||
			click = ClkWinTitle;
 | 
			
		||||
	} else if ((c = wintoclient(ev->window))) {
 | 
			
		||||
| 
						 | 
				
			
			@ -503,9 +522,24 @@ drawbar(Monitor *m)
 | 
			
		|||
 | 
			
		||||
	/* draw status first so it can be overdrawn by tags later */
 | 
			
		||||
	if (m == selmon) { /* status is only drawn on selected monitor */
 | 
			
		||||
		char *text, *s, ch;
 | 
			
		||||
		drw_setscheme(drw, scheme[SchemeNorm]);
 | 
			
		||||
		tw = TEXTW(stext) - lrpad + 2; /* 2px right padding */
 | 
			
		||||
		drw_text(drw, m->ww - tw, 0, tw, bh, 0, stext, 0);
 | 
			
		||||
 | 
			
		||||
		x = 0;
 | 
			
		||||
		for (text = s = stext; *s; s++) {
 | 
			
		||||
			if ((unsigned char)(*s) < ' ') {
 | 
			
		||||
				ch = *s;
 | 
			
		||||
				*s = '\0';
 | 
			
		||||
				tw = TEXTW(text) - lrpad;
 | 
			
		||||
				drw_text(drw, m->ww - statusw + x, 0, tw, bh, 0, text, 0);
 | 
			
		||||
				x += tw;
 | 
			
		||||
				*s = ch;
 | 
			
		||||
				text = s + 1;
 | 
			
		||||
			}
 | 
			
		||||
		}
 | 
			
		||||
		tw = TEXTW(text) - lrpad + 2;
 | 
			
		||||
		drw_text(drw, m->ww - statusw + x, 0, tw, bh, 0, text, 0);
 | 
			
		||||
		tw = statusw;
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	for (c = m->clients; c; c = c->next) {
 | 
			
		||||
| 
						 | 
				
			
			@ -1495,6 +1529,17 @@ spawn(const Arg *arg)
 | 
			
		|||
	if (fork() == 0) {
 | 
			
		||||
		if (dpy)
 | 
			
		||||
			close(ConnectionNumber(dpy));
 | 
			
		||||
		if (arg->v == statuscmd) {
 | 
			
		||||
			for (int i = 0; i < LENGTH(statuscmds); i++) {
 | 
			
		||||
				if (statuscmdn == statuscmds[i].id) {
 | 
			
		||||
					statuscmd[2] = statuscmds[i].cmd;
 | 
			
		||||
					setenv("BUTTON", lastbutton, 1);
 | 
			
		||||
					break;
 | 
			
		||||
				}
 | 
			
		||||
			}
 | 
			
		||||
			if (!statuscmd[2])
 | 
			
		||||
				exit(EXIT_SUCCESS);
 | 
			
		||||
		}
 | 
			
		||||
		setsid();
 | 
			
		||||
 | 
			
		||||
		sigemptyset(&sa.sa_mask);
 | 
			
		||||
| 
						 | 
				
			
			@ -1896,8 +1941,23 @@ updatesizehints(Client *c)
 | 
			
		|||
void
 | 
			
		||||
updatestatus(void)
 | 
			
		||||
{
 | 
			
		||||
	if (!gettextprop(root, XA_WM_NAME, stext, sizeof(stext)))
 | 
			
		||||
	if (!gettextprop(root, XA_WM_NAME, stext, sizeof(stext))) {
 | 
			
		||||
		strcpy(stext, "dwm-"VERSION);
 | 
			
		||||
		statusw = TEXTW(stext) - lrpad + 2;
 | 
			
		||||
	} else {
 | 
			
		||||
		char *text, *s, ch;
 | 
			
		||||
		statusw = 0;
 | 
			
		||||
		for (text = s = stext; *s; s++) {
 | 
			
		||||
			if ((unsigned char)(*s) < ' ') {
 | 
			
		||||
				ch = *s;
 | 
			
		||||
				*s = '\0';
 | 
			
		||||
				statusw += TEXTW(text) - lrpad;
 | 
			
		||||
				*s = ch;
 | 
			
		||||
				text = s + 1;
 | 
			
		||||
			}
 | 
			
		||||
		}
 | 
			
		||||
		statusw += TEXTW(text) - lrpad + 2;
 | 
			
		||||
	}
 | 
			
		||||
	drawbar(selmon);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
							
								
								
									
										8
									
								
								dwm.h
									
									
									
									
									
								
							
							
						
						
									
										8
									
								
								dwm.h
									
									
									
									
									
								
							| 
						 | 
				
			
			@ -130,6 +130,11 @@ typedef struct {
 | 
			
		|||
	int monitor;
 | 
			
		||||
} Rule;
 | 
			
		||||
 | 
			
		||||
typedef struct {
 | 
			
		||||
	const char *cmd;
 | 
			
		||||
	int id;
 | 
			
		||||
} StatusCmd;
 | 
			
		||||
 | 
			
		||||
/* function declarations */
 | 
			
		||||
void applyrules(Client *c);
 | 
			
		||||
int applysizehints(Client *c, int *x, int *y, int *w, int *h, int interact);
 | 
			
		||||
| 
						 | 
				
			
			@ -259,6 +264,9 @@ Display *dpy;
 | 
			
		|||
Drw *drw;
 | 
			
		||||
Monitor *mons, *selmon;
 | 
			
		||||
Window root, wmcheckwin;
 | 
			
		||||
int statusw;
 | 
			
		||||
int statuscmdn;
 | 
			
		||||
char lastbutton[] = "-";
 | 
			
		||||
 | 
			
		||||
/* configuration, allows nested code to access above variables */
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
							
								
								
									
										167
									
								
								patches/dwm-statuscmd-nosignal-20210402-67d76bd.diff
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										167
									
								
								patches/dwm-statuscmd-nosignal-20210402-67d76bd.diff
									
									
									
									
									
										Normal file
									
								
							| 
						 | 
				
			
			@ -0,0 +1,167 @@
 | 
			
		|||
From 02c4a28dd7f3a88eef3a4e533ace35f79cf09d57 Mon Sep 17 00:00:00 2001
 | 
			
		||||
From: Daniel Bylinka <daniel.bylinka@gmail.com>
 | 
			
		||||
Date: Fri, 2 Apr 2021 19:34:38 +0200
 | 
			
		||||
Subject: [PATCH] [statuscmd] Run shell commands based on mouse location and
 | 
			
		||||
 button
 | 
			
		||||
 | 
			
		||||
---
 | 
			
		||||
 config.def.h | 10 ++++++-
 | 
			
		||||
 dwm.c        | 76 +++++++++++++++++++++++++++++++++++++++++++++++++---
 | 
			
		||||
 2 files changed, 81 insertions(+), 5 deletions(-)
 | 
			
		||||
 | 
			
		||||
diff --git a/config.def.h b/config.def.h
 | 
			
		||||
index 1c0b587..8f88366 100644
 | 
			
		||||
--- a/config.def.h
 | 
			
		||||
+++ b/config.def.h
 | 
			
		||||
@@ -59,6 +59,12 @@ static char dmenumon[2] = "0"; /* component of dmenucmd, manipulated in spawn()
 | 
			
		||||
 static const char *dmenucmd[] = { "dmenu_run", "-m", dmenumon, "-fn", dmenufont, "-nb", col_gray1, "-nf", col_gray3, "-sb", col_cyan, "-sf", col_gray4, NULL };
 | 
			
		||||
 static const char *termcmd[]  = { "st", NULL };
 | 
			
		||||
 
 | 
			
		||||
+/* commands spawned when clicking statusbar, the mouse button pressed is exported as BUTTON */
 | 
			
		||||
+static const StatusCmd statuscmds[] = {
 | 
			
		||||
+	{ "notify-send Mouse$BUTTON", 1 },
 | 
			
		||||
+};
 | 
			
		||||
+static const char *statuscmd[] = { "/bin/sh", "-c", NULL, NULL };
 | 
			
		||||
+
 | 
			
		||||
 static Key keys[] = {
 | 
			
		||||
 	/* modifier                     key        function        argument */
 | 
			
		||||
 	{ MODKEY,                       XK_p,      spawn,          {.v = dmenucmd } },
 | 
			
		||||
@@ -103,7 +109,9 @@ static Button buttons[] = {
 | 
			
		||||
 	{ ClkLtSymbol,          0,              Button1,        setlayout,      {0} },
 | 
			
		||||
 	{ ClkLtSymbol,          0,              Button3,        setlayout,      {.v = &layouts[2]} },
 | 
			
		||||
 	{ ClkWinTitle,          0,              Button2,        zoom,           {0} },
 | 
			
		||||
-	{ ClkStatusText,        0,              Button2,        spawn,          {.v = termcmd } },
 | 
			
		||||
+	{ ClkStatusText,        0,              Button1,        spawn,          {.v = statuscmd } },
 | 
			
		||||
+	{ ClkStatusText,        0,              Button2,        spawn,          {.v = statuscmd } },
 | 
			
		||||
+	{ ClkStatusText,        0,              Button3,        spawn,          {.v = statuscmd } },
 | 
			
		||||
 	{ ClkClientWin,         MODKEY,         Button1,        movemouse,      {0} },
 | 
			
		||||
 	{ ClkClientWin,         MODKEY,         Button2,        togglefloating, {0} },
 | 
			
		||||
 	{ ClkClientWin,         MODKEY,         Button3,        resizemouse,    {0} },
 | 
			
		||||
diff --git a/dwm.c b/dwm.c
 | 
			
		||||
index b0b3466..eb478a5 100644
 | 
			
		||||
--- a/dwm.c
 | 
			
		||||
+++ b/dwm.c
 | 
			
		||||
@@ -141,6 +141,11 @@ typedef struct {
 | 
			
		||||
 	int monitor;
 | 
			
		||||
 } Rule;
 | 
			
		||||
 
 | 
			
		||||
+typedef struct {
 | 
			
		||||
+	const char *cmd;
 | 
			
		||||
+	int id;
 | 
			
		||||
+} StatusCmd;
 | 
			
		||||
+
 | 
			
		||||
 /* function declarations */
 | 
			
		||||
 static void applyrules(Client *c);
 | 
			
		||||
 static int applysizehints(Client *c, int *x, int *y, int *w, int *h, int interact);
 | 
			
		||||
@@ -238,6 +243,9 @@ static void zoom(const Arg *arg);
 | 
			
		||||
 /* variables */
 | 
			
		||||
 static const char broken[] = "broken";
 | 
			
		||||
 static char stext[256];
 | 
			
		||||
+static int statusw;
 | 
			
		||||
+static int statuscmdn;
 | 
			
		||||
+static char lastbutton[] = "-";
 | 
			
		||||
 static int screen;
 | 
			
		||||
 static int sw, sh;           /* X display screen geometry width, height */
 | 
			
		||||
 static int bh, blw = 0;      /* bar geometry */
 | 
			
		||||
@@ -440,8 +448,27 @@ buttonpress(XEvent *e)
 | 
			
		||||
 			arg.ui = 1 << i;
 | 
			
		||||
 		} else if (ev->x < x + blw)
 | 
			
		||||
 			click = ClkLtSymbol;
 | 
			
		||||
-		else if (ev->x > selmon->ww - (int)TEXTW(stext))
 | 
			
		||||
+		else if (ev->x > selmon->ww - statusw) {
 | 
			
		||||
+			char *text, *s, ch;
 | 
			
		||||
+			*lastbutton = '0' + ev->button;
 | 
			
		||||
+
 | 
			
		||||
+			x = selmon->ww - statusw;
 | 
			
		||||
 			click = ClkStatusText;
 | 
			
		||||
+
 | 
			
		||||
+			statuscmdn = 0;
 | 
			
		||||
+			for (text = s = stext; *s && x <= ev->x; s++) {
 | 
			
		||||
+				if ((unsigned char)(*s) < ' ') {
 | 
			
		||||
+					ch = *s;
 | 
			
		||||
+					*s = '\0';
 | 
			
		||||
+					x += TEXTW(text) - lrpad;
 | 
			
		||||
+					*s = ch;
 | 
			
		||||
+					text = s + 1;
 | 
			
		||||
+					if (x >= ev->x)
 | 
			
		||||
+						break;
 | 
			
		||||
+					statuscmdn = ch;
 | 
			
		||||
+				}
 | 
			
		||||
+			}
 | 
			
		||||
+		}
 | 
			
		||||
 		else
 | 
			
		||||
 			click = ClkWinTitle;
 | 
			
		||||
 	} else if ((c = wintoclient(ev->window))) {
 | 
			
		||||
@@ -704,9 +731,24 @@ drawbar(Monitor *m)
 | 
			
		||||
 
 | 
			
		||||
 	/* draw status first so it can be overdrawn by tags later */
 | 
			
		||||
 	if (m == selmon) { /* status is only drawn on selected monitor */
 | 
			
		||||
+		char *text, *s, ch;
 | 
			
		||||
 		drw_setscheme(drw, scheme[SchemeNorm]);
 | 
			
		||||
-		tw = TEXTW(stext) - lrpad + 2; /* 2px right padding */
 | 
			
		||||
-		drw_text(drw, m->ww - tw, 0, tw, bh, 0, stext, 0);
 | 
			
		||||
+
 | 
			
		||||
+		x = 0;
 | 
			
		||||
+		for (text = s = stext; *s; s++) {
 | 
			
		||||
+			if ((unsigned char)(*s) < ' ') {
 | 
			
		||||
+				ch = *s;
 | 
			
		||||
+				*s = '\0';
 | 
			
		||||
+				tw = TEXTW(text) - lrpad;
 | 
			
		||||
+				drw_text(drw, m->ww - statusw + x, 0, tw, bh, 0, text, 0);
 | 
			
		||||
+				x += tw;
 | 
			
		||||
+				*s = ch;
 | 
			
		||||
+				text = s + 1;
 | 
			
		||||
+			}
 | 
			
		||||
+		}
 | 
			
		||||
+		tw = TEXTW(text) - lrpad + 2;
 | 
			
		||||
+		drw_text(drw, m->ww - statusw + x, 0, tw, bh, 0, text, 0);
 | 
			
		||||
+		tw = statusw;
 | 
			
		||||
 	}
 | 
			
		||||
 
 | 
			
		||||
 	for (c = m->clients; c; c = c->next) {
 | 
			
		||||
@@ -1645,6 +1687,17 @@ spawn(const Arg *arg)
 | 
			
		||||
 	if (fork() == 0) {
 | 
			
		||||
 		if (dpy)
 | 
			
		||||
 			close(ConnectionNumber(dpy));
 | 
			
		||||
+		if (arg->v == statuscmd) {
 | 
			
		||||
+			for (int i = 0; i < LENGTH(statuscmds); i++) {
 | 
			
		||||
+				if (statuscmdn == statuscmds[i].id) {
 | 
			
		||||
+					statuscmd[2] = statuscmds[i].cmd;
 | 
			
		||||
+					setenv("BUTTON", lastbutton, 1);
 | 
			
		||||
+					break;
 | 
			
		||||
+				}
 | 
			
		||||
+			}
 | 
			
		||||
+			if (!statuscmd[2])
 | 
			
		||||
+				exit(EXIT_SUCCESS);
 | 
			
		||||
+		}
 | 
			
		||||
 		setsid();
 | 
			
		||||
 		execvp(((char **)arg->v)[0], (char **)arg->v);
 | 
			
		||||
 		fprintf(stderr, "dwm: execvp %s", ((char **)arg->v)[0]);
 | 
			
		||||
@@ -1990,8 +2043,23 @@ updatesizehints(Client *c)
 | 
			
		||||
 void
 | 
			
		||||
 updatestatus(void)
 | 
			
		||||
 {
 | 
			
		||||
-	if (!gettextprop(root, XA_WM_NAME, stext, sizeof(stext)))
 | 
			
		||||
+	if (!gettextprop(root, XA_WM_NAME, stext, sizeof(stext))) {
 | 
			
		||||
 		strcpy(stext, "dwm-"VERSION);
 | 
			
		||||
+		statusw = TEXTW(stext) - lrpad + 2;
 | 
			
		||||
+	} else {
 | 
			
		||||
+		char *text, *s, ch;
 | 
			
		||||
+		statusw = 0;
 | 
			
		||||
+		for (text = s = stext; *s; s++) {
 | 
			
		||||
+			if ((unsigned char)(*s) < ' ') {
 | 
			
		||||
+				ch = *s;
 | 
			
		||||
+				*s = '\0';
 | 
			
		||||
+				statusw += TEXTW(text) - lrpad;
 | 
			
		||||
+				*s = ch;
 | 
			
		||||
+				text = s + 1;
 | 
			
		||||
+			}
 | 
			
		||||
+		}
 | 
			
		||||
+		statusw += TEXTW(text) - lrpad + 2;
 | 
			
		||||
+	}
 | 
			
		||||
 	drawbar(selmon);
 | 
			
		||||
 }
 | 
			
		||||
 
 | 
			
		||||
-- 
 | 
			
		||||
2.31.0
 | 
			
		||||
 | 
			
		||||
		Loading…
	
		Reference in New Issue
	
	Block a user