diff options
-rw-r--r-- | config.def.h | 8 | ||||
-rw-r--r-- | config.h | 8 | ||||
-rw-r--r-- | dwm.c | 104 |
3 files changed, 9 insertions, 111 deletions
diff --git a/config.def.h b/config.def.h index 0fd0ef2..4012429 100644 --- a/config.def.h +++ b/config.def.h @@ -61,8 +61,6 @@ static const Layout layouts[] = { /* helper for spawning shell commands in the pre dwm-5.0 fashion */ #define SHCMD(cmd) { .v = (const char*[]){ "/bin/sh", "-c", cmd, NULL } } -#define STATUSBAR "dwmblocks" - /* commands */ static char dmenumon[2] = "0"; /* component of dmenucmd, manipulated in spawn() */ static const char *dmenucmd[] = { "dmenu_run", "-m", dmenumon, "-fn", dmenufont, "-nb", normbgcolor, "-nf", normfgcolor, "-sb", selbgcolor, "-sf", selfgcolor, NULL }; @@ -111,7 +109,7 @@ static const Key keys[] = { { 0, XF86XK_MonBrightnessDown, spawn, SHCMD("brightnessctl set 10%-") }, { 0, XF86XK_MonBrightnessUp, spawn, SHCMD("brightnessctl set 10%+") }, { 0, XF86XK_Launch1, spawn, SHCMD("dmenu-power") }, - { 0, XK_Print, spawn, SHCMD("screenshot.sh") }, + { 0, XK_Print, spawn, SHCMD("screenshot") }, TAGKEYS( XK_ampersand, 0) TAGKEYS( XK_eacute, 1) TAGKEYS( XK_quotedbl, 2) @@ -131,9 +129,7 @@ static const Button buttons[] = { { ClkLtSymbol, 0, Button1, setlayout, {0} }, { ClkLtSymbol, 0, Button3, setlayout, {.v = &layouts[2]} }, { ClkWinTitle, 0, Button2, zoom, {0} }, - { ClkStatusText, 0, Button1, sigstatusbar, {.i = 1} }, - { ClkStatusText, 0, Button2, sigstatusbar, {.i = 2} }, - { ClkStatusText, 0, Button3, sigstatusbar, {.i = 3} }, + { ClkStatusText, 0, Button2, spawn, {.v = termcmd } }, { ClkClientWin, MODKEY, Button1, movemouse, {0} }, { ClkClientWin, MODKEY, Button2, togglefloating, {0} }, { ClkClientWin, MODKEY, Button3, resizemouse, {0} }, @@ -61,8 +61,6 @@ static const Layout layouts[] = { /* helper for spawning shell commands in the pre dwm-5.0 fashion */ #define SHCMD(cmd) { .v = (const char*[]){ "/bin/sh", "-c", cmd, NULL } } -#define STATUSBAR "dwmblocks" - /* commands */ static char dmenumon[2] = "0"; /* component of dmenucmd, manipulated in spawn() */ static const char *dmenucmd[] = { "dmenu_run", "-m", dmenumon, "-fn", dmenufont, "-nb", normbgcolor, "-nf", normfgcolor, "-sb", selbgcolor, "-sf", selfgcolor, NULL }; @@ -111,7 +109,7 @@ static const Key keys[] = { { 0, XF86XK_MonBrightnessDown, spawn, SHCMD("brightnessctl set 10%-") }, { 0, XF86XK_MonBrightnessUp, spawn, SHCMD("brightnessctl set 10%+") }, { 0, XF86XK_Launch1, spawn, SHCMD("dmenu-power") }, - { 0, XK_Print, spawn, SHCMD("screenshot.sh") }, + { 0, XK_Print, spawn, SHCMD("screenshot") }, TAGKEYS( XK_ampersand, 0) TAGKEYS( XK_eacute, 1) TAGKEYS( XK_quotedbl, 2) @@ -131,9 +129,7 @@ static const Button buttons[] = { { ClkLtSymbol, 0, Button1, setlayout, {0} }, { ClkLtSymbol, 0, Button3, setlayout, {.v = &layouts[2]} }, { ClkWinTitle, 0, Button2, zoom, {0} }, - { ClkStatusText, 0, Button1, sigstatusbar, {.i = 1} }, - { ClkStatusText, 0, Button2, sigstatusbar, {.i = 2} }, - { ClkStatusText, 0, Button3, sigstatusbar, {.i = 3} }, + { ClkStatusText, 0, Button2, spawn, {.v = termcmd } }, { ClkClientWin, MODKEY, Button1, movemouse, {0} }, { ClkClientWin, MODKEY, Button2, togglefloating, {0} }, { ClkClientWin, MODKEY, Button3, resizemouse, {0} }, @@ -202,7 +202,6 @@ static void focusstack(const Arg *arg); static Atom getatomprop(Client *c, Atom prop); static int getrootptr(int *x, int *y); static long getstate(Window w); -static pid_t getstatusbarpid(); static int gettextprop(Window w, Atom atom, char *text, unsigned int size); static void grabbuttons(Client *c, int focused); static void grabkeys(void); @@ -240,7 +239,6 @@ static void setmfact(const Arg *arg); static void setup(void); static void seturgent(Client *c, int urg); static void showhide(Client *c); -static void sigstatusbar(const Arg *arg); static void spawn(const Arg *arg); static void tag(const Arg *arg); static void tagmon(const Arg *arg); @@ -286,9 +284,6 @@ static pid_t winpid(Window w); /* variables */ static const char broken[] = "broken"; static char stext[256]; -static int statusw; -static int statussig; -static pid_t statuspid = -1; static int screen; static int sw, sh; /* X display screen geometry width, height */ static int bh; /* bar height */ @@ -537,7 +532,6 @@ buttonpress(XEvent *e) Client *c; Monitor *m; XButtonPressedEvent *ev = &e->xbutton; - char *text, *s, ch; click = ClkRootWin; /* focus monitor if necessary */ @@ -562,27 +556,9 @@ buttonpress(XEvent *e) arg.ui = 1 << i; } else if (ev->x < x + TEXTW(selmon->ltsymbol)) click = ClkLtSymbol; - else if (ev->x > selmon->ww - statusw) { - x = selmon->ww - statusw; + else if (ev->x > selmon->ww - (int)TEXTW(stext)) click = ClkStatusText; - statussig = 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; - /* reset on matching signal raw byte */ - if (ch == statussig) - statussig = 0; - else - statussig = ch; - } - } - } else + else click = ClkWinTitle; } else if ((c = wintoclient(ev->window))) { focus(c); @@ -876,24 +852,9 @@ 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]); - - 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; + tw = TEXTW(stext) - lrpad + 2; /* 2px right padding */ + drw_text(drw, m->ww - tw, 0, tw, bh, 0, stext, 0); } for (c = m->clients; c; c = c->next) { @@ -1080,30 +1041,6 @@ getatomprop(Client *c, Atom prop) return atom; } -pid_t -getstatusbarpid() -{ - char buf[32], *str = buf, *c; - FILE *fp; - - if (statuspid > 0) { - snprintf(buf, sizeof(buf), "/proc/%u/cmdline", statuspid); - if ((fp = fopen(buf, "r"))) { - fgets(buf, sizeof(buf), fp); - while ((c = strchr(str, '/'))) - str = c + 1; - fclose(fp); - if (!strcmp(str, STATUSBAR)) - return statuspid; - } - } - if (!(fp = popen("pidof -s "STATUSBAR, "r"))) - return -1; - fgets(buf, sizeof(buf), fp); - pclose(fp); - return strtol(buf, NULL, 10); -} - int getrootptr(int *x, int *y) { @@ -2000,20 +1937,6 @@ showhide(Client *c) } void -sigstatusbar(const Arg *arg) -{ - union sigval sv; - - if (!statussig) - return; - sv.sival_int = arg->i; - if ((statuspid = getstatusbarpid()) <= 0) - return; - - sigqueue(statuspid, SIGRTMIN+statussig, sv); -} - -void spawn(const Arg *arg) { struct sigaction sa; @@ -2429,25 +2352,8 @@ 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); } |