Compare commits
13 Commits
master
...
18b76b790d
| Author | SHA1 | Date | |
|---|---|---|---|
| 18b76b790d | |||
| fd2408ff83 | |||
| c013256eef | |||
|
|
431135ecd9 | ||
|
|
f2837055a1 | ||
|
|
5bcc02f2a7 | ||
| 9e3e644c21 | |||
| b6d063c786 | |||
| 272db9d233 | |||
| e93f93b98c | |||
| cc4d5e65d7 | |||
|
|
9b49e9ad18 | ||
|
|
cfe958510f |
54
config.def.h
54
config.def.h
@@ -1,7 +1,8 @@
|
|||||||
/* See LICENSE file for copyright and license details. */
|
/* See LICENSE file for copyright and license details. */
|
||||||
|
|
||||||
/* appearance */
|
/* appearance */
|
||||||
static const unsigned int borderpx = 1; /* border pixel of windows */
|
static const unsigned int borderpx = 2; /* border pixel of windows */
|
||||||
|
static const unsigned int gappx = 2; /* gaps between windows */
|
||||||
static const unsigned int snap = 32; /* snap pixel */
|
static const unsigned int snap = 32; /* snap pixel */
|
||||||
static const int showbar = 1; /* 0 means no bar */
|
static const int showbar = 1; /* 0 means no bar */
|
||||||
static const int topbar = 1; /* 0 means bottom bar */
|
static const int topbar = 1; /* 0 means bottom bar */
|
||||||
@@ -12,10 +13,19 @@ static const char col_gray2[] = "#444444";
|
|||||||
static const char col_gray3[] = "#bbbbbb";
|
static const char col_gray3[] = "#bbbbbb";
|
||||||
static const char col_gray4[] = "#eeeeee";
|
static const char col_gray4[] = "#eeeeee";
|
||||||
static const char col_cyan[] = "#005577";
|
static const char col_cyan[] = "#005577";
|
||||||
static const char *colors[][3] = {
|
static const char col_border_focus_light[] = "#df8c20"; // hsl(34 75% 50%)
|
||||||
|
static const char col_border_focus_dark[] = "#b25e34"; // hsl(20 55% 45%)
|
||||||
|
static const char *colorsdark[][3] = {
|
||||||
/* fg bg border */
|
/* fg bg border */
|
||||||
[SchemeNorm] = { col_gray3, col_gray1, col_gray2 },
|
[SchemeNorm] = { col_gray3, col_gray1, col_gray2 },
|
||||||
[SchemeSel] = { col_gray4, col_cyan, col_cyan },
|
[SchemeSel] = { col_gray4, col_cyan, col_border_focus_dark },
|
||||||
|
[SchemeHid] = { col_cyan, col_gray1, col_cyan },
|
||||||
|
};
|
||||||
|
static const char *colorslight[][3] = {
|
||||||
|
/* fg bg border */
|
||||||
|
[SchemeNorm] = { col_gray1, col_gray3, col_gray2 },
|
||||||
|
[SchemeSel] = { col_cyan, col_gray4, col_border_focus_light },
|
||||||
|
[SchemeHid] = { col_cyan, col_gray1, col_cyan },
|
||||||
};
|
};
|
||||||
|
|
||||||
/* tagging */
|
/* tagging */
|
||||||
@@ -45,7 +55,7 @@ static const Layout layouts[] = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
/* key definitions */
|
/* key definitions */
|
||||||
#define MODKEY Mod1Mask
|
#define MODKEY Mod4Mask
|
||||||
#define TAGKEYS(KEY,TAG) \
|
#define TAGKEYS(KEY,TAG) \
|
||||||
{ MODKEY, KEY, view, {.ui = 1 << TAG} }, \
|
{ MODKEY, KEY, view, {.ui = 1 << TAG} }, \
|
||||||
{ MODKEY|ControlMask, KEY, toggleview, {.ui = 1 << TAG} }, \
|
{ MODKEY|ControlMask, KEY, toggleview, {.ui = 1 << TAG} }, \
|
||||||
@@ -56,17 +66,24 @@ static const Layout layouts[] = {
|
|||||||
#define SHCMD(cmd) { .v = (const char*[]){ "/bin/sh", "-c", cmd, NULL } }
|
#define SHCMD(cmd) { .v = (const char*[]){ "/bin/sh", "-c", cmd, NULL } }
|
||||||
|
|
||||||
/* commands */
|
/* commands */
|
||||||
static char dmenumon[2] = "0"; /* component of dmenucmd, manipulated in spawn() */
|
static char dmenumon[2] = "0"; /* component of dmenu{dark,light}, manipulated in spawndmenu() */
|
||||||
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 *dmenudark[] = { "dmenu_run", "-m", dmenumon, "-i", "-fn", dmenufont, "-nb", col_gray1, "-nf", col_gray3, "-sb", col_cyan, "-sf", col_gray4, NULL };
|
||||||
|
static const char *dmenulight[] = { "dmenu_run", "-m", dmenumon, "-i", "-fn", dmenufont, "-nb", col_gray3, "-nf", col_gray1, "-sb", col_cyan, "-sf", col_gray4, NULL };
|
||||||
static const char *termcmd[] = { "st", NULL };
|
static const char *termcmd[] = { "st", NULL };
|
||||||
|
static const char *lockcmd[] = { "slock", NULL };
|
||||||
|
static const char *suspendcmd[] = { "systemctl", "suspend", NULL };
|
||||||
|
static const char *themecmd[] = { "lupan-set-theme", "toggle", NULL };
|
||||||
|
|
||||||
|
#include "exitdwm.c"
|
||||||
static const Key keys[] = {
|
static const Key keys[] = {
|
||||||
/* modifier key function argument */
|
/* modifier key function argument */
|
||||||
{ MODKEY, XK_p, spawn, {.v = dmenucmd } },
|
{ MODKEY, XK_p, spawndmenu, {0} },
|
||||||
{ MODKEY|ShiftMask, XK_Return, spawn, {.v = termcmd } },
|
{ MODKEY|ShiftMask, XK_Return, spawn, {.v = termcmd } },
|
||||||
{ MODKEY, XK_b, togglebar, {0} },
|
{ MODKEY, XK_b, togglebar, {0} },
|
||||||
{ MODKEY, XK_j, focusstack, {.i = +1 } },
|
{ MODKEY, XK_j, focusstackvis, {.i = +1 } },
|
||||||
{ MODKEY, XK_k, focusstack, {.i = -1 } },
|
{ MODKEY, XK_k, focusstackvis, {.i = -1 } },
|
||||||
|
{ MODKEY|ShiftMask, XK_j, focusstackhid, {.i = +1 } },
|
||||||
|
{ MODKEY|ShiftMask, XK_k, focusstackhid, {.i = -1 } },
|
||||||
{ MODKEY, XK_i, incnmaster, {.i = +1 } },
|
{ MODKEY, XK_i, incnmaster, {.i = +1 } },
|
||||||
{ MODKEY, XK_d, incnmaster, {.i = -1 } },
|
{ MODKEY, XK_d, incnmaster, {.i = -1 } },
|
||||||
{ MODKEY, XK_h, setmfact, {.f = -0.05} },
|
{ MODKEY, XK_h, setmfact, {.f = -0.05} },
|
||||||
@@ -85,6 +102,9 @@ static const Key keys[] = {
|
|||||||
{ MODKEY, XK_period, focusmon, {.i = +1 } },
|
{ MODKEY, XK_period, focusmon, {.i = +1 } },
|
||||||
{ MODKEY|ShiftMask, XK_comma, tagmon, {.i = -1 } },
|
{ MODKEY|ShiftMask, XK_comma, tagmon, {.i = -1 } },
|
||||||
{ MODKEY|ShiftMask, XK_period, tagmon, {.i = +1 } },
|
{ MODKEY|ShiftMask, XK_period, tagmon, {.i = +1 } },
|
||||||
|
{ MODKEY, XK_s, show, {0} },
|
||||||
|
{ MODKEY|ShiftMask, XK_s, showall, {0} },
|
||||||
|
{ MODKEY, XK_h, hide, {0} },
|
||||||
TAGKEYS( XK_1, 0)
|
TAGKEYS( XK_1, 0)
|
||||||
TAGKEYS( XK_2, 1)
|
TAGKEYS( XK_2, 1)
|
||||||
TAGKEYS( XK_3, 2)
|
TAGKEYS( XK_3, 2)
|
||||||
@@ -94,7 +114,22 @@ static const Key keys[] = {
|
|||||||
TAGKEYS( XK_7, 6)
|
TAGKEYS( XK_7, 6)
|
||||||
TAGKEYS( XK_8, 7)
|
TAGKEYS( XK_8, 7)
|
||||||
TAGKEYS( XK_9, 8)
|
TAGKEYS( XK_9, 8)
|
||||||
|
{ ControlMask, XK_1, focusbynum, {.i = 0} },
|
||||||
|
{ ControlMask, XK_2, focusbynum, {.i = 1} },
|
||||||
|
{ ControlMask, XK_3, focusbynum, {.i = 2} },
|
||||||
|
{ ControlMask, XK_4, focusbynum, {.i = 3} },
|
||||||
|
{ ControlMask, XK_5, focusbynum, {.i = 4} },
|
||||||
|
{ ControlMask, XK_6, focusbynum, {.i = 5} },
|
||||||
|
{ ControlMask, XK_7, focusbynum, {.i = 6} },
|
||||||
|
{ ControlMask, XK_8, focusbynum, {.i = 7} },
|
||||||
|
{ ControlMask, XK_9, focusbynum, {.i = 8} },
|
||||||
{ MODKEY|ShiftMask, XK_q, quit, {0} },
|
{ MODKEY|ShiftMask, XK_q, quit, {0} },
|
||||||
|
{ MODKEY|ControlMask|ShiftMask, XK_q, quit, {1} },
|
||||||
|
{ MODKEY|ShiftMask, XK_e, exitdwm, {0} },
|
||||||
|
{ MODKEY|ControlMask|ShiftMask, XK_s, spawn, {.v = suspendcmd } },
|
||||||
|
{ MODKEY|ControlMask|ShiftMask, XK_l, spawn, {.v = lockcmd } },
|
||||||
|
{ MODKEY|ControlMask|ShiftMask, XK_t, spawn, {.v = themecmd } },
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
/* button definitions */
|
/* button definitions */
|
||||||
@@ -103,6 +138,7 @@ static const Button buttons[] = {
|
|||||||
/* click event mask button function argument */
|
/* click event mask button function argument */
|
||||||
{ ClkLtSymbol, 0, Button1, setlayout, {0} },
|
{ ClkLtSymbol, 0, Button1, setlayout, {0} },
|
||||||
{ ClkLtSymbol, 0, Button3, setlayout, {.v = &layouts[2]} },
|
{ ClkLtSymbol, 0, Button3, setlayout, {.v = &layouts[2]} },
|
||||||
|
{ ClkWinTitle, 0, Button1, togglewin, {0} },
|
||||||
{ ClkWinTitle, 0, Button2, zoom, {0} },
|
{ ClkWinTitle, 0, Button2, zoom, {0} },
|
||||||
{ ClkStatusText, 0, Button2, spawn, {.v = termcmd } },
|
{ ClkStatusText, 0, Button2, spawn, {.v = termcmd } },
|
||||||
{ ClkClientWin, MODKEY, Button1, movemouse, {0} },
|
{ ClkClientWin, MODKEY, Button1, movemouse, {0} },
|
||||||
|
|||||||
10
dwm.1
10
dwm.1
@@ -142,6 +142,9 @@ Add/remove all windows with nth tag to/from the view.
|
|||||||
.TP
|
.TP
|
||||||
.B Mod1\-Shift\-q
|
.B Mod1\-Shift\-q
|
||||||
Quit dwm.
|
Quit dwm.
|
||||||
|
.TP
|
||||||
|
.B Mod1\-Control\-Shift\-q
|
||||||
|
Restart dwm.
|
||||||
.SS Mouse commands
|
.SS Mouse commands
|
||||||
.TP
|
.TP
|
||||||
.B Mod1\-Button1
|
.B Mod1\-Button1
|
||||||
@@ -155,6 +158,13 @@ Resize focused window while dragging. Tiled windows will be toggled to the float
|
|||||||
.SH CUSTOMIZATION
|
.SH CUSTOMIZATION
|
||||||
dwm is customized by creating a custom config.h and (re)compiling the source
|
dwm is customized by creating a custom config.h and (re)compiling the source
|
||||||
code. This keeps it fast, secure and simple.
|
code. This keeps it fast, secure and simple.
|
||||||
|
.SH SIGNALS
|
||||||
|
.TP
|
||||||
|
.B SIGHUP - 1
|
||||||
|
Restart the dwm process.
|
||||||
|
.TP
|
||||||
|
.B SIGTERM - 15
|
||||||
|
Cleanly terminate the dwm process.
|
||||||
.SH SEE ALSO
|
.SH SEE ALSO
|
||||||
.BR dmenu (1),
|
.BR dmenu (1),
|
||||||
.BR st (1)
|
.BR st (1)
|
||||||
|
|||||||
452
dwm.c
452
dwm.c
@@ -50,18 +50,20 @@
|
|||||||
#define INTERSECT(x,y,w,h,m) (MAX(0, MIN((x)+(w),(m)->wx+(m)->ww) - MAX((x),(m)->wx)) \
|
#define INTERSECT(x,y,w,h,m) (MAX(0, MIN((x)+(w),(m)->wx+(m)->ww) - MAX((x),(m)->wx)) \
|
||||||
* MAX(0, MIN((y)+(h),(m)->wy+(m)->wh) - MAX((y),(m)->wy)))
|
* MAX(0, MIN((y)+(h),(m)->wy+(m)->wh) - MAX((y),(m)->wy)))
|
||||||
#define ISVISIBLE(C) ((C->tags & C->mon->tagset[C->mon->seltags]))
|
#define ISVISIBLE(C) ((C->tags & C->mon->tagset[C->mon->seltags]))
|
||||||
|
#define HIDDEN(C) ((getstate(C->win) == IconicState))
|
||||||
|
#define LENGTH(X) (sizeof X / sizeof X[0])
|
||||||
#define MOUSEMASK (BUTTONMASK|PointerMotionMask)
|
#define MOUSEMASK (BUTTONMASK|PointerMotionMask)
|
||||||
#define WIDTH(X) ((X)->w + 2 * (X)->bw)
|
#define WIDTH(X) ((X)->w + 2 * (X)->bw + gappx)
|
||||||
#define HEIGHT(X) ((X)->h + 2 * (X)->bw)
|
#define HEIGHT(X) ((X)->h + 2 * (X)->bw + gappx)
|
||||||
#define TAGMASK ((1 << LENGTH(tags)) - 1)
|
#define TAGMASK ((1 << LENGTH(tags)) - 1)
|
||||||
#define TEXTW(X) (drw_fontset_getwidth(drw, (X)) + lrpad)
|
#define TEXTW(X) (drw_fontset_getwidth(drw, (X)) + lrpad)
|
||||||
|
|
||||||
/* enums */
|
/* enums */
|
||||||
enum { CurNormal, CurResize, CurMove, CurLast }; /* cursor */
|
enum { CurNormal, CurResize, CurMove, CurLast }; /* cursor */
|
||||||
enum { SchemeNorm, SchemeSel }; /* color schemes */
|
enum { SchemeNorm, SchemeSel, SchemeHid }; /* color schemes */
|
||||||
enum { NetSupported, NetWMName, NetWMState, NetWMCheck,
|
enum { NetSupported, NetWMName, NetWMState, NetWMCheck,
|
||||||
NetWMFullscreen, NetActiveWindow, NetWMWindowType,
|
NetWMFullscreen, NetActiveWindow, NetWMWindowType,
|
||||||
NetWMWindowTypeDialog, NetClientList, NetLast }; /* EWMH atoms */
|
NetWMWindowTypeDialog, NetClientList, NetClientInfo, NetLast }; /* EWMH atoms */
|
||||||
enum { WMProtocols, WMDelete, WMState, WMTakeFocus, WMLast }; /* default atoms */
|
enum { WMProtocols, WMDelete, WMState, WMTakeFocus, WMLast }; /* default atoms */
|
||||||
enum { ClkTagBar, ClkLtSymbol, ClkStatusText, ClkWinTitle,
|
enum { ClkTagBar, ClkLtSymbol, ClkStatusText, ClkWinTitle,
|
||||||
ClkClientWin, ClkRootWin, ClkLast }; /* clicks */
|
ClkClientWin, ClkRootWin, ClkLast }; /* clicks */
|
||||||
@@ -116,6 +118,8 @@ struct Monitor {
|
|||||||
int nmaster;
|
int nmaster;
|
||||||
int num;
|
int num;
|
||||||
int by; /* bar geometry */
|
int by; /* bar geometry */
|
||||||
|
int btw; /* width of tasks portion of bar */
|
||||||
|
int bt; /* number of tasks */
|
||||||
int mx, my, mw, mh; /* screen size */
|
int mx, my, mw, mh; /* screen size */
|
||||||
int wx, wy, ww, wh; /* window area */
|
int wx, wy, ww, wh; /* window area */
|
||||||
unsigned int seltags;
|
unsigned int seltags;
|
||||||
@@ -123,6 +127,7 @@ struct Monitor {
|
|||||||
unsigned int tagset[2];
|
unsigned int tagset[2];
|
||||||
int showbar;
|
int showbar;
|
||||||
int topbar;
|
int topbar;
|
||||||
|
int hidsel;
|
||||||
Client *clients;
|
Client *clients;
|
||||||
Client *sel;
|
Client *sel;
|
||||||
Client *stack;
|
Client *stack;
|
||||||
@@ -152,6 +157,7 @@ static void checkotherwm(void);
|
|||||||
static void cleanup(void);
|
static void cleanup(void);
|
||||||
static void cleanupmon(Monitor *mon);
|
static void cleanupmon(Monitor *mon);
|
||||||
static void clientmessage(XEvent *e);
|
static void clientmessage(XEvent *e);
|
||||||
|
static void colormodehandler(int sig);
|
||||||
static void configure(Client *c);
|
static void configure(Client *c);
|
||||||
static void configurenotify(XEvent *e);
|
static void configurenotify(XEvent *e);
|
||||||
static void configurerequest(XEvent *e);
|
static void configurerequest(XEvent *e);
|
||||||
@@ -167,13 +173,17 @@ static void expose(XEvent *e);
|
|||||||
static void focus(Client *c);
|
static void focus(Client *c);
|
||||||
static void focusin(XEvent *e);
|
static void focusin(XEvent *e);
|
||||||
static void focusmon(const Arg *arg);
|
static void focusmon(const Arg *arg);
|
||||||
static void focusstack(const Arg *arg);
|
static void focusstackvis(const Arg *arg);
|
||||||
|
static void focusstackhid(const Arg *arg);
|
||||||
|
static void focusstack(int inc, int vis);
|
||||||
static Atom getatomprop(Client *c, Atom prop);
|
static Atom getatomprop(Client *c, Atom prop);
|
||||||
static int getrootptr(int *x, int *y);
|
static int getrootptr(int *x, int *y);
|
||||||
static long getstate(Window w);
|
static long getstate(Window w);
|
||||||
static int gettextprop(Window w, Atom atom, char *text, unsigned int size);
|
static int gettextprop(Window w, Atom atom, char *text, unsigned int size);
|
||||||
static void grabbuttons(Client *c, int focused);
|
static void grabbuttons(Client *c, int focused);
|
||||||
static void grabkeys(void);
|
static void grabkeys(void);
|
||||||
|
static void hide(const Arg *arg);
|
||||||
|
static void hidewin(Client *c);
|
||||||
static void incnmaster(const Arg *arg);
|
static void incnmaster(const Arg *arg);
|
||||||
static void keypress(XEvent *e);
|
static void keypress(XEvent *e);
|
||||||
static void killclient(const Arg *arg);
|
static void killclient(const Arg *arg);
|
||||||
@@ -197,21 +207,32 @@ static void scan(void);
|
|||||||
static int sendevent(Client *c, Atom proto);
|
static int sendevent(Client *c, Atom proto);
|
||||||
static void sendmon(Client *c, Monitor *m);
|
static void sendmon(Client *c, Monitor *m);
|
||||||
static void setclientstate(Client *c, long state);
|
static void setclientstate(Client *c, long state);
|
||||||
|
static void setclienttagprop(Client *c);
|
||||||
|
static void setcolormode(void);
|
||||||
static void setfocus(Client *c);
|
static void setfocus(Client *c);
|
||||||
static void setfullscreen(Client *c, int fullscreen);
|
static void setfullscreen(Client *c, int fullscreen);
|
||||||
static void setlayout(const Arg *arg);
|
static void setlayout(const Arg *arg);
|
||||||
static void setmfact(const Arg *arg);
|
static void setmfact(const Arg *arg);
|
||||||
static void setup(void);
|
static void setup(void);
|
||||||
static void seturgent(Client *c, int urg);
|
static void seturgent(Client *c, int urg);
|
||||||
|
static void show(const Arg *arg);
|
||||||
|
static void showall(const Arg *arg);
|
||||||
|
static void showwin(Client *c);
|
||||||
static void showhide(Client *c);
|
static void showhide(Client *c);
|
||||||
|
static void sigchld(int unused);
|
||||||
|
static void sighup(int unused);
|
||||||
|
static void sigterm(int unused);
|
||||||
static void spawn(const Arg *arg);
|
static void spawn(const Arg *arg);
|
||||||
|
static void spawndmenu(const Arg *arg);
|
||||||
static void tag(const Arg *arg);
|
static void tag(const Arg *arg);
|
||||||
static void tagmon(const Arg *arg);
|
static void tagmon(const Arg *arg);
|
||||||
static void tile(Monitor *m);
|
static void tile(Monitor *m);
|
||||||
static void togglebar(const Arg *arg);
|
static void togglebar(const Arg *arg);
|
||||||
static void togglefloating(const Arg *arg);
|
static void togglefloating(const Arg *arg);
|
||||||
|
static void focusbynum(const Arg *arg);
|
||||||
static void toggletag(const Arg *arg);
|
static void toggletag(const Arg *arg);
|
||||||
static void toggleview(const Arg *arg);
|
static void toggleview(const Arg *arg);
|
||||||
|
static void togglewin(const Arg *arg);
|
||||||
static void unfocus(Client *c, int setfocus);
|
static void unfocus(Client *c, int setfocus);
|
||||||
static void unmanage(Client *c, int destroyed);
|
static void unmanage(Client *c, int destroyed);
|
||||||
static void unmapnotify(XEvent *e);
|
static void unmapnotify(XEvent *e);
|
||||||
@@ -226,6 +247,7 @@ static void updatetitle(Client *c);
|
|||||||
static void updatewindowtype(Client *c);
|
static void updatewindowtype(Client *c);
|
||||||
static void updatewmhints(Client *c);
|
static void updatewmhints(Client *c);
|
||||||
static void view(const Arg *arg);
|
static void view(const Arg *arg);
|
||||||
|
static void warp(const Client *c);
|
||||||
static Client *wintoclient(Window w);
|
static Client *wintoclient(Window w);
|
||||||
static Monitor *wintomon(Window w);
|
static Monitor *wintomon(Window w);
|
||||||
static int xerror(Display *dpy, XErrorEvent *ee);
|
static int xerror(Display *dpy, XErrorEvent *ee);
|
||||||
@@ -259,13 +281,16 @@ static void (*handler[LASTEvent]) (XEvent *) = {
|
|||||||
[UnmapNotify] = unmapnotify
|
[UnmapNotify] = unmapnotify
|
||||||
};
|
};
|
||||||
static Atom wmatom[WMLast], netatom[NetLast];
|
static Atom wmatom[WMLast], netatom[NetLast];
|
||||||
|
static int restart = 0;
|
||||||
static int running = 1;
|
static int running = 1;
|
||||||
static Cur *cursor[CurLast];
|
static Cur *cursor[CurLast];
|
||||||
static Clr **scheme;
|
static Clr **scheme, **schemedark, **schemelight;
|
||||||
static Display *dpy;
|
static Display *dpy;
|
||||||
static Drw *drw;
|
static Drw *drw;
|
||||||
static Monitor *mons, *selmon;
|
static Monitor *mons, *selmon;
|
||||||
static Window root, wmcheckwin;
|
static Window root, wmcheckwin;
|
||||||
|
static const char **dmenucmd;
|
||||||
|
static int colormodechanged;
|
||||||
|
|
||||||
/* configuration, allows nested code to access above variables */
|
/* configuration, allows nested code to access above variables */
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
@@ -440,10 +465,25 @@ buttonpress(XEvent *e)
|
|||||||
arg.ui = 1 << i;
|
arg.ui = 1 << i;
|
||||||
} else if (ev->x < x + TEXTW(selmon->ltsymbol))
|
} else if (ev->x < x + TEXTW(selmon->ltsymbol))
|
||||||
click = ClkLtSymbol;
|
click = ClkLtSymbol;
|
||||||
else if (ev->x > selmon->ww - (int)TEXTW(stext))
|
/* 2px right padding */
|
||||||
|
else if (ev->x > selmon->ww - TEXTW(stext) + lrpad - 2)
|
||||||
click = ClkStatusText;
|
click = ClkStatusText;
|
||||||
|
else {
|
||||||
|
x += TEXTW(selmon->ltsymbol);
|
||||||
|
c = m->clients;
|
||||||
|
|
||||||
|
if (c) {
|
||||||
|
do {
|
||||||
|
if (!ISVISIBLE(c))
|
||||||
|
continue;
|
||||||
else
|
else
|
||||||
|
x +=(1.0 / (double)m->bt) * m->btw;
|
||||||
|
} while (ev->x > x && (c = c->next));
|
||||||
|
|
||||||
click = ClkWinTitle;
|
click = ClkWinTitle;
|
||||||
|
arg.v = c;
|
||||||
|
}
|
||||||
|
}
|
||||||
} else if ((c = wintoclient(ev->window))) {
|
} else if ((c = wintoclient(ev->window))) {
|
||||||
focus(c);
|
focus(c);
|
||||||
restack(selmon);
|
restack(selmon);
|
||||||
@@ -453,7 +493,7 @@ buttonpress(XEvent *e)
|
|||||||
for (i = 0; i < LENGTH(buttons); i++)
|
for (i = 0; i < LENGTH(buttons); i++)
|
||||||
if (click == buttons[i].click && buttons[i].func && buttons[i].button == ev->button
|
if (click == buttons[i].click && buttons[i].func && buttons[i].button == ev->button
|
||||||
&& CLEANMASK(buttons[i].mask) == CLEANMASK(ev->state))
|
&& CLEANMASK(buttons[i].mask) == CLEANMASK(ev->state))
|
||||||
buttons[i].func(click == ClkTagBar && buttons[i].arg.i == 0 ? &arg : &buttons[i].arg);
|
buttons[i].func((click == ClkTagBar || click == ClkWinTitle) && buttons[i].arg.i == 0 ? &arg : &buttons[i].arg);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
@@ -485,9 +525,12 @@ cleanup(void)
|
|||||||
cleanupmon(mons);
|
cleanupmon(mons);
|
||||||
for (i = 0; i < CurLast; i++)
|
for (i = 0; i < CurLast; i++)
|
||||||
drw_cur_free(drw, cursor[i]);
|
drw_cur_free(drw, cursor[i]);
|
||||||
for (i = 0; i < LENGTH(colors); i++)
|
for (i = 0; i < LENGTH(colorsdark); i++) {
|
||||||
free(scheme[i]);
|
free(schemedark[i]);
|
||||||
free(scheme);
|
free(schemelight[i]);
|
||||||
|
}
|
||||||
|
free(schemedark);
|
||||||
|
free(schemelight);
|
||||||
XDestroyWindow(dpy, wmcheckwin);
|
XDestroyWindow(dpy, wmcheckwin);
|
||||||
drw_free(drw);
|
drw_free(drw);
|
||||||
XSync(dpy, False);
|
XSync(dpy, False);
|
||||||
@@ -530,6 +573,12 @@ clientmessage(XEvent *e)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
colormodehandler(int sig)
|
||||||
|
{
|
||||||
|
colormodechanged = 1;
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
configure(Client *c)
|
configure(Client *c)
|
||||||
{
|
{
|
||||||
@@ -697,7 +746,7 @@ dirtomon(int dir)
|
|||||||
void
|
void
|
||||||
drawbar(Monitor *m)
|
drawbar(Monitor *m)
|
||||||
{
|
{
|
||||||
int x, w, tw = 0;
|
int x, w, tw = 0, n = 0, scm;
|
||||||
int boxs = drw->fonts->h / 9;
|
int boxs = drw->fonts->h / 9;
|
||||||
int boxw = drw->fonts->h / 6 + 2;
|
int boxw = drw->fonts->h / 6 + 2;
|
||||||
unsigned int i, occ = 0, urg = 0;
|
unsigned int i, occ = 0, urg = 0;
|
||||||
@@ -714,6 +763,8 @@ drawbar(Monitor *m)
|
|||||||
}
|
}
|
||||||
|
|
||||||
for (c = m->clients; c; c = c->next) {
|
for (c = m->clients; c; c = c->next) {
|
||||||
|
if (ISVISIBLE(c))
|
||||||
|
n++;
|
||||||
occ |= c->tags;
|
occ |= c->tags;
|
||||||
if (c->isurgent)
|
if (c->isurgent)
|
||||||
urg |= c->tags;
|
urg |= c->tags;
|
||||||
@@ -734,16 +785,36 @@ drawbar(Monitor *m)
|
|||||||
x = drw_text(drw, x, 0, w, bh, lrpad / 2, m->ltsymbol, 0);
|
x = drw_text(drw, x, 0, w, bh, lrpad / 2, m->ltsymbol, 0);
|
||||||
|
|
||||||
if ((w = m->ww - tw - x) > bh) {
|
if ((w = m->ww - tw - x) > bh) {
|
||||||
if (m->sel) {
|
if (n > 0) {
|
||||||
drw_setscheme(drw, scheme[m == selmon ? SchemeSel : SchemeNorm]);
|
int remainder = w % n;
|
||||||
drw_text(drw, x, 0, w, bh, lrpad / 2, m->sel->name, 0);
|
int tabw = (1.0 / (double)n) * w + 1;
|
||||||
if (m->sel->isfloating)
|
for (c = m->clients; c; c = c->next) {
|
||||||
drw_rect(drw, x + boxs, boxs, boxw, boxw, m->sel->isfixed, 0);
|
if (!ISVISIBLE(c))
|
||||||
|
continue;
|
||||||
|
if (m->sel == c)
|
||||||
|
scm = SchemeSel;
|
||||||
|
else if (HIDDEN(c))
|
||||||
|
scm = SchemeHid;
|
||||||
|
else
|
||||||
|
scm = SchemeNorm;
|
||||||
|
drw_setscheme(drw, scheme[scm]);
|
||||||
|
|
||||||
|
if (remainder >= 0) {
|
||||||
|
if (remainder == 0) {
|
||||||
|
tabw--;
|
||||||
|
}
|
||||||
|
remainder--;
|
||||||
|
}
|
||||||
|
drw_text(drw, x, 0, tabw, bh, lrpad / 2, c->name, 0);
|
||||||
|
x += tabw;
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
drw_setscheme(drw, scheme[SchemeNorm]);
|
drw_setscheme(drw, scheme[SchemeNorm]);
|
||||||
drw_rect(drw, x, 0, w, bh, 1, 1);
|
drw_rect(drw, x, 0, w, bh, 1, 1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
m->bt = n;
|
||||||
|
m->btw = w;
|
||||||
drw_map(drw, m->barwin, 0, 0, m->ww, bh);
|
drw_map(drw, m->barwin, 0, 0, m->ww, bh);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -789,9 +860,17 @@ void
|
|||||||
focus(Client *c)
|
focus(Client *c)
|
||||||
{
|
{
|
||||||
if (!c || !ISVISIBLE(c))
|
if (!c || !ISVISIBLE(c))
|
||||||
for (c = selmon->stack; c && !ISVISIBLE(c); c = c->snext);
|
for (c = selmon->stack; c && (!ISVISIBLE(c) || HIDDEN(c)); c = c->snext);
|
||||||
if (selmon->sel && selmon->sel != c)
|
if (selmon->sel && selmon->sel != c) {
|
||||||
unfocus(selmon->sel, 0);
|
unfocus(selmon->sel, 0);
|
||||||
|
|
||||||
|
if (selmon->hidsel) {
|
||||||
|
hidewin(selmon->sel);
|
||||||
|
if (c)
|
||||||
|
arrange(c->mon);
|
||||||
|
selmon->hidsel = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
if (c) {
|
if (c) {
|
||||||
if (c->mon != selmon)
|
if (c->mon != selmon)
|
||||||
selmon = c->mon;
|
selmon = c->mon;
|
||||||
@@ -832,31 +911,56 @@ focusmon(const Arg *arg)
|
|||||||
unfocus(selmon->sel, 0);
|
unfocus(selmon->sel, 0);
|
||||||
selmon = m;
|
selmon = m;
|
||||||
focus(NULL);
|
focus(NULL);
|
||||||
|
warp(selmon->sel);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
focusstack(const Arg *arg)
|
focusstackvis(const Arg *arg) {
|
||||||
|
focusstack(arg->i, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
focusstackhid(const Arg *arg) {
|
||||||
|
focusstack(arg->i, 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
focusstack(int inc, int hid)
|
||||||
{
|
{
|
||||||
Client *c = NULL, *i;
|
Client *c = NULL, *i;
|
||||||
|
// if no client selected AND exclude hidden client; if client selected but fullscreened
|
||||||
if (!selmon->sel || (selmon->sel->isfullscreen && lockfullscreen))
|
if ((!selmon->sel && !hid) || (selmon->sel && selmon->sel->isfullscreen && lockfullscreen))
|
||||||
return;
|
return;
|
||||||
if (arg->i > 0) {
|
if (!selmon->clients)
|
||||||
for (c = selmon->sel->next; c && !ISVISIBLE(c); c = c->next);
|
return;
|
||||||
|
if (inc > 0) {
|
||||||
|
if (selmon->sel)
|
||||||
|
for (c = selmon->sel->next;
|
||||||
|
c && (!ISVISIBLE(c) || (!hid && HIDDEN(c)));
|
||||||
|
c = c->next);
|
||||||
if (!c)
|
if (!c)
|
||||||
for (c = selmon->clients; c && !ISVISIBLE(c); c = c->next);
|
for (c = selmon->clients;
|
||||||
|
c && (!ISVISIBLE(c) || (!hid && HIDDEN(c)));
|
||||||
|
c = c->next);
|
||||||
} else {
|
} else {
|
||||||
|
if (selmon->sel) {
|
||||||
for (i = selmon->clients; i != selmon->sel; i = i->next)
|
for (i = selmon->clients; i != selmon->sel; i = i->next)
|
||||||
if (ISVISIBLE(i))
|
if (ISVISIBLE(i) && !(!hid && HIDDEN(i)))
|
||||||
c = i;
|
c = i;
|
||||||
|
} else
|
||||||
|
c = selmon->clients;
|
||||||
if (!c)
|
if (!c)
|
||||||
for (; i; i = i->next)
|
for (; i; i = i->next)
|
||||||
if (ISVISIBLE(i))
|
if (ISVISIBLE(i) && !(!hid && HIDDEN(i)))
|
||||||
c = i;
|
c = i;
|
||||||
}
|
}
|
||||||
if (c) {
|
if (c) {
|
||||||
focus(c);
|
focus(c);
|
||||||
restack(selmon);
|
restack(selmon);
|
||||||
|
if (HIDDEN(c)) {
|
||||||
|
showwin(c);
|
||||||
|
c->mon->hidsel = 1;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -976,6 +1080,36 @@ grabkeys(void)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
hide(const Arg *arg)
|
||||||
|
{
|
||||||
|
hidewin(selmon->sel);
|
||||||
|
focus(NULL);
|
||||||
|
arrange(selmon);
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
hidewin(Client *c) {
|
||||||
|
if (!c || HIDDEN(c))
|
||||||
|
return;
|
||||||
|
|
||||||
|
Window w = c->win;
|
||||||
|
static XWindowAttributes ra, ca;
|
||||||
|
|
||||||
|
// more or less taken directly from blackbox's hide() function
|
||||||
|
XGrabServer(dpy);
|
||||||
|
XGetWindowAttributes(dpy, root, &ra);
|
||||||
|
XGetWindowAttributes(dpy, w, &ca);
|
||||||
|
// prevent UnmapNotify events
|
||||||
|
XSelectInput(dpy, root, ra.your_event_mask & ~SubstructureNotifyMask);
|
||||||
|
XSelectInput(dpy, w, ca.your_event_mask & ~StructureNotifyMask);
|
||||||
|
XUnmapWindow(dpy, w);
|
||||||
|
setclientstate(c, IconicState);
|
||||||
|
XSelectInput(dpy, root, ra.your_event_mask);
|
||||||
|
XSelectInput(dpy, w, ca.your_event_mask);
|
||||||
|
XUngrabServer(dpy);
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
incnmaster(const Arg *arg)
|
incnmaster(const Arg *arg)
|
||||||
{
|
{
|
||||||
@@ -1067,6 +1201,26 @@ manage(Window w, XWindowAttributes *wa)
|
|||||||
updatewindowtype(c);
|
updatewindowtype(c);
|
||||||
updatesizehints(c);
|
updatesizehints(c);
|
||||||
updatewmhints(c);
|
updatewmhints(c);
|
||||||
|
{
|
||||||
|
int format;
|
||||||
|
unsigned long *data, n, extra;
|
||||||
|
Monitor *m;
|
||||||
|
Atom atom;
|
||||||
|
if (XGetWindowProperty(dpy, c->win, netatom[NetClientInfo], 0L, 2L, False, XA_CARDINAL,
|
||||||
|
&atom, &format, &n, &extra, (unsigned char **)&data) == Success && n == 2) {
|
||||||
|
c->tags = *data;
|
||||||
|
for (m = mons; m; m = m->next) {
|
||||||
|
if (m->num == *(data+1)) {
|
||||||
|
c->mon = m;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (n > 0)
|
||||||
|
XFree(data);
|
||||||
|
}
|
||||||
|
setclienttagprop(c);
|
||||||
|
|
||||||
XSelectInput(dpy, w, EnterWindowMask|FocusChangeMask|PropertyChangeMask|StructureNotifyMask);
|
XSelectInput(dpy, w, EnterWindowMask|FocusChangeMask|PropertyChangeMask|StructureNotifyMask);
|
||||||
grabbuttons(c, 0);
|
grabbuttons(c, 0);
|
||||||
if (!c->isfloating)
|
if (!c->isfloating)
|
||||||
@@ -1078,11 +1232,13 @@ manage(Window w, XWindowAttributes *wa)
|
|||||||
XChangeProperty(dpy, root, netatom[NetClientList], XA_WINDOW, 32, PropModeAppend,
|
XChangeProperty(dpy, root, netatom[NetClientList], XA_WINDOW, 32, PropModeAppend,
|
||||||
(unsigned char *) &(c->win), 1);
|
(unsigned char *) &(c->win), 1);
|
||||||
XMoveResizeWindow(dpy, c->win, c->x + 2 * sw, c->y, c->w, c->h); /* some windows require this */
|
XMoveResizeWindow(dpy, c->win, c->x + 2 * sw, c->y, c->w, c->h); /* some windows require this */
|
||||||
|
if (!HIDDEN(c))
|
||||||
setclientstate(c, NormalState);
|
setclientstate(c, NormalState);
|
||||||
if (c->mon == selmon)
|
if (c->mon == selmon)
|
||||||
unfocus(selmon->sel, 0);
|
unfocus(selmon->sel, 0);
|
||||||
c->mon->sel = c;
|
c->mon->sel = c;
|
||||||
arrange(c->mon);
|
arrange(c->mon);
|
||||||
|
if (!HIDDEN(c))
|
||||||
XMapWindow(dpy, c->win);
|
XMapWindow(dpy, c->win);
|
||||||
focus(NULL);
|
focus(NULL);
|
||||||
}
|
}
|
||||||
@@ -1204,7 +1360,7 @@ movemouse(const Arg *arg)
|
|||||||
Client *
|
Client *
|
||||||
nexttiled(Client *c)
|
nexttiled(Client *c)
|
||||||
{
|
{
|
||||||
for (; c && (c->isfloating || !ISVISIBLE(c)); c = c->next);
|
for (; c && (c->isfloating || !ISVISIBLE(c) || HIDDEN(c)); c = c->next);
|
||||||
return c;
|
return c;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1224,6 +1380,10 @@ propertynotify(XEvent *e)
|
|||||||
Window trans;
|
Window trans;
|
||||||
XPropertyEvent *ev = &e->xproperty;
|
XPropertyEvent *ev = &e->xproperty;
|
||||||
|
|
||||||
|
if (colormodechanged) {
|
||||||
|
setcolormode();
|
||||||
|
colormodechanged = 0;
|
||||||
|
}
|
||||||
if ((ev->window == root) && (ev->atom == XA_WM_NAME))
|
if ((ev->window == root) && (ev->atom == XA_WM_NAME))
|
||||||
updatestatus();
|
updatestatus();
|
||||||
else if (ev->state == PropertyDelete)
|
else if (ev->state == PropertyDelete)
|
||||||
@@ -1257,6 +1417,17 @@ propertynotify(XEvent *e)
|
|||||||
void
|
void
|
||||||
quit(const Arg *arg)
|
quit(const Arg *arg)
|
||||||
{
|
{
|
||||||
|
if(arg->i) restart = 1;
|
||||||
|
// fix: reloading dwm keeps all the hidden clients hidden
|
||||||
|
Monitor *m;
|
||||||
|
Client *c;
|
||||||
|
for (m = mons; m; m = m->next) {
|
||||||
|
if (m) {
|
||||||
|
for (c = m->stack; c; c = c->next)
|
||||||
|
if (c && HIDDEN(c)) showwin(c);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
running = 0;
|
running = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1285,12 +1456,36 @@ void
|
|||||||
resizeclient(Client *c, int x, int y, int w, int h)
|
resizeclient(Client *c, int x, int y, int w, int h)
|
||||||
{
|
{
|
||||||
XWindowChanges wc;
|
XWindowChanges wc;
|
||||||
|
unsigned int n;
|
||||||
|
unsigned int gapoffset;
|
||||||
|
unsigned int gapincr;
|
||||||
|
Client *nbc;
|
||||||
|
|
||||||
c->oldx = c->x; c->x = wc.x = x;
|
|
||||||
c->oldy = c->y; c->y = wc.y = y;
|
|
||||||
c->oldw = c->w; c->w = wc.width = w;
|
|
||||||
c->oldh = c->h; c->h = wc.height = h;
|
|
||||||
wc.border_width = c->bw;
|
wc.border_width = c->bw;
|
||||||
|
|
||||||
|
/* Get number of clients for the selected monitor */
|
||||||
|
for (n = 0, nbc = nexttiled(selmon->clients); nbc; nbc = nexttiled(nbc->next), n++);
|
||||||
|
|
||||||
|
/* Do nothing if layout is floating */
|
||||||
|
if (c->isfloating || selmon->lt[selmon->sellt]->arrange == NULL) {
|
||||||
|
gapincr = gapoffset = 0;
|
||||||
|
} else {
|
||||||
|
/* Remove border and gap if layout is monocle or only one client */
|
||||||
|
if (selmon->lt[selmon->sellt]->arrange == monocle || n == 1) {
|
||||||
|
gapoffset = 0;
|
||||||
|
gapincr = -2 * borderpx;
|
||||||
|
wc.border_width = 0;
|
||||||
|
} else {
|
||||||
|
gapoffset = gappx;
|
||||||
|
gapincr = 2 * gappx;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
c->oldx = c->x; c->x = wc.x = x + gapoffset;
|
||||||
|
c->oldy = c->y; c->y = wc.y = y + gapoffset;
|
||||||
|
c->oldw = c->w; c->w = wc.width = w - gapincr;
|
||||||
|
c->oldh = c->h; c->h = wc.height = h - gapincr;
|
||||||
|
|
||||||
XConfigureWindow(dpy, c->win, CWX|CWY|CWWidth|CWHeight|CWBorderWidth, &wc);
|
XConfigureWindow(dpy, c->win, CWX|CWY|CWWidth|CWHeight|CWBorderWidth, &wc);
|
||||||
configure(c);
|
configure(c);
|
||||||
XSync(dpy, False);
|
XSync(dpy, False);
|
||||||
@@ -1374,6 +1569,8 @@ restack(Monitor *m)
|
|||||||
wc.sibling = c->win;
|
wc.sibling = c->win;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (m == selmon && (m->tagset[m->seltags] & m->sel->tags) && m->lt[m->sellt]->arrange != &monocle)
|
||||||
|
warp(m->sel);
|
||||||
XSync(dpy, False);
|
XSync(dpy, False);
|
||||||
while (XCheckMaskEvent(dpy, EnterWindowMask, &ev));
|
while (XCheckMaskEvent(dpy, EnterWindowMask, &ev));
|
||||||
}
|
}
|
||||||
@@ -1428,6 +1625,7 @@ sendmon(Client *c, Monitor *m)
|
|||||||
c->tags = m->tagset[m->seltags]; /* assign tags of target monitor */
|
c->tags = m->tagset[m->seltags]; /* assign tags of target monitor */
|
||||||
attach(c);
|
attach(c);
|
||||||
attachstack(c);
|
attachstack(c);
|
||||||
|
setclienttagprop(c);
|
||||||
focus(NULL);
|
focus(NULL);
|
||||||
arrange(NULL);
|
arrange(NULL);
|
||||||
}
|
}
|
||||||
@@ -1441,6 +1639,32 @@ setclientstate(Client *c, long state)
|
|||||||
PropModeReplace, (unsigned char *)data, 2);
|
PropModeReplace, (unsigned char *)data, 2);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
setcolormode(void)
|
||||||
|
{
|
||||||
|
static const char *file = ".lightmode";
|
||||||
|
static char *path = NULL;
|
||||||
|
const char *home;
|
||||||
|
size_t size;
|
||||||
|
|
||||||
|
if (!path && (home = getenv("HOME"))) {
|
||||||
|
size = strlen(home) + 1 + strlen(file) + 1;
|
||||||
|
path = malloc(size);
|
||||||
|
if (!path)
|
||||||
|
die("dwm: malloc failed");
|
||||||
|
|
||||||
|
snprintf(path, size, "%s/%s", home, file);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (access(path, F_OK) == 0) {
|
||||||
|
scheme = schemelight;
|
||||||
|
dmenucmd = dmenulight;
|
||||||
|
} else {
|
||||||
|
scheme = schemedark;
|
||||||
|
dmenucmd = dmenudark;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
sendevent(Client *c, Atom proto)
|
sendevent(Client *c, Atom proto)
|
||||||
{
|
{
|
||||||
@@ -1549,9 +1773,17 @@ setup(void)
|
|||||||
sa.sa_handler = SIG_IGN;
|
sa.sa_handler = SIG_IGN;
|
||||||
sigaction(SIGCHLD, &sa, NULL);
|
sigaction(SIGCHLD, &sa, NULL);
|
||||||
|
|
||||||
|
/* set color mode on SIGUSR1 */
|
||||||
|
sigemptyset(&sa.sa_mask);
|
||||||
|
sa.sa_handler = colormodehandler;
|
||||||
|
sigaction(SIGUSR1, &sa, NULL);
|
||||||
|
|
||||||
/* clean up any zombies (inherited from .xinitrc etc) immediately */
|
/* clean up any zombies (inherited from .xinitrc etc) immediately */
|
||||||
while (waitpid(-1, NULL, WNOHANG) > 0);
|
while (waitpid(-1, NULL, WNOHANG) > 0);
|
||||||
|
|
||||||
|
signal(SIGHUP, sighup);
|
||||||
|
signal(SIGTERM, sigterm);
|
||||||
|
|
||||||
/* init screen */
|
/* init screen */
|
||||||
screen = DefaultScreen(dpy);
|
screen = DefaultScreen(dpy);
|
||||||
sw = DisplayWidth(dpy, screen);
|
sw = DisplayWidth(dpy, screen);
|
||||||
@@ -1578,14 +1810,19 @@ setup(void)
|
|||||||
netatom[NetWMWindowType] = XInternAtom(dpy, "_NET_WM_WINDOW_TYPE", False);
|
netatom[NetWMWindowType] = XInternAtom(dpy, "_NET_WM_WINDOW_TYPE", False);
|
||||||
netatom[NetWMWindowTypeDialog] = XInternAtom(dpy, "_NET_WM_WINDOW_TYPE_DIALOG", False);
|
netatom[NetWMWindowTypeDialog] = XInternAtom(dpy, "_NET_WM_WINDOW_TYPE_DIALOG", False);
|
||||||
netatom[NetClientList] = XInternAtom(dpy, "_NET_CLIENT_LIST", False);
|
netatom[NetClientList] = XInternAtom(dpy, "_NET_CLIENT_LIST", False);
|
||||||
|
netatom[NetClientInfo] = XInternAtom(dpy, "_NET_CLIENT_INFO", False);
|
||||||
/* init cursors */
|
/* init cursors */
|
||||||
cursor[CurNormal] = drw_cur_create(drw, XC_left_ptr);
|
cursor[CurNormal] = drw_cur_create(drw, XC_left_ptr);
|
||||||
cursor[CurResize] = drw_cur_create(drw, XC_sizing);
|
cursor[CurResize] = drw_cur_create(drw, XC_sizing);
|
||||||
cursor[CurMove] = drw_cur_create(drw, XC_fleur);
|
cursor[CurMove] = drw_cur_create(drw, XC_fleur);
|
||||||
/* init appearance */
|
/* init appearance */
|
||||||
scheme = ecalloc(LENGTH(colors), sizeof(Clr *));
|
schemedark = ecalloc(LENGTH(colorsdark), sizeof(Clr *));
|
||||||
for (i = 0; i < LENGTH(colors); i++)
|
schemelight = ecalloc(LENGTH(colorslight), sizeof(Clr *));
|
||||||
scheme[i] = drw_scm_create(drw, colors[i], 3);
|
for (i = 0; i < LENGTH(colorsdark); i++) {
|
||||||
|
schemedark[i] = drw_scm_create(drw, colorsdark[i], 3);
|
||||||
|
schemelight[i] = drw_scm_create(drw, colorslight[i], 3);
|
||||||
|
}
|
||||||
|
setcolormode();
|
||||||
/* init bars */
|
/* init bars */
|
||||||
updatebars();
|
updatebars();
|
||||||
updatestatus();
|
updatestatus();
|
||||||
@@ -1601,6 +1838,7 @@ setup(void)
|
|||||||
XChangeProperty(dpy, root, netatom[NetSupported], XA_ATOM, 32,
|
XChangeProperty(dpy, root, netatom[NetSupported], XA_ATOM, 32,
|
||||||
PropModeReplace, (unsigned char *) netatom, NetLast);
|
PropModeReplace, (unsigned char *) netatom, NetLast);
|
||||||
XDeleteProperty(dpy, root, netatom[NetClientList]);
|
XDeleteProperty(dpy, root, netatom[NetClientList]);
|
||||||
|
XDeleteProperty(dpy, root, netatom[NetClientInfo]);
|
||||||
/* select events */
|
/* select events */
|
||||||
wa.cursor = cursor[CurNormal]->cursor;
|
wa.cursor = cursor[CurNormal]->cursor;
|
||||||
wa.event_mask = SubstructureRedirectMask|SubstructureNotifyMask
|
wa.event_mask = SubstructureRedirectMask|SubstructureNotifyMask
|
||||||
@@ -1625,6 +1863,42 @@ seturgent(Client *c, int urg)
|
|||||||
XFree(wmh);
|
XFree(wmh);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
show(const Arg *arg)
|
||||||
|
{
|
||||||
|
if (selmon->hidsel)
|
||||||
|
selmon->hidsel = 0;
|
||||||
|
showwin(selmon->sel);
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
showall(const Arg *arg)
|
||||||
|
{
|
||||||
|
Client *c = NULL;
|
||||||
|
selmon->hidsel = 0;
|
||||||
|
for (c = selmon->clients; c; c = c->next) {
|
||||||
|
if (ISVISIBLE(c))
|
||||||
|
showwin(c);
|
||||||
|
}
|
||||||
|
if (!selmon->sel) {
|
||||||
|
for (c = selmon->clients; c && !ISVISIBLE(c); c = c->next);
|
||||||
|
if (c)
|
||||||
|
focus(c);
|
||||||
|
}
|
||||||
|
restack(selmon);
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
showwin(Client *c)
|
||||||
|
{
|
||||||
|
if (!c || !HIDDEN(c))
|
||||||
|
return;
|
||||||
|
|
||||||
|
XMapWindow(dpy, c->win);
|
||||||
|
setclientstate(c, NormalState);
|
||||||
|
arrange(c->mon);
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
showhide(Client *c)
|
showhide(Client *c)
|
||||||
{
|
{
|
||||||
@@ -1643,13 +1917,33 @@ showhide(Client *c)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
sigchld(int unused)
|
||||||
|
{
|
||||||
|
if (signal(SIGCHLD, sigchld) == SIG_ERR)
|
||||||
|
die("can't install SIGCHLD handler:");
|
||||||
|
while (0 < waitpid(-1, NULL, WNOHANG));
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
sighup(int unused)
|
||||||
|
{
|
||||||
|
Arg a = {.i = 1};
|
||||||
|
quit(&a);
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
sigterm(int unused)
|
||||||
|
{
|
||||||
|
Arg a = {.i = 0};
|
||||||
|
quit(&a);
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
spawn(const Arg *arg)
|
spawn(const Arg *arg)
|
||||||
{
|
{
|
||||||
struct sigaction sa;
|
struct sigaction sa;
|
||||||
|
|
||||||
if (arg->v == dmenucmd)
|
|
||||||
dmenumon[0] = '0' + selmon->num;
|
|
||||||
if (fork() == 0) {
|
if (fork() == 0) {
|
||||||
if (dpy)
|
if (dpy)
|
||||||
close(ConnectionNumber(dpy));
|
close(ConnectionNumber(dpy));
|
||||||
@@ -1665,11 +1959,29 @@ spawn(const Arg *arg)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
setclienttagprop(Client *c)
|
||||||
|
{
|
||||||
|
long data[] = { (long) c->tags, (long) c->mon->num };
|
||||||
|
XChangeProperty(dpy, c->win, netatom[NetClientInfo], XA_CARDINAL, 32,
|
||||||
|
PropModeReplace, (unsigned char *) data, 2);
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
spawndmenu(const Arg *arg)
|
||||||
|
{
|
||||||
|
dmenumon[0] = '0' + selmon->num;
|
||||||
|
spawn(&(const Arg){.v = dmenucmd});
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
tag(const Arg *arg)
|
tag(const Arg *arg)
|
||||||
{
|
{
|
||||||
|
Client *c;
|
||||||
if (selmon->sel && arg->ui & TAGMASK) {
|
if (selmon->sel && arg->ui & TAGMASK) {
|
||||||
|
c = selmon->sel;
|
||||||
selmon->sel->tags = arg->ui & TAGMASK;
|
selmon->sel->tags = arg->ui & TAGMASK;
|
||||||
|
setclienttagprop(c);
|
||||||
focus(NULL);
|
focus(NULL);
|
||||||
arrange(selmon);
|
arrange(selmon);
|
||||||
}
|
}
|
||||||
@@ -1734,6 +2046,19 @@ togglefloating(const Arg *arg)
|
|||||||
arrange(selmon);
|
arrange(selmon);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
focusbynum(const Arg *arg)
|
||||||
|
{
|
||||||
|
int i;
|
||||||
|
Client *c;
|
||||||
|
|
||||||
|
i = 0;
|
||||||
|
c = nexttiled(selmon->clients);
|
||||||
|
|
||||||
|
for (; c && i < arg->i; c = nexttiled(c->next), i++);
|
||||||
|
focus(c);
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
toggletag(const Arg *arg)
|
toggletag(const Arg *arg)
|
||||||
{
|
{
|
||||||
@@ -1744,6 +2069,7 @@ toggletag(const Arg *arg)
|
|||||||
newtags = selmon->sel->tags ^ (arg->ui & TAGMASK);
|
newtags = selmon->sel->tags ^ (arg->ui & TAGMASK);
|
||||||
if (newtags) {
|
if (newtags) {
|
||||||
selmon->sel->tags = newtags;
|
selmon->sel->tags = newtags;
|
||||||
|
setclienttagprop(selmon->sel);
|
||||||
focus(NULL);
|
focus(NULL);
|
||||||
arrange(selmon);
|
arrange(selmon);
|
||||||
}
|
}
|
||||||
@@ -1761,6 +2087,23 @@ toggleview(const Arg *arg)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
togglewin(const Arg *arg)
|
||||||
|
{
|
||||||
|
Client *c = (Client*)arg->v;
|
||||||
|
|
||||||
|
if (c == selmon->sel) {
|
||||||
|
hidewin(c);
|
||||||
|
focus(NULL);
|
||||||
|
arrange(c->mon);
|
||||||
|
} else {
|
||||||
|
if (HIDDEN(c))
|
||||||
|
showwin(c);
|
||||||
|
focus(c);
|
||||||
|
restack(selmon);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
unfocus(Client *c, int setfocus)
|
unfocus(Client *c, int setfocus)
|
||||||
{
|
{
|
||||||
@@ -1863,6 +2206,16 @@ updateclientlist(void)
|
|||||||
(unsigned char *) &(c->win), 1);
|
(unsigned char *) &(c->win), 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef XINERAMA
|
||||||
|
// Custom comparator: sort monitors by x_org to match physical layout left-to-right
|
||||||
|
static int
|
||||||
|
compare_xinerama_x(const void *a, const void *b) {
|
||||||
|
const XineramaScreenInfo *sa = (const XineramaScreenInfo *)a;
|
||||||
|
const XineramaScreenInfo *sb = (const XineramaScreenInfo *)b;
|
||||||
|
return sa->x_org - sb->x_org;
|
||||||
|
}
|
||||||
|
#endif /* XINERAMA */
|
||||||
|
|
||||||
int
|
int
|
||||||
updategeom(void)
|
updategeom(void)
|
||||||
{
|
{
|
||||||
@@ -1879,6 +2232,8 @@ updategeom(void)
|
|||||||
for (n = 0, m = mons; m; m = m->next, n++);
|
for (n = 0, m = mons; m; m = m->next, n++);
|
||||||
/* only consider unique geometries as separate screens */
|
/* only consider unique geometries as separate screens */
|
||||||
unique = ecalloc(nn, sizeof(XineramaScreenInfo));
|
unique = ecalloc(nn, sizeof(XineramaScreenInfo));
|
||||||
|
// Sort monitors by x_org so dwm handles screens in left-to-right order
|
||||||
|
qsort(info, nn, sizeof(XineramaScreenInfo), compare_xinerama_x);
|
||||||
for (i = 0, j = 0; i < nn; i++)
|
for (i = 0, j = 0; i < nn; i++)
|
||||||
if (isuniquegeom(unique, j, &info[i]))
|
if (isuniquegeom(unique, j, &info[i]))
|
||||||
memcpy(&unique[j++], &info[i], sizeof(XineramaScreenInfo));
|
memcpy(&unique[j++], &info[i], sizeof(XineramaScreenInfo));
|
||||||
@@ -2061,6 +2416,28 @@ view(const Arg *arg)
|
|||||||
arrange(selmon);
|
arrange(selmon);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
warp(const Client *c)
|
||||||
|
{
|
||||||
|
int x, y;
|
||||||
|
|
||||||
|
if (!c) {
|
||||||
|
XWarpPointer(dpy, None, root, 0, 0, 0, 0, selmon->wx + selmon->ww / 2, selmon->wy + selmon->wh / 2);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!getrootptr(&x, &y) ||
|
||||||
|
(x > c->x - c->bw &&
|
||||||
|
y > c->y - c->bw &&
|
||||||
|
x < c->x + c->w + c->bw*2 &&
|
||||||
|
y < c->y + c->h + c->bw*2) ||
|
||||||
|
(y > c->mon->by && y < c->mon->by + bh) ||
|
||||||
|
(c->mon->topbar && !y))
|
||||||
|
return;
|
||||||
|
|
||||||
|
XWarpPointer(dpy, None, c->win, 0, 0, 0, 0, c->w / 2, c->h / 2);
|
||||||
|
}
|
||||||
|
|
||||||
Client *
|
Client *
|
||||||
wintoclient(Window w)
|
wintoclient(Window w)
|
||||||
{
|
{
|
||||||
@@ -2158,6 +2535,7 @@ main(int argc, char *argv[])
|
|||||||
#endif /* __OpenBSD__ */
|
#endif /* __OpenBSD__ */
|
||||||
scan();
|
scan();
|
||||||
run();
|
run();
|
||||||
|
if(restart) execvp(argv[0], argv);
|
||||||
cleanup();
|
cleanup();
|
||||||
XCloseDisplay(dpy);
|
XCloseDisplay(dpy);
|
||||||
return EXIT_SUCCESS;
|
return EXIT_SUCCESS;
|
||||||
|
|||||||
87
exitdwm.c
Normal file
87
exitdwm.c
Normal file
@@ -0,0 +1,87 @@
|
|||||||
|
# include <stdio.h>
|
||||||
|
# include <string.h>
|
||||||
|
|
||||||
|
void exitdwm ()
|
||||||
|
{
|
||||||
|
# if \
|
||||||
|
defined S_LOCK || \
|
||||||
|
defined S_RESTART_DWM || \
|
||||||
|
defined S_OFFSCREEN || \
|
||||||
|
defined S_EXIT || \
|
||||||
|
defined S_REBOOT || \
|
||||||
|
defined S_SHUTDOWN || \
|
||||||
|
defined S_LOCK_ICON || \
|
||||||
|
defined S_RESTART_DWM_ICON || \
|
||||||
|
defined S_OFFSCREEN_ICON || \
|
||||||
|
defined S_EXIT_ICON || \
|
||||||
|
defined S_REBOOT_ICON || \
|
||||||
|
defined S_SHUTDOWN_ICON || \
|
||||||
|
defined S_FORMAT || \
|
||||||
|
defined S_FORMAT_CLEAR
|
||||||
|
# error (conflicting macro names)
|
||||||
|
# endif
|
||||||
|
|
||||||
|
# define S_LOCK "Lock"
|
||||||
|
# define S_RESTART_DWM "restart Dwm"
|
||||||
|
# define S_OFFSCREEN "Off-screen"
|
||||||
|
# define S_EXIT "Exit"
|
||||||
|
# define S_REBOOT "Reboot"
|
||||||
|
# define S_SHUTDOWN "Shutdown"
|
||||||
|
# define S_LOCK_ICON "\uf023" // <= FontAwesome icons
|
||||||
|
# define S_RESTART_DWM_ICON "\uf01e"
|
||||||
|
# define S_OFFSCREEN_ICON "\uf108"
|
||||||
|
# define S_EXIT_ICON "\uf2f5"
|
||||||
|
# define S_REBOOT_ICON "\uf021"
|
||||||
|
# define S_SHUTDOWN_ICON "\uf011"
|
||||||
|
|
||||||
|
# define S_FORMAT(ACTION) S_##ACTION##_ICON " " S_##ACTION
|
||||||
|
# define S_FORMAT_CLEAR "sed 's/^..//'"
|
||||||
|
|
||||||
|
FILE * exit_menu = popen (
|
||||||
|
"echo \""
|
||||||
|
S_FORMAT (LOCK) "\n"
|
||||||
|
S_FORMAT (RESTART_DWM) "\n"
|
||||||
|
S_FORMAT (OFFSCREEN) "\n"
|
||||||
|
S_FORMAT (EXIT) "\n"
|
||||||
|
S_FORMAT (REBOOT) "\n"
|
||||||
|
S_FORMAT (SHUTDOWN)
|
||||||
|
"\" | dmenu -p exit: | " S_FORMAT_CLEAR
|
||||||
|
,
|
||||||
|
"r"
|
||||||
|
);
|
||||||
|
|
||||||
|
char exit_action [16];
|
||||||
|
|
||||||
|
if (
|
||||||
|
exit_menu == NULL ||
|
||||||
|
fscanf (exit_menu, "%15[a-zA-Z -]", exit_action) == EOF
|
||||||
|
) {
|
||||||
|
fputs ("Error. Failure in exit_dwm.", stderr);
|
||||||
|
goto close_streams;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (strcmp (exit_action, S_LOCK) == 0) system ("slock & sleep .5; xset dpms force off");
|
||||||
|
else if (strcmp (exit_action, S_RESTART_DWM) == 0) quit (& (const Arg) {1});
|
||||||
|
else if (strcmp (exit_action, S_OFFSCREEN) == 0) system ("sleep .5; xset dpms force off");
|
||||||
|
else if (strcmp (exit_action, S_EXIT) == 0) quit (& (const Arg) {0});
|
||||||
|
else if (strcmp (exit_action, S_REBOOT) == 0) system ("systemctl reboot");
|
||||||
|
else if (strcmp (exit_action, S_SHUTDOWN) == 0) system ("systemctl poweroff -i");
|
||||||
|
|
||||||
|
close_streams:
|
||||||
|
pclose (exit_menu);
|
||||||
|
|
||||||
|
# undef S_LOCK
|
||||||
|
# undef S_RESTART_DWM
|
||||||
|
# undef S_OFFSCREEN
|
||||||
|
# undef S_EXIT
|
||||||
|
# undef S_REBOOT
|
||||||
|
# undef S_SHUTDOWN
|
||||||
|
# undef S_LOCK_ICON
|
||||||
|
# undef S_RESTART_DWM_ICON
|
||||||
|
# undef S_OFFSCREEN_ICON
|
||||||
|
# undef S_EXIT_ICON
|
||||||
|
# undef S_REBOOT_ICON
|
||||||
|
# undef S_SHUTDOWN_ICON
|
||||||
|
# undef S_FORMAT
|
||||||
|
# undef S_FORMAT_CLEAR
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user