Compare commits
80 Commits
Author | SHA1 | Date | |
---|---|---|---|
37d3482e82 | |||
9d72348d46 | |||
|
061e9fe9a7 | ||
|
9f8855343c | ||
|
e81f17d4c1 | ||
|
348f6559ab | ||
|
712d6639ff | ||
|
89f9905714 | ||
|
ba56fe9fea | ||
|
50ad171eea | ||
|
970f376973 | ||
|
c2b748e793 | ||
|
84d7322113 | ||
|
5799dd1fca | ||
|
44adafe006 | ||
|
a859676ead | ||
|
e0dee91145 | ||
|
5e76e7e21d | ||
|
5b2e5e7a40 | ||
|
786f6e2a6f | ||
|
e03248a4d5 | ||
|
6613d9f9a1 | ||
|
9bffa845fa | ||
|
d3f93c7c1a | ||
|
cd0773cee9 | ||
|
8b48e30973 | ||
|
a83dc20310 | ||
|
a4771de5ba | ||
|
d93ff48803 | ||
|
8806b6e237 | ||
|
bece862a0f | ||
|
60e9a14998 | ||
|
d39e2f3441 | ||
|
8657affa2a | ||
|
a786211d6c | ||
|
716233534b | ||
|
138b405f0c | ||
|
67d76bdc68 | ||
|
61bb8b2241 | ||
|
bb2e7222ba | ||
|
f04cac6d6e | ||
|
f09418bbb6 | ||
|
ed3ab6b4fc | ||
|
f087d20e6e | ||
|
a8e9513783 | ||
|
c82db690cc | ||
|
cb3f58ad06 | ||
|
b69c870a30 | ||
|
e78b4a9207 | ||
|
3cd4023fb3 | ||
|
f40f86fa87 | ||
|
c3a2e016bb | ||
|
c8e9479186 | ||
|
10dfa65860 | ||
|
3bd8466e93 | ||
|
76c8c16d79 | ||
|
3cb34830eb | ||
|
db2236001c | ||
|
3756f7f6b8 | ||
|
99f78fa553 | ||
|
a9b6a312a7 | ||
|
6aa8e37efe | ||
|
ceac8c91ff | ||
|
5b238c8dab | ||
|
022d076054 | ||
|
2952b68db8 | ||
|
bb3bd6fec3 | ||
|
e63bf22948 | ||
|
5376947571 | ||
|
975c898376 | ||
|
a137a86a23 | ||
|
839c7f6939 | ||
|
7a59cd1457 | ||
|
24849acada | ||
|
ab9571bbc5 | ||
|
56a31dc4a7 | ||
|
7af4d439bd | ||
|
cd2d7549b3 | ||
|
3465bed290 | ||
|
4ec3a673ff |
3
.gitignore
vendored
Normal file
3
.gitignore
vendored
Normal file
|
@ -0,0 +1,3 @@
|
||||||
|
/compile_commands.json
|
||||||
|
/build
|
||||||
|
/.cache
|
44
BUGS
44
BUGS
|
@ -1,44 +0,0 @@
|
||||||
---
|
|
||||||
|
|
||||||
18:17 < Biolunar> when i change my resolution in dwm (to a smaller one) and then back to the native, the top bar is not repainted. that's since 5.7.2, in 5.6 it worked fine
|
|
||||||
18:19 < Biolunar> is it just happening to me or a (known) bug?
|
|
||||||
18:24 < Biolunar> and in addition, mplayers fullscreen is limited to the small resolution after i changed it back to the native
|
|
||||||
|
|
||||||
reproducible with xrandr -s but not with --output and --mode, strange
|
|
||||||
|
|
||||||
---
|
|
||||||
|
|
||||||
yet another corner case:
|
|
||||||
open a terminal, focus another monitor, but without moving the mouse
|
|
||||||
pointer there
|
|
||||||
if there is no client on the other monitor to get the focus, then the
|
|
||||||
terminal will be unfocused but it will accept input
|
|
||||||
|
|
||||||
---
|
|
||||||
|
|
||||||
Donald Allen reported this:
|
|
||||||
|
|
||||||
starting emacs from dmenu in archlinux results in missing configure of emacs, but mod1-space or mod1-shift-space fix this problem. this problem is new and did not happen in 1.6 xorg servers
|
|
||||||
|
|
||||||
---
|
|
||||||
|
|
||||||
voltaic reports this:
|
|
||||||
|
|
||||||
When I use two monitors, one larger in resolution than the other, the
|
|
||||||
bar is drawn using the smaller x-dimension on both screens. I think
|
|
||||||
what's happening is that there are two bars drawn, but the short bar
|
|
||||||
is always on top of the long bar such that I can't see the information
|
|
||||||
under the short bar. If I switch to the small screen, hide the short
|
|
||||||
bar, and then switch to the large screen, the long bar is drawn
|
|
||||||
correctly.
|
|
||||||
|
|
||||||
A similar problem occurs when I have started dwm on a small resolution
|
|
||||||
monitor (laptop screen) and then I switch to a large external display.
|
|
||||||
When I do this, the bar itself is drawn for the original smaller
|
|
||||||
resolution, but the information to be printed on the bar is
|
|
||||||
right-aligned for a longer bar. So what I see is a bar that has the
|
|
||||||
right hand side of it cut-off. See attached screenshot.
|
|
||||||
|
|
||||||
I am using standard options for xrandr such as --output VGA1 --auto, etc.
|
|
||||||
|
|
||||||
---
|
|
19
LICENSE
19
LICENSE
|
@ -1,18 +1,23 @@
|
||||||
MIT/X Consortium License
|
MIT/X Consortium License
|
||||||
|
|
||||||
© 2006-2014 Anselm R Garbe <anselm@garbe.us>
|
© 2006-2019 Anselm R Garbe <anselm@garbe.ca>
|
||||||
© 2010-2014 Hiltjo Posthuma <hiltjo@codemadness.org>
|
|
||||||
© 2007-2011 Peter Hartlich <sgkkr at hartlich dot com>
|
|
||||||
© 2010-2011 Connor Lane Smith <cls@lubutu.com>
|
|
||||||
© 2006-2009 Jukka Salmi <jukka at salmi dot ch>
|
© 2006-2009 Jukka Salmi <jukka at salmi dot ch>
|
||||||
© 2007-2009 Premysl Hruby <dfenze at gmail dot com>
|
© 2006-2007 Sander van Dijk <a dot h dot vandijk at gmail dot com>
|
||||||
|
© 2007-2011 Peter Hartlich <sgkkr at hartlich dot com>
|
||||||
© 2007-2009 Szabolcs Nagy <nszabolcs at gmail dot com>
|
© 2007-2009 Szabolcs Nagy <nszabolcs at gmail dot com>
|
||||||
© 2007-2009 Christof Musik <christof at sendfax dot de>
|
© 2007-2009 Christof Musik <christof at sendfax dot de>
|
||||||
© 2009 Mate Nagy <mnagy at port70 dot net>
|
© 2007-2009 Premysl Hruby <dfenze at gmail dot com>
|
||||||
© 2007-2008 Enno Gottox Boland <gottox at s01 dot de>
|
© 2007-2008 Enno Gottox Boland <gottox at s01 dot de>
|
||||||
© 2008 Martin Hurton <martin dot hurton at gmail dot com>
|
© 2008 Martin Hurton <martin dot hurton at gmail dot com>
|
||||||
© 2008 Neale Pickett <neale dot woozle dot org>
|
© 2008 Neale Pickett <neale dot woozle dot org>
|
||||||
© 2006-2007 Sander van Dijk <a dot h dot vandijk at gmail dot com>
|
© 2009 Mate Nagy <mnagy at port70 dot net>
|
||||||
|
© 2010-2016 Hiltjo Posthuma <hiltjo@codemadness.org>
|
||||||
|
© 2010-2012 Connor Lane Smith <cls@lubutu.com>
|
||||||
|
© 2011 Christoph Lohmann <20h@r-36.net>
|
||||||
|
© 2015-2016 Quentin Rameau <quinq@fifth.space>
|
||||||
|
© 2015-2016 Eric Pruitt <eric.pruitt@gmail.com>
|
||||||
|
© 2016-2017 Markus Teich <markus.teich@stusta.mhn.de>
|
||||||
|
© 2020-2022 Chris Down <chris@chrisdown.name>
|
||||||
|
|
||||||
Permission is hereby granted, free of charge, to any person obtaining a
|
Permission is hereby granted, free of charge, to any person obtaining a
|
||||||
copy of this software and associated documentation files (the "Software"),
|
copy of this software and associated documentation files (the "Software"),
|
||||||
|
|
66
Makefile
66
Makefile
|
@ -4,57 +4,35 @@
|
||||||
include config.mk
|
include config.mk
|
||||||
|
|
||||||
SRC = drw.c dwm.c util.c
|
SRC = drw.c dwm.c util.c
|
||||||
OBJ = ${SRC:.c=.o}
|
OBJ = $(patsubst %.c,build/obj/%.c.o,$(SRC))
|
||||||
|
|
||||||
all: options dwm
|
all: build/dwm compile_commands.json
|
||||||
|
|
||||||
options:
|
build/obj/%.c.o: %.c
|
||||||
@echo dwm build options:
|
mkdir -p $(dir $@)
|
||||||
@echo "CFLAGS = ${CFLAGS}"
|
${CC} -c ${CFLAGS} -o $@ $<
|
||||||
@echo "LDFLAGS = ${LDFLAGS}"
|
|
||||||
@echo "CC = ${CC}"
|
|
||||||
|
|
||||||
.c.o:
|
build/dwm: ${OBJ}
|
||||||
@echo CC $<
|
${CC} -o $@ ${OBJ} ${LDFLAGS}
|
||||||
@${CC} -c ${CFLAGS} $<
|
|
||||||
|
|
||||||
${OBJ}: config.h config.mk
|
|
||||||
|
|
||||||
config.h:
|
|
||||||
@echo creating $@ from config.def.h
|
|
||||||
@cp config.def.h $@
|
|
||||||
|
|
||||||
dwm: ${OBJ}
|
|
||||||
@echo CC -o $@
|
|
||||||
@${CC} -o $@ ${OBJ} ${LDFLAGS}
|
|
||||||
|
|
||||||
clean:
|
clean:
|
||||||
@echo cleaning
|
rm -f dwm ${OBJ} dwm-${VERSION}.tar.gz
|
||||||
@rm -f dwm ${OBJ} dwm-${VERSION}.tar.gz
|
|
||||||
|
|
||||||
dist: clean
|
|
||||||
@echo creating dist tarball
|
|
||||||
@mkdir -p dwm-${VERSION}
|
|
||||||
@cp -R LICENSE TODO BUGS Makefile README config.def.h config.mk \
|
|
||||||
dwm.1 drw.h util.h ${SRC} dwm.png transient.c dwm-${VERSION}
|
|
||||||
@tar -cf dwm-${VERSION}.tar dwm-${VERSION}
|
|
||||||
@gzip dwm-${VERSION}.tar
|
|
||||||
@rm -rf dwm-${VERSION}
|
|
||||||
|
|
||||||
install: all
|
install: all
|
||||||
@echo installing executable file to ${DESTDIR}${PREFIX}/bin
|
mkdir -p ${DESTDIR}${PREFIX}/bin
|
||||||
@mkdir -p ${DESTDIR}${PREFIX}/bin
|
cp -f build/dwm ${DESTDIR}${PREFIX}/bin
|
||||||
@cp -f dwm ${DESTDIR}${PREFIX}/bin
|
chmod 755 ${DESTDIR}${PREFIX}/bin/dwm
|
||||||
@chmod 755 ${DESTDIR}${PREFIX}/bin/dwm
|
mkdir -p ${DESTDIR}${MANPREFIX}/man1
|
||||||
@echo installing manual page to ${DESTDIR}${MANPREFIX}/man1
|
sed "s/VERSION/${VERSION}/g" < dwm.1 > ${DESTDIR}${MANPREFIX}/man1/dwm.1
|
||||||
@mkdir -p ${DESTDIR}${MANPREFIX}/man1
|
chmod 644 ${DESTDIR}${MANPREFIX}/man1/dwm.1
|
||||||
@sed "s/VERSION/${VERSION}/g" < dwm.1 > ${DESTDIR}${MANPREFIX}/man1/dwm.1
|
cp dwm.desktop /usr/share/xsessions/dwm.desktop
|
||||||
@chmod 644 ${DESTDIR}${MANPREFIX}/man1/dwm.1
|
|
||||||
|
|
||||||
uninstall:
|
uninstall:
|
||||||
@echo removing executable file from ${DESTDIR}${PREFIX}/bin
|
rm -f ${DESTDIR}${PREFIX}/bin/dwm \
|
||||||
@rm -f ${DESTDIR}${PREFIX}/bin/dwm
|
${DESTDIR}${MANPREFIX}/man1/dwm.1 \
|
||||||
@echo removing manual page from ${DESTDIR}${MANPREFIX}/man1
|
/usr/share/xsessions/dwm.desktop
|
||||||
@rm -f ${DESTDIR}${MANPREFIX}/man1/dwm.1
|
|
||||||
|
|
||||||
.PHONY: all options clean dist install uninstall
|
compile_commands.json:
|
||||||
|
compiledb -n make
|
||||||
|
|
||||||
|
.PHONY: all clean dist install uninstall
|
||||||
|
|
3
README
3
README
|
@ -18,9 +18,6 @@ necessary as root):
|
||||||
|
|
||||||
make clean install
|
make clean install
|
||||||
|
|
||||||
If you are going to use the default bluegray color scheme it is highly
|
|
||||||
recommended to also install the bluegray files shipped in the dextra package.
|
|
||||||
|
|
||||||
|
|
||||||
Running dwm
|
Running dwm
|
||||||
-----------
|
-----------
|
||||||
|
|
4
TODO
4
TODO
|
@ -1,4 +0,0 @@
|
||||||
- add a flag to Key to execute the command on release (needed for commands
|
|
||||||
affecting the keyboard grab, see scrot -s for example)
|
|
||||||
- add updategeom() hook for external tools like dzen
|
|
||||||
- consider onscreenkeyboard hooks for tablet deployment
|
|
113
config.def.h
113
config.def.h
|
@ -1,113 +0,0 @@
|
||||||
/* See LICENSE file for copyright and license details. */
|
|
||||||
|
|
||||||
/* appearance */
|
|
||||||
static const char *fonts[] = {
|
|
||||||
"monospace:size=10"
|
|
||||||
};
|
|
||||||
static const char dmenufont[] = "monospace:size=10";
|
|
||||||
static const char normbordercolor[] = "#444444";
|
|
||||||
static const char normbgcolor[] = "#222222";
|
|
||||||
static const char normfgcolor[] = "#bbbbbb";
|
|
||||||
static const char selbordercolor[] = "#005577";
|
|
||||||
static const char selbgcolor[] = "#005577";
|
|
||||||
static const char selfgcolor[] = "#eeeeee";
|
|
||||||
static const unsigned int borderpx = 1; /* border pixel of 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 */
|
|
||||||
|
|
||||||
/* tagging */
|
|
||||||
static const char *tags[] = { "1", "2", "3", "4", "5", "6", "7", "8", "9" };
|
|
||||||
|
|
||||||
static 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 << 8, 0, -1 },
|
|
||||||
};
|
|
||||||
|
|
||||||
/* layout(s) */
|
|
||||||
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 */
|
|
||||||
|
|
||||||
static const Layout layouts[] = {
|
|
||||||
/* symbol arrange function */
|
|
||||||
{ "[]=", tile }, /* first entry is default */
|
|
||||||
{ "><>", NULL }, /* no layout function means floating behavior */
|
|
||||||
{ "[M]", monocle },
|
|
||||||
};
|
|
||||||
|
|
||||||
/* key definitions */
|
|
||||||
#define MODKEY Mod1Mask
|
|
||||||
#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/sh", "-c", cmd, NULL } }
|
|
||||||
|
|
||||||
/* 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 };
|
|
||||||
static const char *termcmd[] = { "st", NULL };
|
|
||||||
|
|
||||||
static Key keys[] = {
|
|
||||||
/* modifier key function argument */
|
|
||||||
{ MODKEY, XK_p, spawn, {.v = dmenucmd } },
|
|
||||||
{ MODKEY|ShiftMask, XK_Return, spawn, {.v = termcmd } },
|
|
||||||
{ MODKEY, XK_b, togglebar, {0} },
|
|
||||||
{ MODKEY, XK_j, focusstack, {.i = +1 } },
|
|
||||||
{ MODKEY, XK_k, focusstack, {.i = -1 } },
|
|
||||||
{ MODKEY, XK_i, incnmaster, {.i = +1 } },
|
|
||||||
{ MODKEY, XK_d, incnmaster, {.i = -1 } },
|
|
||||||
{ MODKEY, XK_h, setmfact, {.f = -0.05} },
|
|
||||||
{ MODKEY, XK_l, setmfact, {.f = +0.05} },
|
|
||||||
{ MODKEY, XK_Return, zoom, {0} },
|
|
||||||
{ 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_space, setlayout, {0} },
|
|
||||||
{ MODKEY|ShiftMask, XK_space, togglefloating, {0} },
|
|
||||||
{ MODKEY, XK_0, view, {.ui = ~0 } },
|
|
||||||
{ MODKEY|ShiftMask, XK_0, tag, {.ui = ~0 } },
|
|
||||||
{ 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 } },
|
|
||||||
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_q, quit, {0} },
|
|
||||||
};
|
|
||||||
|
|
||||||
/* button definitions */
|
|
||||||
/* click can be ClkLtSymbol, ClkStatusText, ClkWinTitle, ClkClientWin, or ClkRootWin */
|
|
||||||
static 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} },
|
|
||||||
};
|
|
||||||
|
|
162
config.h
Normal file
162
config.h
Normal file
|
@ -0,0 +1,162 @@
|
||||||
|
/* 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* 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" };
|
||||||
|
|
||||||
|
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 };
|
||||||
|
|
||||||
|
/* 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 */
|
||||||
|
|
||||||
|
{ 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 } },
|
||||||
|
{ MODKEY|ShiftMask, XK_e, quit, {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, 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, 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} },
|
||||||
|
{ ClkTagBar, 0, Button1, view, {0} },
|
||||||
|
{ ClkTagBar, 0, Button3, toggleview, {0} },
|
||||||
|
{ ClkTagBar, MODKEY, Button1, tag, {0} },
|
||||||
|
{ ClkTagBar, MODKEY, Button3, toggletag, {0} },
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif
|
|
@ -1,5 +1,5 @@
|
||||||
# dwm version
|
# dwm version
|
||||||
VERSION = 6.1
|
VERSION = 6.5
|
||||||
|
|
||||||
# Customize below to fit your system
|
# Customize below to fit your system
|
||||||
|
|
||||||
|
@ -19,16 +19,17 @@ FREETYPELIBS = -lfontconfig -lXft
|
||||||
FREETYPEINC = /usr/include/freetype2
|
FREETYPEINC = /usr/include/freetype2
|
||||||
# OpenBSD (uncomment)
|
# OpenBSD (uncomment)
|
||||||
#FREETYPEINC = ${X11INC}/freetype2
|
#FREETYPEINC = ${X11INC}/freetype2
|
||||||
|
#MANPREFIX = ${PREFIX}/man
|
||||||
|
|
||||||
# includes and libs
|
# includes and libs
|
||||||
INCS = -I${X11INC} -I${FREETYPEINC}
|
INCS = -I${X11INC} -I${FREETYPEINC}
|
||||||
LIBS = -L${X11LIB} -lX11 ${XINERAMALIBS} ${FREETYPELIBS}
|
LIBS = -L${X11LIB} -lX11 ${XINERAMALIBS} ${FREETYPELIBS}
|
||||||
|
|
||||||
# flags
|
# flags
|
||||||
CPPFLAGS = -D_BSD_SOURCE -D_POSIX_C_SOURCE=2 -DVERSION=\"${VERSION}\" ${XINERAMAFLAGS}
|
CPPFLAGS = -D_DEFAULT_SOURCE -D_BSD_SOURCE -D_XOPEN_SOURCE=700L -DVERSION=\"${VERSION}\" ${XINERAMAFLAGS}
|
||||||
#CFLAGS = -g -std=c99 -pedantic -Wall -O0 ${INCS} ${CPPFLAGS}
|
#CFLAGS = -g -std=c99 -pedantic -Wall -O0 ${INCS} ${CPPFLAGS}
|
||||||
CFLAGS = -std=c99 -pedantic -Wall -Wno-deprecated-declarations -Os ${INCS} ${CPPFLAGS}
|
CFLAGS = -std=c99 -pedantic -Wall -Wno-deprecated-declarations -Os ${INCS} ${CPPFLAGS}
|
||||||
LDFLAGS = -s ${LIBS}
|
LDFLAGS = ${LIBS}
|
||||||
|
|
||||||
# Solaris
|
# Solaris
|
||||||
#CFLAGS = -fast ${INCS} -DVERSION=\"${VERSION}\"
|
#CFLAGS = -fast ${INCS} -DVERSION=\"${VERSION}\"
|
||||||
|
|
310
drw.c
310
drw.c
|
@ -63,9 +63,8 @@ utf8decode(const char *c, long *u, size_t clen)
|
||||||
Drw *
|
Drw *
|
||||||
drw_create(Display *dpy, int screen, Window root, unsigned int w, unsigned int h)
|
drw_create(Display *dpy, int screen, Window root, unsigned int w, unsigned int h)
|
||||||
{
|
{
|
||||||
Drw *drw;
|
Drw *drw = ecalloc(1, sizeof(Drw));
|
||||||
|
|
||||||
drw = ecalloc(1, sizeof(Drw));
|
|
||||||
drw->dpy = dpy;
|
drw->dpy = dpy;
|
||||||
drw->screen = screen;
|
drw->screen = screen;
|
||||||
drw->root = root;
|
drw->root = root;
|
||||||
|
@ -73,7 +72,6 @@ drw_create(Display *dpy, int screen, Window root, unsigned int w, unsigned int h
|
||||||
drw->h = h;
|
drw->h = h;
|
||||||
drw->drawable = XCreatePixmap(dpy, root, w, h, DefaultDepth(dpy, screen));
|
drw->drawable = XCreatePixmap(dpy, root, w, h, DefaultDepth(dpy, screen));
|
||||||
drw->gc = XCreateGC(dpy, root, 0, NULL);
|
drw->gc = XCreateGC(dpy, root, 0, NULL);
|
||||||
drw->fontcount = 0;
|
|
||||||
XSetLineAttributes(dpy, drw->gc, 1, LineSolid, CapButt, JoinMiter);
|
XSetLineAttributes(dpy, drw->gc, 1, LineSolid, CapButt, JoinMiter);
|
||||||
|
|
||||||
return drw;
|
return drw;
|
||||||
|
@ -82,6 +80,9 @@ drw_create(Display *dpy, int screen, Window root, unsigned int w, unsigned int h
|
||||||
void
|
void
|
||||||
drw_resize(Drw *drw, unsigned int w, unsigned int h)
|
drw_resize(Drw *drw, unsigned int w, unsigned int h)
|
||||||
{
|
{
|
||||||
|
if (!drw)
|
||||||
|
return;
|
||||||
|
|
||||||
drw->w = w;
|
drw->w = w;
|
||||||
drw->h = h;
|
drw->h = h;
|
||||||
if (drw->drawable)
|
if (drw->drawable)
|
||||||
|
@ -92,84 +93,57 @@ drw_resize(Drw *drw, unsigned int w, unsigned int h)
|
||||||
void
|
void
|
||||||
drw_free(Drw *drw)
|
drw_free(Drw *drw)
|
||||||
{
|
{
|
||||||
size_t i;
|
|
||||||
|
|
||||||
for (i = 0; i < drw->fontcount; i++)
|
|
||||||
drw_font_free(drw->fonts[i]);
|
|
||||||
XFreePixmap(drw->dpy, drw->drawable);
|
XFreePixmap(drw->dpy, drw->drawable);
|
||||||
XFreeGC(drw->dpy, drw->gc);
|
XFreeGC(drw->dpy, drw->gc);
|
||||||
|
drw_fontset_free(drw->fonts);
|
||||||
free(drw);
|
free(drw);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* This function is an implementation detail. Library users should use
|
/* This function is an implementation detail. Library users should use
|
||||||
* drw_font_create instead.
|
* drw_fontset_create instead.
|
||||||
*/
|
*/
|
||||||
static Fnt *
|
static Fnt *
|
||||||
drw_font_xcreate(Drw *drw, const char *fontname, FcPattern *fontpattern)
|
xfont_create(Drw *drw, const char *fontname, FcPattern *fontpattern)
|
||||||
{
|
{
|
||||||
Fnt *font;
|
Fnt *font;
|
||||||
XftFont *xfont = NULL;
|
XftFont *xfont = NULL;
|
||||||
FcPattern *pattern = NULL;
|
FcPattern *pattern = NULL;
|
||||||
|
|
||||||
if (fontname) {
|
if (fontname) {
|
||||||
/* Using the pattern found at font->xfont->pattern does not yield same
|
/* Using the pattern found at font->xfont->pattern does not yield the
|
||||||
* the same substitution results as using the pattern returned by
|
* same substitution results as using the pattern returned by
|
||||||
* FcNameParse; using the latter results in the desired fallback
|
* FcNameParse; using the latter results in the desired fallback
|
||||||
* behaviour whereas the former just results in
|
* behaviour whereas the former just results in missing-character
|
||||||
* missing-character-rectangles being drawn, at least with some fonts.
|
* rectangles being drawn, at least with some fonts. */
|
||||||
*/
|
|
||||||
if (!(xfont = XftFontOpenName(drw->dpy, drw->screen, fontname))) {
|
if (!(xfont = XftFontOpenName(drw->dpy, drw->screen, fontname))) {
|
||||||
fprintf(stderr, "error, cannot load font: '%s'\n", fontname);
|
fprintf(stderr, "error, cannot load font from name: '%s'\n", fontname);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
if (!(pattern = FcNameParse((FcChar8 *) fontname))) {
|
if (!(pattern = FcNameParse((FcChar8 *) fontname))) {
|
||||||
fprintf(stderr, "error, cannot load font: '%s'\n", fontname);
|
fprintf(stderr, "error, cannot parse font name to pattern: '%s'\n", fontname);
|
||||||
XftFontClose(drw->dpy, xfont);
|
XftFontClose(drw->dpy, xfont);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
} else if (fontpattern) {
|
} else if (fontpattern) {
|
||||||
if (!(xfont = XftFontOpenPattern(drw->dpy, fontpattern))) {
|
if (!(xfont = XftFontOpenPattern(drw->dpy, fontpattern))) {
|
||||||
fprintf(stderr, "error, cannot load font pattern.\n");
|
fprintf(stderr, "error, cannot load font from pattern.\n");
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
die("no font specified.\n");
|
die("no font specified.");
|
||||||
}
|
}
|
||||||
|
|
||||||
font = ecalloc(1, sizeof(Fnt));
|
font = ecalloc(1, sizeof(Fnt));
|
||||||
font->xfont = xfont;
|
font->xfont = xfont;
|
||||||
font->pattern = pattern;
|
font->pattern = pattern;
|
||||||
font->ascent = xfont->ascent;
|
font->h = xfont->ascent + xfont->descent;
|
||||||
font->descent = xfont->descent;
|
|
||||||
font->h = font->ascent + font->descent;
|
|
||||||
font->dpy = drw->dpy;
|
font->dpy = drw->dpy;
|
||||||
|
|
||||||
return font;
|
return font;
|
||||||
}
|
}
|
||||||
|
|
||||||
Fnt*
|
static void
|
||||||
drw_font_create(Drw *drw, const char *fontname)
|
xfont_free(Fnt *font)
|
||||||
{
|
|
||||||
return drw_font_xcreate(drw, fontname, NULL);
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
|
||||||
drw_load_fonts(Drw* drw, const char *fonts[], size_t fontcount)
|
|
||||||
{
|
|
||||||
size_t i;
|
|
||||||
Fnt *font;
|
|
||||||
|
|
||||||
for (i = 0; i < fontcount; i++) {
|
|
||||||
if (drw->fontcount >= DRW_FONT_CACHE_SIZE) {
|
|
||||||
die("font cache exhausted.\n");
|
|
||||||
} else if ((font = drw_font_xcreate(drw, fonts[i], NULL))) {
|
|
||||||
drw->fonts[drw->fontcount++] = font;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
|
||||||
drw_font_free(Fnt *font)
|
|
||||||
{
|
{
|
||||||
if (!font)
|
if (!font)
|
||||||
return;
|
return;
|
||||||
|
@ -179,150 +153,206 @@ drw_font_free(Fnt *font)
|
||||||
free(font);
|
free(font);
|
||||||
}
|
}
|
||||||
|
|
||||||
Clr *
|
Fnt*
|
||||||
drw_clr_create(Drw *drw, const char *clrname)
|
drw_fontset_create(Drw* drw, const char *fonts[], size_t fontcount)
|
||||||
{
|
{
|
||||||
Clr *clr;
|
Fnt *cur, *ret = NULL;
|
||||||
|
size_t i;
|
||||||
|
|
||||||
|
if (!drw || !fonts)
|
||||||
|
return NULL;
|
||||||
|
|
||||||
|
for (i = 1; i <= fontcount; i++) {
|
||||||
|
if ((cur = xfont_create(drw, fonts[fontcount - i], NULL))) {
|
||||||
|
cur->next = ret;
|
||||||
|
ret = cur;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return (drw->fonts = ret);
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
drw_fontset_free(Fnt *font)
|
||||||
|
{
|
||||||
|
if (font) {
|
||||||
|
drw_fontset_free(font->next);
|
||||||
|
xfont_free(font);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
drw_clr_create(Drw *drw, Clr *dest, const char *clrname)
|
||||||
|
{
|
||||||
|
if (!drw || !dest || !clrname)
|
||||||
|
return;
|
||||||
|
|
||||||
clr = ecalloc(1, sizeof(Clr));
|
|
||||||
if (!XftColorAllocName(drw->dpy, DefaultVisual(drw->dpy, drw->screen),
|
if (!XftColorAllocName(drw->dpy, DefaultVisual(drw->dpy, drw->screen),
|
||||||
DefaultColormap(drw->dpy, drw->screen),
|
DefaultColormap(drw->dpy, drw->screen),
|
||||||
clrname, &clr->rgb))
|
clrname, dest))
|
||||||
die("error, cannot allocate color '%s'\n", clrname);
|
die("error, cannot allocate color '%s'", clrname);
|
||||||
clr->pix = clr->rgb.pixel;
|
}
|
||||||
|
|
||||||
return clr;
|
/* Wrapper to create color schemes. The caller has to call free(3) on the
|
||||||
|
* returned color scheme when done using it. */
|
||||||
|
Clr *
|
||||||
|
drw_scm_create(Drw *drw, const char *clrnames[], size_t clrcount)
|
||||||
|
{
|
||||||
|
size_t i;
|
||||||
|
Clr *ret;
|
||||||
|
|
||||||
|
/* need at least two colors for a scheme */
|
||||||
|
if (!drw || !clrnames || clrcount < 2 || !(ret = ecalloc(clrcount, sizeof(XftColor))))
|
||||||
|
return NULL;
|
||||||
|
|
||||||
|
for (i = 0; i < clrcount; i++)
|
||||||
|
drw_clr_create(drw, &ret[i], clrnames[i]);
|
||||||
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
drw_clr_free(Clr *clr)
|
drw_setfontset(Drw *drw, Fnt *set)
|
||||||
{
|
{
|
||||||
free(clr);
|
if (drw)
|
||||||
|
drw->fonts = set;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
drw_setscheme(Drw *drw, ClrScheme *scheme)
|
drw_setscheme(Drw *drw, Clr *scm)
|
||||||
{
|
{
|
||||||
drw->scheme = scheme;
|
if (drw)
|
||||||
|
drw->scheme = scm;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
drw_rect(Drw *drw, int x, int y, unsigned int w, unsigned int h, int filled, int empty, int invert)
|
drw_rect(Drw *drw, int x, int y, unsigned int w, unsigned int h, int filled, int invert)
|
||||||
{
|
{
|
||||||
if (!drw->scheme)
|
if (!drw || !drw->scheme)
|
||||||
return;
|
return;
|
||||||
XSetForeground(drw->dpy, drw->gc, invert ? drw->scheme->bg->pix : drw->scheme->fg->pix);
|
XSetForeground(drw->dpy, drw->gc, invert ? drw->scheme[ColBg].pixel : drw->scheme[ColFg].pixel);
|
||||||
if (filled)
|
if (filled)
|
||||||
XFillRectangle(drw->dpy, drw->drawable, drw->gc, x, y, w + 1, h + 1);
|
XFillRectangle(drw->dpy, drw->drawable, drw->gc, x, y, w, h);
|
||||||
else if (empty)
|
else
|
||||||
XDrawRectangle(drw->dpy, drw->drawable, drw->gc, x, y, w, h);
|
XDrawRectangle(drw->dpy, drw->drawable, drw->gc, x, y, w - 1, h - 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
drw_text(Drw *drw, int x, int y, unsigned int w, unsigned int h, const char *text, int invert)
|
drw_text(Drw *drw, int x, int y, unsigned int w, unsigned int h, unsigned int lpad, const char *text, int invert)
|
||||||
{
|
{
|
||||||
char buf[1024];
|
int i, ty, ellipsis_x = 0;
|
||||||
int tx, ty, th;
|
unsigned int tmpw, ew, ellipsis_w = 0, ellipsis_len;
|
||||||
Extnts tex;
|
|
||||||
XftDraw *d = NULL;
|
XftDraw *d = NULL;
|
||||||
Fnt *curfont, *nextfont;
|
Fnt *usedfont, *curfont, *nextfont;
|
||||||
size_t i, len;
|
int utf8strlen, utf8charlen, render = x || y || w || h;
|
||||||
int utf8strlen, utf8charlen, render;
|
|
||||||
long utf8codepoint = 0;
|
long utf8codepoint = 0;
|
||||||
const char *utf8str;
|
const char *utf8str;
|
||||||
FcCharSet *fccharset;
|
FcCharSet *fccharset;
|
||||||
FcPattern *fcpattern;
|
FcPattern *fcpattern;
|
||||||
FcPattern *match;
|
FcPattern *match;
|
||||||
XftResult result;
|
XftResult result;
|
||||||
int charexists = 0;
|
int charexists = 0, overflow = 0;
|
||||||
|
/* keep track of a couple codepoints for which we have no match. */
|
||||||
|
enum { nomatches_len = 64 };
|
||||||
|
static struct { long codepoint[nomatches_len]; unsigned int idx; } nomatches;
|
||||||
|
static unsigned int ellipsis_width = 0;
|
||||||
|
|
||||||
if (!drw->scheme || !drw->fontcount)
|
if (!drw || (render && (!drw->scheme || !w)) || !text || !drw->fonts)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
if (!(render = x || y || w || h)) {
|
if (!render) {
|
||||||
w = ~w;
|
w = invert ? invert : ~invert;
|
||||||
} else {
|
} else {
|
||||||
XSetForeground(drw->dpy, drw->gc, invert ?
|
XSetForeground(drw->dpy, drw->gc, drw->scheme[invert ? ColFg : ColBg].pixel);
|
||||||
drw->scheme->fg->pix : drw->scheme->bg->pix);
|
|
||||||
XFillRectangle(drw->dpy, drw->drawable, drw->gc, x, y, w, h);
|
XFillRectangle(drw->dpy, drw->drawable, drw->gc, x, y, w, h);
|
||||||
d = XftDrawCreate(drw->dpy, drw->drawable,
|
d = XftDrawCreate(drw->dpy, drw->drawable,
|
||||||
DefaultVisual(drw->dpy, drw->screen),
|
DefaultVisual(drw->dpy, drw->screen),
|
||||||
DefaultColormap(drw->dpy, drw->screen));
|
DefaultColormap(drw->dpy, drw->screen));
|
||||||
|
x += lpad;
|
||||||
|
w -= lpad;
|
||||||
}
|
}
|
||||||
|
|
||||||
curfont = drw->fonts[0];
|
usedfont = drw->fonts;
|
||||||
|
if (!ellipsis_width && render)
|
||||||
|
ellipsis_width = drw_fontset_getwidth(drw, "...");
|
||||||
while (1) {
|
while (1) {
|
||||||
utf8strlen = 0;
|
ew = ellipsis_len = utf8strlen = 0;
|
||||||
utf8str = text;
|
utf8str = text;
|
||||||
nextfont = NULL;
|
nextfont = NULL;
|
||||||
while (*text) {
|
while (*text) {
|
||||||
utf8charlen = utf8decode(text, &utf8codepoint, UTF_SIZ);
|
utf8charlen = utf8decode(text, &utf8codepoint, UTF_SIZ);
|
||||||
for (i = 0; i < drw->fontcount; i++) {
|
for (curfont = drw->fonts; curfont; curfont = curfont->next) {
|
||||||
charexists = charexists || XftCharExists(drw->dpy, drw->fonts[i]->xfont, utf8codepoint);
|
charexists = charexists || XftCharExists(drw->dpy, curfont->xfont, utf8codepoint);
|
||||||
if (charexists) {
|
if (charexists) {
|
||||||
if (drw->fonts[i] == curfont) {
|
drw_font_getexts(curfont, text, utf8charlen, &tmpw, NULL);
|
||||||
|
if (ew + ellipsis_width <= w) {
|
||||||
|
/* keep track where the ellipsis still fits */
|
||||||
|
ellipsis_x = x + ew;
|
||||||
|
ellipsis_w = w - ew;
|
||||||
|
ellipsis_len = utf8strlen;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (ew + tmpw > w) {
|
||||||
|
overflow = 1;
|
||||||
|
/* called from drw_fontset_getwidth_clamp():
|
||||||
|
* it wants the width AFTER the overflow
|
||||||
|
*/
|
||||||
|
if (!render)
|
||||||
|
x += tmpw;
|
||||||
|
else
|
||||||
|
utf8strlen = ellipsis_len;
|
||||||
|
} else if (curfont == usedfont) {
|
||||||
utf8strlen += utf8charlen;
|
utf8strlen += utf8charlen;
|
||||||
text += utf8charlen;
|
text += utf8charlen;
|
||||||
|
ew += tmpw;
|
||||||
} else {
|
} else {
|
||||||
nextfont = drw->fonts[i];
|
nextfont = curfont;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!charexists || (nextfont && nextfont != curfont))
|
if (overflow || !charexists || nextfont)
|
||||||
break;
|
break;
|
||||||
else
|
else
|
||||||
charexists = 0;
|
charexists = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (utf8strlen) {
|
if (utf8strlen) {
|
||||||
drw_font_getexts(curfont, utf8str, utf8strlen, &tex);
|
|
||||||
/* shorten text if necessary */
|
|
||||||
for (len = MIN(utf8strlen, (sizeof buf) - 1); len && (tex.w > w - drw->fonts[0]->h || w < drw->fonts[0]->h); len--)
|
|
||||||
drw_font_getexts(curfont, utf8str, len, &tex);
|
|
||||||
|
|
||||||
if (len) {
|
|
||||||
memcpy(buf, utf8str, len);
|
|
||||||
buf[len] = '\0';
|
|
||||||
if (len < utf8strlen)
|
|
||||||
for (i = len; i && i > len - 3; buf[--i] = '.');
|
|
||||||
|
|
||||||
if (render) {
|
if (render) {
|
||||||
th = curfont->ascent + curfont->descent;
|
ty = y + (h - usedfont->h) / 2 + usedfont->xfont->ascent;
|
||||||
ty = y + (h / 2) - (th / 2) + curfont->ascent;
|
XftDrawStringUtf8(d, &drw->scheme[invert ? ColBg : ColFg],
|
||||||
tx = x + (h / 2);
|
usedfont->xfont, x, ty, (XftChar8 *)utf8str, utf8strlen);
|
||||||
XftDrawStringUtf8(d, invert ? &drw->scheme->bg->rgb : &drw->scheme->fg->rgb, curfont->xfont, tx, ty, (XftChar8 *)buf, len);
|
|
||||||
}
|
|
||||||
x += tex.w;
|
|
||||||
w -= tex.w;
|
|
||||||
}
|
}
|
||||||
|
x += ew;
|
||||||
|
w -= ew;
|
||||||
}
|
}
|
||||||
|
if (render && overflow)
|
||||||
|
drw_text(drw, ellipsis_x, y, ellipsis_w, h, 0, "...", invert);
|
||||||
|
|
||||||
if (!*text) {
|
if (!*text || overflow) {
|
||||||
break;
|
break;
|
||||||
} else if (nextfont) {
|
} else if (nextfont) {
|
||||||
charexists = 0;
|
charexists = 0;
|
||||||
curfont = nextfont;
|
usedfont = nextfont;
|
||||||
} else {
|
} else {
|
||||||
/* Regardless of whether or not a fallback font is found, the
|
/* Regardless of whether or not a fallback font is found, the
|
||||||
* character must be drawn.
|
* character must be drawn. */
|
||||||
*/
|
|
||||||
charexists = 1;
|
charexists = 1;
|
||||||
|
|
||||||
if (drw->fontcount >= DRW_FONT_CACHE_SIZE)
|
for (i = 0; i < nomatches_len; ++i) {
|
||||||
continue;
|
/* avoid calling XftFontMatch if we know we won't find a match */
|
||||||
|
if (utf8codepoint == nomatches.codepoint[i])
|
||||||
|
goto no_match;
|
||||||
|
}
|
||||||
|
|
||||||
fccharset = FcCharSetCreate();
|
fccharset = FcCharSetCreate();
|
||||||
FcCharSetAddChar(fccharset, utf8codepoint);
|
FcCharSetAddChar(fccharset, utf8codepoint);
|
||||||
|
|
||||||
if (!drw->fonts[0]->pattern) {
|
if (!drw->fonts->pattern) {
|
||||||
/* Refer to the comment in drw_font_xcreate for more
|
/* Refer to the comment in xfont_create for more information. */
|
||||||
* information. */
|
die("the first font in the cache must be loaded from a font string.");
|
||||||
die("the first font in the cache must be loaded from a font string.\n");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fcpattern = FcPatternDuplicate(drw->fonts[0]->pattern);
|
fcpattern = FcPatternDuplicate(drw->fonts->pattern);
|
||||||
FcPatternAddCharSet(fcpattern, FC_CHARSET, fccharset);
|
FcPatternAddCharSet(fcpattern, FC_CHARSET, fccharset);
|
||||||
FcPatternAddBool(fcpattern, FC_SCALABLE, FcTrue);
|
FcPatternAddBool(fcpattern, FC_SCALABLE, FcTrue);
|
||||||
|
|
||||||
|
@ -334,12 +364,16 @@ drw_text(Drw *drw, int x, int y, unsigned int w, unsigned int h, const char *tex
|
||||||
FcPatternDestroy(fcpattern);
|
FcPatternDestroy(fcpattern);
|
||||||
|
|
||||||
if (match) {
|
if (match) {
|
||||||
curfont = drw_font_xcreate(drw, NULL, match);
|
usedfont = xfont_create(drw, NULL, match);
|
||||||
if (curfont && XftCharExists(drw->dpy, curfont->xfont, utf8codepoint)) {
|
if (usedfont && XftCharExists(drw->dpy, usedfont->xfont, utf8codepoint)) {
|
||||||
drw->fonts[drw->fontcount++] = curfont;
|
for (curfont = drw->fonts; curfont->next; curfont = curfont->next)
|
||||||
|
; /* NOP */
|
||||||
|
curfont->next = usedfont;
|
||||||
} else {
|
} else {
|
||||||
drw_font_free(curfont);
|
xfont_free(usedfont);
|
||||||
curfont = drw->fonts[0];
|
nomatches.codepoint[++nomatches.idx % nomatches_len] = utf8codepoint;
|
||||||
|
no_match:
|
||||||
|
usedfont = drw->fonts;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -347,34 +381,49 @@ drw_text(Drw *drw, int x, int y, unsigned int w, unsigned int h, const char *tex
|
||||||
if (d)
|
if (d)
|
||||||
XftDrawDestroy(d);
|
XftDrawDestroy(d);
|
||||||
|
|
||||||
return x;
|
return x + (render ? w : 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
drw_map(Drw *drw, Window win, int x, int y, unsigned int w, unsigned int h)
|
drw_map(Drw *drw, Window win, int x, int y, unsigned int w, unsigned int h)
|
||||||
{
|
{
|
||||||
|
if (!drw)
|
||||||
|
return;
|
||||||
|
|
||||||
XCopyArea(drw->dpy, drw->drawable, win, drw->gc, x, y, w, h, x, y);
|
XCopyArea(drw->dpy, drw->drawable, win, drw->gc, x, y, w, h, x, y);
|
||||||
XSync(drw->dpy, False);
|
XSync(drw->dpy, False);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
unsigned int
|
||||||
drw_font_getexts(Fnt *font, const char *text, unsigned int len, Extnts *tex)
|
drw_fontset_getwidth(Drw *drw, const char *text)
|
||||||
{
|
{
|
||||||
XGlyphInfo ext;
|
if (!drw || !drw->fonts || !text)
|
||||||
|
return 0;
|
||||||
XftTextExtentsUtf8(font->dpy, font->xfont, (XftChar8 *)text, len, &ext);
|
return drw_text(drw, 0, 0, 0, 0, 0, text, 0);
|
||||||
tex->h = font->h;
|
|
||||||
tex->w = ext.xOff;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned int
|
unsigned int
|
||||||
drw_font_getexts_width(Fnt *font, const char *text, unsigned int len)
|
drw_fontset_getwidth_clamp(Drw *drw, const char *text, unsigned int n)
|
||||||
{
|
{
|
||||||
Extnts tex;
|
unsigned int tmp = 0;
|
||||||
|
if (drw && drw->fonts && text && n)
|
||||||
|
tmp = drw_text(drw, 0, 0, 0, 0, 0, text, n);
|
||||||
|
return MIN(n, tmp);
|
||||||
|
}
|
||||||
|
|
||||||
drw_font_getexts(font, text, len, &tex);
|
void
|
||||||
|
drw_font_getexts(Fnt *font, const char *text, unsigned int len, unsigned int *w, unsigned int *h)
|
||||||
|
{
|
||||||
|
XGlyphInfo ext;
|
||||||
|
|
||||||
return tex.w;
|
if (!font || !text)
|
||||||
|
return;
|
||||||
|
|
||||||
|
XftTextExtentsUtf8(font->dpy, font->xfont, (XftChar8 *)text, len, &ext);
|
||||||
|
if (w)
|
||||||
|
*w = ext.xOff;
|
||||||
|
if (h)
|
||||||
|
*h = font->h;
|
||||||
}
|
}
|
||||||
|
|
||||||
Cur *
|
Cur *
|
||||||
|
@ -382,7 +431,9 @@ drw_cur_create(Drw *drw, int shape)
|
||||||
{
|
{
|
||||||
Cur *cur;
|
Cur *cur;
|
||||||
|
|
||||||
cur = ecalloc(1, sizeof(Cur));
|
if (!drw || !(cur = ecalloc(1, sizeof(Cur))))
|
||||||
|
return NULL;
|
||||||
|
|
||||||
cur->cursor = XCreateFontCursor(drw->dpy, shape);
|
cur->cursor = XCreateFontCursor(drw->dpy, shape);
|
||||||
|
|
||||||
return cur;
|
return cur;
|
||||||
|
@ -393,6 +444,7 @@ drw_cur_free(Drw *drw, Cur *cursor)
|
||||||
{
|
{
|
||||||
if (!cursor)
|
if (!cursor)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
XFreeCursor(drw->dpy, cursor->cursor);
|
XFreeCursor(drw->dpy, cursor->cursor);
|
||||||
free(cursor);
|
free(cursor);
|
||||||
}
|
}
|
||||||
|
|
84
drw.h
84
drw.h
|
@ -1,29 +1,39 @@
|
||||||
/* See LICENSE file for copyright and license details. */
|
/* See LICENSE file for copyright and license details. */
|
||||||
#define DRW_FONT_CACHE_SIZE 32
|
|
||||||
|
|
||||||
typedef struct {
|
#ifndef _H_DRW
|
||||||
unsigned long pix;
|
#define _H_DRW
|
||||||
XftColor rgb;
|
|
||||||
} Clr;
|
#include <signal.h>
|
||||||
|
#include <stdarg.h>
|
||||||
|
#include <unistd.h>
|
||||||
|
#include <sys/types.h>
|
||||||
|
#include <sys/wait.h>
|
||||||
|
#include <X11/cursorfont.h>
|
||||||
|
#include <X11/keysym.h>
|
||||||
|
#include <X11/Xatom.h>
|
||||||
|
#include <X11/Xlib.h>
|
||||||
|
#include <X11/Xproto.h>
|
||||||
|
#include <X11/Xutil.h>
|
||||||
|
#ifdef XINERAMA
|
||||||
|
#include <X11/extensions/Xinerama.h>
|
||||||
|
#endif /* XINERAMA */
|
||||||
|
#include <X11/Xft/Xft.h>
|
||||||
|
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
Cursor cursor;
|
Cursor cursor;
|
||||||
} Cur;
|
} Cur;
|
||||||
|
|
||||||
typedef struct {
|
typedef struct Fnt {
|
||||||
Display *dpy;
|
Display *dpy;
|
||||||
int ascent;
|
|
||||||
int descent;
|
|
||||||
unsigned int h;
|
unsigned int h;
|
||||||
XftFont *xfont;
|
XftFont *xfont;
|
||||||
FcPattern *pattern;
|
FcPattern *pattern;
|
||||||
|
struct Fnt *next;
|
||||||
} Fnt;
|
} Fnt;
|
||||||
|
|
||||||
typedef struct {
|
enum { ColFg, ColBg, ColBorder }; /* Clr scheme index */
|
||||||
Clr *fg;
|
typedef XftColor Clr;
|
||||||
Clr *bg;
|
|
||||||
Clr *border;
|
|
||||||
} ClrScheme;
|
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
unsigned int w, h;
|
unsigned int w, h;
|
||||||
|
@ -32,43 +42,39 @@ typedef struct {
|
||||||
Window root;
|
Window root;
|
||||||
Drawable drawable;
|
Drawable drawable;
|
||||||
GC gc;
|
GC gc;
|
||||||
ClrScheme *scheme;
|
Clr *scheme;
|
||||||
size_t fontcount;
|
Fnt *fonts;
|
||||||
Fnt *fonts[DRW_FONT_CACHE_SIZE];
|
|
||||||
} Drw;
|
} Drw;
|
||||||
|
|
||||||
typedef struct {
|
|
||||||
unsigned int w;
|
|
||||||
unsigned int h;
|
|
||||||
} Extnts;
|
|
||||||
|
|
||||||
/* Drawable abstraction */
|
/* Drawable abstraction */
|
||||||
Drw *drw_create(Display *, int, Window, unsigned int, unsigned int);
|
Drw *drw_create(Display *dpy, int screen, Window win, unsigned int w, unsigned int h);
|
||||||
void drw_resize(Drw *, unsigned int, unsigned int);
|
void drw_resize(Drw *drw, unsigned int w, unsigned int h);
|
||||||
void drw_free(Drw *);
|
void drw_free(Drw *drw);
|
||||||
|
|
||||||
/* Fnt abstraction */
|
/* Fnt abstraction */
|
||||||
Fnt *drw_font_create(Drw *, const char *);
|
Fnt *drw_fontset_create(Drw* drw, const char *fonts[], size_t fontcount);
|
||||||
void drw_load_fonts(Drw *, const char *[], size_t);
|
void drw_fontset_free(Fnt* set);
|
||||||
void drw_font_free(Fnt *);
|
unsigned int drw_fontset_getwidth(Drw *drw, const char *text);
|
||||||
void drw_font_getexts(Fnt *, const char *, unsigned int, Extnts *);
|
unsigned int drw_fontset_getwidth_clamp(Drw *drw, const char *text, unsigned int n);
|
||||||
unsigned int drw_font_getexts_width(Fnt *, const char *, unsigned int);
|
void drw_font_getexts(Fnt *font, const char *text, unsigned int len, unsigned int *w, unsigned int *h);
|
||||||
|
|
||||||
/* Colour abstraction */
|
/* Colorscheme abstraction */
|
||||||
Clr *drw_clr_create(Drw *, const char *);
|
void drw_clr_create(Drw *drw, Clr *dest, const char *clrname);
|
||||||
void drw_clr_free(Clr *);
|
Clr *drw_scm_create(Drw *drw, const char *clrnames[], size_t clrcount);
|
||||||
|
|
||||||
/* Cursor abstraction */
|
/* Cursor abstraction */
|
||||||
Cur *drw_cur_create(Drw *, int);
|
Cur *drw_cur_create(Drw *drw, int shape);
|
||||||
void drw_cur_free(Drw *, Cur *);
|
void drw_cur_free(Drw *drw, Cur *cursor);
|
||||||
|
|
||||||
/* Drawing context manipulation */
|
/* Drawing context manipulation */
|
||||||
void drw_setfont(Drw *, Fnt *);
|
void drw_setfontset(Drw *drw, Fnt *set);
|
||||||
void drw_setscheme(Drw *, ClrScheme *);
|
void drw_setscheme(Drw *drw, Clr *scm);
|
||||||
|
|
||||||
/* Drawing functions */
|
/* Drawing functions */
|
||||||
void drw_rect(Drw *, int, int, unsigned int, unsigned int, int, int, int);
|
void drw_rect(Drw *drw, int x, int y, unsigned int w, unsigned int h, int filled, int invert);
|
||||||
int drw_text(Drw *, int, int, unsigned int, unsigned int, const char *, int);
|
int drw_text(Drw *drw, int x, int y, unsigned int w, unsigned int h, unsigned int lpad, const char *text, int invert);
|
||||||
|
|
||||||
/* Map functions */
|
/* Map functions */
|
||||||
void drw_map(Drw *, Window, int, int, unsigned int, unsigned int);
|
void drw_map(Drw *drw, Window win, int x, int y, unsigned int w, unsigned int h);
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
31
dwm.1
31
dwm.1
|
@ -10,8 +10,9 @@ and floating layouts. Either layout can be applied dynamically, optimising the
|
||||||
environment for the application in use and the task performed.
|
environment for the application in use and the task performed.
|
||||||
.P
|
.P
|
||||||
In tiled layouts windows are managed in a master and stacking area. The master
|
In tiled layouts windows are managed in a master and stacking area. The master
|
||||||
area contains the window which currently needs most attention, whereas the
|
area on the left contains one window by default, and the stacking area on the
|
||||||
stacking area contains all other windows. In monocle layout all windows are
|
right contains all other windows. The number of master area windows can be
|
||||||
|
adjusted from zero to an arbitrary number. In monocle layout all windows are
|
||||||
maximised to the screen size. In floating layout windows can be resized and
|
maximised to the screen size. In floating layout windows can be resized and
|
||||||
moved freely. Dialog windows are always managed floating, regardless of the
|
moved freely. Dialog windows are always managed floating, regardless of the
|
||||||
layout applied.
|
layout applied.
|
||||||
|
@ -32,7 +33,7 @@ dwm draws a small border around windows to indicate the focus state.
|
||||||
.SH OPTIONS
|
.SH OPTIONS
|
||||||
.TP
|
.TP
|
||||||
.B \-v
|
.B \-v
|
||||||
prints version information to standard output, then exits.
|
prints version information to stderr, then exits.
|
||||||
.SH USAGE
|
.SH USAGE
|
||||||
.SS Status bar
|
.SS Status bar
|
||||||
.TP
|
.TP
|
||||||
|
@ -59,6 +60,11 @@ click on a tag label adds/removes that tag to/from the focused window.
|
||||||
Start
|
Start
|
||||||
.BR st(1).
|
.BR st(1).
|
||||||
.TP
|
.TP
|
||||||
|
.B Mod1\-p
|
||||||
|
Spawn
|
||||||
|
.BR dmenu(1)
|
||||||
|
for launching other programs.
|
||||||
|
.TP
|
||||||
.B Mod1\-,
|
.B Mod1\-,
|
||||||
Focus previous screen, if any.
|
Focus previous screen, if any.
|
||||||
.TP
|
.TP
|
||||||
|
@ -93,10 +99,10 @@ Focus next window.
|
||||||
Focus previous window.
|
Focus previous window.
|
||||||
.TP
|
.TP
|
||||||
.B Mod1\-i
|
.B Mod1\-i
|
||||||
Increase clients in master area.
|
Increase number of windows in master area.
|
||||||
.TP
|
.TP
|
||||||
.B Mod1\-d
|
.B Mod1\-d
|
||||||
Decrease clients in master area.
|
Decrease number of windows in master area.
|
||||||
.TP
|
.TP
|
||||||
.B Mod1\-l
|
.B Mod1\-l
|
||||||
Increase master area size.
|
Increase master area size.
|
||||||
|
@ -110,6 +116,9 @@ Zooms/cycles focused window to/from master area (tiled layouts only).
|
||||||
.B Mod1\-Shift\-c
|
.B Mod1\-Shift\-c
|
||||||
Close focused window.
|
Close focused window.
|
||||||
.TP
|
.TP
|
||||||
|
.B Mod1\-Shift\-f
|
||||||
|
Toggle fullscreen for focused window.
|
||||||
|
.TP
|
||||||
.B Mod1\-Shift\-space
|
.B Mod1\-Shift\-space
|
||||||
Toggle focused window between tiled and floating state.
|
Toggle focused window between tiled and floating state.
|
||||||
.TP
|
.TP
|
||||||
|
@ -152,7 +161,7 @@ code. This keeps it fast, secure and simple.
|
||||||
.SH SEE ALSO
|
.SH SEE ALSO
|
||||||
.BR dmenu (1),
|
.BR dmenu (1),
|
||||||
.BR st (1)
|
.BR st (1)
|
||||||
.SH BUGS
|
.SH ISSUES
|
||||||
Java applications which use the XToolkit/XAWT backend may draw grey windows
|
Java applications which use the XToolkit/XAWT backend may draw grey windows
|
||||||
only. The XToolkit/XAWT backend breaks ICCCM-compliance in recent JDK 1.5 and early
|
only. The XToolkit/XAWT backend breaks ICCCM-compliance in recent JDK 1.5 and early
|
||||||
JDK 1.6 versions, because it assumes a reparenting window manager. Possible workarounds
|
JDK 1.6 versions, because it assumes a reparenting window manager. Possible workarounds
|
||||||
|
@ -166,11 +175,5 @@ or
|
||||||
(to pretend that a non-reparenting window manager is running that the
|
(to pretend that a non-reparenting window manager is running that the
|
||||||
XToolkit/XAWT backend can recognize) or when using OpenJDK setting the environment variable
|
XToolkit/XAWT backend can recognize) or when using OpenJDK setting the environment variable
|
||||||
.BR _JAVA_AWT_WM_NONREPARENTING=1 .
|
.BR _JAVA_AWT_WM_NONREPARENTING=1 .
|
||||||
.P
|
.SH BUGS
|
||||||
GTK 2.10.9+ versions contain a broken
|
Send all bug reports with a patch to hackers@suckless.org.
|
||||||
.BR Save\-As
|
|
||||||
file dialog implementation,
|
|
||||||
which requests to reconfigure its window size in an endless loop. However, its
|
|
||||||
window is still respondable during this state, so you can simply ignore the flicker
|
|
||||||
until a new GTK version appears, which will fix this bug, approximately
|
|
||||||
GTK 2.10.12+ versions.
|
|
||||||
|
|
9
dwm.desktop
Normal file
9
dwm.desktop
Normal file
|
@ -0,0 +1,9 @@
|
||||||
|
# copy to /usr/share/xsessions/dwm.desktop
|
||||||
|
|
||||||
|
[Desktop Entry]
|
||||||
|
Encoding=UTF-8
|
||||||
|
Name=dwm
|
||||||
|
Comment=Dynamic window manager
|
||||||
|
Exec=dwm
|
||||||
|
Icon=dwm
|
||||||
|
Type=XSession
|
292
dwm.h
Normal file
292
dwm.h
Normal file
|
@ -0,0 +1,292 @@
|
||||||
|
#ifndef _H_DWM
|
||||||
|
#define _H_DWM
|
||||||
|
|
||||||
|
#include <errno.h>
|
||||||
|
#include <locale.h>
|
||||||
|
#include <signal.h>
|
||||||
|
#include <stdarg.h>
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <string.h>
|
||||||
|
#include <unistd.h>
|
||||||
|
#include <sys/types.h>
|
||||||
|
#include <sys/wait.h>
|
||||||
|
#include <X11/cursorfont.h>
|
||||||
|
#include <X11/keysym.h>
|
||||||
|
#include <X11/XF86keysym.h>
|
||||||
|
#include <X11/Xatom.h>
|
||||||
|
#include <X11/Xlib.h>
|
||||||
|
#include <X11/Xproto.h>
|
||||||
|
#include <X11/Xutil.h>
|
||||||
|
#ifdef XINERAMA
|
||||||
|
#include <X11/extensions/Xinerama.h>
|
||||||
|
#endif /* XINERAMA */
|
||||||
|
#include <X11/Xft/Xft.h>
|
||||||
|
|
||||||
|
#include "drw.h"
|
||||||
|
#include "util.h"
|
||||||
|
|
||||||
|
|
||||||
|
/* macros */
|
||||||
|
#define BUTTONMASK (ButtonPressMask|ButtonReleaseMask)
|
||||||
|
#define CLEANMASK(mask) (mask & ~(numlockmask|LockMask) & (ShiftMask|ControlMask|Mod1Mask|Mod2Mask|Mod3Mask|Mod4Mask|Mod5Mask))
|
||||||
|
#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)))
|
||||||
|
#define ISVISIBLE(C) ((C->tags & C->mon->tagset[C->mon->seltags]))
|
||||||
|
#define LENGTH(X) (sizeof X / sizeof X[0])
|
||||||
|
#define MOUSEMASK (BUTTONMASK|PointerMotionMask)
|
||||||
|
#define WIDTH(X) ((X)->w + 2 * (X)->bw)
|
||||||
|
#define HEIGHT(X) ((X)->h + 2 * (X)->bw)
|
||||||
|
#define TAGMASK ((1 << LENGTH(tags)) - 1)
|
||||||
|
#define TEXTW(X) (drw_fontset_getwidth(drw, (X)) + lrpad)
|
||||||
|
|
||||||
|
#define GAP_TOGGLE 100
|
||||||
|
#define GAP_RESET 0
|
||||||
|
|
||||||
|
/* enums */
|
||||||
|
enum { CurNormal, CurResize, CurMove, CurLast }; /* cursor */
|
||||||
|
enum { SchemeNorm, SchemeSel }; /* color schemes */
|
||||||
|
enum { NetSupported, NetWMName, NetWMState, NetWMCheck,
|
||||||
|
NetWMFullscreen, NetActiveWindow, NetWMWindowType,
|
||||||
|
NetWMWindowTypeDialog, NetClientList, NetLast }; /* EWMH atoms */
|
||||||
|
enum { WMProtocols, WMDelete, WMState, WMTakeFocus, WMLast }; /* default atoms */
|
||||||
|
enum { ClkTagBar, ClkLtSymbol, ClkStatusText, ClkWinTitle,
|
||||||
|
ClkClientWin, ClkRootWin, ClkLast }; /* clicks */
|
||||||
|
|
||||||
|
typedef union {
|
||||||
|
int i;
|
||||||
|
unsigned int ui;
|
||||||
|
float f;
|
||||||
|
const void *v;
|
||||||
|
} Arg;
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
unsigned int click;
|
||||||
|
unsigned int mask;
|
||||||
|
unsigned int button;
|
||||||
|
void (*func)(const Arg *arg);
|
||||||
|
const Arg arg;
|
||||||
|
} Button;
|
||||||
|
|
||||||
|
typedef struct Monitor Monitor;
|
||||||
|
typedef struct Client Client;
|
||||||
|
struct Client {
|
||||||
|
char name[256];
|
||||||
|
float mina, maxa;
|
||||||
|
int x, y, w, h;
|
||||||
|
int oldx, oldy, oldw, oldh;
|
||||||
|
int basew, baseh, incw, inch, maxw, maxh, minw, minh, hintsvalid;
|
||||||
|
int bw, oldbw;
|
||||||
|
unsigned int tags;
|
||||||
|
int isfixed, isfloating, isurgent, neverfocus, oldstate, isfullscreen;
|
||||||
|
Client *next;
|
||||||
|
Client *snext;
|
||||||
|
Monitor *mon;
|
||||||
|
Window win;
|
||||||
|
};
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
unsigned int mod;
|
||||||
|
KeySym keysym;
|
||||||
|
void (*func)(const Arg *);
|
||||||
|
const Arg arg;
|
||||||
|
} Key;
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
const char *symbol;
|
||||||
|
void (*arrange)(Monitor *);
|
||||||
|
} Layout;
|
||||||
|
|
||||||
|
typedef struct Pertag Pertag;
|
||||||
|
|
||||||
|
struct Monitor {
|
||||||
|
char ltsymbol[16];
|
||||||
|
float mfact;
|
||||||
|
int nmaster;
|
||||||
|
int num;
|
||||||
|
int by; /* bar geometry */
|
||||||
|
int mx, my, mw, mh; /* screen size */
|
||||||
|
int wx, wy, ww, wh; /* window area */
|
||||||
|
unsigned int seltags;
|
||||||
|
unsigned int sellt;
|
||||||
|
unsigned int tagset[2];
|
||||||
|
int showbar;
|
||||||
|
int topbar;
|
||||||
|
Client *clients;
|
||||||
|
Client *sel;
|
||||||
|
Client *stack;
|
||||||
|
Monitor *next;
|
||||||
|
Window barwin;
|
||||||
|
const Layout *lt[2];
|
||||||
|
Pertag *pertag;
|
||||||
|
};
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
const char *class;
|
||||||
|
const char *instance;
|
||||||
|
const char *title;
|
||||||
|
unsigned int tags;
|
||||||
|
int isfloating;
|
||||||
|
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);
|
||||||
|
void arrange(Monitor *m);
|
||||||
|
void arrangemon(Monitor *m);
|
||||||
|
void attach(Client *c);
|
||||||
|
void attachstack(Client *c);
|
||||||
|
void buttonpress(XEvent *e);
|
||||||
|
void checkotherwm(void);
|
||||||
|
void cleanup(void);
|
||||||
|
void cleanupmon(Monitor *mon);
|
||||||
|
void clientmessage(XEvent *e);
|
||||||
|
void configure(Client *c);
|
||||||
|
void configurenotify(XEvent *e);
|
||||||
|
void configurerequest(XEvent *e);
|
||||||
|
Monitor *createmon(void);
|
||||||
|
void destroynotify(XEvent *e);
|
||||||
|
void detach(Client *c);
|
||||||
|
void detachstack(Client *c);
|
||||||
|
Monitor *dirtomon(int dir);
|
||||||
|
void drawbar(Monitor *m);
|
||||||
|
void drawbars(void);
|
||||||
|
void enternotify(XEvent *e);
|
||||||
|
void expose(XEvent *e);
|
||||||
|
void focus(Client *c);
|
||||||
|
void focusin(XEvent *e);
|
||||||
|
void focusmon(const Arg *arg);
|
||||||
|
void focusstack(const Arg *arg);
|
||||||
|
Atom getatomprop(Client *c, Atom prop);
|
||||||
|
int getrootptr(int *x, int *y);
|
||||||
|
long getstate(Window w);
|
||||||
|
int gettextprop(Window w, Atom atom, char *text, unsigned int size);
|
||||||
|
void grabbuttons(Client *c, int focused);
|
||||||
|
void grabkeys(void);
|
||||||
|
void incnmaster(const Arg *arg);
|
||||||
|
void keypress(XEvent *e);
|
||||||
|
void killclient(const Arg *arg);
|
||||||
|
void manage(Window w, XWindowAttributes *wa);
|
||||||
|
void mappingnotify(XEvent *e);
|
||||||
|
void maprequest(XEvent *e);
|
||||||
|
void monocle(Monitor *m);
|
||||||
|
void motionnotify(XEvent *e);
|
||||||
|
void movemouse(const Arg *arg);
|
||||||
|
Client *nexttiled(Client *c);
|
||||||
|
void pop(Client *c);
|
||||||
|
void propertynotify(XEvent *e);
|
||||||
|
void quit(const Arg *arg);
|
||||||
|
Monitor *recttomon(int x, int y, int w, int h);
|
||||||
|
void resize(Client *c, int x, int y, int w, int h, int interact);
|
||||||
|
void resizeclient(Client *c, int x, int y, int w, int h);
|
||||||
|
void resizemouse(const Arg *arg);
|
||||||
|
void restack(Monitor *m);
|
||||||
|
void run(void);
|
||||||
|
void runAutostart(void);
|
||||||
|
void scan(void);
|
||||||
|
int sendevent(Client *c, Atom proto);
|
||||||
|
void sendmon(Client *c, Monitor *m);
|
||||||
|
void setclientstate(Client *c, long state);
|
||||||
|
void setfocus(Client *c);
|
||||||
|
void setfullscreen(Client *c, int fullscreen);
|
||||||
|
void setgaps(const Arg *arg);
|
||||||
|
void setlayout(const Arg *arg);
|
||||||
|
void setmfact(const Arg *arg);
|
||||||
|
void setup(void);
|
||||||
|
void seturgent(Client *c, int urg);
|
||||||
|
void showhide(Client *c);
|
||||||
|
void spawn(const Arg *arg);
|
||||||
|
void tag(const Arg *arg);
|
||||||
|
void tagmon(const Arg *arg);
|
||||||
|
void tile(Monitor *m);
|
||||||
|
void togglebar(const Arg *arg);
|
||||||
|
void togglefloating(const Arg *arg);
|
||||||
|
void togglefullscr(const Arg *arg);
|
||||||
|
void toggletag(const Arg *arg);
|
||||||
|
void toggleview(const Arg *arg);
|
||||||
|
void unfocus(Client *c, int setfocus);
|
||||||
|
void unmanage(Client *c, int destroyed);
|
||||||
|
void unmapnotify(XEvent *e);
|
||||||
|
void updatebarpos(Monitor *m);
|
||||||
|
void updatebars(void);
|
||||||
|
void updateclientlist(void);
|
||||||
|
int updategeom(void);
|
||||||
|
void updatenumlockmask(void);
|
||||||
|
void updatesizehints(Client *c);
|
||||||
|
void updatestatus(void);
|
||||||
|
void updatetitle(Client *c);
|
||||||
|
void updatewindowtype(Client *c);
|
||||||
|
void updatewmhints(Client *c);
|
||||||
|
void view(const Arg *arg);
|
||||||
|
Client *wintoclient(Window w);
|
||||||
|
Monitor *wintomon(Window w);
|
||||||
|
int xerror(Display *dpy, XErrorEvent *ee);
|
||||||
|
int xerrordummy(Display *dpy, XErrorEvent *ee);
|
||||||
|
int xerrorstart(Display *dpy, XErrorEvent *ee);
|
||||||
|
void zoom(const Arg *arg);
|
||||||
|
|
||||||
|
/* variables */
|
||||||
|
const char broken[] = "broken";
|
||||||
|
char stext[256];
|
||||||
|
int screen;
|
||||||
|
int sw, sh; /* X display screen geometry width, height */
|
||||||
|
int bh; /* bar height */
|
||||||
|
int lrpad; /* sum of left and right padding for text */
|
||||||
|
int (*xerrorxlib)(Display *, XErrorEvent *);
|
||||||
|
unsigned int numlockmask = 0;
|
||||||
|
void (*handler[LASTEvent]) (XEvent *) = {
|
||||||
|
[ButtonPress] = buttonpress,
|
||||||
|
[ClientMessage] = clientmessage,
|
||||||
|
[ConfigureRequest] = configurerequest,
|
||||||
|
[ConfigureNotify] = configurenotify,
|
||||||
|
[DestroyNotify] = destroynotify,
|
||||||
|
[EnterNotify] = enternotify,
|
||||||
|
[Expose] = expose,
|
||||||
|
[FocusIn] = focusin,
|
||||||
|
[KeyPress] = keypress,
|
||||||
|
[MappingNotify] = mappingnotify,
|
||||||
|
[MapRequest] = maprequest,
|
||||||
|
[MotionNotify] = motionnotify,
|
||||||
|
[PropertyNotify] = propertynotify,
|
||||||
|
[UnmapNotify] = unmapnotify
|
||||||
|
};
|
||||||
|
Atom wmatom[WMLast], netatom[NetLast];
|
||||||
|
int running = 1;
|
||||||
|
Cur *cursor[CurLast];
|
||||||
|
Clr **scheme;
|
||||||
|
Display *dpy;
|
||||||
|
Drw *drw;
|
||||||
|
Monitor *mons, *selmon;
|
||||||
|
Window root, wmcheckwin;
|
||||||
|
int statusw;
|
||||||
|
int statuscmdn;
|
||||||
|
char lastbutton[] = "-";
|
||||||
|
|
||||||
|
/* configuration, allows nested code to access above variables */
|
||||||
|
|
||||||
|
struct Pertag {
|
||||||
|
unsigned int curtag, prevtag; /* current and previous tag */
|
||||||
|
int nmasters[10]; /* number of windows in master area */
|
||||||
|
float mfacts[10]; /* mfacts per tag */
|
||||||
|
unsigned int sellts[10]; /* selected layouts */
|
||||||
|
const Layout *ltidxs[10][2]; /* matrix of tags and layouts indexes */
|
||||||
|
int showbars[10]; /* display bar for the current tag */
|
||||||
|
|
||||||
|
int drawwithgaps[10]; /* gaps toggle for each tag */
|
||||||
|
int gappx[10]; /* gaps for each tag */
|
||||||
|
};
|
||||||
|
|
||||||
|
/* compile-time check if all tags fit into an unsigned int bit array. */
|
||||||
|
struct NumTags { char limitexceeded[10 > 31 ? -1 : 1]; };
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
68
patches/dwm-actualfullscreen-20211013-cb3f58a.diff
Normal file
68
patches/dwm-actualfullscreen-20211013-cb3f58a.diff
Normal file
|
@ -0,0 +1,68 @@
|
||||||
|
From eea13010ffc3983392857ee1e3804e3aa1064d7a Mon Sep 17 00:00:00 2001
|
||||||
|
From: Soenke Lambert <s.lambert@mittwald.de>
|
||||||
|
Date: Wed, 13 Oct 2021 18:21:09 +0200
|
||||||
|
Subject: [PATCH] Fullscreen current window with [Alt]+[Shift]+[f]
|
||||||
|
|
||||||
|
This actually fullscreens a window, instead of just hiding the statusbar
|
||||||
|
and applying the monocle layout.
|
||||||
|
---
|
||||||
|
config.def.h | 1 +
|
||||||
|
dwm.1 | 3 +++
|
||||||
|
dwm.c | 8 ++++++++
|
||||||
|
3 files changed, 12 insertions(+)
|
||||||
|
|
||||||
|
diff --git a/config.def.h b/config.def.h
|
||||||
|
index 1c0b587..8cd3204 100644
|
||||||
|
--- a/config.def.h
|
||||||
|
+++ b/config.def.h
|
||||||
|
@@ -78,6 +78,7 @@ static Key keys[] = {
|
||||||
|
{ MODKEY, XK_m, setlayout, {.v = &layouts[2]} },
|
||||||
|
{ MODKEY, XK_space, setlayout, {0} },
|
||||||
|
{ MODKEY|ShiftMask, XK_space, togglefloating, {0} },
|
||||||
|
+ { MODKEY|ShiftMask, XK_f, togglefullscr, {0} },
|
||||||
|
{ MODKEY, XK_0, view, {.ui = ~0 } },
|
||||||
|
{ MODKEY|ShiftMask, XK_0, tag, {.ui = ~0 } },
|
||||||
|
{ MODKEY, XK_comma, focusmon, {.i = -1 } },
|
||||||
|
diff --git a/dwm.1 b/dwm.1
|
||||||
|
index 13b3729..a368d05 100644
|
||||||
|
--- a/dwm.1
|
||||||
|
+++ b/dwm.1
|
||||||
|
@@ -116,6 +116,9 @@ Zooms/cycles focused window to/from master area (tiled layouts only).
|
||||||
|
.B Mod1\-Shift\-c
|
||||||
|
Close focused window.
|
||||||
|
.TP
|
||||||
|
+.B Mod1\-Shift\-f
|
||||||
|
+Toggle fullscreen for focused window.
|
||||||
|
+.TP
|
||||||
|
.B Mod1\-Shift\-space
|
||||||
|
Toggle focused window between tiled and floating state.
|
||||||
|
.TP
|
||||||
|
diff --git a/dwm.c b/dwm.c
|
||||||
|
index 4465af1..c1b899a 100644
|
||||||
|
--- a/dwm.c
|
||||||
|
+++ b/dwm.c
|
||||||
|
@@ -211,6 +211,7 @@ static void tagmon(const Arg *arg);
|
||||||
|
static void tile(Monitor *);
|
||||||
|
static void togglebar(const Arg *arg);
|
||||||
|
static void togglefloating(const Arg *arg);
|
||||||
|
+static void togglefullscr(const Arg *arg);
|
||||||
|
static void toggletag(const Arg *arg);
|
||||||
|
static void toggleview(const Arg *arg);
|
||||||
|
static void unfocus(Client *c, int setfocus);
|
||||||
|
@@ -1719,6 +1720,13 @@ togglefloating(const Arg *arg)
|
||||||
|
arrange(selmon);
|
||||||
|
}
|
||||||
|
|
||||||
|
+void
|
||||||
|
+togglefullscr(const Arg *arg)
|
||||||
|
+{
|
||||||
|
+ if(selmon->sel)
|
||||||
|
+ setfullscreen(selmon->sel, !selmon->sel->isfullscreen);
|
||||||
|
+}
|
||||||
|
+
|
||||||
|
void
|
||||||
|
toggletag(const Arg *arg)
|
||||||
|
{
|
||||||
|
--
|
||||||
|
2.30.2
|
||||||
|
|
39
patches/dwm-autostart-20161205-bb3bd6f.diff
Normal file
39
patches/dwm-autostart-20161205-bb3bd6f.diff
Normal file
|
@ -0,0 +1,39 @@
|
||||||
|
commit 5918623c5bd7fda155bf9dc3d33890c4ae1722d0
|
||||||
|
Author: Simon Bremer <simon.bremer@tum.de>
|
||||||
|
Date: Thu Dec 22 17:31:07 2016 +0100
|
||||||
|
|
||||||
|
Applied and fixed autostart patch for previous version;
|
||||||
|
|
||||||
|
diff --git a/dwm.c b/dwm.c
|
||||||
|
index d27cb67..066ed71 100644
|
||||||
|
--- a/dwm.c
|
||||||
|
+++ b/dwm.c
|
||||||
|
@@ -194,6 +194,7 @@ static void resizeclient(Client *c, int x, int y, int w, int h);
|
||||||
|
static void resizemouse(const Arg *arg);
|
||||||
|
static void restack(Monitor *m);
|
||||||
|
static void run(void);
|
||||||
|
+static void runAutostart(void);
|
||||||
|
static void scan(void);
|
||||||
|
static int sendevent(Client *c, Atom proto);
|
||||||
|
static void sendmon(Client *c, Monitor *m);
|
||||||
|
@@ -1386,6 +1387,12 @@ run(void)
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
+runAutostart(void) {
|
||||||
|
+ system("cd ~/.dwm; ./autostart_blocking.sh");
|
||||||
|
+ system("cd ~/.dwm; ./autostart.sh &");
|
||||||
|
+}
|
||||||
|
+
|
||||||
|
+void
|
||||||
|
scan(void)
|
||||||
|
{
|
||||||
|
unsigned int i, num;
|
||||||
|
@@ -2145,6 +2152,7 @@ main(int argc, char *argv[])
|
||||||
|
checkotherwm();
|
||||||
|
setup();
|
||||||
|
scan();
|
||||||
|
+ runAutostart();
|
||||||
|
run();
|
||||||
|
cleanup();
|
||||||
|
XCloseDisplay(dpy);
|
352
patches/dwm-functionalgaps+pertag-6.2.diff
Normal file
352
patches/dwm-functionalgaps+pertag-6.2.diff
Normal file
|
@ -0,0 +1,352 @@
|
||||||
|
diff -pu dwm.git/config.def.h dwm.functionalgapspertag/config.def.h
|
||||||
|
--- dwm.git/config.def.h 2021-02-27 21:17:53.862314811 -0600
|
||||||
|
+++ dwm.functionalgapspertag/config.def.h 2021-03-01 15:40:07.312696974 -0600
|
||||||
|
@@ -2,6 +2,8 @@
|
||||||
|
|
||||||
|
/* appearance */
|
||||||
|
static const unsigned int borderpx = 1; /* border pixel of windows */
|
||||||
|
+static const int startwithgaps[] = { 0 }; /* 1 means gaps are used by default, this can be customized for each tag */
|
||||||
|
+static const unsigned int gappx[] = { 10 }; /* default gap between windows in pixels, this can be customized for each tag */
|
||||||
|
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 */
|
||||||
|
@@ -84,6 +86,10 @@ 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 = -5 } },
|
||||||
|
+ { MODKEY, XK_equal, setgaps, {.i = +5 } },
|
||||||
|
+ { MODKEY|ShiftMask, XK_minus, setgaps, {.i = GAP_RESET } },
|
||||||
|
+ { MODKEY|ShiftMask, XK_equal, setgaps, {.i = GAP_TOGGLE} },
|
||||||
|
TAGKEYS( XK_1, 0)
|
||||||
|
TAGKEYS( XK_2, 1)
|
||||||
|
TAGKEYS( XK_3, 2)
|
||||||
|
diff -pu dwm.git/dwm.c dwm.functionalgapspertag/dwm.c
|
||||||
|
--- dwm.git/dwm.c 2021-02-27 21:17:53.862314811 -0600
|
||||||
|
+++ dwm.functionalgapspertag/dwm.c 2021-03-01 17:10:10.402964866 -0600
|
||||||
|
@@ -57,6 +57,9 @@
|
||||||
|
#define TAGMASK ((1 << LENGTH(tags)) - 1)
|
||||||
|
#define TEXTW(X) (drw_fontset_getwidth(drw, (X)) + lrpad)
|
||||||
|
|
||||||
|
+#define GAP_TOGGLE 100
|
||||||
|
+#define GAP_RESET 0
|
||||||
|
+
|
||||||
|
/* enums */
|
||||||
|
enum { CurNormal, CurResize, CurMove, CurLast }; /* cursor */
|
||||||
|
enum { SchemeNorm, SchemeSel }; /* color schemes */
|
||||||
|
@@ -111,6 +114,8 @@ typedef struct {
|
||||||
|
void (*arrange)(Monitor *);
|
||||||
|
} Layout;
|
||||||
|
|
||||||
|
+typedef struct Pertag Pertag;
|
||||||
|
+
|
||||||
|
struct Monitor {
|
||||||
|
char ltsymbol[16];
|
||||||
|
float mfact;
|
||||||
|
@@ -130,6 +135,7 @@ struct Monitor {
|
||||||
|
Monitor *next;
|
||||||
|
Window barwin;
|
||||||
|
const Layout *lt[2];
|
||||||
|
+ Pertag *pertag;
|
||||||
|
};
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
@@ -200,6 +206,7 @@ static void sendmon(Client *c, Monitor *
|
||||||
|
static void setclientstate(Client *c, long state);
|
||||||
|
static void setfocus(Client *c);
|
||||||
|
static void setfullscreen(Client *c, int fullscreen);
|
||||||
|
+static void setgaps(const Arg *arg);
|
||||||
|
static void setlayout(const Arg *arg);
|
||||||
|
static void setmfact(const Arg *arg);
|
||||||
|
static void setup(void);
|
||||||
|
@@ -272,6 +279,18 @@ static Window root, wmcheckwin;
|
||||||
|
/* configuration, allows nested code to access above variables */
|
||||||
|
#include "config.h"
|
||||||
|
|
||||||
|
+struct Pertag {
|
||||||
|
+ unsigned int curtag, prevtag; /* current and previous tag */
|
||||||
|
+ int nmasters[LENGTH(tags) + 1]; /* number of windows in master area */
|
||||||
|
+ float mfacts[LENGTH(tags) + 1]; /* mfacts per tag */
|
||||||
|
+ unsigned int sellts[LENGTH(tags) + 1]; /* selected layouts */
|
||||||
|
+ const Layout *ltidxs[LENGTH(tags) + 1][2]; /* matrix of tags and layouts indexes */
|
||||||
|
+ int showbars[LENGTH(tags) + 1]; /* display bar for the current tag */
|
||||||
|
+
|
||||||
|
+ int drawwithgaps[LENGTH(tags) + 1]; /* gaps toggle for each tag */
|
||||||
|
+ int gappx[LENGTH(tags) + 1]; /* gaps for each tag */
|
||||||
|
+};
|
||||||
|
+
|
||||||
|
/* compile-time check if all tags fit into an unsigned int bit array. */
|
||||||
|
struct NumTags { char limitexceeded[LENGTH(tags) > 31 ? -1 : 1]; };
|
||||||
|
|
||||||
|
@@ -632,6 +651,7 @@ Monitor *
|
||||||
|
createmon(void)
|
||||||
|
{
|
||||||
|
Monitor *m;
|
||||||
|
+ unsigned int i;
|
||||||
|
|
||||||
|
m = ecalloc(1, sizeof(Monitor));
|
||||||
|
m->tagset[0] = m->tagset[1] = 1;
|
||||||
|
@@ -642,6 +662,26 @@ createmon(void)
|
||||||
|
m->lt[0] = &layouts[0];
|
||||||
|
m->lt[1] = &layouts[1 % LENGTH(layouts)];
|
||||||
|
strncpy(m->ltsymbol, layouts[0].symbol, sizeof m->ltsymbol);
|
||||||
|
+ m->pertag = ecalloc(1, sizeof(Pertag));
|
||||||
|
+ m->pertag->curtag = m->pertag->prevtag = 1;
|
||||||
|
+
|
||||||
|
+ for (i = 0; i <= LENGTH(tags); i++) {
|
||||||
|
+ m->pertag->nmasters[i] = m->nmaster;
|
||||||
|
+ m->pertag->mfacts[i] = m->mfact;
|
||||||
|
+
|
||||||
|
+ m->pertag->ltidxs[i][0] = m->lt[0];
|
||||||
|
+ m->pertag->ltidxs[i][1] = m->lt[1];
|
||||||
|
+ m->pertag->sellts[i] = m->sellt;
|
||||||
|
+
|
||||||
|
+ m->pertag->showbars[i] = m->showbar;
|
||||||
|
+ if (i > 0) {
|
||||||
|
+ m->pertag->drawwithgaps[i] = startwithgaps[(i - 1) % LENGTH(gappx)];
|
||||||
|
+ m->pertag->gappx[i] = gappx[(i - 1) % LENGTH(gappx)];
|
||||||
|
+ }
|
||||||
|
+ }
|
||||||
|
+ m->pertag->drawwithgaps[0] = startwithgaps[0];
|
||||||
|
+ m->pertag->gappx[0] = gappx[0];
|
||||||
|
+
|
||||||
|
return m;
|
||||||
|
}
|
||||||
|
|
||||||
|
@@ -797,6 +837,12 @@ focus(Client *c)
|
||||||
|
attachstack(c);
|
||||||
|
grabbuttons(c, 1);
|
||||||
|
XSetWindowBorder(dpy, c->win, scheme[SchemeSel][ColBorder].pixel);
|
||||||
|
+ if (!selmon->pertag->drawwithgaps[selmon->pertag->curtag] && !c->isfloating) {
|
||||||
|
+ XWindowChanges wc;
|
||||||
|
+ wc.sibling = selmon->barwin;
|
||||||
|
+ wc.stack_mode = Below;
|
||||||
|
+ XConfigureWindow(dpy, c->win, CWSibling | CWStackMode, &wc);
|
||||||
|
+ }
|
||||||
|
setfocus(c);
|
||||||
|
} else {
|
||||||
|
XSetInputFocus(dpy, root, RevertToPointerRoot, CurrentTime);
|
||||||
|
@@ -967,7 +1013,7 @@ grabkeys(void)
|
||||||
|
void
|
||||||
|
incnmaster(const Arg *arg)
|
||||||
|
{
|
||||||
|
- selmon->nmaster = MAX(selmon->nmaster + arg->i, 0);
|
||||||
|
+ selmon->nmaster = selmon->pertag->nmasters[selmon->pertag->curtag] = MAX(selmon->nmaster + arg->i, 0);
|
||||||
|
arrange(selmon);
|
||||||
|
}
|
||||||
|
|
||||||
|
@@ -1113,7 +1159,10 @@ monocle(Monitor *m)
|
||||||
|
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);
|
||||||
|
+ if (selmon->pertag->drawwithgaps[selmon->pertag->curtag])
|
||||||
|
+ resize(c, m->wx, m->wy, m->ww - 2 * c->bw, m->wh - 2 * c->bw, 0);
|
||||||
|
+ else
|
||||||
|
+ resize(c, m->wx - c->bw, m->wy, m->ww, m->wh, False);
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
@@ -1283,6 +1332,15 @@ resizeclient(Client *c, int x, int y, in
|
||||||
|
c->oldw = c->w; c->w = wc.width = w;
|
||||||
|
c->oldh = c->h; c->h = wc.height = h;
|
||||||
|
wc.border_width = c->bw;
|
||||||
|
+ if (!selmon->pertag->drawwithgaps[selmon->pertag->curtag] && /* this is the noborderfloatingfix patch, slightly modified so that it will work if, and only if, gaps are disabled. */
|
||||||
|
+ (((nexttiled(c->mon->clients) == c && !nexttiled(c->next)) /* these two first lines are the only ones changed. if you are manually patching and have noborder installed already, just change these lines; or conversely, just remove this section if the noborder patch is not desired;) */
|
||||||
|
+ || &monocle == c->mon->lt[c->mon->sellt]->arrange))
|
||||||
|
+ && !c->isfullscreen && !c->isfloating
|
||||||
|
+ && NULL != c->mon->lt[c->mon->sellt]->arrange) {
|
||||||
|
+ c->w = wc.width += c->bw * 2;
|
||||||
|
+ c->h = wc.height += c->bw * 2;
|
||||||
|
+ wc.border_width = 0;
|
||||||
|
+ }
|
||||||
|
XConfigureWindow(dpy, c->win, CWX|CWY|CWWidth|CWHeight|CWBorderWidth, &wc);
|
||||||
|
configure(c);
|
||||||
|
XSync(dpy, False);
|
||||||
|
@@ -1499,12 +1557,35 @@ setfullscreen(Client *c, int fullscreen)
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
+setgaps(const Arg *arg)
|
||||||
|
+{
|
||||||
|
+ switch(arg->i)
|
||||||
|
+ {
|
||||||
|
+ case GAP_TOGGLE:
|
||||||
|
+ selmon->pertag->drawwithgaps[selmon->pertag->curtag] = !selmon->pertag->drawwithgaps[selmon->pertag->curtag];
|
||||||
|
+ break;
|
||||||
|
+ case GAP_RESET:
|
||||||
|
+ if (selmon->pertag->curtag > 0)
|
||||||
|
+ selmon->pertag->gappx[selmon->pertag->curtag] = gappx[selmon->pertag->curtag - 1 % LENGTH(gappx)];
|
||||||
|
+ else
|
||||||
|
+ selmon->pertag->gappx[0] = gappx[0];
|
||||||
|
+ break;
|
||||||
|
+ default:
|
||||||
|
+ if (selmon->pertag->gappx[selmon->pertag->curtag] + arg->i < 0)
|
||||||
|
+ selmon->pertag->gappx[selmon->pertag->curtag] = 0;
|
||||||
|
+ else
|
||||||
|
+ selmon->pertag->gappx[selmon->pertag->curtag] += arg->i;
|
||||||
|
+ }
|
||||||
|
+ arrange(selmon);
|
||||||
|
+}
|
||||||
|
+
|
||||||
|
+void
|
||||||
|
setlayout(const Arg *arg)
|
||||||
|
{
|
||||||
|
if (!arg || !arg->v || arg->v != selmon->lt[selmon->sellt])
|
||||||
|
- selmon->sellt ^= 1;
|
||||||
|
+ selmon->sellt = selmon->pertag->sellts[selmon->pertag->curtag] ^= 1;
|
||||||
|
if (arg && arg->v)
|
||||||
|
- selmon->lt[selmon->sellt] = (Layout *)arg->v;
|
||||||
|
+ selmon->lt[selmon->sellt] = selmon->pertag->ltidxs[selmon->pertag->curtag][selmon->sellt] = (Layout *)arg->v;
|
||||||
|
strncpy(selmon->ltsymbol, selmon->lt[selmon->sellt]->symbol, sizeof selmon->ltsymbol);
|
||||||
|
if (selmon->sel)
|
||||||
|
arrange(selmon);
|
||||||
|
@@ -1523,7 +1604,7 @@ setmfact(const Arg *arg)
|
||||||
|
f = arg->f < 1.0 ? arg->f + selmon->mfact : arg->f - 1.0;
|
||||||
|
if (f < 0.05 || f > 0.95)
|
||||||
|
return;
|
||||||
|
- selmon->mfact = f;
|
||||||
|
+ selmon->mfact = selmon->pertag->mfacts[selmon->pertag->curtag] = f;
|
||||||
|
arrange(selmon);
|
||||||
|
}
|
||||||
|
|
||||||
|
@@ -1680,29 +1761,48 @@ tile(Monitor *m)
|
||||||
|
for (n = 0, c = nexttiled(m->clients); c; c = nexttiled(c->next), n++);
|
||||||
|
if (n == 0)
|
||||||
|
return;
|
||||||
|
-
|
||||||
|
- if (n > m->nmaster)
|
||||||
|
- mw = m->nmaster ? m->ww * m->mfact : 0;
|
||||||
|
- else
|
||||||
|
- mw = m->ww;
|
||||||
|
- for (i = my = ty = 0, c = nexttiled(m->clients); c; c = nexttiled(c->next), i++)
|
||||||
|
- if (i < m->nmaster) {
|
||||||
|
- h = (m->wh - my) / (MIN(n, m->nmaster) - i);
|
||||||
|
- resize(c, m->wx, m->wy + my, mw - (2*c->bw), h - (2*c->bw), 0);
|
||||||
|
- if (my + HEIGHT(c) < m->wh)
|
||||||
|
- my += HEIGHT(c);
|
||||||
|
- } else {
|
||||||
|
- h = (m->wh - ty) / (n - i);
|
||||||
|
- resize(c, m->wx + mw, m->wy + ty, m->ww - mw - (2*c->bw), h - (2*c->bw), 0);
|
||||||
|
- if (ty + HEIGHT(c) < m->wh)
|
||||||
|
- ty += HEIGHT(c);
|
||||||
|
- }
|
||||||
|
+ if (m->pertag->drawwithgaps[m->pertag->curtag]) { /* draw with fullgaps logic */
|
||||||
|
+ if (n > m->nmaster)
|
||||||
|
+ mw = m->nmaster ? m->ww * m->mfact : 0;
|
||||||
|
+ else
|
||||||
|
+ mw = m->ww - m->pertag->gappx[m->pertag->curtag];
|
||||||
|
+ for (i = 0, my = ty = m->pertag->gappx[m->pertag->curtag], c = nexttiled(m->clients); c; c = nexttiled(c->next), i++)
|
||||||
|
+ if (i < m->nmaster) {
|
||||||
|
+ h = (m->wh - my) / (MIN(n, m->nmaster) - i) - m->pertag->gappx[m->pertag->curtag];
|
||||||
|
+ resize(c, m->wx + m->pertag->gappx[m->pertag->curtag], m->wy + my, mw - (2*c->bw) - m->pertag->gappx[m->pertag->curtag], h - (2*c->bw), 0);
|
||||||
|
+ if (my + HEIGHT(c) + m->pertag->gappx[m->pertag->curtag] < m->wh)
|
||||||
|
+ my += HEIGHT(c) + m->pertag->gappx[m->pertag->curtag];
|
||||||
|
+ } else {
|
||||||
|
+ h = (m->wh - ty) / (n - i) - m->pertag->gappx[m->pertag->curtag];
|
||||||
|
+ resize(c, m->wx + mw + m->pertag->gappx[m->pertag->curtag], m->wy + ty, m->ww - mw - (2*c->bw) - 2*m->pertag->gappx[m->pertag->curtag], h - (2*c->bw), 0);
|
||||||
|
+ if (ty + HEIGHT(c) + m->pertag->gappx[m->pertag->curtag] < m->wh)
|
||||||
|
+ ty += HEIGHT(c) + m->pertag->gappx[m->pertag->curtag];
|
||||||
|
+ }
|
||||||
|
+ } else { /* draw with singularborders logic */
|
||||||
|
+ if (n > m->nmaster)
|
||||||
|
+ mw = m->nmaster ? m->ww * m->mfact : 0;
|
||||||
|
+ else
|
||||||
|
+ mw = m->ww;
|
||||||
|
+ for (i = my = ty = 0, c = nexttiled(m->clients); c; c = nexttiled(c->next), i++)
|
||||||
|
+ if (i < m->nmaster) {
|
||||||
|
+ h = (m->wh - my) / (MIN(n, m->nmaster) - i);
|
||||||
|
+ if (n == 1)
|
||||||
|
+ resize(c, m->wx - c->bw, m->wy, m->ww, m->wh, False);
|
||||||
|
+ else
|
||||||
|
+ resize(c, m->wx - c->bw, m->wy + my, mw - c->bw, h - c->bw, False);
|
||||||
|
+ my += HEIGHT(c) - c->bw;
|
||||||
|
+ } else {
|
||||||
|
+ h = (m->wh - ty) / (n - i);
|
||||||
|
+ resize(c, m->wx + mw - c->bw, m->wy + ty, m->ww - mw, h - c->bw, False);
|
||||||
|
+ ty += HEIGHT(c) - c->bw;
|
||||||
|
+ }
|
||||||
|
+ }
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
togglebar(const Arg *arg)
|
||||||
|
{
|
||||||
|
- selmon->showbar = !selmon->showbar;
|
||||||
|
+ selmon->showbar = selmon->pertag->showbars[selmon->pertag->curtag] = !selmon->showbar;
|
||||||
|
updatebarpos(selmon);
|
||||||
|
XMoveResizeWindow(dpy, selmon->barwin, selmon->wx, selmon->by, selmon->ww, bh);
|
||||||
|
arrange(selmon);
|
||||||
|
@@ -1741,9 +1841,33 @@ void
|
||||||
|
toggleview(const Arg *arg)
|
||||||
|
{
|
||||||
|
unsigned int newtagset = selmon->tagset[selmon->seltags] ^ (arg->ui & TAGMASK);
|
||||||
|
+ int i;
|
||||||
|
|
||||||
|
if (newtagset) {
|
||||||
|
selmon->tagset[selmon->seltags] = newtagset;
|
||||||
|
+
|
||||||
|
+ if (newtagset == ~0) {
|
||||||
|
+ selmon->pertag->prevtag = selmon->pertag->curtag;
|
||||||
|
+ selmon->pertag->curtag = 0;
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ /* test if the user did not select the same tag */
|
||||||
|
+ if (!(newtagset & 1 << (selmon->pertag->curtag - 1))) {
|
||||||
|
+ selmon->pertag->prevtag = selmon->pertag->curtag;
|
||||||
|
+ for (i = 0; !(newtagset & 1 << i); i++) ;
|
||||||
|
+ selmon->pertag->curtag = i + 1;
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ /* apply settings for this view */
|
||||||
|
+ selmon->nmaster = selmon->pertag->nmasters[selmon->pertag->curtag];
|
||||||
|
+ selmon->mfact = selmon->pertag->mfacts[selmon->pertag->curtag];
|
||||||
|
+ selmon->sellt = selmon->pertag->sellts[selmon->pertag->curtag];
|
||||||
|
+ selmon->lt[selmon->sellt] = selmon->pertag->ltidxs[selmon->pertag->curtag][selmon->sellt];
|
||||||
|
+ selmon->lt[selmon->sellt^1] = selmon->pertag->ltidxs[selmon->pertag->curtag][selmon->sellt^1];
|
||||||
|
+
|
||||||
|
+ if (selmon->showbar != selmon->pertag->showbars[selmon->pertag->curtag])
|
||||||
|
+ togglebar(NULL);
|
||||||
|
+
|
||||||
|
focus(NULL);
|
||||||
|
arrange(selmon);
|
||||||
|
}
|
||||||
|
@@ -2038,11 +2162,37 @@ updatewmhints(Client *c)
|
||||||
|
void
|
||||||
|
view(const Arg *arg)
|
||||||
|
{
|
||||||
|
+ int i;
|
||||||
|
+ unsigned int tmptag;
|
||||||
|
+
|
||||||
|
if ((arg->ui & TAGMASK) == selmon->tagset[selmon->seltags])
|
||||||
|
return;
|
||||||
|
selmon->seltags ^= 1; /* toggle sel tagset */
|
||||||
|
- if (arg->ui & TAGMASK)
|
||||||
|
+ if (arg->ui & TAGMASK) {
|
||||||
|
selmon->tagset[selmon->seltags] = arg->ui & TAGMASK;
|
||||||
|
+ selmon->pertag->prevtag = selmon->pertag->curtag;
|
||||||
|
+
|
||||||
|
+ if (arg->ui == ~0)
|
||||||
|
+ selmon->pertag->curtag = 0;
|
||||||
|
+ else {
|
||||||
|
+ for (i = 0; !(arg->ui & 1 << i); i++) ;
|
||||||
|
+ selmon->pertag->curtag = i + 1;
|
||||||
|
+ }
|
||||||
|
+ } else {
|
||||||
|
+ tmptag = selmon->pertag->prevtag;
|
||||||
|
+ selmon->pertag->prevtag = selmon->pertag->curtag;
|
||||||
|
+ selmon->pertag->curtag = tmptag;
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ selmon->nmaster = selmon->pertag->nmasters[selmon->pertag->curtag];
|
||||||
|
+ selmon->mfact = selmon->pertag->mfacts[selmon->pertag->curtag];
|
||||||
|
+ selmon->sellt = selmon->pertag->sellts[selmon->pertag->curtag];
|
||||||
|
+ selmon->lt[selmon->sellt] = selmon->pertag->ltidxs[selmon->pertag->curtag][selmon->sellt];
|
||||||
|
+ selmon->lt[selmon->sellt^1] = selmon->pertag->ltidxs[selmon->pertag->curtag][selmon->sellt^1];
|
||||||
|
+
|
||||||
|
+ if (selmon->showbar != selmon->pertag->showbars[selmon->pertag->curtag])
|
||||||
|
+ togglebar(NULL);
|
||||||
|
+
|
||||||
|
focus(NULL);
|
||||||
|
arrange(selmon);
|
||||||
|
}
|
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
|
||||||
|
|
25
util.c
25
util.c
|
@ -6,18 +6,9 @@
|
||||||
|
|
||||||
#include "util.h"
|
#include "util.h"
|
||||||
|
|
||||||
void *
|
|
||||||
ecalloc(size_t nmemb, size_t size)
|
|
||||||
{
|
|
||||||
void *p;
|
|
||||||
|
|
||||||
if (!(p = calloc(nmemb, size)))
|
|
||||||
perror(NULL);
|
|
||||||
return p;
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
void
|
||||||
die(const char *fmt, ...) {
|
die(const char *fmt, ...)
|
||||||
|
{
|
||||||
va_list ap;
|
va_list ap;
|
||||||
|
|
||||||
va_start(ap, fmt);
|
va_start(ap, fmt);
|
||||||
|
@ -27,7 +18,19 @@ die(const char *fmt, ...) {
|
||||||
if (fmt[0] && fmt[strlen(fmt)-1] == ':') {
|
if (fmt[0] && fmt[strlen(fmt)-1] == ':') {
|
||||||
fputc(' ', stderr);
|
fputc(' ', stderr);
|
||||||
perror(NULL);
|
perror(NULL);
|
||||||
|
} else {
|
||||||
|
fputc('\n', stderr);
|
||||||
}
|
}
|
||||||
|
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void *
|
||||||
|
ecalloc(size_t nmemb, size_t size)
|
||||||
|
{
|
||||||
|
void *p;
|
||||||
|
|
||||||
|
if (!(p = calloc(nmemb, size)))
|
||||||
|
die("calloc:");
|
||||||
|
return p;
|
||||||
|
}
|
||||||
|
|
4
util.h
4
util.h
|
@ -4,5 +4,5 @@
|
||||||
#define MIN(A, B) ((A) < (B) ? (A) : (B))
|
#define MIN(A, B) ((A) < (B) ? (A) : (B))
|
||||||
#define BETWEEN(X, A, B) ((A) <= (X) && (X) <= (B))
|
#define BETWEEN(X, A, B) ((A) <= (X) && (X) <= (B))
|
||||||
|
|
||||||
void die(const char *errstr, ...);
|
void die(const char *fmt, ...);
|
||||||
void *ecalloc(size_t, size_t);
|
void *ecalloc(size_t nmemb, size_t size);
|
||||||
|
|
Loading…
Reference in New Issue
Block a user