commit d339349c0218560e5ce00227985595cd0fc0edfc
Author: mrgrouse <bdmfegys@duck.com>
Date: Tue, 10 Jun 2025 05:05:18 -0400
migrate repository!
Diffstat:
32 files changed, 6208 insertions(+), 0 deletions(-)
diff --git a/LICENSE b/LICENSE
@@ -0,0 +1,38 @@
+MIT/X Consortium License
+
+© 2006-2019 Anselm R Garbe <anselm@garbe.ca>
+© 2006-2009 Jukka Salmi <jukka at salmi dot ch>
+© 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 Christof Musik <christof at sendfax dot de>
+© 2007-2009 Premysl Hruby <dfenze at gmail dot com>
+© 2007-2008 Enno Gottox Boland <gottox at s01 dot de>
+© 2008 Martin Hurton <martin dot hurton at gmail dot com>
+© 2008 Neale Pickett <neale dot woozle dot org>
+© 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
+copy of this software and associated documentation files (the "Software"),
+to deal in the Software without restriction, including without limitation
+the rights to use, copy, modify, merge, publish, distribute, sublicense,
+and/or sell copies of the Software, and to permit persons to whom the
+Software is furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+DEALINGS IN THE SOFTWARE.
diff --git a/Makefile b/Makefile
@@ -0,0 +1,85 @@
+# birdwm - dynamic window manager for birds
+# See LICENSE file for copyright and license details.
+
+include config.mk
+
+SRC = drw.c birdwm.c util.c
+OBJ = ${SRC:.c=.o}
+
+#all: options birdwm
+all: birdwm
+
+options:
+ @echo birdwm build options:
+ @echo "CFLAGS = ${CFLAGS}"
+ @echo "LDFLAGS = ${LDFLAGS}"
+ @echo "CC = ${CC}"
+
+.c.o:
+ ${CC} -c ${CFLAGS} $<
+
+${OBJ}: config.h config.mk
+
+config.h:
+ cp config.def.h $@
+ sed -i "1i#define GIFDIR \"${GIFDIR}\"" config.h
+ sed -i "1i#define WALLPAPERDIR \"${WALLPAPERDIR}\"" config.h
+ sed -i "1i#define HOME \"${HOME}\"" config.h
+
+birdwm: ${OBJ}
+ ${CC} -o $@ ${OBJ} ${LDFLAGS}
+ [ -z "$(shell which upx)" ] || upx birdwm;
+
+clean:
+ rm -f *.rej *.orig birdwm ${OBJ} birdwm-${VERSION}.tar.gz
+
+dist: clean
+ mkdir -p birdwm-${VERSION}
+ cp -R LICENSE Makefile README config.def.h config.mk\
+ birdwm.1 drw.h util.h ${SRC} birdwm.png transient.c birdwm-${VERSION}
+ tar -cf birdwm-${VERSION}.tar birdwm-${VERSION}
+ gzip birdwm-${VERSION}.tar
+ rm -rf birdwm-${VERSION}
+
+install: all
+ # TODO: fix next line so XDG_DATA_HOME gets the user's XDG_DATA_HOME, possibly with `configure` script (?)
+ # NOTE: the following only works on GNU based systems: use `stat -c '$U' file.txt` to programatically get owner of `file.txt`
+ # Alternatively, use `LC_ALL=C ls -ld file | LC_ALL=C awk '{print $3; exit}'` to do it in a POSIX way
+ cp -r autostart ${XDG_DATA_HOME}/birdwm
+ mkdir -p ${DESTDIR}${PREFIX}/bin
+ cp -f birdwm ${DESTDIR}${PREFIX}/bin
+ chmod 755 ${DESTDIR}${PREFIX}/bin/birdwm
+ mkdir -p ${DESTDIR}${MANPREFIX}/man1
+ sed "s/VERSION/${VERSION}/g" < birdwm.1 > ${DESTDIR}${MANPREFIX}/man1/birdwm.1
+ chmod 644 ${DESTDIR}${MANPREFIX}/man1/birdwm.1
+ mkdir -p /usr/share/xsessions
+ cp -f extras/birdwm.desktop /usr/share/xsessions/birdwm.desktop
+ cp -f extras/volume.sh ${DESTDIR}${PREFIX}/bin
+ cp -f extras/restarter ${DESTDIR}${PREFIX}/bin
+ chmod 755 ${DESTDIR}${PREFIX}/bin/volume.sh
+ chmod 755 ${DESTDIR}${PREFIX}/bin/restarter
+
+uninstall:
+ rm -f ${DESTDIR}${PREFIX}/bin/birdwm\
+ /usr/share/xsessions/birdwm.desktop\
+ ${DESTDIR}${PREFIX}/bin/volume.sh\
+ ${DESTDIR}${PREFIX}/bin/restarter\
+ ${DESTDIR}${MANPREFIX}/man1/birdwm.1
+ rm -rf ${XDG_DATA_HOME}/birdwm
+
+full:
+ make -C slock
+ make -C slstatus
+ make
+
+fullinstall:
+ make -C slock install
+ make -C slstatus install
+ make install
+
+fullclean:
+ make -C slock clean
+ make -C slstatus clean
+ make clean
+
+.PHONY: all options clean dist install uninstall
diff --git a/README.md b/README.md
@@ -0,0 +1,44 @@
+# Birdwm, dwm for birds, by a bird!
+
+
+## Dependencies:
+- libxinerama
+- freetype2
+- libev
+- execline (optional: only for [my specific startup script](/mrgrouse/birdwm/src/branch/main/autostart/autostart.e))
+- a few more, i haven't checked yet (don't hurt me please)
+
+## Patches and Features
+
+- [xrdb](https://dwm.suckless.org/patches/xrdb): Birdwm patch that reads [Xresources](https://dwm.suckless.org/patches/xresources) colors/variables (i.e. works with `pywal`, etc.).
+- [scratchpads](https://dwm.suckless.org/patches/scratchpads): Accessible with <kbd>mod+y</kbd>.
+- [uselessgaps](https://dwm.suckless.org/patches/uselessgap): Adds useless gaps around windows, except in monocle mode.
+- [alpha](https://dwm.suckless.org/patches/alpha): Allows birdwm to have translucent bars, with opaque text.
+- [systray](https://dwm.suckless.org/patches/systray): System tray patch for birdwm in the corner of the bar
+- [winicon](https://dwm.suckless.org/patches/winicon): Patch for birdwm to display the icon of currently focused program
+- [autostart](https://dwm.suckless.org/patches/autostart)(modified): runs selected script upon startup
+- [birdmenu-emoji](https://github.com/porras/dmenu-emoji)(modified): runs dmenu-emoji script (modified for birdmenu), accessible via <kbd>mod+e</kbd>.
+
+### Misc. features
+- [desktop entry](https://git.mrgrouse.com/mrgrouse/birdwm/src/branch/main/extras/birdwm.desktop): desktop entry for easy startup in display managers
+- [various scripts](https://git.mrgrouse.com/mrgrouse/birdwm/src/branch/main/extras): various shell scripts for things such as:
+ - restarting daemons and other programs
+ - taking screenshots from a selection
+ - setting and getting volume for/from pulse audio
+
+- strong compatibility with my forks of other suckless programs, such as:
+ - [slstatus](https://git.mrgrouse.com/mrgrouse/slstatus): a status bar with few patches for birdwm
+ - [slock](https://git.mrgrouse.com/mrgrouse/slock): a simple screen lock tool with Xresources compatibility
+ - [birdmenu](https://git.mrgrouse.com/mrgrouse/birdmenu): my dmenu fork, including Xresources, password mode, and mouse clickability.
+ - [birdterm](https://git.mrgrouse.com/mrgrouse/birdterm): my st (simple terminal) fork, including transparency and scrollback.
+
+## Installation for birdwm on linux distros
+### See `config.h` for customization options
+
+```sh
+git clone https://git.mrgrouse.com/mrgrouse/birdwm
+cd birdwm
+sudo make install
+```
+
+<!-- There is also a `PKGBUILD` for compatible distros. Run `makepkg -si` instead of `sudo make install`. -->
diff --git a/autostart/autostart.e b/autostart/autostart.e
@@ -0,0 +1,50 @@
+#!/bin/execlineb -P
+#<=============================================================
+#|| _
+#|| _ __ ___ _ __ __ _ _ __ ___ _ _ ___ ___( )___
+#|| | '_ ` _ \| '__/ _` | '__/ _ \| | | / __|/ _ \// __|
+#|| | | | | | | | | (_| | | | (_) | |_| \__ \ __/ \__ \
+#|| |_| |_| |_|_| \__, |_| \___/ \__,_|___/\___| |___/
+#|| |___/
+#|| _ _ _
+#|| __ _ _ _| |_ ___ ___| |_ __ _ _ __| |_
+#|| / _` | | | | __/ _ \/ __| __/ _` | '__| __|
+#|| | (_| | |_| | || (_) \__ \ || (_| | | | |_
+#|| \__,_|\__,_|\__\___/|___/\__\__,_|_| \__|
+#||
+#<=============================================================
+foreground { xrandr --auto }
+background { slstatus }
+
+# enable the wallpaper line(s) if you are using my wallpaper setter, included in my dotfiles
+# for dotfiles, see https://git.tetraonini.online/grouse/dotfiles
+
+# X utilities
+#picom &
+#wal -R &
+#dunst &
+
+# if you use multiple monitors, customize this example function and that i use for my double monitor setup
+#foreground { xrandr --output DP-0 --mode 1920x1080 --rate 140 --right-of HDMI-0 --output HDMI-0 --mode 1920x1080 --rate 165 }
+
+# X wallpaper setters
+#feh --bg-fill $HOME/.config/wall.png &
+# or you can use xgifwallpaper for gifs if you have it installed
+#xgifwallpaper -s FILL Pictures/wallpapers/gif/cyberpunkcrop.gif &
+
+# use suckless' lock util with xautolock
+#xautolock -time 7 -locker slock
+
+# GUI apps can go here
+#cider &
+#vesktop &
+#signal-desktop &
+#pasystray &
+
+# mate GUI polkit daemon, swap out with anything else
+#exec /usr/lib/mate-polkit/polkit-mate-authentication-agent-1 &
+# gnome-keyring daemon, replace with whatever you have installed on your system if you'd like
+#gnome-keyring-daemon &
+foreground { sleep 3 }
+foreground { xdotool key Alt+F5 }
+
diff --git a/birdwm b/birdwm
Binary files differ.
diff --git a/birdwm.1 b/birdwm.1
@@ -0,0 +1,209 @@
+.TH BIRDWM 1 birdwm\-VERSION
+.SH NAME
+birdwm \- dynamic window manager for birds
+.SH SYNOPSIS
+.B birdwm
+.RB [ \-v ]
+.SH DESCRIPTION
+birdwm is a dynamic window manager for birds. It manages windows in tiled, monocle
+and floating layouts. Either layout can be applied dynamically, optimising the
+environment for the application in use and the task performed.
+.P
+In tiled layouts windows are managed in a master and stacking area. The master
+area on the left contains one window by default, and the stacking area on the
+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
+moved freely. Dialog windows are always managed floating, regardless of the
+layout applied.
+.P
+Windows are grouped by tags. Each window can be tagged with one or multiple
+tags. Selecting certain tags displays all windows with these tags.
+.P
+Each screen contains a small status bar which displays all available tags, the
+layout, the title of the focused window, and the text read from the root window
+name property, if the screen is focused. A floating window is indicated with an
+empty square and a maximised floating window is indicated with a filled square
+before the windows title. The selected tags are indicated with a different
+color. The tags of the focused window are indicated with a filled square in the
+top left corner. The tags which are applied to one or more windows are
+indicated with an empty square in the top left corner.
+.P
+birdwm draws a small border around windows to indicate the focus state.
+.P
+On start, birdwm can start additional programs that may be specified in two special
+shell scripts (see the FILES section below), autostart_blocking.sh and
+autostart.sh. The former is executed first and birdwm will wait for its
+termination before starting. The latter is executed in the background before
+birdwm enters its handler loop.
+.P
+Either of these files may be omitted.
+.SH OPTIONS
+.TP
+.B \-v
+prints version information to stderr, then exits.
+.SH USAGE
+.SS Status bar
+.TP
+.B X root window name
+is read and displayed in the status text area. It can be set with the
+.BR xsetroot (1)
+command.
+.TP
+.B Button1
+click on a tag label to display all windows with that tag, click on the layout
+label toggles between tiled and floating layout.
+.TP
+.B Button3
+click on a tag label adds/removes all windows with that tag to/from the view.
+.TP
+.B Mod1\-Button1
+click on a tag label applies that tag to the focused window.
+.TP
+.B Mod1\-Button3
+click on a tag label adds/removes that tag to/from the focused window.
+.SS Keyboard commands
+.TP
+.B Mod1\-Shift\-Return
+Start
+.BR st(1).
+.TP
+.B Mod1\-p
+Spawn
+.BR dmenu(1)
+for launching other programs.
+.TP
+.B Mod1\-,
+Focus previous screen, if any.
+.TP
+.B Mod1\-.
+Focus next screen, if any.
+.TP
+.B Mod1\-Shift\-,
+Send focused window to previous screen, if any.
+.TP
+.B Mod1\-Shift\-.
+Send focused window to next screen, if any.
+.TP
+.B Mod1\-b
+Toggles bar on and off.
+.TP
+.B Mod1\-t
+Sets tiled layout.
+.TP
+.B Mod1\-f
+Sets floating layout.
+.TP
+.B Mod1\-m
+Sets monocle layout.
+.TP
+.B Mod1\-space
+Toggles between current and previous layout.
+.TP
+.B Mod1\-j
+Focus next window.
+.TP
+.B Mod1\-k
+Focus previous window.
+.TP
+.B Mod1\-i
+Increase number of windows in master area.
+.TP
+.B Mod1\-d
+Decrease number of windows in master area.
+.TP
+.B Mod1\-l
+Increase master area size.
+.TP
+.B Mod1\-h
+Decrease master area size.
+.TP
+.B Mod1\-Return
+Zooms/cycles focused window to/from master area (tiled layouts only).
+.TP
+.B Mod1\-Shift\-c
+Close focused window.
+.TP
+.B Mod1\-Shift\-space
+Toggle focused window between tiled and floating state.
+.TP
+.B Mod1\-Tab
+Toggles to the previously selected tags.
+.TP
+.B Mod1\-Shift\-[1..n]
+Apply nth tag to focused window.
+.TP
+.B Mod1\-Shift\-0
+Apply all tags to focused window.
+.TP
+.B Mod1\-Control\-Shift\-[1..n]
+Add/remove nth tag to/from focused window.
+.TP
+.B Mod1\-[1..n]
+View all windows with nth tag.
+.TP
+.B Mod1\-0
+View all windows with any tag.
+.TP
+.B Mod1\-Control\-[1..n]
+Add/remove all windows with nth tag to/from the view.
+.TP
+.B Mod1\-Shift\-q
+Quit birdwm.
+.TP
+.B Mod1\-Control\-Shift\-q
+Restart birdwm.
+.SS Mouse commands
+.TP
+.B Mod1\-Button1
+Move focused window while dragging. Tiled windows will be toggled to the floating state.
+.TP
+.B Mod1\-Button2
+Toggles focused window between floating and tiled state.
+.TP
+.B Mod1\-Button3
+Resize focused window while dragging. Tiled windows will be toggled to the floating state.
+.SH FILES
+The files containing programs to be started along with birdwm are searched for in
+the following directories:
+.IP "1. $XDG_DATA_HOME/dwm"
+.IP "2. $HOME/.local/share/dwm"
+.IP "3. $HOME/.dwm"
+.P
+The first existing directory is scanned for any of the autostart files below.
+.TP 15
+autostart.sh
+This file is started as a shell background process before birdwm enters its handler
+loop.
+.TP 15
+autostart_blocking.sh
+This file is started before any autostart.sh; birdwm waits for its termination.
+.SH CUSTOMIZATION
+birdwm is customized by creating a custom config.h and (re)compiling the source
+code. This keeps it fast, secure and simple.
+.SH SIGNALS
+.TP
+.B SIGHUP - 1
+Restart the birdwm process.
+.TP
+.B SIGTERM - 15
+Cleanly terminate the birdwm process.
+.SH SEE ALSO
+.BR dmenu (1),
+.BR st (1)
+.SH ISSUES
+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
+JDK 1.6 versions, because it assumes a reparenting window manager. Possible workarounds
+are using JDK 1.4 (which doesn't contain the XToolkit/XAWT backend) or setting the
+environment variable
+.BR AWT_TOOLKIT=MToolkit
+(to use the older Motif backend instead) or running
+.B xprop -root -f _NET_WM_NAME 32a -set _NET_WM_NAME LG3D
+or
+.B wmname LG3D
+(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
+.BR _JAVA_AWT_WM_NONREPARENTING=1 .
+.SH BUGS
+Send all bug reports with a patch to hackers@suckless.org.
diff --git a/birdwm.c b/birdwm.c
@@ -0,0 +1,2827 @@
+/* See LICENSE file for copyright and license details.
+ *
+ * dynamic window manager (for birds) is designed like any other X client as well (but oriented towards birds). It is
+ * driven through handling X events. In contrast to other X clients, a window
+ * manager selects for SubstructureRedirectMask on the root window, to receive
+ * events about window (dis-)appearance. Only one X connection at a time is
+ * allowed to select for this event mask.
+ *
+ * The event handlers of dwm are organized in an array which is accessed
+ * whenever a new event has been fetched. This allows event dispatching
+ * in O(1) time.
+ *
+ * Each child of the root window is called a client, except windows which have
+ * set the override_redirect flag. Clients are organized in a linked client
+ * list on each monitor, the focus history is remembered through a stack list
+ * on each monitor. Each client contains a bit array to indicate the tags of a
+ * client.
+ *
+ * Keys and tagging rules are organized as arrays and defined in config.h.
+ * To understand everything else, start reading main().
+ */
+#include <X11/XF86keysym.h>
+#include <X11/Xatom.h>
+#include <X11/Xlib.h>
+#include <X11/Xproto.h>
+#include <X11/Xresource.h>
+#include <X11/Xutil.h>
+#include <X11/cursorfont.h>
+#include <X11/keysym.h>
+#include <errno.h>
+#include <limits.h>
+#include <locale.h>
+#include <signal.h>
+#include <stdarg.h>
+#include <stdint.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <sys/stat.h>
+#include <sys/types.h>
+#include <sys/wait.h>
+#include <unistd.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 + gappx)
+#define HEIGHT(X) ((X)->h + 2 * (X)->bw + gappx)
+#define NUMTAGS (LENGTH(tags) + LENGTH(scratchpads))
+#define TAGMASK ((1 << NUMTAGS) - 1)
+#define SPTAG(i) ((1 << LENGTH(tags)) << (i))
+#define SPTAGMASK (((1 << LENGTH(scratchpads)) - 1) << LENGTH(tags))
+#define TEXTW(X) (drw_fontset_getwidth(drw, (X)) + lrpad)
+
+#define XRDB_LOAD_COLOR(R, V) \
+ if (XrmGetResource(xrdb, R, NULL, &type, &value) == True) { \
+ if (value.addr != NULL && strnlen(value.addr, 8) == 7 && \
+ value.addr[0] == '#') { \
+ int i = 1; \
+ for (; i <= 6; i++) { \
+ if (value.addr[i] < 48) \
+ break; \
+ if (value.addr[i] > 57 && value.addr[i] < 65) \
+ break; \
+ if (value.addr[i] > 70 && value.addr[i] < 97) \
+ break; \
+ if (value.addr[i] > 102) \
+ break; \
+ } \
+ if (i == 7) { \
+ strncpy(V, value.addr, 7); \
+ V[7] = '\0'; \
+ } \
+ } \
+ }
+#define OPAQUE 0xffU
+
+#define SYSTEM_TRAY_REQUEST_DOCK 0
+#define _NET_SYSTEM_TRAY_ORIENTATION_HORZ 0
+
+/* XEMBED messages */
+#define XEMBED_EMBEDDED_NOTIFY 0
+#define XEMBED_WINDOW_ACTIVATE 1
+#define XEMBED_FOCUS_IN 4
+#define XEMBED_MODALITY_ON 10
+
+#define XEMBED_MAPPED (1 << 0)
+#define XEMBED_WINDOW_ACTIVATE 1
+#define XEMBED_WINDOW_DEACTIVATE 2
+
+#define VERSION_MAJOR 0
+#define VERSION_MINOR 0
+#define XEMBED_EMBEDDED_VERSION (VERSION_MAJOR << 16) | VERSION_MINOR
+
+/* enums */
+enum { Manager, Xembed, XembedInfo, XLast }; /* Xembed atoms */
+enum { CurNormal, CurResize, CurMove, CurLast }; /* cursor */
+enum { SchemeNorm, SchemeSel }; /* color schemes */
+enum {
+ NetSupported,
+ NetSystemTray,
+ NetSystemTrayOP,
+ NetSystemTrayOrientation,
+ NetSystemTrayVisual,
+ NetWMName,
+ NetWMIcon,
+ NetWMState,
+ NetWMFullscreen,
+ NetActiveWindow,
+ NetWMWindowType,
+ NetWMWindowTypeDock,
+ NetSystemTrayOrientationHorz,
+ NetWMWindowTypeDialog,
+ NetClientList,
+ NetWMCheck,
+ 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;
+ unsigned int icw, ich;
+ Picture icon;
+ 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;
+
+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];
+};
+
+typedef struct {
+ const char *class;
+ const char *instance;
+ const char *title;
+ unsigned int tags;
+ int isfloating;
+ int monitor;
+} Rule;
+
+typedef struct Systray Systray;
+struct Systray {
+ Window win;
+ Client *icons;
+};
+
+/* function declarations */
+static void applyrules(Client *c);
+static int applysizehints(Client *c, int *x, int *y, int *w, int *h,
+ int interact);
+static void arrange(Monitor *m);
+static void arrangemon(Monitor *m);
+static void attach(Client *c);
+static void attachstack(Client *c);
+static void buttonpress(XEvent *e);
+static void checkotherwm(void);
+static void cleanup(void);
+static void cleanupmon(Monitor *mon);
+static void clientmessage(XEvent *e);
+static void configure(Client *c);
+static void configurenotify(XEvent *e);
+static void configurerequest(XEvent *e);
+static Monitor *createmon(void);
+static void destroynotify(XEvent *e);
+static void detach(Client *c);
+static void detachstack(Client *c);
+static Monitor *dirtomon(int dir);
+static void drawbar(Monitor *m);
+static void drawbars(void);
+static void enternotify(XEvent *e);
+static void expose(XEvent *e);
+static void focus(Client *c);
+static void focusin(XEvent *e);
+static void focusmon(const Arg *arg);
+static void focusstack(const Arg *arg);
+static Atom getatomprop(Client *c, Atom prop);
+static Picture geticonprop(Window w, unsigned int *icw, unsigned int *ich);
+static int getrootptr(int *x, int *y);
+static long getstate(Window w);
+static int gettextprop(Window w, Atom atom, char *text, unsigned int size);
+static unsigned int getsystraywidth();
+static void grabbuttons(Client *c, int focused);
+static void grabkeys(void);
+static void incnmaster(const Arg *arg);
+static void keypress(XEvent *e);
+static void killclient(const Arg *arg);
+static void loadxrdb(void);
+static void manage(Window w, XWindowAttributes *wa);
+static void mappingnotify(XEvent *e);
+static void maprequest(XEvent *e);
+static void monocle(Monitor *m);
+static void motionnotify(XEvent *e);
+static void movemouse(const Arg *arg);
+static Client *nexttiled(Client *c);
+static void pop(Client *c);
+static void propertynotify(XEvent *e);
+static void quit(const Arg *arg);
+static Monitor *recttomon(int x, int y, int w, int h);
+static void resize(Client *c, int x, int y, int w, int h, int interact);
+static void resizeclient(Client *c, int x, int y, int w, int h);
+static void resizemouse(const Arg *arg);
+static void removesystrayicon(Client *i);
+static void resizerequest(XEvent *e);
+static void restack(Monitor *m);
+static void run(void);
+static void runautostart(void);
+static void scan(void);
+static int sendevent(Window w, Atom proto, int m, long d0, long d1, long d2,
+ long d3, long d4);
+static void sendmon(Client *c, Monitor *m);
+static void setclientstate(Client *c, long state);
+static void setfocus(Client *c);
+static void setfullscreen(Client *c, int fullscreen);
+static void setlayout(const Arg *arg);
+static void setmfact(const Arg *arg);
+static void setup(void);
+static void seturgent(Client *c, int urg);
+static void showhide(Client *c);
+static void sighup(int unused);
+static void sigterm(int unused);
+static void spawn(const Arg *arg);
+static Monitor *systraytomon(Monitor *m);
+static void tag(const Arg *arg);
+static void tagmon(const Arg *arg);
+static void tile(Monitor *m);
+static void togglebar(const Arg *arg);
+static void togglefloating(const Arg *arg);
+static void togglescratch(const Arg *arg);
+static void toggletag(const Arg *arg);
+static void toggleview(const Arg *arg);
+static void freeicon(Client *c);
+static void unfocus(Client *c, int setfocus);
+static void unmanage(Client *c, int destroyed);
+static void unmapnotify(XEvent *e);
+static void updatebarpos(Monitor *m);
+static void updatebars(void);
+static void updateclientlist(void);
+static int updategeom(void);
+static void updatenumlockmask(void);
+static void updatesizehints(Client *c);
+static void updatestatus(void);
+static void updatesystray(int updatebar);
+static void updatesystrayicongeom(Client *i, int w, int h);
+static void updatesystrayiconstate(Client *i, XPropertyEvent *ev);
+static void updatetitle(Client *c);
+static void updateicon(Client *c);
+static void updatewindowtype(Client *c);
+static void updatewmhints(Client *c);
+static void view(const Arg *arg);
+static Client *wintoclient(Window w);
+static Monitor *wintomon(Window w);
+static Client *wintosystrayicon(Window w);
+static int xerror(Display *dpy, XErrorEvent *ee);
+static int xerrordummy(Display *dpy, XErrorEvent *ee);
+static int xerrorstart(Display *dpy, XErrorEvent *ee);
+static void xinitvisual();
+static void xrdb(const Arg *arg);
+static void zoom(const Arg *arg);
+
+/* variables */
+static const char autostartblocksh[] = "autostart_blocking.sh";
+static const char autostartsh[] = "autostart.sh";
+static const char broken[] = "broken";
+static const char dwmdir[] = "birdwm";
+static const char localshare[] = ".local/share";
+static char stext[256];
+static int screen;
+static int sw, sh; /* X display screen geometry width, height */
+static int bh; /* bar height */
+static int lrpad; /* sum of left and right padding for text */
+static int (*xerrorxlib)(Display *, XErrorEvent *);
+static unsigned int numlockmask = 0;
+static 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,
+ [ResizeRequest] = resizerequest,
+ [UnmapNotify] = unmapnotify};
+static Atom wmatom[WMLast], netatom[NetLast], xatom[XLast];
+static int restart = 0;
+static int running = 1;
+static Cur *cursor[CurLast];
+static Clr **scheme;
+static Display *dpy;
+static Drw *drw;
+static Monitor *mons, *selmon;
+static Window root, wmcheckwin;
+
+static Systray *systray = NULL;
+static unsigned long systrayorientation = _NET_SYSTEM_TRAY_ORIENTATION_HORZ;
+
+static int useargb = 0;
+static Visual *visual;
+static int depth;
+static Colormap cmap;
+
+/* configuration, allows nested code to access above variables */
+#include "config.h"
+
+/* compile-time check if all tags fit into an unsigned int bit array. */
+struct NumTags {
+ char limitexceeded[LENGTH(tags) > 31 ? -1 : 1];
+};
+
+/* function implementations */
+void applyrules(Client *c) {
+ const char *class, *instance;
+ unsigned int i;
+ const Rule *r;
+ Monitor *m;
+ XClassHint ch = {NULL, NULL};
+
+ /* rule matching */
+ c->isfloating = 0;
+ c->tags = 0;
+ XGetClassHint(dpy, c->win, &ch);
+ class = ch.res_class ? ch.res_class : broken;
+ instance = ch.res_name ? ch.res_name : broken;
+
+ for (i = 0; i < LENGTH(rules); i++) {
+ r = &rules[i];
+ if ((!r->title || strstr(c->name, r->title)) &&
+ (!r->class || strstr(class, r->class)) &&
+ (!r->instance || strstr(instance, r->instance))) {
+ c->isfloating = r->isfloating;
+ c->tags |= r->tags;
+ if ((r->tags & SPTAGMASK) && r->isfloating) {
+ c->x = c->mon->wx + (c->mon->ww / 2 - WIDTH(c) / 2);
+ c->y = c->mon->wy + (c->mon->wh / 2 - HEIGHT(c) / 2);
+ }
+
+ for (m = mons; m && m->num != r->monitor; m = m->next)
+ ;
+ if (m)
+ c->mon = m;
+ }
+ }
+ if (ch.res_class)
+ XFree(ch.res_class);
+ if (ch.res_name)
+ XFree(ch.res_name);
+ c->tags = c->tags & TAGMASK ? c->tags & TAGMASK
+ : (c->mon->tagset[c->mon->seltags] & ~SPTAGMASK);
+}
+
+int applysizehints(Client *c, int *x, int *y, int *w, int *h, int interact) {
+ int baseismin;
+ Monitor *m = c->mon;
+
+ /* set minimum possible */
+ *w = MAX(1, *w);
+ *h = MAX(1, *h);
+ if (interact) {
+ if (*x > sw)
+ *x = sw - WIDTH(c);
+ if (*y > sh)
+ *y = sh - HEIGHT(c);
+ if (*x + *w + 2 * c->bw < 0)
+ *x = 0;
+ if (*y + *h + 2 * c->bw < 0)
+ *y = 0;
+ } else {
+ if (*x >= m->wx + m->ww)
+ *x = m->wx + m->ww - WIDTH(c);
+ if (*y >= m->wy + m->wh)
+ *y = m->wy + m->wh - HEIGHT(c);
+ if (*x + *w + 2 * c->bw <= m->wx)
+ *x = m->wx;
+ if (*y + *h + 2 * c->bw <= m->wy)
+ *y = m->wy;
+ }
+ if (*h < bh)
+ *h = bh;
+ if (*w < bh)
+ *w = bh;
+ if (resizehints || c->isfloating || !c->mon->lt[c->mon->sellt]->arrange) {
+ if (!c->hintsvalid)
+ updatesizehints(c);
+ /* see last two sentences in ICCCM 4.1.2.3 */
+ baseismin = c->basew == c->minw && c->baseh == c->minh;
+ if (!baseismin) { /* temporarily remove base dimensions */
+ *w -= c->basew;
+ *h -= c->baseh;
+ }
+ /* adjust for aspect limits */
+ if (c->mina > 0 && c->maxa > 0) {
+ if (c->maxa < (float)*w / *h)
+ *w = *h * c->maxa + 0.5;
+ else if (c->mina < (float)*h / *w)
+ *h = *w * c->mina + 0.5;
+ }
+ if (baseismin) { /* increment calculation requires this */
+ *w -= c->basew;
+ *h -= c->baseh;
+ }
+ /* adjust for increment value */
+ if (c->incw)
+ *w -= *w % c->incw;
+ if (c->inch)
+ *h -= *h % c->inch;
+ /* restore base dimensions */
+ *w = MAX(*w + c->basew, c->minw);
+ *h = MAX(*h + c->baseh, c->minh);
+ if (c->maxw)
+ *w = MIN(*w, c->maxw);
+ if (c->maxh)
+ *h = MIN(*h, c->maxh);
+ }
+ return *x != c->x || *y != c->y || *w != c->w || *h != c->h;
+}
+
+void arrange(Monitor *m) {
+ if (m)
+ showhide(m->stack);
+ else
+ for (m = mons; m; m = m->next)
+ showhide(m->stack);
+ if (m) {
+ arrangemon(m);
+ restack(m);
+ } else
+ for (m = mons; m; m = m->next)
+ arrangemon(m);
+}
+
+void arrangemon(Monitor *m) {
+ strncpy(m->ltsymbol, m->lt[m->sellt]->symbol, sizeof m->ltsymbol);
+ if (m->lt[m->sellt]->arrange)
+ m->lt[m->sellt]->arrange(m);
+}
+
+void attach(Client *c) {
+ c->next = c->mon->clients;
+ c->mon->clients = c;
+}
+
+void attachstack(Client *c) {
+ c->snext = c->mon->stack;
+ c->mon->stack = c;
+}
+
+void buttonpress(XEvent *e) {
+ unsigned int i, x, click;
+ Arg arg = {0};
+ Client *c;
+ Monitor *m;
+ XButtonPressedEvent *ev = &e->xbutton;
+
+ click = ClkRootWin;
+ /* focus monitor if necessary */
+ if ((m = wintomon(ev->window)) && m != selmon) {
+ unfocus(selmon->sel, 1);
+ selmon = m;
+ focus(NULL);
+ }
+ if (ev->window == selmon->barwin) {
+ i = x = 0;
+ do
+ x += TEXTW(tags[i]);
+ while (ev->x >= x && ++i < LENGTH(tags));
+ if (i < LENGTH(tags)) {
+ click = ClkTagBar;
+ arg.ui = 1 << i;
+ } else if (ev->x < x + TEXTW(selmon->ltsymbol))
+ click = ClkLtSymbol;
+ else if (ev->x > selmon->ww - (int)TEXTW(stext) - getsystraywidth())
+ click = ClkStatusText;
+ else
+ click = ClkWinTitle;
+ } else if ((c = wintoclient(ev->window))) {
+ focus(c);
+ restack(selmon);
+ XAllowEvents(dpy, ReplayPointer, CurrentTime);
+ click = ClkClientWin;
+ }
+ for (i = 0; i < LENGTH(buttons); i++)
+ if (click == buttons[i].click && buttons[i].func &&
+ buttons[i].button == ev->button &&
+ CLEANMASK(buttons[i].mask) == CLEANMASK(ev->state))
+ buttons[i].func(
+ click == ClkTagBar && buttons[i].arg.i == 0 ? &arg : &buttons[i].arg);
+}
+
+void checkotherwm(void) {
+ xerrorxlib = XSetErrorHandler(xerrorstart);
+ /* this causes an error if some other window manager is running */
+ XSelectInput(dpy, DefaultRootWindow(dpy), SubstructureRedirectMask);
+ XSync(dpy, False);
+ XSetErrorHandler(xerror);
+ XSync(dpy, False);
+}
+
+void cleanup(void) {
+ Arg a = {.ui = ~0};
+ Layout foo = {"", NULL};
+ Monitor *m;
+ size_t i;
+
+ view(&a);
+ selmon->lt[selmon->sellt] = &foo;
+ for (m = mons; m; m = m->next)
+ while (m->stack)
+ unmanage(m->stack, 0);
+ XUngrabKey(dpy, AnyKey, AnyModifier, root);
+ while (mons)
+ cleanupmon(mons);
+ if (showsystray) {
+ while (systray->icons)
+ removesystrayicon(systray->icons);
+ XUnmapWindow(dpy, systray->win);
+ XDestroyWindow(dpy, systray->win);
+ free(systray);
+ }
+ for (i = 0; i < CurLast; i++)
+ drw_cur_free(drw, cursor[i]);
+ for (i = 0; i < LENGTH(colors); i++)
+ free(scheme[i]);
+ free(scheme);
+ XDestroyWindow(dpy, wmcheckwin);
+ drw_free(drw);
+ XSync(dpy, False);
+ XSetInputFocus(dpy, PointerRoot, RevertToPointerRoot, CurrentTime);
+ XDeleteProperty(dpy, root, netatom[NetActiveWindow]);
+}
+
+void cleanupmon(Monitor *mon) {
+ Monitor *m;
+
+ if (mon == mons)
+ mons = mons->next;
+ else {
+ for (m = mons; m && m->next != mon; m = m->next)
+ ;
+ m->next = mon->next;
+ }
+ XUnmapWindow(dpy, mon->barwin);
+ XDestroyWindow(dpy, mon->barwin);
+ free(mon);
+}
+
+void clientmessage(XEvent *e) {
+ XWindowAttributes wa;
+ XSetWindowAttributes swa;
+ XClientMessageEvent *cme = &e->xclient;
+ Client *c = wintoclient(cme->window);
+
+ if (showsystray && cme->window == systray->win &&
+ cme->message_type == netatom[NetSystemTrayOP]) {
+ /* add systray icons */
+ if (cme->data.l[1] == SYSTEM_TRAY_REQUEST_DOCK) {
+ if (!(c = (Client *)calloc(1, sizeof(Client))))
+ die("fatal: could not malloc() %u bytes\n", sizeof(Client));
+ if (!(c->win = cme->data.l[2])) {
+ free(c);
+ return;
+ }
+
+ c->mon = selmon;
+ c->next = systray->icons;
+ systray->icons = c;
+ XGetWindowAttributes(dpy, c->win, &wa);
+ c->x = c->oldx = c->y = c->oldy = 0;
+ c->w = c->oldw = wa.width;
+ c->h = c->oldh = wa.height;
+ c->oldbw = wa.border_width;
+ c->bw = 0;
+ c->isfloating = True;
+ /* reuse tags field as mapped status */
+ c->tags = 1;
+ updatesizehints(c);
+ updatesystrayicongeom(c, wa.width, wa.height);
+ XAddToSaveSet(dpy, c->win);
+ XSelectInput(dpy, c->win,
+ StructureNotifyMask | PropertyChangeMask |
+ ResizeRedirectMask);
+ XReparentWindow(dpy, c->win, systray->win, 0, 0);
+ /* use parents background color */
+ swa.background_pixel = scheme[SchemeNorm][ColBg].pixel;
+ XChangeWindowAttributes(dpy, c->win, CWBackPixel, &swa);
+ sendevent(c->win, netatom[Xembed], StructureNotifyMask, CurrentTime,
+ XEMBED_EMBEDDED_NOTIFY, 0, systray->win,
+ XEMBED_EMBEDDED_VERSION);
+ XSync(dpy, False);
+ setclientstate(c, NormalState);
+ updatesystray(1);
+ }
+ return;
+ }
+
+ if (!c)
+ return;
+ if (cme->message_type == netatom[NetWMState]) {
+ if (cme->data.l[1] == netatom[NetWMFullscreen] ||
+ cme->data.l[2] == netatom[NetWMFullscreen])
+ setfullscreen(c, (cme->data.l[0] == 1 /* _NET_WM_STATE_ADD */
+ || (cme->data.l[0] == 2 /* _NET_WM_STATE_TOGGLE */ &&
+ !c->isfullscreen)));
+ } else if (cme->message_type == netatom[NetActiveWindow]) {
+ if (c != selmon->sel && !c->isurgent)
+ seturgent(c, 1);
+ }
+}
+
+void configure(Client *c) {
+ XConfigureEvent ce;
+
+ ce.type = ConfigureNotify;
+ ce.display = dpy;
+ ce.event = c->win;
+ ce.window = c->win;
+ ce.x = c->x;
+ ce.y = c->y;
+ ce.width = c->w;
+ ce.height = c->h;
+ ce.border_width = c->bw;
+ ce.above = None;
+ ce.override_redirect = False;
+ XSendEvent(dpy, c->win, False, StructureNotifyMask, (XEvent *)&ce);
+}
+
+void configurenotify(XEvent *e) {
+ Monitor *m;
+ Client *c;
+ XConfigureEvent *ev = &e->xconfigure;
+ int dirty;
+
+ /* TODO: updategeom handling sucks, needs to be simplified */
+ if (ev->window == root) {
+ dirty = (sw != ev->width || sh != ev->height);
+ sw = ev->width;
+ sh = ev->height;
+ if (updategeom() || dirty) {
+ drw_resize(drw, sw, bh);
+ updatebars();
+ for (m = mons; m; m = m->next) {
+ for (c = m->clients; c; c = c->next)
+ if (c->isfullscreen)
+ resizeclient(c, m->mx, m->my, m->mw, m->mh);
+ XMoveResizeWindow(dpy, m->barwin, m->wx, m->by, m->ww, bh);
+ }
+ focus(NULL);
+ arrange(NULL);
+ }
+ }
+}
+
+void configurerequest(XEvent *e) {
+ Client *c;
+ Monitor *m;
+ XConfigureRequestEvent *ev = &e->xconfigurerequest;
+ XWindowChanges wc;
+
+ if ((c = wintoclient(ev->window))) {
+ if (ev->value_mask & CWBorderWidth)
+ c->bw = ev->border_width;
+ else if (c->isfloating || !selmon->lt[selmon->sellt]->arrange) {
+ m = c->mon;
+ if (ev->value_mask & CWX) {
+ c->oldx = c->x;
+ c->x = m->mx + ev->x;
+ }
+ if (ev->value_mask & CWY) {
+ c->oldy = c->y;
+ c->y = m->my + ev->y;
+ }
+ if (ev->value_mask & CWWidth) {
+ c->oldw = c->w;
+ c->w = ev->width;
+ }
+ if (ev->value_mask & CWHeight) {
+ c->oldh = c->h;
+ c->h = ev->height;
+ }
+ if ((c->x + c->w) > m->mx + m->mw && c->isfloating)
+ c->x = m->mx + (m->mw / 2 - WIDTH(c) / 2); /* center in x direction */
+ if ((c->y + c->h) > m->my + m->mh && c->isfloating)
+ c->y = m->my + (m->mh / 2 - HEIGHT(c) / 2); /* center in y direction */
+ if ((ev->value_mask & (CWX | CWY)) &&
+ !(ev->value_mask & (CWWidth | CWHeight)))
+ configure(c);
+ if (ISVISIBLE(c))
+ XMoveResizeWindow(dpy, c->win, c->x, c->y, c->w, c->h);
+ } else
+ configure(c);
+ } else {
+ wc.x = ev->x;
+ wc.y = ev->y;
+ wc.width = ev->width;
+ wc.height = ev->height;
+ wc.border_width = ev->border_width;
+ wc.sibling = ev->above;
+ wc.stack_mode = ev->detail;
+ XConfigureWindow(dpy, ev->window, ev->value_mask, &wc);
+ }
+ XSync(dpy, False);
+}
+
+Monitor *createmon(void) {
+ Monitor *m;
+
+ m = ecalloc(1, sizeof(Monitor));
+ m->tagset[0] = m->tagset[1] = 1;
+ m->mfact = mfact;
+ m->nmaster = nmaster;
+ m->showbar = showbar;
+ m->topbar = topbar;
+ m->lt[0] = &layouts[0];
+ m->lt[1] = &layouts[1 % LENGTH(layouts)];
+ strncpy(m->ltsymbol, layouts[0].symbol, sizeof m->ltsymbol);
+ return m;
+}
+
+void destroynotify(XEvent *e) {
+ Client *c;
+ XDestroyWindowEvent *ev = &e->xdestroywindow;
+
+ if ((c = wintoclient(ev->window)))
+ unmanage(c, 1);
+ else if (showsystray && (c = wintosystrayicon(ev->window))) {
+ removesystrayicon(c);
+ updatesystray(1);
+ }
+}
+
+void detach(Client *c) {
+ Client **tc;
+
+ for (tc = &c->mon->clients; *tc && *tc != c; tc = &(*tc)->next)
+ ;
+ *tc = c->next;
+}
+
+void detachstack(Client *c) {
+ Client **tc, *t;
+
+ for (tc = &c->mon->stack; *tc && *tc != c; tc = &(*tc)->snext)
+ ;
+ *tc = c->snext;
+
+ if (c == c->mon->sel) {
+ for (t = c->mon->stack; t && !ISVISIBLE(t); t = t->snext)
+ ;
+ c->mon->sel = t;
+ }
+}
+
+Monitor *dirtomon(int dir) {
+ Monitor *m = NULL;
+
+ if (dir > 0) {
+ if (!(m = selmon->next))
+ m = mons;
+ } else if (selmon == mons)
+ for (m = mons; m->next; m = m->next)
+ ;
+ else
+ for (m = mons; m->next != selmon; m = m->next)
+ ;
+ return m;
+}
+
+void drawbar(Monitor *m) {
+ int x, w, tw = 0, stw = 0;
+ int boxs = drw->fonts->h / 9;
+ int boxw = drw->fonts->h / 6 + 2;
+ unsigned int i, occ = 0, urg = 0;
+ Client *c;
+
+ if (showsystray && m == systraytomon(m)) {
+ stw = getsystraywidth();
+ drw_setscheme(drw, scheme[SchemeNorm]);
+ drw_rect(drw, m->ww - stw, 0, stw, bh, 1, 1);
+ }
+
+ if (!m->showbar)
+ return;
+
+ /* draw status first so it can be overdrawn by tags later */
+ if (m == selmon) { /* status is only drawn on selected monitor */
+ drw_setscheme(drw, scheme[SchemeNorm]);
+ tw = TEXTW(stext) - lrpad + 2; /* 2px right padding */
+ drw_text(drw, m->ww - tw - stw, 0, tw, bh, 0, stext, 0);
+ }
+
+ for (c = m->clients; c; c = c->next) {
+ occ |= c->tags;
+ if (c->isurgent)
+ urg |= c->tags;
+ }
+ x = 0;
+ for (i = 0; i < LENGTH(tags); i++) {
+ w = TEXTW(tags[i]);
+ drw_setscheme(
+ drw, scheme[m->tagset[m->seltags] & 1 << i ? SchemeSel : SchemeNorm]);
+ drw_text(drw, x, 0, w, bh, lrpad / 2, tags[i], urg & 1 << i);
+ if (occ & 1 << i)
+ drw_rect(drw, x + boxs, boxs, boxw, boxw,
+ m == selmon && selmon->sel && selmon->sel->tags & 1 << i,
+ urg & 1 << i);
+ x += w;
+ }
+ w = TEXTW(m->ltsymbol);
+ drw_setscheme(drw, scheme[SchemeNorm]);
+ x = drw_text(drw, x, 0, w, bh, lrpad / 2, m->ltsymbol, 0);
+
+ if ((w = m->ww - tw - stw - x) > bh) {
+ if (m->sel) {
+ drw_setscheme(drw, scheme[m == selmon ? SchemeSel : SchemeNorm]);
+ drw_text(drw, x, 0, w, bh,
+ lrpad / 2 + (m->sel->icon ? m->sel->icw + ICONSPACING : 0),
+ m->sel->name, 0);
+ if (m->sel->icon)
+ drw_pic(drw, x + lrpad / 2, (bh - m->sel->ich) / 2, m->sel->icw,
+ m->sel->ich, m->sel->icon);
+ if (m->sel->isfloating)
+ drw_rect(drw, x + boxs, boxs, boxw, boxw, m->sel->isfixed, 0);
+ } else {
+ drw_setscheme(drw, scheme[SchemeNorm]);
+ drw_rect(drw, x, 0, w, bh, 1, 1);
+ }
+ }
+ drw_map(drw, m->barwin, 0, 0, m->ww, bh);
+}
+
+void drawbars(void) {
+ Monitor *m;
+
+ for (m = mons; m; m = m->next)
+ drawbar(m);
+
+ if (showsystray && !systraypinning)
+ updatesystray(0);
+}
+
+void enternotify(XEvent *e) {
+ Client *c;
+ Monitor *m;
+ XCrossingEvent *ev = &e->xcrossing;
+
+ if ((ev->mode != NotifyNormal || ev->detail == NotifyInferior) &&
+ ev->window != root)
+ return;
+ c = wintoclient(ev->window);
+ m = c ? c->mon : wintomon(ev->window);
+ if (m != selmon) {
+ unfocus(selmon->sel, 1);
+ selmon = m;
+ } else if (!c || c == selmon->sel)
+ return;
+ focus(c);
+}
+
+void expose(XEvent *e) {
+ Monitor *m;
+ XExposeEvent *ev = &e->xexpose;
+
+ if (ev->count == 0 && (m = wintomon(ev->window))) {
+ drawbar(m);
+
+ if (showsystray && m == systraytomon(m))
+ updatesystray(0);
+ }
+}
+
+void focus(Client *c) {
+ if (!c || !ISVISIBLE(c))
+ for (c = selmon->stack; c && !ISVISIBLE(c); c = c->snext)
+ ;
+ if (selmon->sel && selmon->sel != c)
+ unfocus(selmon->sel, 0);
+ if (c) {
+ if (c->mon != selmon)
+ selmon = c->mon;
+ if (c->isurgent)
+ seturgent(c, 0);
+ detachstack(c);
+ attachstack(c);
+ grabbuttons(c, 1);
+ XSetWindowBorder(dpy, c->win, scheme[SchemeSel][ColBorder].pixel);
+ setfocus(c);
+ } else {
+ XSetInputFocus(dpy, root, RevertToPointerRoot, CurrentTime);
+ XDeleteProperty(dpy, root, netatom[NetActiveWindow]);
+ }
+ selmon->sel = c;
+ drawbars();
+}
+
+/* there are some broken focus acquiring clients needing extra handling */
+void focusin(XEvent *e) {
+ XFocusChangeEvent *ev = &e->xfocus;
+
+ if (selmon->sel && ev->window != selmon->sel->win)
+ setfocus(selmon->sel);
+}
+
+void focusmon(const Arg *arg) {
+ Monitor *m;
+
+ if (!mons->next)
+ return;
+ if ((m = dirtomon(arg->i)) == selmon)
+ return;
+ unfocus(selmon->sel, 0);
+ selmon = m;
+ focus(NULL);
+ if (selmon->sel)
+ XWarpPointer(dpy, None, selmon->sel->win, 0, 0, 0, 0, selmon->sel->w / 2,
+ selmon->sel->h / 2);
+}
+
+void focusstack(const Arg *arg) {
+ Client *c = NULL, *i;
+
+ if (!selmon->sel || (selmon->sel->isfullscreen && lockfullscreen))
+ return;
+ if (arg->i > 0) {
+ for (c = selmon->sel->next; c && !ISVISIBLE(c); c = c->next)
+ ;
+ if (!c)
+ for (c = selmon->clients; c && !ISVISIBLE(c); c = c->next)
+ ;
+ } else {
+ for (i = selmon->clients; i != selmon->sel; i = i->next)
+ if (ISVISIBLE(i))
+ c = i;
+ if (!c)
+ for (; i; i = i->next)
+ if (ISVISIBLE(i))
+ c = i;
+ }
+ if (c) {
+ focus(c);
+ restack(selmon);
+ XWarpPointer(dpy, None, c->win, 0, 0, 0, 0, c->w / 2, c->h / 2);
+ }
+}
+
+Atom getatomprop(Client *c, Atom prop) {
+ int di;
+ unsigned long dl;
+ unsigned char *p = NULL;
+ Atom da, atom = None;
+
+ /* FIXME getatomprop should return the number of items and a pointer to
+ * the stored data instead of this workaround */
+ Atom req = XA_ATOM;
+ if (prop == xatom[XembedInfo])
+ req = xatom[XembedInfo];
+
+ if (XGetWindowProperty(dpy, c->win, prop, 0L, sizeof atom, False, req, &da,
+ &di, &dl, &dl, &p) == Success &&
+ p) {
+ atom = *(Atom *)p;
+ if (da == xatom[XembedInfo] && dl == 2)
+ atom = ((Atom *)p)[1];
+ XFree(p);
+ }
+ return atom;
+}
+
+static uint32_t prealpha(uint32_t p) {
+ uint8_t a = p >> 24u;
+ uint32_t rb = (a * (p & 0xFF00FFu)) >> 8u;
+ uint32_t g = (a * (p & 0x00FF00u)) >> 8u;
+ return (rb & 0xFF00FFu) | (g & 0x00FF00u) | (a << 24u);
+}
+
+Picture geticonprop(Window win, unsigned int *picw, unsigned int *pich) {
+ int format;
+ unsigned long n, extra, *p = NULL;
+ Atom real;
+
+ if (XGetWindowProperty(dpy, win, netatom[NetWMIcon], 0L, LONG_MAX, False,
+ AnyPropertyType, &real, &format, &n, &extra,
+ (unsigned char **)&p) != Success)
+ return None;
+ if (n == 0 || format != 32) {
+ XFree(p);
+ return None;
+ }
+
+ unsigned long *bstp = NULL;
+ uint32_t w, h, sz;
+ {
+ unsigned long *i;
+ const unsigned long *end = p + n;
+ uint32_t bstd = UINT32_MAX, d, m;
+ for (i = p; i < end - 1; i += sz) {
+ if ((w = *i++) >= 16384 || (h = *i++) >= 16384) {
+ XFree(p);
+ return None;
+ }
+ if ((sz = w * h) > end - i)
+ break;
+ if ((m = w > h ? w : h) >= ICONSIZE && (d = m - ICONSIZE) < bstd) {
+ bstd = d;
+ bstp = i;
+ }
+ }
+ if (!bstp) {
+ for (i = p; i < end - 1; i += sz) {
+ if ((w = *i++) >= 16384 || (h = *i++) >= 16384) {
+ XFree(p);
+ return None;
+ }
+ if ((sz = w * h) > end - i)
+ break;
+ if ((d = ICONSIZE - (w > h ? w : h)) < bstd) {
+ bstd = d;
+ bstp = i;
+ }
+ }
+ }
+ if (!bstp) {
+ XFree(p);
+ return None;
+ }
+ }
+
+ if ((w = *(bstp - 2)) == 0 || (h = *(bstp - 1)) == 0) {
+ XFree(p);
+ return None;
+ }
+
+ uint32_t icw, ich;
+ if (w <= h) {
+ ich = ICONSIZE;
+ icw = w * ICONSIZE / h;
+ if (icw == 0)
+ icw = 1;
+ } else {
+ icw = ICONSIZE;
+ ich = h * ICONSIZE / w;
+ if (ich == 0)
+ ich = 1;
+ }
+ *picw = icw;
+ *pich = ich;
+
+ uint32_t i, *bstp32 = (uint32_t *)bstp;
+ for (sz = w * h, i = 0; i < sz; ++i)
+ bstp32[i] = prealpha(bstp[i]);
+
+ Picture ret = drw_picture_create_resized(drw, (char *)bstp, w, h, icw, ich);
+ XFree(p);
+
+ return ret;
+}
+
+int getrootptr(int *x, int *y) {
+ int di;
+ unsigned int dui;
+ Window dummy;
+
+ return XQueryPointer(dpy, root, &dummy, &dummy, x, y, &di, &di, &dui);
+}
+
+long getstate(Window w) {
+ int format;
+ long result = -1;
+ unsigned char *p = NULL;
+ unsigned long n, extra;
+ Atom real;
+
+ if (XGetWindowProperty(dpy, w, wmatom[WMState], 0L, 2L, False,
+ wmatom[WMState], &real, &format, &n, &extra,
+ (unsigned char **)&p) != Success)
+ return -1;
+ if (n != 0)
+ result = *p;
+ XFree(p);
+ return result;
+}
+
+unsigned int getsystraywidth() {
+ unsigned int w = 0;
+ Client *i;
+ if (showsystray)
+ for (i = systray->icons; i; w += i->w + systrayspacing, i = i->next)
+ ;
+ return w ? w + systrayspacing : 0;
+}
+
+int gettextprop(Window w, Atom atom, char *text, unsigned int size) {
+ char **list = NULL;
+ int n;
+ XTextProperty name;
+
+ if (!text || size == 0)
+ return 0;
+ text[0] = '\0';
+ if (!XGetTextProperty(dpy, w, &name, atom) || !name.nitems)
+ return 0;
+ if (name.encoding == XA_STRING) {
+ strncpy(text, (char *)name.value, size - 1);
+ } else if (XmbTextPropertyToTextList(dpy, &name, &list, &n) >= Success &&
+ n > 0 && *list) {
+ strncpy(text, *list, size - 1);
+ XFreeStringList(list);
+ }
+ text[size - 1] = '\0';
+ XFree(name.value);
+ return 1;
+}
+
+void grabbuttons(Client *c, int focused) {
+ updatenumlockmask();
+ {
+ unsigned int i, j;
+ unsigned int modifiers[] = {0, LockMask, numlockmask,
+ numlockmask | LockMask};
+ XUngrabButton(dpy, AnyButton, AnyModifier, c->win);
+ if (!focused)
+ XGrabButton(dpy, AnyButton, AnyModifier, c->win, False, BUTTONMASK,
+ GrabModeSync, GrabModeSync, None, None);
+ for (i = 0; i < LENGTH(buttons); i++)
+ if (buttons[i].click == ClkClientWin)
+ for (j = 0; j < LENGTH(modifiers); j++)
+ XGrabButton(dpy, buttons[i].button, buttons[i].mask | modifiers[j],
+ c->win, False, BUTTONMASK, GrabModeAsync, GrabModeSync,
+ None, None);
+ }
+}
+
+void grabkeys(void) {
+ updatenumlockmask();
+ {
+ unsigned int i, j, k;
+ unsigned int modifiers[] = {0, LockMask, numlockmask,
+ numlockmask | LockMask};
+ int start, end, skip;
+ KeySym *syms;
+
+ XUngrabKey(dpy, AnyKey, AnyModifier, root);
+ XDisplayKeycodes(dpy, &start, &end);
+ syms = XGetKeyboardMapping(dpy, start, end - start + 1, &skip);
+ if (!syms)
+ return;
+ for (k = start; k <= end; k++)
+ for (i = 0; i < LENGTH(keys); i++)
+ /* skip modifier codes, we do that ourselves */
+ if (keys[i].keysym == syms[(k - start) * skip])
+ for (j = 0; j < LENGTH(modifiers); j++)
+ XGrabKey(dpy, k, keys[i].mod | modifiers[j], root, True,
+ GrabModeAsync, GrabModeAsync);
+ XFree(syms);
+ }
+}
+
+void incnmaster(const Arg *arg) {
+ selmon->nmaster = MAX(selmon->nmaster + arg->i, 0);
+ arrange(selmon);
+}
+
+#ifdef XINERAMA
+static int isuniquegeom(XineramaScreenInfo *unique, size_t n,
+ XineramaScreenInfo *info) {
+ while (n--)
+ if (unique[n].x_org == info->x_org && unique[n].y_org == info->y_org &&
+ unique[n].width == info->width && unique[n].height == info->height)
+ return 0;
+ return 1;
+}
+#endif /* XINERAMA */
+
+void keypress(XEvent *e) {
+ unsigned int i;
+ KeySym keysym;
+ XKeyEvent *ev;
+
+ ev = &e->xkey;
+ keysym = XKeycodeToKeysym(dpy, (KeyCode)ev->keycode, 0);
+ for (i = 0; i < LENGTH(keys); i++)
+ if (keysym == keys[i].keysym &&
+ CLEANMASK(keys[i].mod) == CLEANMASK(ev->state) && keys[i].func)
+ keys[i].func(&(keys[i].arg));
+}
+
+void killclient(const Arg *arg) {
+ if (!selmon->sel)
+ return;
+ if (!sendevent(selmon->sel->win, wmatom[WMDelete], NoEventMask,
+ wmatom[WMDelete], CurrentTime, 0, 0, 0)) {
+ XGrabServer(dpy);
+ XSetErrorHandler(xerrordummy);
+ XSetCloseDownMode(dpy, DestroyAll);
+ XKillClient(dpy, selmon->sel->win);
+ XSync(dpy, False);
+ XSetErrorHandler(xerror);
+ XUngrabServer(dpy);
+ }
+}
+
+void loadxrdb() {
+ Display *display;
+ char *resm;
+ XrmDatabase xrdb;
+ char *type;
+ XrmValue value;
+
+ display = XOpenDisplay(NULL);
+
+ if (display != NULL) {
+ resm = XResourceManagerString(display);
+
+ if (resm != NULL) {
+ xrdb = XrmGetStringDatabase(resm);
+
+ if (xrdb != NULL) {
+ XRDB_LOAD_COLOR("dwm.normbordercolor", normbordercolor);
+ XRDB_LOAD_COLOR("dwm.normbgcolor", normbgcolor);
+ XRDB_LOAD_COLOR("dwm.normfgcolor", normfgcolor);
+ XRDB_LOAD_COLOR("dwm.selbordercolor", selbordercolor);
+ XRDB_LOAD_COLOR("dwm.selbgcolor", selbgcolor);
+ XRDB_LOAD_COLOR("dwm.selfgcolor", selfgcolor);
+ }
+ }
+ }
+
+ XCloseDisplay(display);
+}
+
+void manage(Window w, XWindowAttributes *wa) {
+ Client *c, *t = NULL;
+ Window trans = None;
+ XWindowChanges wc;
+
+ c = ecalloc(1, sizeof(Client));
+ c->win = w;
+ /* geometry */
+ c->x = c->oldx = wa->x;
+ c->y = c->oldy = wa->y;
+ c->w = c->oldw = wa->width;
+ c->h = c->oldh = wa->height;
+ c->oldbw = wa->border_width;
+
+ updateicon(c);
+ updatetitle(c);
+ if (XGetTransientForHint(dpy, w, &trans) && (t = wintoclient(trans))) {
+ c->mon = t->mon;
+ c->tags = t->tags;
+ } else {
+ c->mon = selmon;
+ applyrules(c);
+ }
+
+ if (c->x + WIDTH(c) > c->mon->wx + c->mon->ww)
+ c->x = c->mon->wx + c->mon->ww - WIDTH(c);
+ if (c->y + HEIGHT(c) > c->mon->wy + c->mon->wh)
+ c->y = c->mon->wy + c->mon->wh - HEIGHT(c);
+ c->x = MAX(c->x, c->mon->wx);
+ c->y = MAX(c->y, c->mon->wy);
+ c->bw = borderpx;
+
+ wc.border_width = c->bw;
+ XConfigureWindow(dpy, w, CWBorderWidth, &wc);
+ XSetWindowBorder(dpy, w, scheme[SchemeNorm][ColBorder].pixel);
+ configure(c); /* propagates border_width, if size doesn't change */
+ updatewindowtype(c);
+ updatesizehints(c);
+ updatewmhints(c);
+ XSelectInput(dpy, w,
+ EnterWindowMask | FocusChangeMask | PropertyChangeMask |
+ StructureNotifyMask);
+ grabbuttons(c, 0);
+ if (!c->isfloating)
+ c->isfloating = c->oldstate = trans != None || c->isfixed;
+ if (c->isfloating)
+ XRaiseWindow(dpy, c->win);
+ attach(c);
+ attachstack(c);
+ XChangeProperty(dpy, root, netatom[NetClientList], XA_WINDOW, 32,
+ PropModeAppend, (unsigned char *)&(c->win), 1);
+ XMoveResizeWindow(dpy, c->win, c->x + 2 * sw, c->y, c->w,
+ c->h); /* some windows require this */
+ setclientstate(c, NormalState);
+ if (c->mon == selmon)
+ unfocus(selmon->sel, 0);
+ c->mon->sel = c;
+ arrange(c->mon);
+ XMapWindow(dpy, c->win);
+ focus(NULL);
+}
+
+void mappingnotify(XEvent *e) {
+ XMappingEvent *ev = &e->xmapping;
+
+ XRefreshKeyboardMapping(ev);
+ if (ev->request == MappingKeyboard)
+ grabkeys();
+}
+
+void maprequest(XEvent *e) {
+ static XWindowAttributes wa;
+ XMapRequestEvent *ev = &e->xmaprequest;
+
+ Client *i;
+ if (showsystray && (i = wintosystrayicon(ev->window))) {
+ sendevent(i->win, netatom[Xembed], StructureNotifyMask, CurrentTime,
+ XEMBED_WINDOW_ACTIVATE, 0, systray->win, XEMBED_EMBEDDED_VERSION);
+ updatesystray(1);
+ }
+
+ if (!XGetWindowAttributes(dpy, ev->window, &wa) || wa.override_redirect)
+ return;
+ if (!wintoclient(ev->window))
+ manage(ev->window, &wa);
+}
+
+void monocle(Monitor *m) {
+ unsigned int n = 0;
+ Client *c;
+
+ for (c = m->clients; c; c = c->next)
+ if (ISVISIBLE(c))
+ n++;
+ if (n > 0) /* override layout symbol */
+ snprintf(m->ltsymbol, sizeof m->ltsymbol, "[%d]", n);
+ for (c = nexttiled(m->clients); c; c = nexttiled(c->next))
+ resize(c, m->wx, m->wy, m->ww - 2 * c->bw, m->wh - 2 * c->bw, 0);
+}
+
+void motionnotify(XEvent *e) {
+ static Monitor *mon = NULL;
+ Monitor *m;
+ XMotionEvent *ev = &e->xmotion;
+
+ if (ev->window != root)
+ return;
+ if ((m = recttomon(ev->x_root, ev->y_root, 1, 1)) != mon && mon) {
+ unfocus(selmon->sel, 1);
+ selmon = m;
+ focus(NULL);
+ }
+ mon = m;
+}
+
+void movemouse(const Arg *arg) {
+ int x, y, ocx, ocy, nx, ny;
+ Client *c;
+ Monitor *m;
+ XEvent ev;
+ Time lasttime = 0;
+
+ if (!(c = selmon->sel))
+ return;
+ if (c->isfullscreen) /* no support moving fullscreen windows by mouse */
+ return;
+ restack(selmon);
+ ocx = c->x;
+ ocy = c->y;
+ if (XGrabPointer(dpy, root, False, MOUSEMASK, GrabModeAsync, GrabModeAsync,
+ None, cursor[CurMove]->cursor, CurrentTime) != GrabSuccess)
+ return;
+ if (!getrootptr(&x, &y))
+ return;
+ do {
+ XMaskEvent(dpy, MOUSEMASK | ExposureMask | SubstructureRedirectMask, &ev);
+ switch (ev.type) {
+ case ConfigureRequest:
+ case Expose:
+ case MapRequest:
+ handler[ev.type](&ev);
+ break;
+ case MotionNotify:
+ if ((ev.xmotion.time - lasttime) <= (1000 / 60))
+ continue;
+ lasttime = ev.xmotion.time;
+
+ nx = ocx + (ev.xmotion.x - x);
+ ny = ocy + (ev.xmotion.y - y);
+ if (abs(selmon->wx - nx) < snap)
+ nx = selmon->wx;
+ else if (abs((selmon->wx + selmon->ww) - (nx + WIDTH(c))) < snap)
+ nx = selmon->wx + selmon->ww - WIDTH(c);
+ if (abs(selmon->wy - ny) < snap)
+ ny = selmon->wy;
+ else if (abs((selmon->wy + selmon->wh) - (ny + HEIGHT(c))) < snap)
+ ny = selmon->wy + selmon->wh - HEIGHT(c);
+ if (!c->isfloating && selmon->lt[selmon->sellt]->arrange &&
+ (abs(nx - c->x) > snap || abs(ny - c->y) > snap))
+ togglefloating(NULL);
+ if (!selmon->lt[selmon->sellt]->arrange || c->isfloating)
+ resize(c, nx, ny, c->w, c->h, 1);
+ break;
+ }
+ } while (ev.type != ButtonRelease);
+ XUngrabPointer(dpy, CurrentTime);
+ if ((m = recttomon(c->x, c->y, c->w, c->h)) != selmon) {
+ sendmon(c, m);
+ selmon = m;
+ focus(NULL);
+ }
+}
+
+Client *nexttiled(Client *c) {
+ for (; c && (c->isfloating || !ISVISIBLE(c)); c = c->next)
+ ;
+ return c;
+}
+
+void pop(Client *c) {
+ detach(c);
+ attach(c);
+ focus(c);
+ arrange(c->mon);
+}
+
+void propertynotify(XEvent *e) {
+ Client *c;
+ Window trans;
+ XPropertyEvent *ev = &e->xproperty;
+
+ if (showsystray && (c = wintosystrayicon(ev->window))) {
+ if (ev->atom == XA_WM_NORMAL_HINTS) {
+ updatesizehints(c);
+ updatesystrayicongeom(c, c->w, c->h);
+ } else
+ updatesystrayiconstate(c, ev);
+ updatesystray(1);
+ }
+
+ if ((ev->window == root) && (ev->atom == XA_WM_NAME))
+ updatestatus();
+ else if (ev->state == PropertyDelete)
+ return; /* ignore */
+ else if ((c = wintoclient(ev->window))) {
+ switch (ev->atom) {
+ default:
+ break;
+ case XA_WM_TRANSIENT_FOR:
+ if (!c->isfloating && (XGetTransientForHint(dpy, c->win, &trans)) &&
+ (c->isfloating = (wintoclient(trans)) != NULL))
+ arrange(c->mon);
+ break;
+ case XA_WM_NORMAL_HINTS:
+ c->hintsvalid = 0;
+ break;
+ case XA_WM_HINTS:
+ updatewmhints(c);
+ drawbars();
+ break;
+ }
+ if (ev->atom == XA_WM_NAME || ev->atom == netatom[NetWMName]) {
+ updatetitle(c);
+ if (c == c->mon->sel)
+ drawbar(c->mon);
+ } else if (ev->atom == netatom[NetWMIcon]) {
+ updateicon(c);
+ if (c == c->mon->sel)
+ drawbar(c->mon);
+ }
+ if (ev->atom == netatom[NetWMWindowType])
+ updatewindowtype(c);
+ }
+}
+
+void quit(const Arg *arg) {
+ if (arg->i)
+ restart = 1;
+ running = 0;
+}
+
+Monitor *recttomon(int x, int y, int w, int h) {
+ Monitor *m, *r = selmon;
+ int a, area = 0;
+
+ for (m = mons; m; m = m->next)
+ if ((a = INTERSECT(x, y, w, h, m)) > area) {
+ area = a;
+ r = m;
+ }
+ return r;
+}
+
+void removesystrayicon(Client *i) {
+ Client **ii;
+
+ if (!showsystray || !i)
+ return;
+ for (ii = &systray->icons; *ii && *ii != i; ii = &(*ii)->next)
+ ;
+ if (ii)
+ *ii = i->next;
+ free(i);
+}
+
+void resize(Client *c, int x, int y, int w, int h, int interact) {
+ if (applysizehints(c, &x, &y, &w, &h, interact))
+ resizeclient(c, x, y, w, h);
+}
+
+void resizeclient(Client *c, int x, int y, int w, int h) {
+ XWindowChanges wc;
+ unsigned int n;
+ unsigned int gapoffset;
+ unsigned int gapincr;
+ Client *nbc;
+
+ wc.border_width = c->bw;
+
+ /* Get number of clients for the client's monitor */
+ for (n = 0, nbc = nexttiled(c->mon->clients); nbc;
+ nbc = nexttiled(nbc->next), n++)
+ ;
+
+ /* Do nothing if layout is floating */
+ if (c->isfloating || c->mon->lt[c->mon->sellt]->arrange == NULL) {
+ gapincr = gapoffset = 0;
+ } else {
+ /* Remove border and gap if layout is monocle or only one client */
+ if (c->mon->lt[c->mon->sellt]->arrange == monocle || n == 1) {
+ gapoffset = 0;
+ gapincr = -2 * borderpx;
+ wc.border_width = 0;
+ } else {
+ gapoffset = gappx;
+ gapincr = 2 * gappx;
+ }
+ }
+
+ c->oldx = c->x;
+ c->x = wc.x = x + gapoffset;
+ c->oldy = c->y;
+ c->y = wc.y = y + gapoffset;
+ c->oldw = c->w;
+ c->w = wc.width = w - gapincr;
+ c->oldh = c->h;
+ c->h = wc.height = h - gapincr;
+
+ XConfigureWindow(dpy, c->win, CWX | CWY | CWWidth | CWHeight | CWBorderWidth,
+ &wc);
+ configure(c);
+ XSync(dpy, False);
+}
+
+void resizemouse(const Arg *arg) {
+ int ocx, ocy, nw, nh;
+ Client *c;
+ Monitor *m;
+ XEvent ev;
+ Time lasttime = 0;
+
+ if (!(c = selmon->sel))
+ return;
+ if (c->isfullscreen) /* no support resizing fullscreen windows by mouse */
+ return;
+ restack(selmon);
+ ocx = c->x;
+ ocy = c->y;
+ if (XGrabPointer(dpy, root, False, MOUSEMASK, GrabModeAsync, GrabModeAsync,
+ None, cursor[CurResize]->cursor, CurrentTime) != GrabSuccess)
+ return;
+ XWarpPointer(dpy, None, c->win, 0, 0, 0, 0, c->w + c->bw - 1,
+ c->h + c->bw - 1);
+ do {
+ XMaskEvent(dpy, MOUSEMASK | ExposureMask | SubstructureRedirectMask, &ev);
+ switch (ev.type) {
+ case ConfigureRequest:
+ case Expose:
+ case MapRequest:
+ handler[ev.type](&ev);
+ break;
+ case MotionNotify:
+ if ((ev.xmotion.time - lasttime) <= (1000 / 60))
+ continue;
+ lasttime = ev.xmotion.time;
+
+ nw = MAX(ev.xmotion.x - ocx - 2 * c->bw + 1, 1);
+ nh = MAX(ev.xmotion.y - ocy - 2 * c->bw + 1, 1);
+ if (c->mon->wx + nw >= selmon->wx &&
+ c->mon->wx + nw <= selmon->wx + selmon->ww &&
+ c->mon->wy + nh >= selmon->wy &&
+ c->mon->wy + nh <= selmon->wy + selmon->wh) {
+ if (!c->isfloating && selmon->lt[selmon->sellt]->arrange &&
+ (abs(nw - c->w) > snap || abs(nh - c->h) > snap))
+ togglefloating(NULL);
+ }
+ if (!selmon->lt[selmon->sellt]->arrange || c->isfloating)
+ resize(c, c->x, c->y, nw, nh, 1);
+ break;
+ }
+ } while (ev.type != ButtonRelease);
+ XWarpPointer(dpy, None, c->win, 0, 0, 0, 0, c->w + c->bw - 1,
+ c->h + c->bw - 1);
+ XUngrabPointer(dpy, CurrentTime);
+ while (XCheckMaskEvent(dpy, EnterWindowMask, &ev))
+ ;
+ if ((m = recttomon(c->x, c->y, c->w, c->h)) != selmon) {
+ sendmon(c, m);
+ selmon = m;
+ focus(NULL);
+ }
+}
+
+void resizerequest(XEvent *e) {
+ XResizeRequestEvent *ev = &e->xresizerequest;
+ Client *i;
+
+ if ((i = wintosystrayicon(ev->window))) {
+ updatesystrayicongeom(i, ev->width, ev->height);
+ updatesystray(1);
+ }
+}
+
+void restack(Monitor *m) {
+ Client *c;
+ XEvent ev;
+ XWindowChanges wc;
+
+ drawbar(m);
+ if (!m->sel)
+ return;
+ if (m->sel->isfloating || !m->lt[m->sellt]->arrange)
+ XRaiseWindow(dpy, m->sel->win);
+ if (m->lt[m->sellt]->arrange) {
+ wc.stack_mode = Below;
+ wc.sibling = m->barwin;
+ for (c = m->stack; c; c = c->snext)
+ if (!c->isfloating && ISVISIBLE(c)) {
+ XConfigureWindow(dpy, c->win, CWSibling | CWStackMode, &wc);
+ wc.sibling = c->win;
+ }
+ }
+ XSync(dpy, False);
+ while (XCheckMaskEvent(dpy, EnterWindowMask, &ev))
+ ;
+}
+
+void run(void) {
+ XEvent ev;
+ /* main event loop */
+ XSync(dpy, False);
+ while (running && !XNextEvent(dpy, &ev))
+ if (handler[ev.type])
+ handler[ev.type](&ev); /* call handler */
+}
+
+void runautostart(void) {
+ char *pathpfx;
+ char *path;
+ char *xdgdatahome;
+ char *home;
+ struct stat sb;
+
+ if ((home = getenv("HOME")) == NULL)
+ /* this is almost impossible */
+ return;
+
+ /* if $XDG_DATA_HOME is set and not empty, use $XDG_DATA_HOME/dwm,
+ * otherwise use ~/.local/share/birdwm as autostart script directory
+ */
+ xdgdatahome = getenv("XDG_DATA_HOME");
+ if (xdgdatahome != NULL && *xdgdatahome != '\0') {
+ /* space for path segments, separators and nul */
+ pathpfx = ecalloc(1, strlen(xdgdatahome) + strlen(dwmdir) + 2);
+
+ if (sprintf(pathpfx, "%s/%s", xdgdatahome, dwmdir) <= 0) {
+ free(pathpfx);
+ return;
+ }
+ } else {
+ /* space for path segments, separators and nul */
+ pathpfx =
+ ecalloc(1, strlen(home) + strlen(localshare) + strlen(dwmdir) + 3);
+
+ if (sprintf(pathpfx, "%s/%s/%s", home, localshare, dwmdir) < 0) {
+ free(pathpfx);
+ return;
+ }
+ }
+
+ /* check if the autostart script directory exists */
+ if (!(stat(pathpfx, &sb) == 0 && S_ISDIR(sb.st_mode))) {
+ /* the XDG conformant path does not exist or is no directory
+ * so we try ~/.dwm instead
+ */
+ char *pathpfx_new = realloc(pathpfx, strlen(home) + strlen(dwmdir) + 3);
+ if (pathpfx_new == NULL) {
+ free(pathpfx);
+ return;
+ }
+ pathpfx = pathpfx_new;
+
+ if (sprintf(pathpfx, "%s/.local/share/%s", home, dwmdir) <= 0) {
+ free(pathpfx);
+ return;
+ }
+ }
+
+ /* try the blocking script first */
+ path = ecalloc(1, strlen(pathpfx) + strlen(autostartblocksh) + 2);
+ if (sprintf(path, "%s/%s", pathpfx, autostartblocksh) <= 0) {
+ free(path);
+ free(pathpfx);
+ }
+
+ if (access(path, X_OK) == 0)
+ system(path);
+
+ /* now the non-blocking script */
+ if (sprintf(path, "%s/%s", pathpfx, autostartsh) <= 0) {
+ free(path);
+ free(pathpfx);
+ }
+
+ if (access(path, X_OK) == 0)
+ system(strcat(path, " &"));
+
+ free(pathpfx);
+ free(path);
+}
+
+void scan(void) {
+ unsigned int i, num;
+ Window d1, d2, *wins = NULL;
+ XWindowAttributes wa;
+
+ if (XQueryTree(dpy, root, &d1, &d2, &wins, &num)) {
+ for (i = 0; i < num; i++) {
+ if (!XGetWindowAttributes(dpy, wins[i], &wa) || wa.override_redirect ||
+ XGetTransientForHint(dpy, wins[i], &d1))
+ continue;
+ if (wa.map_state == IsViewable || getstate(wins[i]) == IconicState)
+ manage(wins[i], &wa);
+ }
+ for (i = 0; i < num; i++) { /* now the transients */
+ if (!XGetWindowAttributes(dpy, wins[i], &wa))
+ continue;
+ if (XGetTransientForHint(dpy, wins[i], &d1) &&
+ (wa.map_state == IsViewable || getstate(wins[i]) == IconicState))
+ manage(wins[i], &wa);
+ }
+ if (wins)
+ XFree(wins);
+ }
+}
+
+void sendmon(Client *c, Monitor *m) {
+ if (c->mon == m)
+ return;
+ unfocus(c, 1);
+ detach(c);
+ detachstack(c);
+ c->mon = m;
+ c->tags = m->tagset[m->seltags]; /* assign tags of target monitor */
+ attach(c);
+ attachstack(c);
+ focus(NULL);
+ arrange(NULL);
+}
+
+void setclientstate(Client *c, long state) {
+ long data[] = {state, None};
+
+ XChangeProperty(dpy, c->win, wmatom[WMState], wmatom[WMState], 32,
+ PropModeReplace, (unsigned char *)data, 2);
+}
+
+int sendevent(Window w, Atom proto, int mask, long d0, long d1, long d2,
+ long d3, long d4) {
+ int n;
+ Atom *protocols, mt;
+ int exists = 0;
+ XEvent ev;
+
+ if (proto == wmatom[WMTakeFocus] || proto == wmatom[WMDelete]) {
+ mt = wmatom[WMProtocols];
+ if (XGetWMProtocols(dpy, w, &protocols, &n)) {
+ while (!exists && n--)
+ exists = protocols[n] == proto;
+ XFree(protocols);
+ }
+ } else {
+ exists = True;
+ mt = proto;
+ }
+ if (exists) {
+ ev.type = ClientMessage;
+ ev.xclient.window = w;
+ ev.xclient.message_type = mt;
+ ev.xclient.format = 32;
+ ev.xclient.data.l[0] = d0;
+ ev.xclient.data.l[1] = d1;
+ ev.xclient.data.l[2] = d2;
+ ev.xclient.data.l[3] = d3;
+ ev.xclient.data.l[4] = d4;
+ XSendEvent(dpy, w, False, mask, &ev);
+ }
+ return exists;
+}
+
+void setfocus(Client *c) {
+ if (!c->neverfocus) {
+ XSetInputFocus(dpy, c->win, RevertToPointerRoot, CurrentTime);
+ XChangeProperty(dpy, root, netatom[NetActiveWindow], XA_WINDOW, 32,
+ PropModeReplace, (unsigned char *)&(c->win), 1);
+ }
+ sendevent(c->win, wmatom[WMTakeFocus], NoEventMask, wmatom[WMTakeFocus],
+ CurrentTime, 0, 0, 0);
+}
+
+void setfullscreen(Client *c, int fullscreen) {
+ if (fullscreen && !c->isfullscreen) {
+ XChangeProperty(dpy, c->win, netatom[NetWMState], XA_ATOM, 32,
+ PropModeReplace, (unsigned char *)&netatom[NetWMFullscreen],
+ 1);
+ c->isfullscreen = 1;
+ c->oldstate = c->isfloating;
+ c->oldbw = c->bw;
+ c->bw = 0;
+ c->isfloating = 1;
+ resizeclient(c, c->mon->mx, c->mon->my, c->mon->mw, c->mon->mh);
+ XRaiseWindow(dpy, c->win);
+ } else if (!fullscreen && c->isfullscreen) {
+ XChangeProperty(dpy, c->win, netatom[NetWMState], XA_ATOM, 32,
+ PropModeReplace, (unsigned char *)0, 0);
+ c->isfullscreen = 0;
+ c->isfloating = c->oldstate;
+ c->bw = c->oldbw;
+ c->x = c->oldx;
+ c->y = c->oldy;
+ c->w = c->oldw;
+ c->h = c->oldh;
+ resizeclient(c, c->x, c->y, c->w, c->h);
+ arrange(c->mon);
+ }
+}
+
+void setlayout(const Arg *arg) {
+ if (!arg || !arg->v || arg->v != selmon->lt[selmon->sellt])
+ selmon->sellt ^= 1;
+ if (arg && arg->v)
+ selmon->lt[selmon->sellt] = (Layout *)arg->v;
+ strncpy(selmon->ltsymbol, selmon->lt[selmon->sellt]->symbol,
+ sizeof selmon->ltsymbol);
+ if (selmon->sel)
+ arrange(selmon);
+ else
+ drawbar(selmon);
+}
+
+/* arg > 1.0 will set mfact absolutely */
+void setmfact(const Arg *arg) {
+ float f;
+
+ if (!arg || !selmon->lt[selmon->sellt]->arrange)
+ return;
+ f = arg->f < 1.0 ? arg->f + selmon->mfact : arg->f - 1.0;
+ if (f < 0.05 || f > 0.95)
+ return;
+ selmon->mfact = f;
+ arrange(selmon);
+}
+
+void setup(void) {
+ int i;
+ XSetWindowAttributes wa;
+ Atom utf8string;
+ struct sigaction sa;
+
+ /* do not transform children into zombies when they terminate */
+ sigemptyset(&sa.sa_mask);
+ sa.sa_flags = SA_NOCLDSTOP | SA_NOCLDWAIT | SA_RESTART;
+ sa.sa_handler = SIG_IGN;
+ sigaction(SIGCHLD, &sa, NULL);
+
+ /* clean up any zombies (inherited from .xinitrc etc) immediately */
+ while (waitpid(-1, NULL, WNOHANG) > 0)
+ ;
+
+ signal(SIGHUP, sighup);
+ signal(SIGTERM, sigterm);
+
+ /* init screen */
+ screen = DefaultScreen(dpy);
+ sw = DisplayWidth(dpy, screen);
+ sh = DisplayHeight(dpy, screen);
+ root = RootWindow(dpy, screen);
+ xinitvisual();
+ drw = drw_create(dpy, screen, root, sw, sh, visual, depth, cmap);
+ if (!drw_fontset_create(drw, fonts, LENGTH(fonts)))
+ die("no fonts could be loaded.");
+ lrpad = drw->fonts->h;
+ bh = drw->fonts->h + 2;
+ updategeom();
+ /* init atoms */
+ utf8string = XInternAtom(dpy, "UTF8_STRING", False);
+ wmatom[WMProtocols] = XInternAtom(dpy, "WM_PROTOCOLS", False);
+ wmatom[WMDelete] = XInternAtom(dpy, "WM_DELETE_WINDOW", False);
+ wmatom[WMState] = XInternAtom(dpy, "WM_STATE", False);
+ wmatom[WMTakeFocus] = XInternAtom(dpy, "WM_TAKE_FOCUS", False);
+ netatom[NetActiveWindow] = XInternAtom(dpy, "_NET_ACTIVE_WINDOW", False);
+ netatom[NetSupported] = XInternAtom(dpy, "_NET_SUPPORTED", False);
+ netatom[NetSystemTray] = XInternAtom(dpy, "_NET_SYSTEM_TRAY_S0", False);
+ netatom[NetSystemTrayOP] = XInternAtom(dpy, "_NET_SYSTEM_TRAY_OPCODE", False);
+ netatom[NetSystemTrayOrientation] =
+ XInternAtom(dpy, "_NET_SYSTEM_TRAY_ORIENTATION", False);
+ netatom[NetSystemTrayOrientationHorz] =
+ XInternAtom(dpy, "_NET_SYSTEM_TRAY_ORIENTATION_HORZ", False);
+ netatom[NetSystemTrayVisual] =
+ XInternAtom(dpy, "_NET_SYSTEM_TRAY_VISUAL", False);
+ netatom[NetWMName] = XInternAtom(dpy, "_NET_WM_NAME", False);
+ netatom[NetWMIcon] = XInternAtom(dpy, "_NET_WM_ICON", False);
+ netatom[NetWMState] = XInternAtom(dpy, "_NET_WM_STATE", False);
+ netatom[NetWMCheck] = XInternAtom(dpy, "_NET_SUPPORTING_WM_CHECK", False);
+ netatom[NetWMFullscreen] =
+ XInternAtom(dpy, "_NET_WM_STATE_FULLSCREEN", False);
+ netatom[NetWMWindowType] = XInternAtom(dpy, "_NET_WM_WINDOW_TYPE", False);
+ netatom[NetWMWindowTypeDock] =
+ XInternAtom(dpy, "_NET_WM_WINDOW_TYPE_DOCK", False);
+ netatom[NetWMWindowTypeDialog] =
+ XInternAtom(dpy, "_NET_WM_WINDOW_TYPE_DIALOG", False);
+ netatom[NetClientList] = XInternAtom(dpy, "_NET_CLIENT_LIST", False);
+ xatom[Manager] = XInternAtom(dpy, "MANAGER", False);
+ xatom[Xembed] = XInternAtom(dpy, "_XEMBED", False);
+ xatom[XembedInfo] = XInternAtom(dpy, "_XEMBED_INFO", False);
+ /* init cursors */
+ cursor[CurNormal] = drw_cur_create(drw, XC_left_ptr);
+ cursor[CurResize] = drw_cur_create(drw, XC_sizing);
+ cursor[CurMove] = drw_cur_create(drw, XC_fleur);
+ /* init appearance */
+ scheme = ecalloc(LENGTH(colors), sizeof(Clr *));
+ for (i = 0; i < LENGTH(colors); i++)
+ scheme[i] = drw_scm_create(drw, colors[i], alphas[i], 3);
+ /* init system tray */
+ if (showsystray)
+ updatesystray(0);
+ /* init bars */
+ updatebars();
+ updatestatus();
+ /* supporting window for NetWMCheck */
+ wmcheckwin = XCreateSimpleWindow(dpy, root, 0, 0, 1, 1, 0, 0, 0);
+ XChangeProperty(dpy, wmcheckwin, netatom[NetWMCheck], XA_WINDOW, 32,
+ PropModeReplace, (unsigned char *)&wmcheckwin, 1);
+ XChangeProperty(dpy, wmcheckwin, netatom[NetWMName], utf8string, 8,
+ PropModeReplace, (unsigned char *)"dwm", 3);
+ XChangeProperty(dpy, root, netatom[NetWMCheck], XA_WINDOW, 32,
+ PropModeReplace, (unsigned char *)&wmcheckwin, 1);
+ /* EWMH support per view */
+ XChangeProperty(dpy, root, netatom[NetSupported], XA_ATOM, 32,
+ PropModeReplace, (unsigned char *)netatom, NetLast);
+ XDeleteProperty(dpy, root, netatom[NetClientList]);
+ /* select events */
+ wa.cursor = cursor[CurNormal]->cursor;
+ wa.event_mask = SubstructureRedirectMask | SubstructureNotifyMask |
+ ButtonPressMask | PointerMotionMask | EnterWindowMask |
+ LeaveWindowMask | StructureNotifyMask | PropertyChangeMask;
+ XChangeWindowAttributes(dpy, root, CWEventMask | CWCursor, &wa);
+ XSelectInput(dpy, root, wa.event_mask);
+ grabkeys();
+ focus(NULL);
+}
+
+void seturgent(Client *c, int urg) {
+ XWMHints *wmh;
+
+ c->isurgent = urg;
+ if (!(wmh = XGetWMHints(dpy, c->win)))
+ return;
+ wmh->flags = urg ? (wmh->flags | XUrgencyHint) : (wmh->flags & ~XUrgencyHint);
+ XSetWMHints(dpy, c->win, wmh);
+ XFree(wmh);
+}
+
+void showhide(Client *c) {
+ if (!c)
+ return;
+ if (ISVISIBLE(c)) {
+ if ((c->tags & SPTAGMASK) && c->isfloating) {
+ c->x = c->mon->wx + (c->mon->ww / 2 - WIDTH(c) / 2);
+ c->y = c->mon->wy + (c->mon->wh / 2 - HEIGHT(c) / 2);
+ }
+ /* show clients top down */
+ XMoveWindow(dpy, c->win, c->x, c->y);
+ if ((!c->mon->lt[c->mon->sellt]->arrange || c->isfloating) &&
+ !c->isfullscreen)
+ resize(c, c->x, c->y, c->w, c->h, 0);
+ showhide(c->snext);
+ } else {
+ /* hide clients bottom up */
+ showhide(c->snext);
+ XMoveWindow(dpy, c->win, WIDTH(c) * -2, c->y);
+ }
+}
+
+void sighup(int unused) {
+ Arg a = {.i = 1};
+ quit(&a);
+}
+
+void sigterm(int unused) {
+ Arg a = {.i = 0};
+ quit(&a);
+}
+
+void spawn(const Arg *arg) {
+ struct sigaction sa;
+
+ if (arg->v == dmenucmd)
+ dmenumon[0] = '0' + selmon->num;
+ if (fork() == 0) {
+ if (dpy)
+ close(ConnectionNumber(dpy));
+ setsid();
+
+ sigemptyset(&sa.sa_mask);
+ sa.sa_flags = 0;
+ sa.sa_handler = SIG_DFL;
+ sigaction(SIGCHLD, &sa, NULL);
+
+ execvp(((char **)arg->v)[0], (char **)arg->v);
+ die("birdwm: execvp '%s' failed:", ((char **)arg->v)[0]);
+ }
+}
+
+Monitor *systraytomon(Monitor *m) {
+ Monitor *t;
+ int i, n;
+ if (!systraypinning) {
+ if (!m)
+ return selmon;
+ return m == selmon ? m : NULL;
+ }
+ for (n = 1, t = mons; t && t->next; n++, t = t->next)
+ ;
+ for (i = 1, t = mons; t && t->next && i < systraypinning; i++, t = t->next)
+ ;
+ if (systraypinningfailfirst && n < systraypinning)
+ return mons;
+ return t;
+}
+
+void tag(const Arg *arg) {
+ if (selmon->sel && arg->ui & TAGMASK) {
+ selmon->sel->tags = arg->ui & TAGMASK;
+ focus(NULL);
+ arrange(selmon);
+ }
+}
+
+void tagmon(const Arg *arg) {
+ if (!selmon->sel || !mons->next)
+ return;
+ sendmon(selmon->sel, dirtomon(arg->i));
+}
+
+void tile(Monitor *m) {
+ unsigned int i, n, h, mw, my, ty;
+ Client *c;
+
+ 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) + (n > 1 ? gappx : 0),
+ 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);
+ }
+}
+
+void togglebar(const Arg *arg) {
+ selmon->showbar = !selmon->showbar;
+ updatebarpos(selmon);
+ XMoveResizeWindow(dpy, selmon->barwin, selmon->wx, selmon->by, selmon->ww,
+ bh);
+ if (showsystray) {
+ XWindowChanges wc;
+ if (!selmon->showbar)
+ wc.y = -bh;
+ else if (selmon->showbar) {
+#if BARPADDING_PATCH
+ wc.y = vp;
+ if (!selmon->topbar)
+ wc.y = selmon->mh - bh + vp;
+#else
+ wc.y = 0;
+ if (!selmon->topbar)
+ wc.y = selmon->mh - bh;
+#endif // BARPADDING_PATCH
+ }
+ XConfigureWindow(dpy, systray->win, CWY, &wc);
+ }
+ arrange(selmon);
+}
+
+void togglefloating(const Arg *arg) {
+ if (!selmon->sel)
+ return;
+ if (selmon->sel->isfullscreen) /* no support for fullscreen windows */
+ return;
+ selmon->sel->isfloating = !selmon->sel->isfloating || selmon->sel->isfixed;
+ if (selmon->sel->isfloating)
+ resize(selmon->sel, selmon->sel->x, selmon->sel->y, selmon->sel->w,
+ selmon->sel->h, 0);
+ arrange(selmon);
+}
+
+void togglescratch(const Arg *arg) {
+ Client *c;
+ unsigned int found = 0;
+ unsigned int scratchtag = SPTAG(arg->ui);
+ Arg sparg = {.v = scratchpads[arg->ui].cmd};
+
+ for (c = selmon->clients; c && !(found = c->tags & scratchtag); c = c->next)
+ ;
+ if (found) {
+ unsigned int newtagset = selmon->tagset[selmon->seltags] ^ scratchtag;
+ if (newtagset) {
+ selmon->tagset[selmon->seltags] = newtagset;
+ focus(NULL);
+ arrange(selmon);
+ }
+ if (ISVISIBLE(c)) {
+ focus(c);
+ restack(selmon);
+ }
+ } else {
+ selmon->tagset[selmon->seltags] |= scratchtag;
+ spawn(&sparg);
+ }
+}
+
+void toggletag(const Arg *arg) {
+ unsigned int newtags;
+
+ if (!selmon->sel)
+ return;
+ newtags = selmon->sel->tags ^ (arg->ui & TAGMASK);
+ if (newtags) {
+ selmon->sel->tags = newtags;
+ focus(NULL);
+ arrange(selmon);
+ }
+}
+
+void toggleview(const Arg *arg) {
+ unsigned int newtagset =
+ selmon->tagset[selmon->seltags] ^ (arg->ui & TAGMASK);
+
+ if (newtagset) {
+ selmon->tagset[selmon->seltags] = newtagset;
+ focus(NULL);
+ arrange(selmon);
+ }
+}
+
+void freeicon(Client *c) {
+ if (c->icon) {
+ XRenderFreePicture(dpy, c->icon);
+ c->icon = None;
+ }
+}
+
+void unfocus(Client *c, int setfocus) {
+ if (!c)
+ return;
+ grabbuttons(c, 0);
+ XSetWindowBorder(dpy, c->win, scheme[SchemeNorm][ColBorder].pixel);
+ if (setfocus) {
+ XSetInputFocus(dpy, root, RevertToPointerRoot, CurrentTime);
+ XDeleteProperty(dpy, root, netatom[NetActiveWindow]);
+ }
+}
+
+void unmanage(Client *c, int destroyed) {
+ Monitor *m = c->mon;
+ XWindowChanges wc;
+
+ detach(c);
+ detachstack(c);
+ freeicon(c);
+ if (!destroyed) {
+ wc.border_width = c->oldbw;
+ XGrabServer(dpy); /* avoid race conditions */
+ XSetErrorHandler(xerrordummy);
+ XSelectInput(dpy, c->win, NoEventMask);
+ XConfigureWindow(dpy, c->win, CWBorderWidth, &wc); /* restore border */
+ XUngrabButton(dpy, AnyButton, AnyModifier, c->win);
+ setclientstate(c, WithdrawnState);
+ XSync(dpy, False);
+ XSetErrorHandler(xerror);
+ XUngrabServer(dpy);
+ }
+ free(c);
+ focus(NULL);
+ updateclientlist();
+ arrange(m);
+}
+
+void unmapnotify(XEvent *e) {
+ Client *c;
+ XUnmapEvent *ev = &e->xunmap;
+
+ if ((c = wintoclient(ev->window))) {
+ if (ev->send_event)
+ setclientstate(c, WithdrawnState);
+ else
+ unmanage(c, 0);
+ } else if (showsystray && (c = wintosystrayicon(ev->window))) {
+ /* KLUDGE! sometimes icons occasionally unmap their windows, but do
+ * _not_ destroy them. We map those windows back */
+ XMapRaised(dpy, c->win);
+ updatesystray(1);
+ }
+}
+
+void updatebars(void) {
+ Monitor *m;
+ XSetWindowAttributes wa = {.override_redirect = True,
+ .background_pixel = 0,
+ .border_pixel = 0,
+ .colormap = cmap,
+ .event_mask = ButtonPressMask | ExposureMask};
+ XClassHint ch = {"dwm", "dwm"};
+ for (m = mons; m; m = m->next) {
+ if (m->barwin)
+ continue;
+ m->barwin = XCreateWindow(dpy, root, m->wx, m->by, m->ww, bh, 0, depth,
+ InputOutput, visual,
+ CWOverrideRedirect | CWBackPixel | CWBorderPixel |
+ CWColormap | CWEventMask,
+ &wa);
+ XDefineCursor(dpy, m->barwin, cursor[CurNormal]->cursor);
+ if (showsystray && m == systraytomon(m))
+ XMapRaised(dpy, systray->win);
+ XMapRaised(dpy, m->barwin);
+ XSetClassHint(dpy, m->barwin, &ch);
+ }
+}
+
+void updatebarpos(Monitor *m) {
+ m->wy = m->my;
+ m->wh = m->mh;
+ if (m->showbar) {
+ m->wh -= bh;
+ m->by = m->topbar ? m->wy : m->wy + m->wh;
+ m->wy = m->topbar ? m->wy + bh : m->wy;
+ } else
+ m->by = -bh;
+}
+
+void updateclientlist() {
+ Client *c;
+ Monitor *m;
+
+ XDeleteProperty(dpy, root, netatom[NetClientList]);
+ for (m = mons; m; m = m->next)
+ for (c = m->clients; c; c = c->next)
+ XChangeProperty(dpy, root, netatom[NetClientList], XA_WINDOW, 32,
+ PropModeAppend, (unsigned char *)&(c->win), 1);
+}
+
+int updategeom(void) {
+ int dirty = 0;
+
+#ifdef XINERAMA
+ if (XineramaIsActive(dpy)) {
+ int i, j, n, nn;
+ Client *c;
+ Monitor *m;
+ XineramaScreenInfo *info = XineramaQueryScreens(dpy, &nn);
+ XineramaScreenInfo *unique = NULL;
+
+ for (n = 0, m = mons; m; m = m->next, n++)
+ ;
+ /* only consider unique geometries as separate screens */
+ unique = ecalloc(nn, sizeof(XineramaScreenInfo));
+ for (i = 0, j = 0; i < nn; i++)
+ if (isuniquegeom(unique, j, &info[i]))
+ memcpy(&unique[j++], &info[i], sizeof(XineramaScreenInfo));
+ XFree(info);
+ nn = j;
+
+ /* new monitors if nn > n */
+ for (i = n; i < nn; i++) {
+ for (m = mons; m && m->next; m = m->next)
+ ;
+ if (m)
+ m->next = createmon();
+ else
+ mons = createmon();
+ }
+ for (i = 0, m = mons; i < nn && m; m = m->next, i++)
+ if (i >= n || unique[i].x_org != m->mx || unique[i].y_org != m->my ||
+ unique[i].width != m->mw || unique[i].height != m->mh) {
+ dirty = 1;
+ m->num = i;
+ m->mx = m->wx = unique[i].x_org;
+ m->my = m->wy = unique[i].y_org;
+ m->mw = m->ww = unique[i].width;
+ m->mh = m->wh = unique[i].height;
+ updatebarpos(m);
+ }
+ /* removed monitors if n > nn */
+ for (i = nn; i < n; i++) {
+ for (m = mons; m && m->next; m = m->next)
+ ;
+ while ((c = m->clients)) {
+ dirty = 1;
+ m->clients = c->next;
+ detachstack(c);
+ c->mon = mons;
+ attach(c);
+ attachstack(c);
+ }
+ if (m == selmon)
+ selmon = mons;
+ cleanupmon(m);
+ }
+ free(unique);
+ } else
+#endif /* XINERAMA */
+ { /* default monitor setup */
+ if (!mons)
+ mons = createmon();
+ if (mons->mw != sw || mons->mh != sh) {
+ dirty = 1;
+ mons->mw = mons->ww = sw;
+ mons->mh = mons->wh = sh;
+ updatebarpos(mons);
+ }
+ }
+ if (dirty) {
+ selmon = mons;
+ selmon = wintomon(root);
+ }
+ return dirty;
+}
+
+void updatenumlockmask(void) {
+ unsigned int i, j;
+ XModifierKeymap *modmap;
+
+ numlockmask = 0;
+ modmap = XGetModifierMapping(dpy);
+ for (i = 0; i < 8; i++)
+ for (j = 0; j < modmap->max_keypermod; j++)
+ if (modmap->modifiermap[i * modmap->max_keypermod + j] ==
+ XKeysymToKeycode(dpy, XK_Num_Lock))
+ numlockmask = (1 << i);
+ XFreeModifiermap(modmap);
+}
+
+void updatesizehints(Client *c) {
+ long msize;
+ XSizeHints size;
+
+ if (!XGetWMNormalHints(dpy, c->win, &size, &msize))
+ /* size is uninitialized, ensure that size.flags aren't used */
+ size.flags = PSize;
+ if (size.flags & PBaseSize) {
+ c->basew = size.base_width;
+ c->baseh = size.base_height;
+ } else if (size.flags & PMinSize) {
+ c->basew = size.min_width;
+ c->baseh = size.min_height;
+ } else
+ c->basew = c->baseh = 0;
+ if (size.flags & PResizeInc) {
+ c->incw = size.width_inc;
+ c->inch = size.height_inc;
+ } else
+ c->incw = c->inch = 0;
+ if (size.flags & PMaxSize) {
+ c->maxw = size.max_width;
+ c->maxh = size.max_height;
+ } else
+ c->maxw = c->maxh = 0;
+ if (size.flags & PMinSize) {
+ c->minw = size.min_width;
+ c->minh = size.min_height;
+ } else if (size.flags & PBaseSize) {
+ c->minw = size.base_width;
+ c->minh = size.base_height;
+ } else
+ c->minw = c->minh = 0;
+ if (size.flags & PAspect) {
+ c->mina = (float)size.min_aspect.y / size.min_aspect.x;
+ c->maxa = (float)size.max_aspect.x / size.max_aspect.y;
+ } else
+ c->maxa = c->mina = 0.0;
+ c->isfixed = (c->maxw && c->maxh && c->maxw == c->minw && c->maxh == c->minh);
+ c->hintsvalid = 1;
+}
+
+void updatestatus(void) {
+ if (!gettextprop(root, XA_WM_NAME, stext, sizeof(stext)))
+ strcpy(stext, "dwm-" VERSION);
+ drawbar(selmon);
+}
+
+void updatesystray(int updatebar) {
+ XSetWindowAttributes wa;
+ XWindowChanges wc;
+ Client *i;
+ Monitor *m = systraytomon(NULL);
+ unsigned int x = m->mx + m->mw;
+ unsigned int w = 1, xpad = 0, ypad = 0;
+#if BARPADDING_PATCH
+ xpad = sp;
+ ypad = vp;
+#endif // BARPADDING_PATCH
+
+ if (!showsystray)
+ return;
+ if (!systray) {
+ /* init systray */
+ if (!(systray = (Systray *)calloc(1, sizeof(Systray))))
+ die("fatal: could not malloc() %u bytes\n", sizeof(Systray));
+
+ wa.override_redirect = True;
+ wa.event_mask = ButtonPressMask | ExposureMask;
+ wa.background_pixel = 0;
+ wa.border_pixel = 0;
+ wa.colormap = cmap;
+ systray->win = XCreateWindow(dpy, root, x - xpad, m->by + ypad, w, bh, 0,
+ depth, InputOutput, visual,
+ CWOverrideRedirect | CWBackPixel |
+ CWBorderPixel | CWColormap | CWEventMask,
+ &wa);
+ XSelectInput(dpy, systray->win, SubstructureNotifyMask);
+ XChangeProperty(dpy, systray->win, netatom[NetSystemTrayOrientation],
+ XA_CARDINAL, 32, PropModeReplace,
+ (unsigned char *)&systrayorientation, 1);
+ XChangeProperty(dpy, systray->win, netatom[NetSystemTrayVisual],
+ XA_VISUALID, 32, PropModeReplace,
+ (unsigned char *)&visual->visualid, 1);
+ XChangeProperty(dpy, systray->win, netatom[NetWMWindowType], XA_ATOM, 32,
+ PropModeReplace,
+ (unsigned char *)&netatom[NetWMWindowTypeDock], 1);
+ XMapRaised(dpy, systray->win);
+ XSetSelectionOwner(dpy, netatom[NetSystemTray], systray->win, CurrentTime);
+ if (XGetSelectionOwner(dpy, netatom[NetSystemTray]) == systray->win) {
+ sendevent(root, xatom[Manager], StructureNotifyMask, CurrentTime,
+ netatom[NetSystemTray], systray->win, 0, 0);
+ XSync(dpy, False);
+ } else {
+ fprintf(stderr, "dwm: unable to obtain system tray.\n");
+ free(systray);
+ systray = NULL;
+ return;
+ }
+ }
+
+ for (w = 0, i = systray->icons; i; i = i->next) {
+ wa.background_pixel = 0;
+ XChangeWindowAttributes(dpy, i->win, CWBackPixel, &wa);
+ XMapRaised(dpy, i->win);
+ w += systrayspacing;
+ i->x = w;
+ XMoveResizeWindow(dpy, i->win, i->x, 0, i->w, i->h);
+ w += i->w;
+ if (i->mon != m)
+ i->mon = m;
+ }
+ w = w ? w + systrayspacing : 1;
+ x -= w;
+ XMoveResizeWindow(dpy, systray->win, x - xpad, m->by + ypad, w, bh);
+ wc.x = x - xpad;
+ wc.y = m->by + ypad;
+ wc.width = w;
+ wc.height = bh;
+ wc.stack_mode = Above;
+ wc.sibling = m->barwin;
+ XConfigureWindow(dpy, systray->win,
+ CWX | CWY | CWWidth | CWHeight | CWSibling | CWStackMode,
+ &wc);
+ XMapWindow(dpy, systray->win);
+ XMapSubwindows(dpy, systray->win);
+ XSync(dpy, False);
+
+ if (updatebar)
+ drawbar(m);
+}
+
+void updatesystrayicongeom(Client *i, int w, int h) {
+ if (i) {
+ i->h = bh;
+ if (w == h)
+ i->w = bh;
+ else if (h == bh)
+ i->w = w;
+ else
+ i->w = (int)((float)bh * ((float)w / (float)h));
+ applysizehints(i, &(i->x), &(i->y), &(i->w), &(i->h), False);
+ /* force icons into the systray dimensions if they don't want to */
+ if (i->h > bh) {
+ if (i->w == i->h)
+ i->w = bh;
+ else
+ i->w = (int)((float)bh * ((float)i->w / (float)i->h));
+ i->h = bh;
+ }
+ if (i->w > 2 * bh)
+ i->w = bh;
+ }
+}
+
+void updatesystrayiconstate(Client *i, XPropertyEvent *ev) {
+ long flags;
+ int code = 0;
+
+ if (!showsystray || !i || ev->atom != xatom[XembedInfo] ||
+ !(flags = getatomprop(i, xatom[XembedInfo])))
+ return;
+
+ if (flags & XEMBED_MAPPED && !i->tags) {
+ i->tags = 1;
+ code = XEMBED_WINDOW_ACTIVATE;
+ XMapRaised(dpy, i->win);
+ setclientstate(i, NormalState);
+ } else if (!(flags & XEMBED_MAPPED) && i->tags) {
+ i->tags = 0;
+ code = XEMBED_WINDOW_DEACTIVATE;
+ XUnmapWindow(dpy, i->win);
+ setclientstate(i, WithdrawnState);
+ } else
+ return;
+ sendevent(i->win, xatom[Xembed], StructureNotifyMask, CurrentTime, code, 0,
+ systray->win, XEMBED_EMBEDDED_VERSION);
+}
+
+void updatetitle(Client *c) {
+ if (!gettextprop(c->win, netatom[NetWMName], c->name, sizeof c->name))
+ gettextprop(c->win, XA_WM_NAME, c->name, sizeof c->name);
+ if (c->name[0] == '\0') /* hack to mark broken clients */
+ strcpy(c->name, broken);
+}
+
+void updateicon(Client *c) {
+ freeicon(c);
+ c->icon = geticonprop(c->win, &c->icw, &c->ich);
+}
+
+void updatewindowtype(Client *c) {
+ Atom state = getatomprop(c, netatom[NetWMState]);
+ Atom wtype = getatomprop(c, netatom[NetWMWindowType]);
+
+ if (state == netatom[NetWMFullscreen])
+ setfullscreen(c, 1);
+ if (wtype == netatom[NetWMWindowTypeDialog])
+ c->isfloating = 1;
+}
+
+void updatewmhints(Client *c) {
+ XWMHints *wmh;
+
+ if ((wmh = XGetWMHints(dpy, c->win))) {
+ if (c == selmon->sel && wmh->flags & XUrgencyHint) {
+ wmh->flags &= ~XUrgencyHint;
+ XSetWMHints(dpy, c->win, wmh);
+ } else
+ c->isurgent = (wmh->flags & XUrgencyHint) ? 1 : 0;
+ if (wmh->flags & InputHint)
+ c->neverfocus = !wmh->input;
+ else
+ c->neverfocus = 0;
+ XFree(wmh);
+ }
+}
+
+void view(const Arg *arg) {
+ if ((arg->ui & TAGMASK) == selmon->tagset[selmon->seltags])
+ return;
+ selmon->seltags ^= 1; /* toggle sel tagset */
+ if (arg->ui & TAGMASK)
+ selmon->tagset[selmon->seltags] = arg->ui & TAGMASK;
+ focus(NULL);
+ arrange(selmon);
+}
+
+Client *wintoclient(Window w) {
+ Client *c;
+ Monitor *m;
+
+ for (m = mons; m; m = m->next)
+ for (c = m->clients; c; c = c->next)
+ if (c->win == w)
+ return c;
+ return NULL;
+}
+
+Monitor *wintomon(Window w) {
+ int x, y;
+ Client *c;
+ Monitor *m;
+
+ if (w == root && getrootptr(&x, &y))
+ return recttomon(x, y, 1, 1);
+ for (m = mons; m; m = m->next)
+ if (w == m->barwin)
+ return m;
+ if ((c = wintoclient(w)))
+ return c->mon;
+ return selmon;
+}
+
+Client *wintosystrayicon(Window w) {
+ Client *i = NULL;
+
+ if (!showsystray || !w)
+ return i;
+ for (i = systray->icons; i && i->win != w; i = i->next)
+ ;
+ return i;
+}
+
+/* There's no way to check accesses to destroyed windows, thus those cases are
+ * ignored (especially on UnmapNotify's). Other types of errors call Xlibs
+ * default error handler, which may call exit. */
+int xerror(Display *dpy, XErrorEvent *ee) {
+ if (ee->error_code == BadWindow ||
+ (ee->request_code == X_SetInputFocus && ee->error_code == BadMatch) ||
+ (ee->request_code == X_PolyText8 && ee->error_code == BadDrawable) ||
+ (ee->request_code == X_PolyFillRectangle &&
+ ee->error_code == BadDrawable) ||
+ (ee->request_code == X_PolySegment && ee->error_code == BadDrawable) ||
+ (ee->request_code == X_ConfigureWindow && ee->error_code == BadMatch) ||
+ (ee->request_code == X_GrabButton && ee->error_code == BadAccess) ||
+ (ee->request_code == X_GrabKey && ee->error_code == BadAccess) ||
+ (ee->request_code == X_CopyArea && ee->error_code == BadDrawable))
+ return 0;
+ fprintf(stderr, "dwm: fatal error: request code=%d, error code=%d\n",
+ ee->request_code, ee->error_code);
+ return xerrorxlib(dpy, ee); /* may call exit */
+}
+
+int xerrordummy(Display *dpy, XErrorEvent *ee) { return 0; }
+
+/* Startup Error handler to check if another window manager
+ * is already running. */
+int xerrorstart(Display *dpy, XErrorEvent *ee) {
+ die("birdwm: another window manager is already running");
+ return -1;
+}
+
+void xinitvisual() {
+ XVisualInfo *infos;
+ XRenderPictFormat *fmt;
+ int nitems;
+ int i;
+
+ XVisualInfo tpl = {.screen = screen, .depth = 32, .class = TrueColor};
+ long masks = VisualScreenMask | VisualDepthMask | VisualClassMask;
+
+ infos = XGetVisualInfo(dpy, masks, &tpl, &nitems);
+ visual = NULL;
+ for (i = 0; i < nitems; i++) {
+ fmt = XRenderFindVisualFormat(dpy, infos[i].visual);
+ if (fmt->type == PictTypeDirect && fmt->direct.alphaMask) {
+ visual = infos[i].visual;
+ depth = infos[i].depth;
+ cmap = XCreateColormap(dpy, root, visual, AllocNone);
+ useargb = 1;
+ break;
+ }
+ }
+
+ XFree(infos);
+
+ if (!visual) {
+ visual = DefaultVisual(dpy, screen);
+ depth = DefaultDepth(dpy, screen);
+ cmap = DefaultColormap(dpy, screen);
+ }
+}
+
+void xrdb(const Arg *arg) {
+ loadxrdb();
+ int i;
+ for (i = 0; i < LENGTH(colors); i++)
+ // scheme[i] = drw_scm_create(drw, colors[i], 3);
+ scheme[i] = drw_scm_create(drw, colors[i], alphas[i], 3);
+ focus(NULL);
+ arrange(NULL);
+}
+
+void zoom(const Arg *arg) {
+ Client *c = selmon->sel;
+
+ if (!selmon->lt[selmon->sellt]->arrange || !c || c->isfloating)
+ return;
+ if (c == nexttiled(selmon->clients) && !(c = nexttiled(c->next)))
+ return;
+ pop(c);
+}
+
+int main(int argc, char *argv[]) {
+ if (argc == 2 && !strcmp("-v", argv[1]))
+ die("birdwm-" VERSION);
+ else if (argc != 1)
+ die("usage: birdwm [-v]");
+ if (!setlocale(LC_CTYPE, "") || !XSupportsLocale())
+ fputs("warning: no locale support\n", stderr);
+ if (!(dpy = XOpenDisplay(NULL)))
+ die("birdwm: cannot open display");
+ checkotherwm();
+ XrmInitialize();
+ loadxrdb();
+ setup();
+#ifdef __OpenBSD__
+ if (pledge("stdio rpath proc exec", NULL) == -1)
+ die("pledge");
+#endif /* __OpenBSD__ */
+ scan();
+ runautostart();
+ run();
+ if (restart)
+ execvp(argv[0], argv);
+ cleanup();
+ XCloseDisplay(dpy);
+ return EXIT_SUCCESS;
+}
diff --git a/birdwm.o b/birdwm.o
Binary files differ.
diff --git a/birdwm.png b/birdwm.png
Binary files differ.
diff --git a/config.def.h b/config.def.h
@@ -0,0 +1,213 @@
+/* See LICENSE file for copyright and license details. */
+#include <X11/XF86keysym.h>
+/* appearance */
+static const unsigned int borderpx = 0; /* border pixel of windows */
+static const unsigned int gappx = 7; /* gaps between windows */
+static const unsigned int snap = 32; /* snap pixel */
+static const int showbar = 1; /* 0 means no bar */
+static const int topbar = 1; /* 0 means bottom bar */
+#define ICONSIZE 16 /* icon size */
+#define ICONSPACING 5 /* space between icon and title */
+static const unsigned int systraypinning = 0; /* 0: sloppy systray follows selected monitor, >0: pin systray to monitor X */
+static const unsigned int systrayspacing = 2; /* systray spacing */
+static const int systraypinningfailfirst = 1; /* 1: if pinning fails, display systray on the first monitor, False: display systray on the last monitor */
+static const int showsystray = 1; /* 0 means no systray */
+static const char *fonts[] = { "LexendDeca-Bold:pixelsize=18" };
+static const char dmenufont[] = "LexendDeca-Bold:pixelsize=18";
+static const unsigned int baralpha = 0xff;
+static const unsigned int borderalpha = OPAQUE;
+static const unsigned int ALTMONNUM = 1; /* number of the alt/secondary monitor */
+static char normbgcolor[] = "#222222";
+static char normbordercolor[] = "#444444";
+static char normfgcolor[] = "#bbbbbb";
+static char selfgcolor[] = "#eeeeee";
+static char selbordercolor[] = "#005577";
+static char selbgcolor[] = "#005577";
+static char *colors[][3] = {
+ /* fg bg border */
+ [SchemeNorm] = { normfgcolor, normbgcolor, normbordercolor },
+ [SchemeSel] = { selfgcolor, selbgcolor, selbordercolor },
+};
+typedef struct {
+ const char *name;
+ const void *cmd;
+} Sp;
+
+//char scratchpadsize[] = "144x41"; /* size of scratchpad (for st/birdterm)*/
+char termfm[] = "nnn"; /* terminal file manager */
+char upgradescript[] = "upgrader.sh"; /* upgrade script */
+char musicterm[] = "kew"; /* tui music player */
+char termtop[] = "htop"; /* htop scratchpad */
+
+static const char *spcmd1[] = {"kitty", "--name", "spterm", }; /* regular terminal scratchpad */
+static const char *spcmd2[] = {"kitty", "--name", "spfm", termfm, }; /* file manager scratchpad */
+static const char *spcmd3[] = {"kitty", "--name", "upgrader", upgradescript, }; /* upgrade script, change if your script is named differently */
+static const char *spcmd4[] = {"kitty", "--name", "musicterm", musicterm, }; /* scratchpad for tui music clients */
+static const char *spcmd5[] = {"kitty", "--name", "termtop", termtop, }; /* scratchpad for tui resource monitor */
+static Sp scratchpads[] = {
+ /* name cmd */
+ {"spterm", spcmd1},
+ {"spfm", spcmd2},
+ {"upgrader", spcmd3},
+ {"musicterm", spcmd4},
+ {"termtop", spcmd5},
+};
+
+static const unsigned int alphas[][3] = {
+ /* fg bg border*/
+ [SchemeNorm] = { OPAQUE, baralpha, borderalpha },
+ [SchemeSel] = { OPAQUE, baralpha, borderalpha },
+};
+
+/* tagging */
+static const char *tags[] = { "\uf303", "\uf120", "\uf25f", "\uf001", "\uf1ff", "\uf199", };
+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 }, /* gimp menu floating rule */
+ { NULL, NULL, "Signal Desktop Preferences", 0, 1, -1 }, /* signal settings floating rule */
+ { NULL, NULL, "Blanket", 0, 1, -1 }, /* blanket (ambience program) floating rule */
+ { "python3", "python3", NULL, 0, 1, -1 }, /* blanket (ambience program) floating rule */
+
+/* scratchpad floating rules */
+ { NULL, "spterm", NULL, SPTAG(0), 1, -1 }, /* scratchpad floating rule */
+ { NULL, "spfm", NULL, SPTAG(1), 1, -1 }, /* suckless file manager command */
+ { NULL, "upgrader", NULL, SPTAG(2), 1, -1 }, /* upgrade script command floating */
+ { NULL, "musicterm",NULL, SPTAG(3), 1, -1 }, /* terminal music player scratchpad */
+ { NULL, "termtop", NULL, SPTAG(4), 1, -1 }, /* htop or other terminal monitor scratchpad */
+/* { "Alacritty","Alacritty",NULL, 0, 1, -1 },*/ /* alacritty (used for possible switch to alacritty as scratchpad) */
+
+/* end of scratchpad floating rules */
+ { "widget", NULL, NULL, 0, 1, -1 }, /* used sometimes, for using sww widgets */
+ { "python3", NULL, NULL, 0, 1, -1 }, /* i cant remember what this is tbh */
+ { NULL, NULL, HOME"/.config/nnn/plugins/preview-tui", 0, 1, -1 },
+ { NULL, "Toolkit", NULL, 0, 1, -1 }, /* browser floating media player floating rule */
+ { "steam","steamwebhelper",NULL, 0, 1, -1 }, /* just to make the steam menus float */
+
+/* all rules below this start on the second monitor */
+/* { "VencordDesktop", "vencorddesktop", NULL, 1 << 4, 0, ALTMONNUM },*/ /* starts discord on the discord icon tag */
+ { "vesktop", "vesktop", NULL, 1 << 4, 0, ALTMONNUM }, /* starts vesktop discord client on the discord icon tag */
+ { "tutanota-desktop","tutanota-desktop",NULL,1 << 5,0, ALTMONNUM }, /* starts tutanota-desktop on the mail tag */
+ { "Cider", "cider", NULL, 1 << 3, 0, ALTMONNUM }, /* starts cider on the music tag */
+ { "VSCodium", "vscodium", NULL, 1 << 1, 0, ALTMONNUM }, /* starts vscodium by default on the cli/code tag */
+ { "Element", "element", NULL, 1 << 5, 0, ALTMONNUM }, /* starts element on the chat tag */
+ { "Signal", "signal", NULL, 1 << 2, 0, ALTMONNUM }, /* starts element on the chat tag */
+};
+
+/* 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 = 0; /* 1 means respect size hints in tiled resizals */
+static const int lockfullscreen = 1; /* 1 will force focus on the fullscreen window */
+
+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 WINKEY 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/sh", "-c", cmd, NULL } }
+
+/* commands */
+static char dmenumon[2] = "0"; /* component of dmenucmd, manipulated in spawn() */
+static const char *dmenucmd[] = { "birdmenu_run", "-i", NULL };
+static const char *termcmd[] = { "kitty", NULL };
+static const char *wallpaper[] = { "nsxiv", "-t", WALLPAPERDIR, NULL };
+static const char *wallpapergif[] = { "nsxiv", "-t", GIFDIR, NULL }; /* calling gif wallpaper picker script, utilizes nsxiv */
+static const char *restarter[] = { "restarter" }; /* dmenu script for restarting daemons and getting system info through dunst */
+static const char *browser[] = { "io.gitlab.librewolf-community" }; /* browser shortcut */
+static const char *screenshot[] = { "screenshot.sh" }; /* screenshot script */
+static const char *emojiscript[] = { "dmenu-emoji.sh" }; /* (bir)dmenu emoji finder */
+
+/* pulseaudio script for setting volume, called by XF86 keys, found in 'extras' folder */
+static const char *volup[] = { "volume.sh", "up", NULL};
+static const char *voldown[] = { "volume.sh", "down", NULL};
+static const char *volmute[] = { "volume.sh", "mute", NULL};
+
+
+#include "exitdwm.c"
+static const Key keys[] = {
+ /* modifier key function argument */
+ { MODKEY, XK_p, spawn, {.v = dmenucmd } },
+ { MODKEY|ShiftMask, XK_Return, spawn, {.v = termcmd } },
+ { MODKEY, XK_w, spawn, {.v = wallpaper } },
+ { MODKEY, XK_g, spawn, {.v = wallpapergif } },
+ { MODKEY|ShiftMask, XK_j, spawn, {.v = restarter } },
+ { MODKEY, XK_f, spawn, {.v = browser } },
+ { MODKEY, XK_e, spawn, {.v = emojiscript } },
+ { WINKEY|ShiftMask, XK_s, spawn, {.v = screenshot} },
+ { 0, XF86XK_AudioRaiseVolume, spawn, {.v = volup} },
+ { 0, XF86XK_AudioLowerVolume, spawn, {.v = voldown} },
+ { 0, XF86XK_AudioMute, spawn, {.v = volmute} },
+ { 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_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 } },
+ { MODKEY, XK_F5, xrdb, {.v = NULL } },
+ { MODKEY, XK_y, togglescratch, {.ui = 0 } },
+ { MODKEY, XK_u, togglescratch, {.ui = 1 } },
+ { MODKEY|ShiftMask, XK_u, togglescratch, {.ui = 2 } },
+ { MODKEY|ShiftMask, XK_m, togglescratch, {.ui = 3 } },
+ { MODKEY|ShiftMask, XK_h, togglescratch, {.ui = 4 } },
+ 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)
+/* following line is commented out due to exitmenu patch */
+/* { MODKEY|ShiftMask, XK_q, quit, {0} }, */
+ { MODKEY|ControlMask|ShiftMask, XK_q, quit, {1} },
+ { MODKEY|ShiftMask, XK_e, exitdwm, {0} },
+};
+
+/* button definitions */
+/* click can be ClkTagBar, ClkLtSymbol, ClkStatusText, ClkWinTitle, ClkClientWin, or ClkRootWin */
+static const Button buttons[] = {
+ /* click event mask button function argument */
+ { ClkLtSymbol, 0, Button1, setlayout, {0} },
+ { ClkLtSymbol, 0, Button3, setlayout, {.v = &layouts[2]} },
+ { ClkWinTitle, 0, Button2, zoom, {0} },
+ { ClkStatusText, 0, Button2, spawn, {.v = termcmd } },
+ { ClkClientWin, MODKEY, Button1, movemouse, {0} },
+ { ClkClientWin, MODKEY, Button2, togglefloating, {0} },
+ { ClkClientWin, MODKEY, Button3, resizemouse, {0} },
+ { ClkTagBar, 0, Button1, view, {0} },
+ { ClkTagBar, 0, Button3, toggleview, {0} },
+ { ClkTagBar, MODKEY, Button1, tag, {0} },
+ { ClkTagBar, MODKEY, Button3, toggletag, {0} },
+};
+
diff --git a/config.h b/config.h
@@ -0,0 +1,216 @@
+#define HOME "/home/mrgrouse"
+#define WALLPAPERDIR "/home/mrgrouse/Pictures/wallpapers"
+#define GIFDIR "/home/mrgrouse/Pictures/wallpapers/gif"
+/* See LICENSE file for copyright and license details. */
+#include <X11/XF86keysym.h>
+/* appearance */
+static const unsigned int borderpx = 0; /* border pixel of windows */
+static const unsigned int gappx = 7; /* gaps between windows */
+static const unsigned int snap = 32; /* snap pixel */
+static const int showbar = 1; /* 0 means no bar */
+static const int topbar = 1; /* 0 means bottom bar */
+#define ICONSIZE 16 /* icon size */
+#define ICONSPACING 5 /* space between icon and title */
+static const unsigned int systraypinning = 0; /* 0: sloppy systray follows selected monitor, >0: pin systray to monitor X */
+static const unsigned int systrayspacing = 2; /* systray spacing */
+static const int systraypinningfailfirst = 1; /* 1: if pinning fails, display systray on the first monitor, False: display systray on the last monitor */
+static const int showsystray = 1; /* 0 means no systray */
+static const char *fonts[] = { "LexendDeca-Bold:pixelsize=18" };
+static const char dmenufont[] = "LexendDeca-Bold:pixelsize=18";
+static const unsigned int baralpha = 0xff;
+static const unsigned int borderalpha = OPAQUE;
+static const unsigned int ALTMONNUM = 1; /* number of the alt/secondary monitor */
+static char normbgcolor[] = "#222222";
+static char normbordercolor[] = "#444444";
+static char normfgcolor[] = "#bbbbbb";
+static char selfgcolor[] = "#eeeeee";
+static char selbordercolor[] = "#005577";
+static char selbgcolor[] = "#005577";
+static char *colors[][3] = {
+ /* fg bg border */
+ [SchemeNorm] = { normfgcolor, normbgcolor, normbordercolor },
+ [SchemeSel] = { selfgcolor, selbgcolor, selbordercolor },
+};
+typedef struct {
+ const char *name;
+ const void *cmd;
+} Sp;
+
+//char scratchpadsize[] = "144x41"; /* size of scratchpad (for st/birdterm)*/
+char termfm[] = "nnn"; /* terminal file manager */
+char upgradescript[] = "upgrader.sh"; /* upgrade script */
+char musicterm[] = "kew"; /* tui music player */
+char termtop[] = "htop"; /* htop scratchpad */
+
+static const char *spcmd1[] = {"kitty", "--name", "spterm", }; /* regular terminal scratchpad */
+static const char *spcmd2[] = {"kitty", "--name", "spfm", termfm, }; /* file manager scratchpad */
+static const char *spcmd3[] = {"kitty", "--name", "upgrader", upgradescript, }; /* upgrade script, change if your script is named differently */
+static const char *spcmd4[] = {"kitty", "--name", "musicterm", musicterm, }; /* scratchpad for tui music clients */
+static const char *spcmd5[] = {"kitty", "--name", "termtop", termtop, }; /* scratchpad for tui resource monitor */
+static Sp scratchpads[] = {
+ /* name cmd */
+ {"spterm", spcmd1},
+ {"spfm", spcmd2},
+ {"upgrader", spcmd3},
+ {"musicterm", spcmd4},
+ {"termtop", spcmd5},
+};
+
+static const unsigned int alphas[][3] = {
+ /* fg bg border*/
+ [SchemeNorm] = { OPAQUE, baralpha, borderalpha },
+ [SchemeSel] = { OPAQUE, baralpha, borderalpha },
+};
+
+/* tagging */
+static const char *tags[] = { "\uf303", "\uf120", "\uf25f", "\uf001", "\uf1ff", "\uf199", };
+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 }, /* gimp menu floating rule */
+ { NULL, NULL, "Signal Desktop Preferences", 0, 1, -1 }, /* signal settings floating rule */
+ { NULL, NULL, "Blanket", 0, 1, -1 }, /* blanket (ambience program) floating rule */
+ { "python3", "python3", NULL, 0, 1, -1 }, /* blanket (ambience program) floating rule */
+
+/* scratchpad floating rules */
+ { NULL, "spterm", NULL, SPTAG(0), 1, -1 }, /* scratchpad floating rule */
+ { NULL, "spfm", NULL, SPTAG(1), 1, -1 }, /* suckless file manager command */
+ { NULL, "upgrader", NULL, SPTAG(2), 1, -1 }, /* upgrade script command floating */
+ { NULL, "musicterm",NULL, SPTAG(3), 1, -1 }, /* terminal music player scratchpad */
+ { NULL, "termtop", NULL, SPTAG(4), 1, -1 }, /* htop or other terminal monitor scratchpad */
+/* { "Alacritty","Alacritty",NULL, 0, 1, -1 },*/ /* alacritty (used for possible switch to alacritty as scratchpad) */
+
+/* end of scratchpad floating rules */
+ { "widget", NULL, NULL, 0, 1, -1 }, /* used sometimes, for using sww widgets */
+ { "python3", NULL, NULL, 0, 1, -1 }, /* i cant remember what this is tbh */
+ { NULL, NULL, HOME"/.config/nnn/plugins/preview-tui", 0, 1, -1 },
+ { NULL, "Toolkit", NULL, 0, 1, -1 }, /* browser floating media player floating rule */
+ { "steam","steamwebhelper",NULL, 0, 1, -1 }, /* just to make the steam menus float */
+
+/* all rules below this start on the second monitor */
+/* { "VencordDesktop", "vencorddesktop", NULL, 1 << 4, 0, ALTMONNUM },*/ /* starts discord on the discord icon tag */
+ { "vesktop", "vesktop", NULL, 1 << 4, 0, ALTMONNUM }, /* starts vesktop discord client on the discord icon tag */
+ { "tutanota-desktop","tutanota-desktop",NULL,1 << 5,0, ALTMONNUM }, /* starts tutanota-desktop on the mail tag */
+ { "Cider", "cider", NULL, 1 << 3, 0, ALTMONNUM }, /* starts cider on the music tag */
+ { "VSCodium", "vscodium", NULL, 1 << 1, 0, ALTMONNUM }, /* starts vscodium by default on the cli/code tag */
+ { "Element", "element", NULL, 1 << 5, 0, ALTMONNUM }, /* starts element on the chat tag */
+ { "Signal", "signal", NULL, 1 << 2, 0, ALTMONNUM }, /* starts element on the chat tag */
+};
+
+/* 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 = 0; /* 1 means respect size hints in tiled resizals */
+static const int lockfullscreen = 1; /* 1 will force focus on the fullscreen window */
+
+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 WINKEY 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/sh", "-c", cmd, NULL } }
+
+/* commands */
+static char dmenumon[2] = "0"; /* component of dmenucmd, manipulated in spawn() */
+static const char *dmenucmd[] = { "birdmenu_run", "-i", NULL };
+static const char *termcmd[] = { "kitty", NULL };
+static const char *wallpaper[] = { "nsxiv", "-t", WALLPAPERDIR, NULL };
+static const char *wallpapergif[] = { "nsxiv", "-t", GIFDIR, NULL }; /* calling gif wallpaper picker script, utilizes nsxiv */
+static const char *restarter[] = { "restarter" }; /* dmenu script for restarting daemons and getting system info through dunst */
+static const char *browser[] = { "io.gitlab.librewolf-community" }; /* browser shortcut */
+static const char *screenshot[] = { "screenshot.sh" }; /* screenshot script */
+static const char *emojiscript[] = { "dmenu-emoji.sh" }; /* (bir)dmenu emoji finder */
+
+/* pulseaudio script for setting volume, called by XF86 keys, found in 'extras' folder */
+static const char *volup[] = { "volume.sh", "up", NULL};
+static const char *voldown[] = { "volume.sh", "down", NULL};
+static const char *volmute[] = { "volume.sh", "mute", NULL};
+
+
+#include "exitdwm.c"
+static const Key keys[] = {
+ /* modifier key function argument */
+ { MODKEY, XK_p, spawn, {.v = dmenucmd } },
+ { MODKEY|ShiftMask, XK_Return, spawn, {.v = termcmd } },
+ { MODKEY, XK_w, spawn, {.v = wallpaper } },
+ { MODKEY, XK_g, spawn, {.v = wallpapergif } },
+ { MODKEY|ShiftMask, XK_j, spawn, {.v = restarter } },
+ { MODKEY, XK_f, spawn, {.v = browser } },
+ { MODKEY, XK_e, spawn, {.v = emojiscript } },
+ { WINKEY|ShiftMask, XK_s, spawn, {.v = screenshot} },
+ { 0, XF86XK_AudioRaiseVolume, spawn, {.v = volup} },
+ { 0, XF86XK_AudioLowerVolume, spawn, {.v = voldown} },
+ { 0, XF86XK_AudioMute, spawn, {.v = volmute} },
+ { 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_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 } },
+ { MODKEY, XK_F5, xrdb, {.v = NULL } },
+ { MODKEY, XK_y, togglescratch, {.ui = 0 } },
+ { MODKEY, XK_u, togglescratch, {.ui = 1 } },
+ { MODKEY|ShiftMask, XK_u, togglescratch, {.ui = 2 } },
+ { MODKEY|ShiftMask, XK_m, togglescratch, {.ui = 3 } },
+ { MODKEY|ShiftMask, XK_h, togglescratch, {.ui = 4 } },
+ 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)
+/* following line is commented out due to exitmenu patch */
+/* { MODKEY|ShiftMask, XK_q, quit, {0} }, */
+ { MODKEY|ControlMask|ShiftMask, XK_q, quit, {1} },
+ { MODKEY|ShiftMask, XK_e, exitdwm, {0} },
+};
+
+/* button definitions */
+/* click can be ClkTagBar, ClkLtSymbol, ClkStatusText, ClkWinTitle, ClkClientWin, or ClkRootWin */
+static const Button buttons[] = {
+ /* click event mask button function argument */
+ { ClkLtSymbol, 0, Button1, setlayout, {0} },
+ { ClkLtSymbol, 0, Button3, setlayout, {.v = &layouts[2]} },
+ { ClkWinTitle, 0, Button2, zoom, {0} },
+ { ClkStatusText, 0, Button2, spawn, {.v = termcmd } },
+ { ClkClientWin, MODKEY, Button1, movemouse, {0} },
+ { ClkClientWin, MODKEY, Button2, togglefloating, {0} },
+ { ClkClientWin, MODKEY, Button3, resizemouse, {0} },
+ { ClkTagBar, 0, Button1, view, {0} },
+ { ClkTagBar, 0, Button3, toggleview, {0} },
+ { ClkTagBar, MODKEY, Button1, tag, {0} },
+ { ClkTagBar, MODKEY, Button3, toggletag, {0} },
+};
+
diff --git a/config.mk b/config.mk
@@ -0,0 +1,45 @@
+# birdwm version
+VERSION = 6.4
+
+# Customize below to fit your system
+
+# paths
+PREFIX = /usr/local
+MANPREFIX = ${PREFIX}/share/man
+
+X11INC = /usr/X11R6/include
+X11LIB = /usr/X11R6/lib
+
+# Xinerama, comment if you don't want it
+XINERAMALIBS = -lXinerama
+XINERAMAFLAGS = -DXINERAMA
+
+# Wallpaper folder location, for the wallpaper script:
+XDG_PICTURES ?= ${HOME}/Pictures
+WALLPAPERDIR = ${XDG_PICTURES}/wallpapers
+GIFDIR = ${WALLPAPERDIR}/gif
+
+# freetype
+FREETYPELIBS = -lfontconfig -lXft
+FREETYPEINC = /usr/include/freetype2
+# OpenBSD (uncomment)
+#FREETYPEINC = ${X11INC}/freetype2
+#MANPREFIX = ${PREFIX}/man
+
+# includes and libs
+INCS = -I${X11INC} -I${FREETYPEINC}
+LIBS = -L${X11LIB} -lX11 ${XINERAMALIBS} ${FREETYPELIBS} -lXrender -lImlib2
+
+# flags
+CPPFLAGS = -D_DEFAULT_SOURCE -D_BSD_SOURCE -D_XOPEN_SOURCE=700L -DVERSION=\"${VERSION}\" ${XINERAMAFLAGS}
+#CFLAGS = -std=c99 -pedantic -Wall -Wno-deprecated-declarations -O2 ${INCS} ${CPPFLAGS}
+CFLAGS = -static -std=c99 -pedantic -Wall -Wno-deprecated-declarations -O3 -march=native ${INCS} ${CPPFLAGS}
+LDFLAGS = ${LIBS}
+
+# Solaris
+#CFLAGS = -fast ${INCS} -DVERSION=\"${VERSION}\"
+#LDFLAGS = ${LIBS}
+
+# compiler and linker
+# even though gcc sucks, it has the best speeds for the binary
+CC = gcc
diff --git a/drw.c b/drw.c
@@ -0,0 +1,527 @@
+/* See LICENSE file for copyright and license details. */
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <X11/Xlib.h>
+#include <X11/Xft/Xft.h>
+#include <Imlib2.h>
+
+#include "drw.h"
+#include "util.h"
+
+#define UTF_INVALID 0xFFFD
+#define UTF_SIZ 4
+
+static const unsigned char utfbyte[UTF_SIZ + 1] = {0x80, 0, 0xC0, 0xE0, 0xF0};
+static const unsigned char utfmask[UTF_SIZ + 1] = {0xC0, 0x80, 0xE0, 0xF0, 0xF8};
+static const long utfmin[UTF_SIZ + 1] = { 0, 0, 0x80, 0x800, 0x10000};
+static const long utfmax[UTF_SIZ + 1] = {0x10FFFF, 0x7F, 0x7FF, 0xFFFF, 0x10FFFF};
+
+static long
+utf8decodebyte(const char c, size_t *i)
+{
+ for (*i = 0; *i < (UTF_SIZ + 1); ++(*i))
+ if (((unsigned char)c & utfmask[*i]) == utfbyte[*i])
+ return (unsigned char)c & ~utfmask[*i];
+ return 0;
+}
+
+static size_t
+utf8validate(long *u, size_t i)
+{
+ if (!BETWEEN(*u, utfmin[i], utfmax[i]) || BETWEEN(*u, 0xD800, 0xDFFF))
+ *u = UTF_INVALID;
+ for (i = 1; *u > utfmax[i]; ++i)
+ ;
+ return i;
+}
+
+static size_t
+utf8decode(const char *c, long *u, size_t clen)
+{
+ size_t i, j, len, type;
+ long udecoded;
+
+ *u = UTF_INVALID;
+ if (!clen)
+ return 0;
+ udecoded = utf8decodebyte(c[0], &len);
+ if (!BETWEEN(len, 1, UTF_SIZ))
+ return 1;
+ for (i = 1, j = 1; i < clen && j < len; ++i, ++j) {
+ udecoded = (udecoded << 6) | utf8decodebyte(c[i], &type);
+ if (type)
+ return j;
+ }
+ if (j < len)
+ return 0;
+ *u = udecoded;
+ utf8validate(u, len);
+
+ return len;
+}
+
+Drw *
+drw_create(Display *dpy, int screen, Window root, unsigned int w, unsigned int h, Visual *visual, unsigned int depth, Colormap cmap)
+{
+ Drw *drw = ecalloc(1, sizeof(Drw));
+
+ drw->dpy = dpy;
+ drw->screen = screen;
+ drw->root = root;
+ drw->w = w;
+ drw->h = h;
+ drw->visual = visual;
+ drw->depth = depth;
+ drw->cmap = cmap;
+ drw->drawable = XCreatePixmap(dpy, root, w, h, depth);
+ drw->picture = XRenderCreatePicture(dpy, drw->drawable, XRenderFindVisualFormat(dpy, visual), 0, NULL);
+ drw->gc = XCreateGC(dpy, drw->drawable, 0, NULL);
+ XSetLineAttributes(dpy, drw->gc, 1, LineSolid, CapButt, JoinMiter);
+
+ return drw;
+}
+
+void
+drw_resize(Drw *drw, unsigned int w, unsigned int h)
+{
+ if (!drw)
+ return;
+
+ drw->w = w;
+ drw->h = h;
+ if (drw->picture)
+ XRenderFreePicture(drw->dpy, drw->picture);
+ if (drw->drawable)
+ XFreePixmap(drw->dpy, drw->drawable);
+ drw->drawable = XCreatePixmap(drw->dpy, drw->root, w, h, drw->depth);
+ drw->picture = XRenderCreatePicture(drw->dpy, drw->drawable, XRenderFindVisualFormat(drw->dpy, drw->visual), 0, NULL);
+}
+
+void
+drw_free(Drw *drw)
+{
+ XRenderFreePicture(drw->dpy, drw->picture);
+ XFreePixmap(drw->dpy, drw->drawable);
+ XFreeGC(drw->dpy, drw->gc);
+ drw_fontset_free(drw->fonts);
+ free(drw);
+}
+
+/* This function is an implementation detail. Library users should use
+ * drw_fontset_create instead.
+ */
+static Fnt *
+xfont_create(Drw *drw, const char *fontname, FcPattern *fontpattern)
+{
+ Fnt *font;
+ XftFont *xfont = NULL;
+ FcPattern *pattern = NULL;
+
+ if (fontname) {
+ /* Using the pattern found at font->xfont->pattern does not yield the
+ * same substitution results as using the pattern returned by
+ * FcNameParse; using the latter results in the desired fallback
+ * behaviour whereas the former just results in missing-character
+ * rectangles being drawn, at least with some fonts. */
+ if (!(xfont = XftFontOpenName(drw->dpy, drw->screen, fontname))) {
+ fprintf(stderr, "error, cannot load font from name: '%s'\n", fontname);
+ return NULL;
+ }
+ if (!(pattern = FcNameParse((FcChar8 *) fontname))) {
+ fprintf(stderr, "error, cannot parse font name to pattern: '%s'\n", fontname);
+ XftFontClose(drw->dpy, xfont);
+ return NULL;
+ }
+ } else if (fontpattern) {
+ if (!(xfont = XftFontOpenPattern(drw->dpy, fontpattern))) {
+ fprintf(stderr, "error, cannot load font from pattern.\n");
+ return NULL;
+ }
+ } else {
+ die("no font specified.");
+ }
+
+ font = ecalloc(1, sizeof(Fnt));
+ font->xfont = xfont;
+ font->pattern = pattern;
+ font->h = xfont->ascent + xfont->descent;
+ font->dpy = drw->dpy;
+
+ return font;
+}
+
+static void
+xfont_free(Fnt *font)
+{
+ if (!font)
+ return;
+ if (font->pattern)
+ FcPatternDestroy(font->pattern);
+ XftFontClose(font->dpy, font->xfont);
+ free(font);
+}
+
+Fnt*
+drw_fontset_create(Drw* drw, const char *fonts[], size_t fontcount)
+{
+ 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, unsigned int alpha)
+{
+ if (!drw || !dest || !clrname)
+ return;
+
+ if (!XftColorAllocName(drw->dpy, drw->visual, drw->cmap,
+ clrname, dest))
+ die("error, cannot allocate color '%s'", clrname);
+
+ dest->pixel = (dest->pixel & 0x00ffffffU) | (alpha << 24);
+}
+
+/* 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, char *clrnames[], const unsigned int alphas[], 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], alphas[i]);
+ return ret;
+}
+
+void
+drw_setfontset(Drw *drw, Fnt *set)
+{
+ if (drw)
+ drw->fonts = set;
+}
+
+void
+drw_setscheme(Drw *drw, Clr *scm)
+{
+ if (drw)
+ drw->scheme = scm;
+}
+
+Picture
+drw_picture_create_resized(Drw *drw, char *src, unsigned int srcw, unsigned int srch, unsigned int dstw, unsigned int dsth) {
+ Pixmap pm;
+ Picture pic;
+ GC gc;
+
+ if (srcw <= (dstw << 1u) && srch <= (dsth << 1u)) {
+ XImage img = {
+ srcw, srch, 0, ZPixmap, src,
+ ImageByteOrder(drw->dpy), BitmapUnit(drw->dpy), BitmapBitOrder(drw->dpy), 32,
+ 32, 0, 32,
+ 0, 0, 0
+ };
+ XInitImage(&img);
+
+ pm = XCreatePixmap(drw->dpy, drw->root, srcw, srch, 32);
+ gc = XCreateGC(drw->dpy, pm, 0, NULL);
+ XPutImage(drw->dpy, pm, gc, &img, 0, 0, 0, 0, srcw, srch);
+ XFreeGC(drw->dpy, gc);
+
+ pic = XRenderCreatePicture(drw->dpy, pm, XRenderFindStandardFormat(drw->dpy, PictStandardARGB32), 0, NULL);
+ XFreePixmap(drw->dpy, pm);
+
+ XRenderSetPictureFilter(drw->dpy, pic, FilterBilinear, NULL, 0);
+ XTransform xf;
+ xf.matrix[0][0] = (srcw << 16u) / dstw; xf.matrix[0][1] = 0; xf.matrix[0][2] = 0;
+ xf.matrix[1][0] = 0; xf.matrix[1][1] = (srch << 16u) / dsth; xf.matrix[1][2] = 0;
+ xf.matrix[2][0] = 0; xf.matrix[2][1] = 0; xf.matrix[2][2] = 65536;
+ XRenderSetPictureTransform(drw->dpy, pic, &xf);
+ } else {
+ Imlib_Image origin = imlib_create_image_using_data(srcw, srch, (DATA32 *)src);
+ if (!origin) return None;
+ imlib_context_set_image(origin);
+ imlib_image_set_has_alpha(1);
+ Imlib_Image scaled = imlib_create_cropped_scaled_image(0, 0, srcw, srch, dstw, dsth);
+ imlib_free_image_and_decache();
+ if (!scaled) return None;
+ imlib_context_set_image(scaled);
+ imlib_image_set_has_alpha(1);
+
+ XImage img = {
+ dstw, dsth, 0, ZPixmap, (char *)imlib_image_get_data_for_reading_only(),
+ ImageByteOrder(drw->dpy), BitmapUnit(drw->dpy), BitmapBitOrder(drw->dpy), 32,
+ 32, 0, 32,
+ 0, 0, 0
+ };
+ XInitImage(&img);
+
+ pm = XCreatePixmap(drw->dpy, drw->root, dstw, dsth, 32);
+ gc = XCreateGC(drw->dpy, pm, 0, NULL);
+ XPutImage(drw->dpy, pm, gc, &img, 0, 0, 0, 0, dstw, dsth);
+ imlib_free_image_and_decache();
+ XFreeGC(drw->dpy, gc);
+
+ pic = XRenderCreatePicture(drw->dpy, pm, XRenderFindStandardFormat(drw->dpy, PictStandardARGB32), 0, NULL);
+ XFreePixmap(drw->dpy, pm);
+ }
+
+ return pic;
+}
+
+void
+drw_rect(Drw *drw, int x, int y, unsigned int w, unsigned int h, int filled, int invert)
+{
+ if (!drw || !drw->scheme)
+ return;
+ XSetForeground(drw->dpy, drw->gc, invert ? drw->scheme[ColBg].pixel : drw->scheme[ColFg].pixel);
+ if (filled)
+ XFillRectangle(drw->dpy, drw->drawable, drw->gc, x, y, w, h);
+ else
+ XDrawRectangle(drw->dpy, drw->drawable, drw->gc, x, y, w - 1, h - 1);
+}
+
+int
+drw_text(Drw *drw, int x, int y, unsigned int w, unsigned int h, unsigned int lpad, const char *text, int invert)
+{
+ int i, ty, ellipsis_x = 0;
+ unsigned int tmpw, ew, ellipsis_w = 0, ellipsis_len;
+ XftDraw *d = NULL;
+ Fnt *usedfont, *curfont, *nextfont;
+ int utf8strlen, utf8charlen, render = x || y || w || h;
+ long utf8codepoint = 0;
+ const char *utf8str;
+ FcCharSet *fccharset;
+ FcPattern *fcpattern;
+ FcPattern *match;
+ XftResult result;
+ 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 || (render && (!drw->scheme || !w)) || !text || !drw->fonts)
+ return 0;
+
+ if (!render) {
+ w = invert ? invert : ~invert;
+ } else {
+ XSetForeground(drw->dpy, drw->gc, drw->scheme[invert ? ColFg : ColBg].pixel);
+ XFillRectangle(drw->dpy, drw->drawable, drw->gc, x, y, w, h);
+ d = XftDrawCreate(drw->dpy, drw->drawable, drw->visual, drw->cmap);
+ x += lpad;
+ w -= lpad;
+ }
+
+ usedfont = drw->fonts;
+ if (!ellipsis_width && render)
+ ellipsis_width = drw_fontset_getwidth(drw, "...");
+ while (1) {
+ ew = ellipsis_len = utf8strlen = 0;
+ utf8str = text;
+ nextfont = NULL;
+ while (*text) {
+ utf8charlen = utf8decode(text, &utf8codepoint, UTF_SIZ);
+ for (curfont = drw->fonts; curfont; curfont = curfont->next) {
+ charexists = charexists || XftCharExists(drw->dpy, curfont->xfont, utf8codepoint);
+ if (charexists) {
+ 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;
+ text += utf8charlen;
+ ew += tmpw;
+ } else {
+ nextfont = curfont;
+ }
+ break;
+ }
+ }
+
+ if (overflow || !charexists || nextfont)
+ break;
+ else
+ charexists = 0;
+ }
+
+ if (utf8strlen) {
+ if (render) {
+ ty = y + (h - usedfont->h) / 2 + usedfont->xfont->ascent;
+ XftDrawStringUtf8(d, &drw->scheme[invert ? ColBg : ColFg],
+ usedfont->xfont, x, ty, (XftChar8 *)utf8str, utf8strlen);
+ }
+ x += ew;
+ w -= ew;
+ }
+ if (render && overflow)
+ drw_text(drw, ellipsis_x, y, ellipsis_w, h, 0, "...", invert);
+
+ if (!*text || overflow) {
+ break;
+ } else if (nextfont) {
+ charexists = 0;
+ usedfont = nextfont;
+ } else {
+ /* Regardless of whether or not a fallback font is found, the
+ * character must be drawn. */
+ charexists = 1;
+
+ for (i = 0; i < nomatches_len; ++i) {
+ /* avoid calling XftFontMatch if we know we won't find a match */
+ if (utf8codepoint == nomatches.codepoint[i])
+ goto no_match;
+ }
+
+ fccharset = FcCharSetCreate();
+ FcCharSetAddChar(fccharset, utf8codepoint);
+
+ if (!drw->fonts->pattern) {
+ /* Refer to the comment in xfont_create for more information. */
+ die("the first font in the cache must be loaded from a font string.");
+ }
+
+ fcpattern = FcPatternDuplicate(drw->fonts->pattern);
+ FcPatternAddCharSet(fcpattern, FC_CHARSET, fccharset);
+ FcPatternAddBool(fcpattern, FC_SCALABLE, FcTrue);
+
+ FcConfigSubstitute(NULL, fcpattern, FcMatchPattern);
+ FcDefaultSubstitute(fcpattern);
+ match = XftFontMatch(drw->dpy, drw->screen, fcpattern, &result);
+
+ FcCharSetDestroy(fccharset);
+ FcPatternDestroy(fcpattern);
+
+ if (match) {
+ usedfont = xfont_create(drw, NULL, match);
+ if (usedfont && XftCharExists(drw->dpy, usedfont->xfont, utf8codepoint)) {
+ for (curfont = drw->fonts; curfont->next; curfont = curfont->next)
+ ; /* NOP */
+ curfont->next = usedfont;
+ } else {
+ xfont_free(usedfont);
+ nomatches.codepoint[++nomatches.idx % nomatches_len] = utf8codepoint;
+no_match:
+ usedfont = drw->fonts;
+ }
+ }
+ }
+ }
+ if (d)
+ XftDrawDestroy(d);
+
+ return x + (render ? w : 0);
+}
+
+void
+drw_pic(Drw *drw, int x, int y, unsigned int w, unsigned int h, Picture pic)
+{
+ if (!drw)
+ return;
+ XRenderComposite(drw->dpy, PictOpOver, pic, None, drw->picture, 0, 0, 0, 0, x, y, w, h);
+}
+
+void
+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);
+ XSync(drw->dpy, False);
+}
+
+unsigned int
+drw_fontset_getwidth(Drw *drw, const char *text)
+{
+ if (!drw || !drw->fonts || !text)
+ return 0;
+ return drw_text(drw, 0, 0, 0, 0, 0, text, 0);
+}
+
+unsigned int
+drw_fontset_getwidth_clamp(Drw *drw, const char *text, unsigned int n)
+{
+ 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);
+}
+
+void
+drw_font_getexts(Fnt *font, const char *text, unsigned int len, unsigned int *w, unsigned int *h)
+{
+ XGlyphInfo ext;
+
+ if (!font || !text)
+ return;
+
+ XftTextExtentsUtf8(font->dpy, font->xfont, (XftChar8 *)text, len, &ext);
+ if (w)
+ *w = ext.xOff;
+ if (h)
+ *h = font->h;
+}
+
+Cur *
+drw_cur_create(Drw *drw, int shape)
+{
+ Cur *cur;
+
+ if (!drw || !(cur = ecalloc(1, sizeof(Cur))))
+ return NULL;
+
+ cur->cursor = XCreateFontCursor(drw->dpy, shape);
+
+ return cur;
+}
+
+void
+drw_cur_free(Drw *drw, Cur *cursor)
+{
+ if (!cursor)
+ return;
+
+ XFreeCursor(drw->dpy, cursor->cursor);
+ free(cursor);
+}
diff --git a/drw.h b/drw.h
@@ -0,0 +1,65 @@
+/* See LICENSE file for copyright and license details. */
+
+typedef struct {
+ Cursor cursor;
+} Cur;
+
+typedef struct Fnt {
+ Display *dpy;
+ unsigned int h;
+ XftFont *xfont;
+ FcPattern *pattern;
+ struct Fnt *next;
+} Fnt;
+
+enum { ColFg, ColBg, ColBorder }; /* Clr scheme index */
+typedef XftColor Clr;
+
+typedef struct {
+ unsigned int w, h;
+ Display *dpy;
+ int screen;
+ Window root;
+ Visual *visual;
+ unsigned int depth;
+ Colormap cmap;
+ Drawable drawable;
+ Picture picture;
+ GC gc;
+ Clr *scheme;
+ Fnt *fonts;
+} Drw;
+
+/* Drawable abstraction */
+Drw *drw_create(Display *dpy, int screen, Window win, unsigned int w, unsigned int h, Visual *visual, unsigned int depth, Colormap cmap);
+void drw_resize(Drw *drw, unsigned int w, unsigned int h);
+void drw_free(Drw *drw);
+
+/* Fnt abstraction */
+Fnt *drw_fontset_create(Drw* drw, const char *fonts[], size_t fontcount);
+void drw_fontset_free(Fnt* set);
+unsigned int drw_fontset_getwidth(Drw *drw, const char *text);
+unsigned int drw_fontset_getwidth_clamp(Drw *drw, const char *text, unsigned int n);
+void drw_font_getexts(Fnt *font, const char *text, unsigned int len, unsigned int *w, unsigned int *h);
+
+/* Colorscheme abstraction */
+void drw_clr_create(Drw *drw, Clr *dest, const char *clrname, unsigned int alpha);
+Clr *drw_scm_create(Drw *drw, char *clrnames[], const unsigned int alphas[], size_t clrcount);
+
+/* Cursor abstraction */
+Cur *drw_cur_create(Drw *drw, int shape);
+void drw_cur_free(Drw *drw, Cur *cursor);
+
+/* Drawing context manipulation */
+void drw_setfontset(Drw *drw, Fnt *set);
+void drw_setscheme(Drw *drw, Clr *scm);
+
+Picture drw_picture_create_resized(Drw *drw, char *src, unsigned int src_w, unsigned int src_h, unsigned int dst_w, unsigned int dst_h);
+
+/* Drawing functions */
+void drw_rect(Drw *drw, int x, int y, unsigned int w, unsigned int h, int filled, int invert);
+int drw_text(Drw *drw, int x, int y, unsigned int w, unsigned int h, unsigned int lpad, const char *text, int invert);
+void drw_pic(Drw *drw, int x, int y, unsigned int w, unsigned int h, Picture pic);
+
+/* Map functions */
+void drw_map(Drw *drw, Window win, int x, int y, unsigned int w, unsigned int h);
diff --git a/drw.o b/drw.o
Binary files differ.
diff --git a/exitdwm.c b/exitdwm.c
@@ -0,0 +1,79 @@
+#include <stdio.h>
+#include <string.h>
+
+void exitdwm() {
+#if defined S_LOCK || defined S_RESTART_DWM || defined S_SLEEP || \
+ defined S_RESTARTER_SCRIPT || defined S_EXIT || defined S_REBOOT || \
+ defined S_SHUTDOWN || defined S_LOCK_ICON || defined S_RESTART_DWM_ICON || \
+ defined S_SLEEP_ICON || defined S_EXIT_ICON || \
+ defined S_RESTARTER_SCRIPT_ICON || defined S_REBOOT_ICON || \
+ defined S_SHUTDOWN_ICON || defined S_FORMAT || defined S_FORMAT_CLEAR
+#error(conflicting macro names)
+#endif
+
+#define S_LOCK "Lock"
+#define S_RESTART_DWM "restart birdwm"
+#define S_SLEEP "Off-screen"
+#define S_RESTARTER_SCRIPT "Restarter Script"
+#define S_EXIT "Exit"
+#define S_REBOOT "Reboot"
+#define S_SHUTDOWN "Shutdown"
+#define S_LOCK_ICON "\uf023" // <= FontAwesome icons
+#define S_RESTART_DWM_ICON "\uf01e"
+#define S_SLEEP_ICON "\uf108"
+#define S_EXIT_ICON "\uf2f5"
+#define S_RESTARTER_SCRIPT_ICON "\uf0c9"
+#define S_REBOOT_ICON "\uf021"
+#define S_SHUTDOWN_ICON "\uf011"
+
+#define S_FORMAT(ACTION) S_##ACTION##_ICON " " S_##ACTION
+#define S_FORMAT_CLEAR "sed 's/^..//'"
+
+ FILE *exit_menu = popen(
+ "echo \"" S_FORMAT(LOCK) "\n" S_FORMAT(RESTART_DWM) "\n" S_FORMAT(SLEEP) "\n" S_FORMAT(
+ RESTARTER_SCRIPT) "\n" S_FORMAT(EXIT) "\n" S_FORMAT(REBOOT) "\n" S_FORMAT(SHUTDOWN) "\" | birdmenu -i -p exit: | " S_FORMAT_CLEAR,
+ "r");
+
+ char exit_action[16];
+
+ if (exit_menu == NULL ||
+ fscanf(exit_menu, "%15[a-zA-Z -]", exit_action) == EOF) {
+ fputs("Error. Failure in exit_dwm.", stderr);
+ goto close_streams;
+ }
+
+ if (strcmp(exit_action, S_LOCK) == 0)
+ system("slock & sleep 5; xset dpms force off");
+ else if (strcmp(exit_action, S_RESTART_DWM) == 0)
+ quit(&(const Arg){1});
+ else if (strcmp(exit_action, S_SLEEP) == 0)
+ system("pkexec loginctl suspend");
+ else if (strcmp(exit_action, S_EXIT) == 0)
+ quit(&(const Arg){0});
+ else if (strcmp(exit_action, S_RESTARTER_SCRIPT) == 0)
+ system("restarter");
+ else if (strcmp(exit_action, S_REBOOT) == 0)
+ system("pkexec reboot");
+ else if (strcmp(exit_action, S_SHUTDOWN) == 0)
+ system("pkexec poweroff now");
+
+close_streams:
+ pclose(exit_menu);
+
+#undef S_LOCK
+#undef S_RESTART_DWM
+#undef S_SLEEP
+#undef S_EXIT
+#undef S_RESTARTER_SCRIPT
+#undef S_REBOOT
+#undef S_SHUTDOWN
+#undef S_LOCK_ICON
+#undef S_RESTART_DWM_ICON
+#undef S_SLEEP_ICON
+#undef S_EXIT_ICON
+#undef S_RESTARTER_SCRIPT_ICON
+#undef S_REBOOT_ICON
+#undef S_SHUTDOWN_ICON
+#undef S_FORMAT
+#undef S_FORMAT_CLEAR
+}
diff --git a/extras/birdmenu-emoji/LICENSE b/extras/birdmenu-emoji/LICENSE
@@ -0,0 +1,19 @@
+Copyright (c) 2018 Sergio Gil
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in all
+copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+SOFTWARE.
diff --git a/extras/birdmenu-emoji/Makefile b/extras/birdmenu-emoji/Makefile
@@ -0,0 +1,22 @@
+default: dmenu-emoji.sh
+
+dmenu-emoji.sh: script.sh emoji.txt
+ @cat script.sh emoji.txt > $@
+ @chmod +x $@
+ @du -sh $@
+
+emoji.txt: emoji.json parse.sh
+ @sh parse.sh < emoji.json > $@
+
+emoji.json:
+ @echo "Downloading emoji table from https://github.com/github/gemoji (Emoji Ruby gem)"
+ @echo
+ @curl https://raw.githubusercontent.com/github/gemoji/master/db/emoji.json > $@
+ @echo
+
+.PHONY: update
+update: clean default
+
+.PHONY: clean
+clean:
+ @rm -f emoji.json emoji.txt
diff --git a/extras/birdmenu-emoji/README.md b/extras/birdmenu-emoji/README.md
@@ -0,0 +1,40 @@
+# dmenu-emoji 💃
+
+Search an emoji by name and copy it to the clipboard. Works best with a dmenu variant that does fuzzy search such as [rofi](https://github.com/DaveDavenport/rofi), but it's compatible with plain [dmenu](https://tools.suckless.org/dmenu/).
+
+If possible, it also sends a desktop notification for better user feedback.
+
+[](https://i.imgur.com/E6kJHGL.gifv)
+
+[Click the screenshot for a 4MB GIF of how the emoji in the header was added]
+
+## Usage with i3
+
+Download `dmenu-emoji.sh`, make sure it's executable (`chmod + x <file>`), and store it somewhere in your home directory (or in your `$PATH` if you prefer). Assign a keystroke in your [i3](https://i3wm.org/) configuration:
+
+```
+# ~/.config/i3/config
+
+bindsym $mod+space exec path/to/dmenu-emoji.sh
+```
+
+`dmenu-emoji.sh` is the only file you need, the rest of the files in this repository are scripts to generate that one, which you don't need unless you want to modify it (PRs welcome!).
+
+### Tweeking the `dmenu` command
+
+By default, `dmenu` is called. If you want to use a different menu or pass some option to it, you can use the `list` and `copy` subcommands:
+
+```
+# ~/.config/i3/config
+
+bindsym $mod+space exec dmenu-emoji.sh list | rofi -dmenu -p 'Emoji: ' | dmenu-emoji.sh copy
+```
+
+## Similar scripts
+
+* [emoji.sh](https://gist.github.com/markmandel/546fc099590f1c08fa936795ac9da143). One liner, requests emojis each time, no autocomplete
+* [rofimoji](https://github.com/fdw/rofimoji). Python-based, rofi only, can insert directly instead of copy&paste
+* [emoji-rofi-menu](https://github.com/rob-a-bolton/emoji-rofi-menu). Rofi only, can insert directly
+* [rofi-emoji](https://github.com/hatzel/rofi-emoji/). Python-based (but generates a bash script so Python is not used each time), rofi only, inserts-directly
+
+It takes very little time to write so there are probably more 😅
diff --git a/extras/birdmenu-emoji/dmenu-emoji.sh b/extras/birdmenu-emoji/dmenu-emoji.sh
@@ -0,0 +1,1457 @@
+#!/bin/bash
+
+set -e
+
+case "$1" in
+ "list")
+ data=$(sed '0,/^__DATA__$/d' "$0")
+ echo "$data"
+ ;;
+ "copy")
+ input=$(tee)
+ if [ ! -z "$input" ]; then
+ emoji=${input: -1}
+ echo -n "$emoji" | xclip -selection c
+ command -v notify-send > /dev/null && notify-send -t 200 "$emoji copied!"
+ fi
+ ;;
+ "")
+ bash $0 list | dmenu -p 'Emoji: ' | bash $0 copy
+ ;;
+esac
+
+exit
+
+__DATA__
+grinning face 😀
+smiling face with open mouth 😃
+smiling face with open mouth & smiling eyes 😄
+grinning face with smiling eyes 😁
+smiling face with open mouth & closed eyes 😆
+smiling face with open mouth & cold sweat 😅
+face with tears of joy 😂
+rolling on the floor laughing 🤣
+smiling face ☺️
+smiling face with smiling eyes 😊
+smiling face with halo 😇
+slightly smiling face 🙂
+upside-down face 🙃
+winking face 😉
+relieved face 😌
+smiling face with heart-eyes 😍
+face blowing a kiss 😘
+kissing face 😗
+kissing face with smiling eyes 😙
+kissing face with closed eyes 😚
+face savouring delicious food 😋
+face with stuck-out tongue & winking eye 😜
+face with stuck-out tongue & closed eyes 😝
+face with stuck-out tongue 😛
+money-mouth face 🤑
+hugging face 🤗
+nerd face 🤓
+smiling face with sunglasses 😎
+clown face 🤡
+cowboy hat face 🤠
+smirking face 😏
+unamused face 😒
+disappointed face 😞
+pensive face 😔
+worried face 😟
+confused face 😕
+slightly frowning face 🙁
+frowning face ☹️
+persevering face 😣
+confounded face 😖
+tired face 😫
+weary face 😩
+face with steam from nose 😤
+angry face 😠
+pouting face 😡
+face without mouth 😶
+neutral face 😐
+expressionless face 😑
+hushed face 😯
+frowning face with open mouth 😦
+anguished face 😧
+face with open mouth 😮
+astonished face 😲
+dizzy face 😵
+flushed face 😳
+face screaming in fear 😱
+fearful face 😨
+face with open mouth & cold sweat 😰
+crying face 😢
+disappointed but relieved face 😥
+drooling face 🤤
+loudly crying face 😭
+face with cold sweat 😓
+sleepy face 😪
+sleeping face 😴
+face with rolling eyes 🙄
+thinking face 🤔
+lying face 🤥
+grimacing face 😬
+zipper-mouth face 🤐
+nauseated face 🤢
+sneezing face 🤧
+face with medical mask 😷
+face with thermometer 🤒
+face with head-bandage 🤕
+smiling face with horns 😈
+angry face with horns 👿
+ogre 👹
+goblin 👺
+pile of poo 💩
+ghost 👻
+skull 💀
+skull and crossbones ☠️
+alien 👽
+alien monster 👾
+robot face 🤖
+jack-o-lantern 🎃
+smiling cat face with open mouth 😺
+grinning cat face with smiling eyes 😸
+cat face with tears of joy 😹
+smiling cat face with heart-eyes 😻
+cat face with wry smile 😼
+kissing cat face with closed eyes 😽
+weary cat face 🙀
+crying cat face 😿
+pouting cat face 😾
+open hands 👐
+raising hands 🙌
+clapping hands 👏
+folded hands 🙏
+handshake 🤝
+thumbs up 👍
+thumbs down 👎
+oncoming fist 👊
+raised fist ✊
+left-facing fist 🤛
+right-facing fist 🤜
+crossed fingers 🤞
+victory hand ✌️
+sign of the horns 🤘
+OK hand 👌
+backhand index pointing left 👈
+backhand index pointing right 👉
+backhand index pointing up 👆
+backhand index pointing down 👇
+index pointing up ☝️
+raised hand ✋
+raised back of hand 🤚
+raised hand with fingers splayed 🖐
+vulcan salute 🖖
+waving hand 👋
+call me hand 🤙
+flexed biceps 💪
+middle finger 🖕
+writing hand ✍️
+selfie 🤳
+nail polish 💅
+ring 💍
+lipstick 💄
+kiss mark 💋
+mouth 👄
+tongue 👅
+ear 👂
+nose 👃
+footprints 👣
+eye 👁
+eyes 👀
+speaking head 🗣
+bust in silhouette 👤
+busts in silhouette 👥
+baby 👶
+boy 👦
+girl 👧
+man 👨
+woman 👩
+blond-haired woman 👱♀
+blond-haired person 👱
+old man 👴
+old woman 👵
+man with Chinese cap 👲
+woman wearing turban 👳♀
+person wearing turban 👳
+woman police officer 👮♀
+police officer 👮
+woman construction worker 👷♀
+construction worker 👷
+woman guard 💂♀
+guard 💂
+woman detective 🕵️♀️
+detective 🕵
+woman health worker 👩⚕
+man health worker 👨⚕
+woman farmer 👩🌾
+man farmer 👨🌾
+woman cook 👩🍳
+man cook 👨🍳
+woman student 👩🎓
+man student 👨🎓
+woman singer 👩🎤
+man singer 👨🎤
+woman teacher 👩🏫
+man teacher 👨🏫
+woman factory worker 👩🏭
+man factory worker 👨🏭
+woman technologist 👩💻
+man technologist 👨💻
+woman office worker 👩💼
+man office worker 👨💼
+woman mechanic 👩🔧
+man mechanic 👨🔧
+woman scientist 👩🔬
+man scientist 👨🔬
+woman artist 👩🎨
+man artist 👨🎨
+woman firefighter 👩🚒
+man firefighter 👨🚒
+woman pilot 👩✈
+man pilot 👨✈
+woman astronaut 👩🚀
+man astronaut 👨🚀
+woman judge 👩⚖
+man judge 👨⚖
+Mrs. Claus 🤶
+Santa Claus 🎅
+princess 👸
+prince 🤴
+bride with veil 👰
+man in tuxedo 🤵
+baby angel 👼
+pregnant woman 🤰
+woman bowing 🙇♀
+person bowing 🙇
+person tipping hand 💁
+man tipping hand 💁♂
+person gesturing NO 🙅
+man gesturing NO 🙅♂
+person gesturing OK 🙆
+man gesturing OK 🙆♂
+person raising hand 🙋
+man raising hand 🙋♂
+woman facepalming 🤦♀
+man facepalming 🤦♂
+woman shrugging 🤷♀
+man shrugging 🤷♂
+person pouting 🙎
+man pouting 🙎♂
+person frowning 🙍
+man frowning 🙍♂
+person getting haircut 💇
+man getting haircut 💇♂
+person getting massage 💆
+man getting massage 💆♂
+man in business suit levitating 🕴
+woman dancing 💃
+man dancing 🕺
+people with bunny ears partying 👯
+men with bunny ears partying 👯♂
+woman walking 🚶♀
+person walking 🚶
+woman running 🏃♀
+person running 🏃
+man and woman holding hands 👫
+two women holding hands 👭
+two men holding hands 👬
+couple with heart 💑
+couple with heart: woman woman 👩❤️👩
+couple with heart: man man 👨❤️👨
+kiss 💏
+kiss: woman woman 👩❤️💋👩
+kiss: man man 👨❤️💋👨
+family 👪
+family: man woman girl 👨👩👧
+family: man woman girl boy 👨👩👧👦
+family: man woman boy boy 👨👩👦👦
+family: man woman girl girl 👨👩👧👧
+family: woman woman boy 👩👩👦
+family: woman woman girl 👩👩👧
+family: woman woman girl boy 👩👩👧👦
+family: woman woman boy boy 👩👩👦👦
+family: woman woman girl girl 👩👩👧👧
+family: man man boy 👨👨👦
+family: man man girl 👨👨👧
+family: man man girl boy 👨👨👧👦
+family: man man boy boy 👨👨👦👦
+family: man man girl girl 👨👨👧👧
+family: woman boy 👩👦
+family: woman girl 👩👧
+family: woman girl boy 👩👧👦
+family: woman boy boy 👩👦👦
+family: woman girl girl 👩👧👧
+family: man boy 👨👦
+family: man girl 👨👧
+family: man girl boy 👨👧👦
+family: man boy boy 👨👦👦
+family: man girl girl 👨👧👧
+woman’s clothes 👚
+t-shirt 👕
+jeans 👖
+necktie 👔
+dress 👗
+bikini 👙
+kimono 👘
+high-heeled shoe 👠
+woman’s sandal 👡
+woman’s boot 👢
+man’s shoe 👞
+running shoe 👟
+woman’s hat 👒
+top hat 🎩
+graduation cap 🎓
+crown 👑
+rescue worker’s helmet ⛑
+school backpack 🎒
+clutch bag 👝
+purse 👛
+handbag 👜
+briefcase 💼
+glasses 👓
+sunglasses 🕶
+closed umbrella 🌂
+umbrella ☂️
+dog face 🐶
+cat face 🐱
+mouse face 🐭
+hamster face 🐹
+rabbit face 🐰
+fox face 🦊
+bear face 🐻
+panda face 🐼
+koala 🐨
+tiger face 🐯
+lion face 🦁
+cow face 🐮
+pig face 🐷
+pig nose 🐽
+frog face 🐸
+monkey face 🐵
+see-no-evil monkey 🙈
+hear-no-evil monkey 🙉
+speak-no-evil monkey 🙊
+monkey 🐒
+chicken 🐔
+penguin 🐧
+bird 🐦
+baby chick 🐤
+hatching chick 🐣
+front-facing baby chick 🐥
+duck 🦆
+eagle 🦅
+owl 🦉
+bat 🦇
+wolf face 🐺
+boar 🐗
+horse face 🐴
+unicorn face 🦄
+honeybee 🐝
+bug 🐛
+butterfly 🦋
+snail 🐌
+spiral shell 🐚
+lady beetle 🐞
+ant 🐜
+spider 🕷
+spider web 🕸
+turtle 🐢
+snake 🐍
+lizard 🦎
+scorpion 🦂
+crab 🦀
+squid 🦑
+octopus 🐙
+shrimp 🦐
+tropical fish 🐠
+fish 🐟
+blowfish 🐡
+dolphin 🐬
+shark 🦈
+spouting whale 🐳
+whale 🐋
+crocodile 🐊
+leopard 🐆
+tiger 🐅
+water buffalo 🐃
+ox 🐂
+cow 🐄
+deer 🦌
+camel 🐪
+two-hump camel 🐫
+elephant 🐘
+rhinoceros 🦏
+gorilla 🦍
+horse 🐎
+pig 🐖
+goat 🐐
+ram 🐏
+sheep 🐑
+dog 🐕
+poodle 🐩
+cat 🐈
+rooster 🐓
+turkey 🦃
+dove 🕊
+rabbit 🐇
+mouse 🐁
+rat 🐀
+chipmunk 🐿
+paw prints 🐾
+dragon 🐉
+dragon face 🐲
+cactus 🌵
+Christmas tree 🎄
+evergreen tree 🌲
+deciduous tree 🌳
+palm tree 🌴
+seedling 🌱
+herb 🌿
+shamrock ☘️
+four leaf clover 🍀
+pine decoration 🎍
+tanabata tree 🎋
+leaf fluttering in wind 🍃
+fallen leaf 🍂
+maple leaf 🍁
+mushroom 🍄
+sheaf of rice 🌾
+bouquet 💐
+tulip 🌷
+rose 🌹
+wilted flower 🥀
+sunflower 🌻
+blossom 🌼
+cherry blossom 🌸
+hibiscus 🌺
+globe showing Americas 🌎
+globe showing Europe-Africa 🌍
+globe showing Asia-Australia 🌏
+full moon 🌕
+waning gibbous moon 🌖
+last quarter moon 🌗
+waning crescent moon 🌘
+new moon 🌑
+waxing crescent moon 🌒
+first quarter moon 🌓
+waxing gibbous moon 🌔
+new moon face 🌚
+full moon with face 🌝
+sun with face 🌞
+first quarter moon with face 🌛
+last quarter moon with face 🌜
+crescent moon 🌙
+dizzy 💫
+white medium star ⭐️
+glowing star 🌟
+sparkles ✨
+high voltage ⚡️
+fire 🔥
+collision 💥
+comet ☄
+sun ☀️
+sun behind small cloud 🌤
+sun behind cloud ⛅️
+sun behind large cloud 🌥
+sun behind rain cloud 🌦
+rainbow 🌈
+cloud ☁️
+cloud with rain 🌧
+cloud with lightning and rain ⛈
+cloud with lightning 🌩
+cloud with snow 🌨
+snowman ☃️
+snowman without snow ⛄️
+snowflake ❄️
+wind face 🌬
+dashing away 💨
+tornado 🌪
+fog 🌫
+water wave 🌊
+droplet 💧
+sweat droplets 💦
+umbrella with rain drops ☔️
+green apple 🍏
+red apple 🍎
+pear 🍐
+tangerine 🍊
+lemon 🍋
+banana 🍌
+watermelon 🍉
+grapes 🍇
+strawberry 🍓
+melon 🍈
+cherries 🍒
+peach 🍑
+pineapple 🍍
+kiwi fruit 🥝
+avocado 🥑
+tomato 🍅
+eggplant 🍆
+cucumber 🥒
+carrot 🥕
+ear of corn 🌽
+hot pepper 🌶
+potato 🥔
+roasted sweet potato 🍠
+chestnut 🌰
+peanuts 🥜
+honey pot 🍯
+croissant 🥐
+bread 🍞
+baguette bread 🥖
+cheese wedge 🧀
+egg 🥚
+cooking 🍳
+bacon 🥓
+pancakes 🥞
+fried shrimp 🍤
+poultry leg 🍗
+meat on bone 🍖
+pizza 🍕
+hot dog 🌭
+hamburger 🍔
+french fries 🍟
+stuffed flatbread 🥙
+taco 🌮
+burrito 🌯
+green salad 🥗
+shallow pan of food 🥘
+spaghetti 🍝
+steaming bowl 🍜
+pot of food 🍲
+fish cake with swirl 🍥
+sushi 🍣
+bento box 🍱
+curry rice 🍛
+cooked rice 🍚
+rice ball 🍙
+rice cracker 🍘
+oden 🍢
+dango 🍡
+shaved ice 🍧
+ice cream 🍨
+soft ice cream 🍦
+shortcake 🍰
+birthday cake 🎂
+custard 🍮
+lollipop 🍭
+candy 🍬
+chocolate bar 🍫
+popcorn 🍿
+doughnut 🍩
+cookie 🍪
+glass of milk 🥛
+baby bottle 🍼
+hot beverage ☕️
+teacup without handle 🍵
+sake 🍶
+beer mug 🍺
+clinking beer mugs 🍻
+clinking glasses 🥂
+wine glass 🍷
+tumbler glass 🥃
+cocktail glass 🍸
+tropical drink 🍹
+bottle with popping cork 🍾
+spoon 🥄
+fork and knife 🍴
+fork and knife with plate 🍽
+soccer ball ⚽️
+basketball 🏀
+american football 🏈
+baseball ⚾️
+tennis 🎾
+volleyball 🏐
+rugby football 🏉
+pool 8 ball 🎱
+ping pong 🏓
+badminton 🏸
+goal net 🥅
+ice hockey 🏒
+field hockey 🏑
+cricket 🏏
+flag in hole ⛳️
+bow and arrow 🏹
+fishing pole 🎣
+boxing glove 🥊
+martial arts uniform 🥋
+ice skate ⛸
+skis 🎿
+skier ⛷
+snowboarder 🏂
+woman lifting weights 🏋️♀️
+person lifting weights 🏋
+person fencing 🤺
+women wrestling 🤼♀
+men wrestling 🤼♂
+woman cartwheeling 🤸♀
+man cartwheeling 🤸♂
+woman bouncing ball ⛹️♀️
+person bouncing ball ⛹
+woman playing handball 🤾♀
+man playing handball 🤾♂
+woman golfing 🏌️♀️
+person golfing 🏌
+woman surfing 🏄♀
+person surfing 🏄
+woman swimming 🏊♀
+person swimming 🏊
+woman playing water polo 🤽♀
+man playing water polo 🤽♂
+woman rowing boat 🚣♀
+person rowing boat 🚣
+horse racing 🏇
+woman biking 🚴♀
+person biking 🚴
+woman mountain biking 🚵♀
+person mountain biking 🚵
+running shirt 🎽
+sports medal 🏅
+military medal 🎖
+1st place medal 🥇
+2nd place medal 🥈
+3rd place medal 🥉
+trophy 🏆
+rosette 🏵
+reminder ribbon 🎗
+ticket 🎫
+admission tickets 🎟
+circus tent 🎪
+woman juggling 🤹♀
+man juggling 🤹♂
+performing arts 🎭
+artist palette 🎨
+clapper board 🎬
+microphone 🎤
+headphone 🎧
+musical score 🎼
+musical keyboard 🎹
+drum 🥁
+saxophone 🎷
+trumpet 🎺
+guitar 🎸
+violin 🎻
+game die 🎲
+direct hit 🎯
+bowling 🎳
+video game 🎮
+slot machine 🎰
+automobile 🚗
+taxi 🚕
+sport utility vehicle 🚙
+bus 🚌
+trolleybus 🚎
+racing car 🏎
+police car 🚓
+ambulance 🚑
+fire engine 🚒
+minibus 🚐
+delivery truck 🚚
+articulated lorry 🚛
+tractor 🚜
+kick scooter 🛴
+bicycle 🚲
+motor scooter 🛵
+motorcycle 🏍
+police car light 🚨
+oncoming police car 🚔
+oncoming bus 🚍
+oncoming automobile 🚘
+oncoming taxi 🚖
+aerial tramway 🚡
+mountain cableway 🚠
+suspension railway 🚟
+railway car 🚃
+tram car 🚋
+mountain railway 🚞
+monorail 🚝
+high-speed train 🚄
+high-speed train with bullet nose 🚅
+light rail 🚈
+locomotive 🚂
+train 🚆
+metro 🚇
+tram 🚊
+station 🚉
+helicopter 🚁
+small airplane 🛩
+airplane ✈️
+airplane departure 🛫
+airplane arrival 🛬
+rocket 🚀
+satellite 🛰
+seat 💺
+canoe 🛶
+sailboat ⛵️
+motor boat 🛥
+speedboat 🚤
+passenger ship 🛳
+ferry ⛴
+ship 🚢
+anchor ⚓️
+construction 🚧
+fuel pump ⛽️
+bus stop 🚏
+vertical traffic light 🚦
+horizontal traffic light 🚥
+world map 🗺
+moai 🗿
+Statue of Liberty 🗽
+fountain ⛲️
+Tokyo tower 🗼
+castle 🏰
+Japanese castle 🏯
+stadium 🏟
+ferris wheel 🎡
+roller coaster 🎢
+carousel horse 🎠
+umbrella on ground ⛱
+beach with umbrella 🏖
+desert island 🏝
+mountain ⛰
+snow-capped mountain 🏔
+mount fuji 🗻
+volcano 🌋
+desert 🏜
+camping 🏕
+tent ⛺️
+railway track 🛤
+motorway 🛣
+building construction 🏗
+factory 🏭
+house 🏠
+house with garden 🏡
+house 🏘
+derelict house 🏚
+office building 🏢
+department store 🏬
+Japanese post office 🏣
+post office 🏤
+hospital 🏥
+bank 🏦
+hotel 🏨
+convenience store 🏪
+school 🏫
+love hotel 🏩
+wedding 💒
+classical building 🏛
+church ⛪️
+mosque 🕌
+synagogue 🕍
+kaaba 🕋
+shinto shrine ⛩
+map of Japan 🗾
+moon viewing ceremony 🎑
+national park 🏞
+sunrise 🌅
+sunrise over mountains 🌄
+shooting star 🌠
+sparkler 🎇
+fireworks 🎆
+sunset 🌇
+cityscape at dusk 🌆
+cityscape 🏙
+night with stars 🌃
+milky way 🌌
+bridge at night 🌉
+foggy 🌁
+watch ⌚️
+mobile phone 📱
+mobile phone with arrow 📲
+laptop computer 💻
+keyboard ⌨️
+desktop computer 🖥
+printer 🖨
+computer mouse 🖱
+trackball 🖲
+joystick 🕹
+clamp 🗜
+computer disk 💽
+floppy disk 💾
+optical disk 💿
+dvd 📀
+videocassette 📼
+camera 📷
+camera with flash 📸
+video camera 📹
+movie camera 🎥
+film projector 📽
+film frames 🎞
+telephone receiver 📞
+telephone ☎️
+pager 📟
+fax machine 📠
+television 📺
+radio 📻
+studio microphone 🎙
+level slider 🎚
+control knobs 🎛
+stopwatch ⏱
+timer clock ⏲
+alarm clock ⏰
+mantelpiece clock 🕰
+hourglass ⌛️
+hourglass with flowing sand ⏳
+satellite antenna 📡
+battery 🔋
+electric plug 🔌
+light bulb 💡
+flashlight 🔦
+candle 🕯
+wastebasket 🗑
+oil drum 🛢
+money with wings 💸
+dollar banknote 💵
+yen banknote 💴
+euro banknote 💶
+pound banknote 💷
+money bag 💰
+credit card 💳
+gem stone 💎
+balance scale ⚖️
+wrench 🔧
+hammer 🔨
+hammer and pick ⚒
+hammer and wrench 🛠
+pick ⛏
+nut and bolt 🔩
+gear ⚙️
+chains ⛓
+pistol 🔫
+bomb 💣
+kitchen knife 🔪
+dagger 🗡
+crossed swords ⚔️
+shield 🛡
+cigarette 🚬
+coffin ⚰️
+funeral urn ⚱️
+amphora 🏺
+crystal ball 🔮
+prayer beads 📿
+barber pole 💈
+alembic ⚗️
+telescope 🔭
+microscope 🔬
+hole 🕳
+pill 💊
+syringe 💉
+thermometer 🌡
+toilet 🚽
+potable water 🚰
+shower 🚿
+bathtub 🛁
+person taking bath 🛀
+bellhop bell 🛎
+key 🔑
+old key 🗝
+door 🚪
+couch and lamp 🛋
+bed 🛏
+person in bed 🛌
+framed picture 🖼
+shopping bags 🛍
+shopping cart 🛒
+wrapped gift 🎁
+balloon 🎈
+carp streamer 🎏
+ribbon 🎀
+confetti ball 🎊
+party popper 🎉
+Japanese dolls 🎎
+red paper lantern 🏮
+wind chime 🎐
+envelope ✉️
+envelope with arrow 📩
+incoming envelope 📨
+e-mail 📧
+love letter 💌
+inbox tray 📥
+outbox tray 📤
+package 📦
+label 🏷
+closed mailbox with lowered flag 📪
+closed mailbox with raised flag 📫
+open mailbox with raised flag 📬
+open mailbox with lowered flag 📭
+postbox 📮
+postal horn 📯
+scroll 📜
+page with curl 📃
+page facing up 📄
+bookmark tabs 📑
+bar chart 📊
+chart increasing 📈
+chart decreasing 📉
+spiral notepad 🗒
+spiral calendar 🗓
+tear-off calendar 📆
+calendar 📅
+card index 📇
+card file box 🗃
+ballot box with ballot 🗳
+file cabinet 🗄
+clipboard 📋
+file folder 📁
+open file folder 📂
+card index dividers 🗂
+rolled-up newspaper 🗞
+newspaper 📰
+notebook 📓
+notebook with decorative cover 📔
+ledger 📒
+closed book 📕
+green book 📗
+blue book 📘
+orange book 📙
+books 📚
+open book 📖
+bookmark 🔖
+link 🔗
+paperclip 📎
+linked paperclips 🖇
+triangular ruler 📐
+straight ruler 📏
+pushpin 📌
+round pushpin 📍
+scissors ✂️
+pen 🖊
+fountain pen 🖋
+black nib ✒️
+paintbrush 🖌
+crayon 🖍
+memo 📝
+pencil ✏️
+left-pointing magnifying glass 🔍
+right-pointing magnifying glass 🔎
+locked with pen 🔏
+locked with key 🔐
+locked 🔒
+unlocked 🔓
+red heart ❤️
+yellow heart 💛
+green heart 💚
+blue heart 💙
+purple heart 💜
+black heart 🖤
+broken heart 💔
+heavy heart exclamation ❣️
+two hearts 💕
+revolving hearts 💞
+beating heart 💓
+growing heart 💗
+sparkling heart 💖
+heart with arrow 💘
+heart with ribbon 💝
+heart decoration 💟
+peace symbol ☮️
+latin cross ✝️
+star and crescent ☪️
+om 🕉
+wheel of dharma ☸️
+star of David ✡️
+dotted six-pointed star 🔯
+menorah 🕎
+yin yang ☯️
+orthodox cross ☦️
+place of worship 🛐
+Ophiuchus ⛎
+Aries ♈️
+Taurus ♉️
+Gemini ♊️
+Cancer ♋️
+Leo ♌️
+Virgo ♍️
+Libra ♎️
+Scorpius ♏️
+Sagittarius ♐️
+Capricorn ♑️
+Aquarius ♒️
+Pisces ♓️
+ID button 🆔
+atom symbol ⚛️
+Japanese “acceptable” button 🉑
+radioactive ☢️
+biohazard ☣️
+mobile phone off 📴
+vibration mode 📳
+Japanese “not free of charge” button 🈶
+Japanese “free of charge” button 🈚️
+Japanese “application” button 🈸
+Japanese “open for business” button 🈺
+Japanese “monthly amount” button 🈷️
+eight-pointed star ✴️
+VS button 🆚
+white flower 💮
+Japanese “bargain” button 🉐
+Japanese “secret” button ㊙️
+Japanese “congratulations” button ㊗️
+Japanese “passing grade” button 🈴
+Japanese “no vacancy” button 🈵
+Japanese “discount” button 🈹
+Japanese “prohibited” button 🈲
+A button (blood type) 🅰️
+B button (blood type) 🅱️
+AB button (blood type) 🆎
+CL button 🆑
+O button (blood type) 🅾️
+SOS button 🆘
+cross mark ❌
+heavy large circle ⭕️
+stop sign 🛑
+no entry ⛔️
+name badge 📛
+prohibited 🚫
+hundred points 💯
+anger symbol 💢
+hot springs ♨️
+no pedestrians 🚷
+no littering 🚯
+no bicycles 🚳
+non-potable water 🚱
+no one under eighteen 🔞
+no mobile phones 📵
+no smoking 🚭
+exclamation mark ❗️
+white exclamation mark ❕
+question mark ❓
+white question mark ❔
+double exclamation mark ‼️
+exclamation question mark ⁉️
+dim button 🔅
+bright button 🔆
+part alternation mark 〽️
+warning ⚠️
+children crossing 🚸
+trident emblem 🔱
+fleur-de-lis ⚜️
+Japanese symbol for beginner 🔰
+recycling symbol ♻️
+white heavy check mark ✅
+Japanese “reserved” button 🈯️
+chart increasing with yen 💹
+sparkle ❇️
+eight-spoked asterisk ✳️
+cross mark button ❎
+globe with meridians 🌐
+diamond with a dot 💠
+circled M Ⓜ️
+cyclone 🌀
+zzz 💤
+ATM sign 🏧
+water closet 🚾
+wheelchair symbol ♿️
+P button 🅿️
+Japanese “vacancy” button 🈳
+Japanese “service charge” button 🈂️
+passport control 🛂
+customs 🛃
+baggage claim 🛄
+left luggage 🛅
+men’s room 🚹
+women’s room 🚺
+baby symbol 🚼
+restroom 🚻
+litter in bin sign 🚮
+cinema 🎦
+antenna bars 📶
+Japanese “here” button 🈁
+input symbols 🔣
+information ℹ️
+input latin letters 🔤
+input latin lowercase 🔡
+input latin uppercase 🔠
+NG button 🆖
+OK button 🆗
+UP! button 🆙
+COOL button 🆒
+NEW button 🆕
+FREE button 🆓
+keycap: 0 0️⃣
+keycap: 1 1️⃣
+keycap: 2 2️⃣
+keycap: 3 3️⃣
+keycap: 4 4️⃣
+keycap: 5 5️⃣
+keycap: 6 6️⃣
+keycap: 7 7️⃣
+keycap: 8 8️⃣
+keycap: 9 9️⃣
+keycap 10 🔟
+input numbers 🔢
+keycap: # #️⃣
+keycap: * *️⃣
+play button ▶️
+pause button ⏸
+play or pause button ⏯
+stop button ⏹
+record button ⏺
+next track button ⏭
+last track button ⏮
+fast-forward button ⏩
+fast reverse button ⏪
+fast up button ⏫
+fast down button ⏬
+reverse button ◀️
+up button 🔼
+down button 🔽
+right arrow ➡️
+left arrow ⬅️
+up arrow ⬆️
+down arrow ⬇️
+up-right arrow ↗️
+down-right arrow ↘️
+down-left arrow ↙️
+up-left arrow ↖️
+up-down arrow ↕️
+left-right arrow ↔️
+left arrow curving right ↪️
+right arrow curving left ↩️
+right arrow curving up ⤴️
+right arrow curving down ⤵️
+shuffle tracks button 🔀
+repeat button 🔁
+repeat single button 🔂
+anticlockwise arrows button 🔄
+clockwise vertical arrows 🔃
+musical note 🎵
+musical notes 🎶
+heavy plus sign ➕
+heavy minus sign ➖
+heavy division sign ➗
+heavy multiplication x ✖️
+heavy dollar sign 💲
+currency exchange 💱
+trade mark ™️
+copyright ©️
+registered ®️
+wavy dash 〰️
+curly loop ➰
+double curly loop ➿
+END arrow 🔚
+BACK arrow 🔙
+ON! arrow 🔛
+TOP arrow 🔝
+SOON arrow 🔜
+heavy check mark ✔️
+ballot box with check ☑️
+radio button 🔘
+white circle ⚪️
+black circle ⚫️
+red circle 🔴
+blue circle 🔵
+red triangle pointed up 🔺
+red triangle pointed down 🔻
+small orange diamond 🔸
+small blue diamond 🔹
+large orange diamond 🔶
+large blue diamond 🔷
+white square button 🔳
+black square button 🔲
+black small square ▪️
+white small square ▫️
+black medium-small square ◾️
+white medium-small square ◽️
+black medium square ◼️
+white medium square ◻️
+black large square ⬛️
+white large square ⬜️
+speaker low volume 🔈
+muted speaker 🔇
+speaker medium volume 🔉
+speaker high volume 🔊
+bell 🔔
+bell with slash 🔕
+megaphone 📣
+loudspeaker 📢
+eye in speech bubble 👁🗨
+speech balloon 💬
+thought balloon 💭
+right anger bubble 🗯
+spade suit ♠️
+club suit ♣️
+heart suit ♥️
+diamond suit ♦️
+joker 🃏
+flower playing cards 🎴
+mahjong red dragon 🀄️
+one o’clock 🕐
+two o’clock 🕑
+three o’clock 🕒
+four o’clock 🕓
+five o’clock 🕔
+six o’clock 🕕
+seven o’clock 🕖
+eight o’clock 🕗
+nine o’clock 🕘
+ten o’clock 🕙
+eleven o’clock 🕚
+twelve o’clock 🕛
+one-thirty 🕜
+two-thirty 🕝
+three-thirty 🕞
+four-thirty 🕟
+five-thirty 🕠
+six-thirty 🕡
+seven-thirty 🕢
+eight-thirty 🕣
+nine-thirty 🕤
+ten-thirty 🕥
+eleven-thirty 🕦
+twelve-thirty 🕧
+white flag 🏳️
+black flag 🏴
+chequered flag 🏁
+triangular flag 🚩
+rainbow flag 🏳️🌈
+Afghanistan 🇦🇫
+Åland Islands 🇦🇽
+Albania 🇦🇱
+Algeria 🇩🇿
+American Samoa 🇦🇸
+Andorra 🇦🇩
+Angola 🇦🇴
+Anguilla 🇦🇮
+Antarctica 🇦🇶
+Antigua & Barbuda 🇦🇬
+Argentina 🇦🇷
+Armenia 🇦🇲
+Aruba 🇦🇼
+Australia 🇦🇺
+Austria 🇦🇹
+Azerbaijan 🇦🇿
+Bahamas 🇧🇸
+Bahrain 🇧🇭
+Bangladesh 🇧🇩
+Barbados 🇧🇧
+Belarus 🇧🇾
+Belgium 🇧🇪
+Belize 🇧🇿
+Benin 🇧🇯
+Bermuda 🇧🇲
+Bhutan 🇧🇹
+Bolivia 🇧🇴
+Caribbean Netherlands 🇧🇶
+Bosnia & Herzegovina 🇧🇦
+Botswana 🇧🇼
+Brazil 🇧🇷
+British Indian Ocean Territory 🇮🇴
+British Virgin Islands 🇻🇬
+Brunei 🇧🇳
+Bulgaria 🇧🇬
+Burkina Faso 🇧🇫
+Burundi 🇧🇮
+Cape Verde 🇨🇻
+Cambodia 🇰🇭
+Cameroon 🇨🇲
+Canada 🇨🇦
+Canary Islands 🇮🇨
+Cayman Islands 🇰🇾
+Central African Republic 🇨🇫
+Chad 🇹🇩
+Chile 🇨🇱
+China 🇨🇳
+Christmas Island 🇨🇽
+Cocos (Keeling) Islands 🇨🇨
+Colombia 🇨🇴
+Comoros 🇰🇲
+Congo - Brazzaville 🇨🇬
+Congo - Kinshasa 🇨🇩
+Cook Islands 🇨🇰
+Costa Rica 🇨🇷
+Côte d’Ivoire 🇨🇮
+Croatia 🇭🇷
+Cuba 🇨🇺
+Curaçao 🇨🇼
+Cyprus 🇨🇾
+Czech Republic 🇨🇿
+Denmark 🇩🇰
+Djibouti 🇩🇯
+Dominica 🇩🇲
+Dominican Republic 🇩🇴
+Ecuador 🇪🇨
+Egypt 🇪🇬
+El Salvador 🇸🇻
+Equatorial Guinea 🇬🇶
+Eritrea 🇪🇷
+Estonia 🇪🇪
+Ethiopia 🇪🇹
+European Union 🇪🇺
+Falkland Islands 🇫🇰
+Faroe Islands 🇫🇴
+Fiji 🇫🇯
+Finland 🇫🇮
+France 🇫🇷
+French Guiana 🇬🇫
+French Polynesia 🇵🇫
+French Southern Territories 🇹🇫
+Gabon 🇬🇦
+Gambia 🇬🇲
+Georgia 🇬🇪
+Germany 🇩🇪
+Ghana 🇬🇭
+Gibraltar 🇬🇮
+Greece 🇬🇷
+Greenland 🇬🇱
+Grenada 🇬🇩
+Guadeloupe 🇬🇵
+Guam 🇬🇺
+Guatemala 🇬🇹
+Guernsey 🇬🇬
+Guinea 🇬🇳
+Guinea-Bissau 🇬🇼
+Guyana 🇬🇾
+Haiti 🇭🇹
+Honduras 🇭🇳
+Hong Kong SAR China 🇭🇰
+Hungary 🇭🇺
+Iceland 🇮🇸
+India 🇮🇳
+Indonesia 🇮🇩
+Iran 🇮🇷
+Iraq 🇮🇶
+Ireland 🇮🇪
+Isle of Man 🇮🇲
+Israel 🇮🇱
+Italy 🇮🇹
+Jamaica 🇯🇲
+Japan 🇯🇵
+crossed flags 🎌
+Jersey 🇯🇪
+Jordan 🇯🇴
+Kazakhstan 🇰🇿
+Kenya 🇰🇪
+Kiribati 🇰🇮
+Kosovo 🇽🇰
+Kuwait 🇰🇼
+Kyrgyzstan 🇰🇬
+Laos 🇱🇦
+Latvia 🇱🇻
+Lebanon 🇱🇧
+Lesotho 🇱🇸
+Liberia 🇱🇷
+Libya 🇱🇾
+Liechtenstein 🇱🇮
+Lithuania 🇱🇹
+Luxembourg 🇱🇺
+Macau SAR China 🇲🇴
+Macedonia 🇲🇰
+Madagascar 🇲🇬
+Malawi 🇲🇼
+Malaysia 🇲🇾
+Maldives 🇲🇻
+Mali 🇲🇱
+Malta 🇲🇹
+Marshall Islands 🇲🇭
+Martinique 🇲🇶
+Mauritania 🇲🇷
+Mauritius 🇲🇺
+Mayotte 🇾🇹
+Mexico 🇲🇽
+Micronesia 🇫🇲
+Moldova 🇲🇩
+Monaco 🇲🇨
+Mongolia 🇲🇳
+Montenegro 🇲🇪
+Montserrat 🇲🇸
+Morocco 🇲🇦
+Mozambique 🇲🇿
+Myanmar (Burma) 🇲🇲
+Namibia 🇳🇦
+Nauru 🇳🇷
+Nepal 🇳🇵
+Netherlands 🇳🇱
+New Caledonia 🇳🇨
+New Zealand 🇳🇿
+Nicaragua 🇳🇮
+Niger 🇳🇪
+Nigeria 🇳🇬
+Niue 🇳🇺
+Norfolk Island 🇳🇫
+Northern Mariana Islands 🇲🇵
+North Korea 🇰🇵
+Norway 🇳🇴
+Oman 🇴🇲
+Pakistan 🇵🇰
+Palau 🇵🇼
+Palestinian Territories 🇵🇸
+Panama 🇵🇦
+Papua New Guinea 🇵🇬
+Paraguay 🇵🇾
+Peru 🇵🇪
+Philippines 🇵🇭
+Pitcairn Islands 🇵🇳
+Poland 🇵🇱
+Portugal 🇵🇹
+Puerto Rico 🇵🇷
+Qatar 🇶🇦
+Réunion 🇷🇪
+Romania 🇷🇴
+Russia 🇷🇺
+Rwanda 🇷🇼
+St. Barthélemy 🇧🇱
+St. Helena 🇸🇭
+St. Kitts & Nevis 🇰🇳
+St. Lucia 🇱🇨
+St. Pierre & Miquelon 🇵🇲
+St. Vincent & Grenadines 🇻🇨
+Samoa 🇼🇸
+San Marino 🇸🇲
+São Tomé & Príncipe 🇸🇹
+Saudi Arabia 🇸🇦
+Senegal 🇸🇳
+Serbia 🇷🇸
+Seychelles 🇸🇨
+Sierra Leone 🇸🇱
+Singapore 🇸🇬
+Sint Maarten 🇸🇽
+Slovakia 🇸🇰
+Slovenia 🇸🇮
+Solomon Islands 🇸🇧
+Somalia 🇸🇴
+South Africa 🇿🇦
+South Georgia & South Sandwich Islands 🇬🇸
+South Korea 🇰🇷
+South Sudan 🇸🇸
+Spain 🇪🇸
+Sri Lanka 🇱🇰
+Sudan 🇸🇩
+Suriname 🇸🇷
+Swaziland 🇸🇿
+Sweden 🇸🇪
+Switzerland 🇨🇭
+Syria 🇸🇾
+Taiwan 🇹🇼
+Tajikistan 🇹🇯
+Tanzania 🇹🇿
+Thailand 🇹🇭
+Timor-Leste 🇹🇱
+Togo 🇹🇬
+Tokelau 🇹🇰
+Tonga 🇹🇴
+Trinidad & Tobago 🇹🇹
+Tunisia 🇹🇳
+Turkey 🇹🇷
+Turkmenistan 🇹🇲
+Turks & Caicos Islands 🇹🇨
+Tuvalu 🇹🇻
+Uganda 🇺🇬
+Ukraine 🇺🇦
+United Arab Emirates 🇦🇪
+United Kingdom 🇬🇧
+United States 🇺🇸
+U.S. Virgin Islands 🇻🇮
+Uruguay 🇺🇾
+Uzbekistan 🇺🇿
+Vanuatu 🇻🇺
+Vatican City 🇻🇦
+Venezuela 🇻🇪
+Vietnam 🇻🇳
+Wallis & Futuna 🇼🇫
+Western Sahara 🇪🇭
+Yemen 🇾🇪
+Zambia 🇿🇲
+Zimbabwe 🇿🇼
diff --git a/extras/birdmenu-emoji/parse.sh b/extras/birdmenu-emoji/parse.sh
@@ -0,0 +1 @@
+jq --raw-output '.[] | (.description + "," + .emoji)'|grep -v ',$'|awk 'gsub(",", sprintf("%*s", 50 - length($0), ""))'
diff --git a/extras/birdmenu-emoji/script.sh b/extras/birdmenu-emoji/script.sh
@@ -0,0 +1,25 @@
+#!/bin/bash
+
+set -e
+
+case "$1" in
+ "list")
+ data=$(sed '0,/^__DATA__$/d' "$0")
+ echo "$data"
+ ;;
+ "copy")
+ input=$(tee)
+ if [ ! -z "$input" ]; then
+ emoji=${input: -1}
+ echo -n "$emoji" | xclip -selection c
+ command -v notify-send > /dev/null && notify-send -t 200 "$emoji copied!"
+ fi
+ ;;
+ "")
+ bash $0 list | dmenu -p 'Emoji: ' | bash $0 copy
+ ;;
+esac
+
+exit
+
+__DATA__
diff --git a/extras/birdwm.desktop b/extras/birdwm.desktop
@@ -0,0 +1,8 @@
+[Desktop Entry]
+Name=BIRDWM
+Comment=Dynamic Window Manager for birds
+TryExec=birdwm
+Exec=birdwm
+Type=Application
+Icon=birdwm
+Type=XSession
diff --git a/extras/darling-6.4.patch b/extras/darling-6.4.patch
@@ -0,0 +1,67 @@
+commit a1d93e976274d027e732e3d4a3fc9a6b360af015
+Author: grouse <bdmfegys@duck.com>
+Date: Sun Dec 3 00:52:21 2023 -0500
+
+ darling patch for dwm is a colorscheme patch based on gmk's darling keycaps
+
+diff --git a/config.def.h b/config.def.h
+index 9efa774..365859c 100644
+--- a/config.def.h
++++ b/config.def.h
+@@ -7,16 +7,44 @@ static const int showbar = 1; /* 0 means no bar */
+ static const int topbar = 1; /* 0 means bottom bar */
+ static const char *fonts[] = { "monospace:size=10" };
+ static const char dmenufont[] = "monospace:size=10";
++/* commented and replaced by darling theme
+ static const char col_gray1[] = "#222222";
+ static const char col_gray2[] = "#444444";
+ static const char col_gray3[] = "#bbbbbb";
+ static const char col_gray4[] = "#eeeeee";
+ static const char col_cyan[] = "#005577";
+ static const char *colors[][3] = {
+- /* fg bg border */
++// fg bg border
+ [SchemeNorm] = { col_gray3, col_gray1, col_gray2 },
+ [SchemeSel] = { col_gray4, col_cyan, col_cyan },
+ };
++*/
++/*
++color codes:
++ dark red: #861a22
++ pink: #f4cdd4
++ white: #f7f2ea
++ red: #bb1e10
++ - unused cause it didnt look right
++ blue: #00a7e2
++*/
++// non-focused background
++static const char darlingunselbg[] = "#861a22";
++// non-focused border
++static const char darlingunselborder[] = "#861a22";
++// non-focused foreground
++static const char darlingunselfg[] = "#f7f2ea";
++// focused foreground
++static const char darlingselfg[] = "#f4cdd4";
++// focused background
++static const char darlingselbg[] = "#bb1e10";
++// focused border
++static const char darlingselborder[] = "#f4cdd4";
++static const char *colors[][3] = {
++ /* fg bg border */
++ [SchemeNorm] = { darlingunselfg, darlingunselbg, darlingunselborder },
++ [SchemeSel] = { darlingselfg, darlingselbg, darlingselborder },
++};
+
+ /* tagging */
+ static const char *tags[] = { "1", "2", "3", "4", "5", "6", "7", "8", "9" };
+@@ -57,7 +85,10 @@ static const Layout layouts[] = {
+
+ /* commands */
+ static char dmenumon[2] = "0"; /* component of dmenucmd, manipulated in spawn() */
++/* uncommented and replaced by darling patch
+ 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 *dmenucmd[] = { "dmenu_run", "-m", dmenumon, "-fn", dmenufont, "-nb", darlingunselbg, "-nf", darlingunselfg, "-sb", darlingselbg, "-sf", darlingselfg, NULL };
+ static const char *termcmd[] = { "st", NULL };
+
+ static const Key keys[] = {
diff --git a/extras/restarter b/extras/restarter
@@ -0,0 +1,9 @@
+#!/bin/sh
+# restart X programs
+case "$(printf "Get IP\nRestart slstatus\nRestart picom\nRestart dunst" | dmenu -i)" in
+ "Get IP") dunstify $(curl ifconfig.co ifconfig.co/city);;
+ "Restart picom") { [ -z $(pgrep picom) ] && pkill picom ;} || picom ;;
+ "Restart slstatus") { [ -z $(pgrep slstatus) ] && pkill slstatus ;} || slstatus;;
+ "Restart dunst") { [ -z $(pgrep dunst) ] && pkill dunst ;} || dunst ;;
+ *) exit 1 ;;
+esac
diff --git a/extras/screenshot.png b/extras/screenshot.png
Binary files differ.
diff --git a/extras/screenshot.sh b/extras/screenshot.sh
@@ -0,0 +1,5 @@
+#!/bin/sh
+pkill picom
+selection=$(hacksaw)
+shotgun -g "$selection"
+picom & disown
diff --git a/extras/volume.sh b/extras/volume.sh
@@ -0,0 +1,71 @@
+#!/bin/bash
+# volume up icon is from <a href="https://www.flaticon.com/free-icons/volume-up" title="volume up icons">Volume up icons created by Freepik - Flaticon</a>.
+# volume down icon is from "https://www.flaticon.com/free-icons/volume-down" title="volume down icons">Volume down icons created by Freepik - Flaticon
+# volume mute icon is from <a href="https://www.flaticon.com/free-icons/ui" title="ui icons">Ui icons created by Icon Hubs - Flaticon</a>.
+# Credit from https://gist.github.com/sebastiencs/5d7227f388d93374cebdf72e783fbd6a & https://wiki.archlinux.org/title/Dunst .
+
+# You can call this script like this:
+# $./volume.sh up
+# $./volume.sh down
+# $./volume.sh mute
+
+function get_volume {
+ #pamixer --get-volume
+ wpctl get-volume @DEFAULT_AUDIO_SINK@
+}
+
+#function is_mute {
+# amixer get Master | grep '%' | grep -oE '[^ ]+$' | grep off > /dev/null
+#}
+
+function send_notification {
+ volume=`get_volume`
+ # Make the bar with the special character ─ (it's not dash -)
+ # https://en.wikipedia.org/wiki/Box-drawing_character
+ bar=$(seq -s "─" $(($volume / 2)) | sed 's/[0-9]//g')
+ # Send the notification
+ #dunstify -i $HOME/Pictures/sysicon/volume-up.png -t 8000 -r 2593 -u normal -h int:value:"$volume" "Volume: ${volume}%"
+ dunstify -i $HOME/Pictures/sysicon/volume-up.png -t 8000 -r 2593 -u normal -h int:value:"$volume" "${volume}%"
+ #notify-send "volume: $volume%"
+}
+
+function send_notification1 {
+ volume=`get_volume`
+ # Make the bar with the special character ─ (it's not dash -)
+ # https://en.wikipedia.org/wiki/Box-drawing_character
+ bar=$(seq -s "─" $(($volume / 2)) | sed 's/[0-9]//g')
+ # Send the notification
+ dunstify -i $HOME/Pictures/sysicon/volume-down.png -t 8000 -r 2593 -u normal -h int:value:"$volume" "${volume}%"
+ #notify-send "volume: $volume%"
+}
+case $1 in
+ get)
+ get_volume
+ send_notification
+ ;;
+ up)
+ # Set the volume on (if it was muted)
+ #amixer -D pulse set Master on > /dev/null
+ # Up the volume (+ 1%)
+ #amixer -D pulse sset Master 1%+ > /dev/null
+
+ # new version for pulseaudio
+ pactl set-sink-volume @DEFAULT_SINK@ +1%
+ send_notification
+ ;;
+ down)
+ # new version for pulseaudio
+ pactl set-sink-volume @DEFAULT_SINK@ -1%
+ send_notification1
+ ;;
+ mute)
+ # Toggle mute
+# amixer -D pulse set Master 1+ toggle > /dev/null
+# if is_mute ; then
+# dunstify -i $HOME/Pictures/sysicon/volume-mute.png -t 8000 -r 2593 -u normal "Volume: Mute"
+# else
+ pactl set-sink-mute @DEFAULT_SINK@ toggle
+ send_notification
+# fi
+ ;;
+esac
diff --git a/transient.c b/transient.c
@@ -0,0 +1,42 @@
+/* cc transient.c -o transient -lX11 */
+
+#include <stdlib.h>
+#include <unistd.h>
+#include <X11/Xlib.h>
+#include <X11/Xutil.h>
+
+int main(void) {
+ Display *d;
+ Window r, f, t = None;
+ XSizeHints h;
+ XEvent e;
+
+ d = XOpenDisplay(NULL);
+ if (!d)
+ exit(1);
+ r = DefaultRootWindow(d);
+
+ f = XCreateSimpleWindow(d, r, 100, 100, 400, 400, 0, 0, 0);
+ h.min_width = h.max_width = h.min_height = h.max_height = 400;
+ h.flags = PMinSize | PMaxSize;
+ XSetWMNormalHints(d, f, &h);
+ XStoreName(d, f, "floating");
+ XMapWindow(d, f);
+
+ XSelectInput(d, f, ExposureMask);
+ while (1) {
+ XNextEvent(d, &e);
+
+ if (t == None) {
+ sleep(5);
+ t = XCreateSimpleWindow(d, r, 50, 50, 100, 100, 0, 0, 0);
+ XSetTransientForHint(d, t, f);
+ XStoreName(d, t, "transient");
+ XMapWindow(d, t);
+ XSelectInput(d, t, ExposureMask);
+ }
+ }
+
+ XCloseDisplay(d);
+ exit(0);
+}
diff --git a/util.c b/util.c
@@ -0,0 +1,36 @@
+/* See LICENSE file for copyright and license details. */
+#include <stdarg.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+#include "util.h"
+
+void
+die(const char *fmt, ...)
+{
+ va_list ap;
+
+ va_start(ap, fmt);
+ vfprintf(stderr, fmt, ap);
+ va_end(ap);
+
+ if (fmt[0] && fmt[strlen(fmt)-1] == ':') {
+ fputc(' ', stderr);
+ perror(NULL);
+ } else {
+ fputc('\n', stderr);
+ }
+
+ exit(1);
+}
+
+void *
+ecalloc(size_t nmemb, size_t size)
+{
+ void *p;
+
+ if (!(p = calloc(nmemb, size)))
+ die("calloc:");
+ return p;
+}
diff --git a/util.h b/util.h
@@ -0,0 +1,8 @@
+/* See LICENSE file for copyright and license details. */
+
+#define MAX(A, B) ((A) > (B) ? (A) : (B))
+#define MIN(A, B) ((A) < (B) ? (A) : (B))
+#define BETWEEN(X, A, B) ((A) <= (X) && (X) <= (B))
+
+void die(const char *fmt, ...);
+void *ecalloc(size_t nmemb, size_t size);
diff --git a/util.o b/util.o
Binary files differ.