diff --git a/.local/src2/dmenu/FUNDING.yml b/.local/src2/dmenu/FUNDING.yml deleted file mode 100644 index f8e60767..00000000 --- a/.local/src2/dmenu/FUNDING.yml +++ /dev/null @@ -1,3 +0,0 @@ -github: lukesmithxyz -custom: ["https://lukesmith.xyz/donate", "https://paypal.me/lukemsmith", "https://lukesmith.xyz/crypto"] -patreon: lukesmith diff --git a/.local/src2/dmenu/LICENSE b/.local/src2/dmenu/LICENSE deleted file mode 100644 index 3afd28ed..00000000 --- a/.local/src2/dmenu/LICENSE +++ /dev/null @@ -1,30 +0,0 @@ -MIT/X Consortium License - -© 2006-2019 Anselm R Garbe <anselm@garbe.ca> -© 2006-2008 Sander van Dijk <a.h.vandijk@gmail.com> -© 2006-2007 Michał Janeczek <janeczek@gmail.com> -© 2007 Kris Maglione <jg@suckless.org> -© 2009 Gottox <gottox@s01.de> -© 2009 Markus Schnalke <meillo@marmaro.de> -© 2009 Evan Gates <evan.gates@gmail.com> -© 2010-2012 Connor Lane Smith <cls@lubutu.com> -© 2014-2020 Hiltjo Posthuma <hiltjo@codemadness.org> -© 2015-2019 Quentin Rameau <quinq@fifth.space> - -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/.local/src2/dmenu/Makefile b/.local/src2/dmenu/Makefile deleted file mode 100644 index 244961a6..00000000 --- a/.local/src2/dmenu/Makefile +++ /dev/null @@ -1,64 +0,0 @@ -# dmenu - dynamic menu -# See LICENSE file for copyright and license details. - -include config.mk - -SRC = drw.c dmenu.c stest.c util.c -OBJ = $(SRC:.c=.o) - -all: options dmenu stest - -options: - @echo dmenu build options: - @echo "CFLAGS = $(CFLAGS)" - @echo "LDFLAGS = $(LDFLAGS)" - @echo "CC = $(CC)" - -.c.o: - $(CC) -c $(CFLAGS) $< - -config.h: - cp config.def.h $@ - -$(OBJ): arg.h config.h config.mk drw.h - -dmenu: dmenu.o drw.o util.o - $(CC) -o $@ dmenu.o drw.o util.o $(LDFLAGS) - -stest: stest.o - $(CC) -o $@ stest.o $(LDFLAGS) - -clean: - rm -f dmenu stest $(OBJ) dmenu-$(VERSION).tar.gz *.rej *.orig - -dist: clean - mkdir -p dmenu-$(VERSION) - cp LICENSE Makefile README arg.h config.def.h config.mk dmenu.1\ - drw.h util.h dmenu_path dmenu_run stest.1 $(SRC)\ - dmenu-$(VERSION) - tar -cf dmenu-$(VERSION).tar dmenu-$(VERSION) - gzip dmenu-$(VERSION).tar - rm -rf dmenu-$(VERSION) - -install: all - mkdir -p $(DESTDIR)$(PREFIX)/bin - cp -f dmenu dmenu_path dmenu_run stest $(DESTDIR)$(PREFIX)/bin - chmod 755 $(DESTDIR)$(PREFIX)/bin/dmenu - chmod 755 $(DESTDIR)$(PREFIX)/bin/dmenu_path - chmod 755 $(DESTDIR)$(PREFIX)/bin/dmenu_run - chmod 755 $(DESTDIR)$(PREFIX)/bin/stest - mkdir -p $(DESTDIR)$(MANPREFIX)/man1 - sed "s/VERSION/$(VERSION)/g" < dmenu.1 > $(DESTDIR)$(MANPREFIX)/man1/dmenu.1 - sed "s/VERSION/$(VERSION)/g" < stest.1 > $(DESTDIR)$(MANPREFIX)/man1/stest.1 - chmod 644 $(DESTDIR)$(MANPREFIX)/man1/dmenu.1 - chmod 644 $(DESTDIR)$(MANPREFIX)/man1/stest.1 - -uninstall: - rm -f $(DESTDIR)$(PREFIX)/bin/dmenu\ - $(DESTDIR)$(PREFIX)/bin/dmenu_path\ - $(DESTDIR)$(PREFIX)/bin/dmenu_run\ - $(DESTDIR)$(PREFIX)/bin/stest\ - $(DESTDIR)$(MANPREFIX)/man1/dmenu.1\ - $(DESTDIR)$(MANPREFIX)/man1/stest.1 - -.PHONY: all options clean dist install uninstall diff --git a/.local/src2/dmenu/README.md b/.local/src2/dmenu/README.md deleted file mode 100644 index c8fb594d..00000000 --- a/.local/src2/dmenu/README.md +++ /dev/null @@ -1,16 +0,0 @@ -# Luke's dmenu - -Extra stuff added to vanilla dmenu: - -- reads Xresources (ergo pywal compatible) -- alpha patch, which importantly allows this build to be embedded in transparent st -- can view color characters like emoji (libxft-bgra is required for this reason) -- `-P` for password mode: hide user input -- `-r` to reject non-matching input -- dmenu options are mouse clickable - -## Installation - -You must have `libxft-bgra` installed until the libxft upstream is fixed. - -After making any config changes that you want, but `make`, `sudo make install` it. diff --git a/.local/src2/dmenu/arg.h b/.local/src2/dmenu/arg.h deleted file mode 100644 index e94e02bb..00000000 --- a/.local/src2/dmenu/arg.h +++ /dev/null @@ -1,49 +0,0 @@ -/* - * Copy me if you can. - * by 20h - */ - -#ifndef ARG_H__ -#define ARG_H__ - -extern char *argv0; - -/* use main(int argc, char *argv[]) */ -#define ARGBEGIN for (argv0 = *argv, argv++, argc--;\ - argv[0] && argv[0][0] == '-'\ - && argv[0][1];\ - argc--, argv++) {\ - char argc_;\ - char **argv_;\ - int brk_;\ - if (argv[0][1] == '-' && argv[0][2] == '\0') {\ - argv++;\ - argc--;\ - break;\ - }\ - for (brk_ = 0, argv[0]++, argv_ = argv;\ - argv[0][0] && !brk_;\ - argv[0]++) {\ - if (argv_ != argv)\ - break;\ - argc_ = argv[0][0];\ - switch (argc_) - -#define ARGEND }\ - } - -#define ARGC() argc_ - -#define EARGF(x) ((argv[0][1] == '\0' && argv[1] == NULL)?\ - ((x), abort(), (char *)0) :\ - (brk_ = 1, (argv[0][1] != '\0')?\ - (&argv[0][1]) :\ - (argc--, argv++, argv[0]))) - -#define ARGF() ((argv[0][1] == '\0' && argv[1] == NULL)?\ - (char *)0 :\ - (brk_ = 1, (argv[0][1] != '\0')?\ - (&argv[0][1]) :\ - (argc--, argv++, argv[0]))) - -#endif diff --git a/.local/src2/dmenu/config.h b/.local/src2/dmenu/config.h deleted file mode 100644 index 5fbe2257..00000000 --- a/.local/src2/dmenu/config.h +++ /dev/null @@ -1,33 +0,0 @@ -/* See LICENSE file for copyright and license details. */ -/* Default settings; can be overriden by command line. */ - -static int topbar = 1; /* -b option; if 0, dmenu appears at bottom */ -/* -fn option overrides fonts[0]; default X11 font or font set */ -static const char *fonts[] = { - "monospace:size=10", - "JoyPixels:pixelsize=8:antialias=true:autohint=true" -}; -static const unsigned int bgalpha = 0xe0; -static const unsigned int fgalpha = OPAQUE; -static const char *prompt = NULL; /* -p option; prompt to the left of input field */ -static const char *colors[SchemeLast][2] = { - /* fg bg */ - [SchemeNorm] = { "#bbbbbb", "#222222" }, - [SchemeSel] = { "#eeeeee", "#005577" }, - [SchemeOut] = { "#000000", "#00ffff" }, -}; -static const unsigned int alphas[SchemeLast][2] = { - /* fgalpha bgalphga */ - [SchemeNorm] = { fgalpha, bgalpha }, - [SchemeSel] = { fgalpha, bgalpha }, - [SchemeOut] = { fgalpha, bgalpha }, -}; - -/* -l option; if nonzero, dmenu uses vertical list with given number of lines */ -static unsigned int lines = 0; - -/* - * Characters not considered part of a word while deleting words - * for example: " /?\"&[]" - */ -static const char worddelimiters[] = " "; diff --git a/.local/src2/dmenu/config.mk b/.local/src2/dmenu/config.mk deleted file mode 100644 index 8531fb99..00000000 --- a/.local/src2/dmenu/config.mk +++ /dev/null @@ -1,31 +0,0 @@ -# dmenu version -VERSION = 5.0 - -# 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 - -# freetype -FREETYPELIBS = -lfontconfig -lXft -FREETYPEINC = /usr/include/freetype2 -# OpenBSD (uncomment) -#FREETYPEINC = $(X11INC)/freetype2 - -# includes and libs -INCS = -I$(X11INC) -I$(FREETYPEINC) -LIBS = -L$(X11LIB) -lX11 $(XINERAMALIBS) $(FREETYPELIBS) -lXrender - -# flags -CPPFLAGS = -D_DEFAULT_SOURCE -D_BSD_SOURCE -D_XOPEN_SOURCE=700 -D_POSIX_C_SOURCE=200809L -DVERSION=\"$(VERSION)\" $(XINERAMAFLAGS) -CFLAGS = -std=c99 -pedantic -Wall -Os $(INCS) $(CPPFLAGS) -LDFLAGS = $(LIBS) - -# compiler and linker -CC = cc diff --git a/.local/src2/dmenu/dmenu b/.local/src2/dmenu/dmenu deleted file mode 100755 index ffc3698e..00000000 Binary files a/.local/src2/dmenu/dmenu and /dev/null differ diff --git a/.local/src2/dmenu/dmenu.1 b/.local/src2/dmenu/dmenu.1 deleted file mode 100644 index 4c870749..00000000 --- a/.local/src2/dmenu/dmenu.1 +++ /dev/null @@ -1,200 +0,0 @@ -.TH DMENU 1 dmenu\-VERSION -.SH NAME -dmenu \- dynamic menu -.SH SYNOPSIS -.B dmenu -.RB [ \-bfirvP ] -.RB [ \-l -.IR lines ] -.RB [ \-m -.IR monitor ] -.RB [ \-p -.IR prompt ] -.RB [ \-fn -.IR font ] -.RB [ \-nb -.IR color ] -.RB [ \-nf -.IR color ] -.RB [ \-sb -.IR color ] -.RB [ \-sf -.IR color ] -.RB [ \-w -.IR windowid ] -.P -.BR dmenu_run " ..." -.SH DESCRIPTION -.B dmenu -is a dynamic menu for X, which reads a list of newline\-separated items from -stdin. When the user selects an item and presses Return, their choice is printed -to stdout and dmenu terminates. Entering text will narrow the items to those -matching the tokens in the input. -.P -.B dmenu_run -is a script used by -.IR dwm (1) -which lists programs in the user's $PATH and runs the result in their $SHELL. -.SH OPTIONS -.TP -.B \-b -dmenu appears at the bottom of the screen. -.TP -.B \-f -dmenu grabs the keyboard before reading stdin if not reading from a tty. This -is faster, but will lock up X until stdin reaches end\-of\-file. -.TP -.B \-i -dmenu matches menu items case insensitively. -.TP -.B \-P -dmenu will not directly display the keyboard input, but instead replace it with dots. All data from stdin will be ignored. -.TP -.B \-r -dmenu will reject any input which would result in no matching option left. -.TP -.BI \-l " lines" -dmenu lists items vertically, with the given number of lines. -.TP -.BI \-m " monitor" -dmenu is displayed on the monitor number supplied. Monitor numbers are starting -from 0. -.TP -.BI \-p " prompt" -defines the prompt to be displayed to the left of the input field. -.TP -.BI \-fn " font" -defines the font or font set used. -.TP -.BI \-nb " color" -defines the normal background color. -.IR #RGB , -.IR #RRGGBB , -and X color names are supported. -.TP -.BI \-nf " color" -defines the normal foreground color. -.TP -.BI \-sb " color" -defines the selected background color. -.TP -.BI \-sf " color" -defines the selected foreground color. -.TP -.B \-v -prints version information to stdout, then exits. -.TP -.BI \-w " windowid" -embed into windowid. -.SH USAGE -dmenu is completely controlled by the keyboard. Items are selected using the -arrow keys, page up, page down, home, and end. -.TP -.B Tab -Copy the selected item to the input field. -.TP -.B Return -Confirm selection. Prints the selected item to stdout and exits, returning -success. -.TP -.B Ctrl-Return -Confirm selection. Prints the selected item to stdout and continues. -.TP -.B Shift\-Return -Confirm input. Prints the input text to stdout and exits, returning success. -.TP -.B Escape -Exit without selecting an item, returning failure. -.TP -.B Ctrl-Left -Move cursor to the start of the current word -.TP -.B Ctrl-Right -Move cursor to the end of the current word -.TP -.B C\-a -Home -.TP -.B C\-b -Left -.TP -.B C\-c -Escape -.TP -.B C\-d -Delete -.TP -.B C\-e -End -.TP -.B C\-f -Right -.TP -.B C\-g -Escape -.TP -.B C\-h -Backspace -.TP -.B C\-i -Tab -.TP -.B C\-j -Return -.TP -.B C\-J -Shift-Return -.TP -.B C\-k -Delete line right -.TP -.B C\-m -Return -.TP -.B C\-M -Shift-Return -.TP -.B C\-n -Down -.TP -.B C\-p -Up -.TP -.B C\-u -Delete line left -.TP -.B C\-w -Delete word left -.TP -.B C\-y -Paste from primary X selection -.TP -.B C\-Y -Paste from X clipboard -.TP -.B M\-b -Move cursor to the start of the current word -.TP -.B M\-f -Move cursor to the end of the current word -.TP -.B M\-g -Home -.TP -.B M\-G -End -.TP -.B M\-h -Up -.TP -.B M\-j -Page down -.TP -.B M\-k -Page up -.TP -.B M\-l -Down -.SH SEE ALSO -.IR dwm (1), -.IR stest (1) diff --git a/.local/src2/dmenu/dmenu.c b/.local/src2/dmenu/dmenu.c deleted file mode 100644 index bde0869e..00000000 --- a/.local/src2/dmenu/dmenu.c +++ /dev/null @@ -1,995 +0,0 @@ -/* See LICENSE file for copyright and license details. */ -#include <ctype.h> -#include <locale.h> -#include <stdio.h> -#include <stdlib.h> -#include <string.h> -#include <strings.h> -#include <time.h> -#include <unistd.h> - -#include <X11/Xlib.h> -#include <X11/Xatom.h> -#include <X11/Xutil.h> -#ifdef XINERAMA -#include <X11/extensions/Xinerama.h> -#endif -#include <X11/Xft/Xft.h> -#include <X11/Xresource.h> - -#include "drw.h" -#include "util.h" - -/* macros */ -#define INTERSECT(x,y,w,h,r) (MAX(0, MIN((x)+(w),(r).x_org+(r).width) - MAX((x),(r).x_org)) \ - && MAX(0, MIN((y)+(h),(r).y_org+(r).height) - MAX((y),(r).y_org))) -#define LENGTH(X) (sizeof X / sizeof X[0]) -#define TEXTW(X) (drw_fontset_getwidth(drw, (X)) + lrpad) - -/* define opaqueness */ -#define OPAQUE 0xFFU - -/* enums */ -enum { SchemeNorm, SchemeSel, SchemeOut, SchemeLast }; /* color schemes */ - -struct item { - char *text; - struct item *left, *right; - int out; -}; - -static char text[BUFSIZ] = ""; -static char *embed; -static int bh, mw, mh; -static int inputw = 0, promptw, passwd = 0; -static int lrpad; /* sum of left and right padding */ -static int reject_no_match = 0; -static size_t cursor; -static struct item *items = NULL; -static struct item *matches, *matchend; -static struct item *prev, *curr, *next, *sel; -static int mon = -1, screen; - -static Atom clip, utf8; -static Display *dpy; -static Window root, parentwin, win; -static XIC xic; - -static Drw *drw; -static int usergb = 0; -static Visual *visual; -static int depth; -static Colormap cmap; -static Clr *scheme[SchemeLast]; - -#include "config.h" - -static int (*fstrncmp)(const char *, const char *, size_t) = strncmp; -static char *(*fstrstr)(const char *, const char *) = strstr; - - -static 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); - usergb = 1; - break; - } - } - - XFree(infos); - - if (! visual) { - visual = DefaultVisual(dpy, screen); - depth = DefaultDepth(dpy, screen); - cmap = DefaultColormap(dpy, screen); - } -} - -static void -appenditem(struct item *item, struct item **list, struct item **last) -{ - if (*last) - (*last)->right = item; - else - *list = item; - - item->left = *last; - item->right = NULL; - *last = item; -} - -static void -calcoffsets(void) -{ - int i, n; - - if (lines > 0) - n = lines * bh; - else - n = mw - (promptw + inputw + TEXTW("<") + TEXTW(">")); - /* calculate which items will begin the next page and previous page */ - for (i = 0, next = curr; next; next = next->right) - if ((i += (lines > 0) ? bh : MIN(TEXTW(next->text), n)) > n) - break; - for (i = 0, prev = curr; prev && prev->left; prev = prev->left) - if ((i += (lines > 0) ? bh : MIN(TEXTW(prev->left->text), n)) > n) - break; -} - -static void -cleanup(void) -{ - size_t i; - - XUngrabKey(dpy, AnyKey, AnyModifier, root); - for (i = 0; i < SchemeLast; i++) - free(scheme[i]); - drw_free(drw); - XSync(dpy, False); - XCloseDisplay(dpy); -} - -static char * -cistrstr(const char *s, const char *sub) -{ - size_t len; - - for (len = strlen(sub); *s; s++) - if (!strncasecmp(s, sub, len)) - return (char *)s; - return NULL; -} - -static int -drawitem(struct item *item, int x, int y, int w) -{ - if (item == sel) - drw_setscheme(drw, scheme[SchemeSel]); - else if (item->out) - drw_setscheme(drw, scheme[SchemeOut]); - else - drw_setscheme(drw, scheme[SchemeNorm]); - - return drw_text(drw, x, y, w, bh, lrpad / 2, item->text, 0); -} - -static void -drawmenu(void) -{ - unsigned int curpos; - struct item *item; - int x = 0, y = 0, w; - char *censort; - - drw_setscheme(drw, scheme[SchemeNorm]); - drw_rect(drw, 0, 0, mw, mh, 1, 1); - - if (prompt && *prompt) { - drw_setscheme(drw, scheme[SchemeSel]); - x = drw_text(drw, x, 0, promptw, bh, lrpad / 2, prompt, 0); - } - /* draw input field */ - w = (lines > 0 || !matches) ? mw - x : inputw; - drw_setscheme(drw, scheme[SchemeNorm]); - if (passwd) { - censort = ecalloc(1, sizeof(text)); - memset(censort, '.', strlen(text)); - drw_text(drw, x, 0, w, bh, lrpad / 2, censort, 0); - free(censort); - } else drw_text(drw, x, 0, w, bh, lrpad / 2, text, 0); - - curpos = TEXTW(text) - TEXTW(&text[cursor]); - if ((curpos += lrpad / 2 - 1) < w) { - drw_setscheme(drw, scheme[SchemeNorm]); - drw_rect(drw, x + curpos, 2, 2, bh - 4, 1, 0); - } - - if (lines > 0) { - /* draw vertical list */ - for (item = curr; item != next; item = item->right) - drawitem(item, x, y += bh, mw - x); - } else if (matches) { - /* draw horizontal list */ - x += inputw; - w = TEXTW("<"); - if (curr->left) { - drw_setscheme(drw, scheme[SchemeNorm]); - drw_text(drw, x, 0, w, bh, lrpad / 2, "<", 0); - } - x += w; - for (item = curr; item != next; item = item->right) - x = drawitem(item, x, 0, MIN(TEXTW(item->text), mw - x - TEXTW(">"))); - if (next) { - w = TEXTW(">"); - drw_setscheme(drw, scheme[SchemeNorm]); - drw_text(drw, mw - w, 0, w, bh, lrpad / 2, ">", 0); - } - } - drw_map(drw, win, 0, 0, mw, mh); -} - -static void -grabfocus(void) -{ - struct timespec ts = { .tv_sec = 0, .tv_nsec = 10000000 }; - Window focuswin; - int i, revertwin; - - for (i = 0; i < 100; ++i) { - XGetInputFocus(dpy, &focuswin, &revertwin); - if (focuswin == win) - return; - XSetInputFocus(dpy, win, RevertToParent, CurrentTime); - nanosleep(&ts, NULL); - } - die("cannot grab focus"); -} - -static void -grabkeyboard(void) -{ - struct timespec ts = { .tv_sec = 0, .tv_nsec = 1000000 }; - int i; - - if (embed) - return; - /* try to grab keyboard, we may have to wait for another process to ungrab */ - for (i = 0; i < 1000; i++) { - if (XGrabKeyboard(dpy, DefaultRootWindow(dpy), True, GrabModeAsync, - GrabModeAsync, CurrentTime) == GrabSuccess) - return; - nanosleep(&ts, NULL); - } - die("cannot grab keyboard"); -} - -static void -match(void) -{ - static char **tokv = NULL; - static int tokn = 0; - - char buf[sizeof text], *s; - int i, tokc = 0; - size_t len, textsize; - struct item *item, *lprefix, *lsubstr, *prefixend, *substrend; - - strcpy(buf, text); - /* separate input text into tokens to be matched individually */ - for (s = strtok(buf, " "); s; tokv[tokc - 1] = s, s = strtok(NULL, " ")) - if (++tokc > tokn && !(tokv = realloc(tokv, ++tokn * sizeof *tokv))) - die("cannot realloc %u bytes:", tokn * sizeof *tokv); - len = tokc ? strlen(tokv[0]) : 0; - - matches = lprefix = lsubstr = matchend = prefixend = substrend = NULL; - textsize = strlen(text) + 1; - for (item = items; item && item->text; item++) { - for (i = 0; i < tokc; i++) - if (!fstrstr(item->text, tokv[i])) - break; - if (i != tokc) /* not all tokens match */ - continue; - /* exact matches go first, then prefixes, then substrings */ - if (!tokc || !fstrncmp(text, item->text, textsize)) - appenditem(item, &matches, &matchend); - else if (!fstrncmp(tokv[0], item->text, len)) - appenditem(item, &lprefix, &prefixend); - else - appenditem(item, &lsubstr, &substrend); - } - if (lprefix) { - if (matches) { - matchend->right = lprefix; - lprefix->left = matchend; - } else - matches = lprefix; - matchend = prefixend; - } - if (lsubstr) { - if (matches) { - matchend->right = lsubstr; - lsubstr->left = matchend; - } else - matches = lsubstr; - matchend = substrend; - } - curr = sel = matches; - calcoffsets(); -} - -static void -insert(const char *str, ssize_t n) -{ - if (strlen(text) + n > sizeof text - 1) - return; - - static char last[BUFSIZ] = ""; - if(reject_no_match) { - /* store last text value in case we need to revert it */ - memcpy(last, text, BUFSIZ); - } - - /* move existing text out of the way, insert new text, and update cursor */ - memmove(&text[cursor + n], &text[cursor], sizeof text - cursor - MAX(n, 0)); - if (n > 0) - memcpy(&text[cursor], str, n); - cursor += n; - match(); - - if(!matches && reject_no_match) { - /* revert to last text value if theres no match */ - memcpy(text, last, BUFSIZ); - cursor -= n; - match(); - } -} - -static size_t -nextrune(int inc) -{ - ssize_t n; - - /* return location of next utf8 rune in the given direction (+1 or -1) */ - for (n = cursor + inc; n + inc >= 0 && (text[n] & 0xc0) == 0x80; n += inc) - ; - return n; -} - -static void -movewordedge(int dir) -{ - if (dir < 0) { /* move cursor to the start of the word*/ - while (cursor > 0 && strchr(worddelimiters, text[nextrune(-1)])) - cursor = nextrune(-1); - while (cursor > 0 && !strchr(worddelimiters, text[nextrune(-1)])) - cursor = nextrune(-1); - } else { /* move cursor to the end of the word */ - while (text[cursor] && strchr(worddelimiters, text[cursor])) - cursor = nextrune(+1); - while (text[cursor] && !strchr(worddelimiters, text[cursor])) - cursor = nextrune(+1); - } -} - -static void -keypress(XKeyEvent *ev) -{ - char buf[32]; - int len; - KeySym ksym; - Status status; - - len = XmbLookupString(xic, ev, buf, sizeof buf, &ksym, &status); - switch (status) { - default: /* XLookupNone, XBufferOverflow */ - return; - case XLookupChars: - goto insert; - case XLookupKeySym: - case XLookupBoth: - break; - } - - if (ev->state & ControlMask) { - switch(ksym) { - case XK_a: ksym = XK_Home; break; - case XK_b: ksym = XK_Left; break; - case XK_c: ksym = XK_Escape; break; - case XK_d: ksym = XK_Delete; break; - case XK_e: ksym = XK_End; break; - case XK_f: ksym = XK_Right; break; - case XK_g: ksym = XK_Escape; break; - case XK_h: ksym = XK_BackSpace; break; - case XK_i: ksym = XK_Tab; break; - case XK_j: /* fallthrough */ - case XK_J: /* fallthrough */ - case XK_m: /* fallthrough */ - case XK_M: ksym = XK_Return; ev->state &= ~ControlMask; break; - case XK_n: ksym = XK_Down; break; - case XK_p: ksym = XK_Up; break; - - case XK_k: /* delete right */ - text[cursor] = '\0'; - match(); - break; - case XK_u: /* delete left */ - insert(NULL, 0 - cursor); - break; - case XK_w: /* delete word */ - while (cursor > 0 && strchr(worddelimiters, text[nextrune(-1)])) - insert(NULL, nextrune(-1) - cursor); - while (cursor > 0 && !strchr(worddelimiters, text[nextrune(-1)])) - insert(NULL, nextrune(-1) - cursor); - break; - case XK_y: /* paste selection */ - case XK_Y: - XConvertSelection(dpy, (ev->state & ShiftMask) ? clip : XA_PRIMARY, - utf8, utf8, win, CurrentTime); - return; - case XK_Left: - movewordedge(-1); - goto draw; - case XK_Right: - movewordedge(+1); - goto draw; - case XK_Return: - case XK_KP_Enter: - break; - case XK_bracketleft: - cleanup(); - exit(1); - default: - return; - } - } else if (ev->state & Mod1Mask) { - switch(ksym) { - case XK_b: - movewordedge(-1); - goto draw; - case XK_f: - movewordedge(+1); - goto draw; - case XK_g: ksym = XK_Home; break; - case XK_G: ksym = XK_End; break; - case XK_h: ksym = XK_Up; break; - case XK_j: ksym = XK_Next; break; - case XK_k: ksym = XK_Prior; break; - case XK_l: ksym = XK_Down; break; - default: - return; - } - } - - switch(ksym) { - default: -insert: - if (!iscntrl(*buf)) - insert(buf, len); - break; - case XK_Delete: - if (text[cursor] == '\0') - return; - cursor = nextrune(+1); - /* fallthrough */ - case XK_BackSpace: - if (cursor == 0) - return; - insert(NULL, nextrune(-1) - cursor); - break; - case XK_End: - if (text[cursor] != '\0') { - cursor = strlen(text); - break; - } - if (next) { - /* jump to end of list and position items in reverse */ - curr = matchend; - calcoffsets(); - curr = prev; - calcoffsets(); - while (next && (curr = curr->right)) - calcoffsets(); - } - sel = matchend; - break; - case XK_Escape: - cleanup(); - exit(1); - case XK_Home: - if (sel == matches) { - cursor = 0; - break; - } - sel = curr = matches; - calcoffsets(); - break; - case XK_Left: - if (cursor > 0 && (!sel || !sel->left || lines > 0)) { - cursor = nextrune(-1); - break; - } - if (lines > 0) - return; - /* fallthrough */ - case XK_Up: - if (sel && sel->left && (sel = sel->left)->right == curr) { - curr = prev; - calcoffsets(); - } - break; - case XK_Next: - if (!next) - return; - sel = curr = next; - calcoffsets(); - break; - case XK_Prior: - if (!prev) - return; - sel = curr = prev; - calcoffsets(); - break; - case XK_Return: - case XK_KP_Enter: - puts((sel && !(ev->state & ShiftMask)) ? sel->text : text); - if (!(ev->state & ControlMask)) { - cleanup(); - exit(0); - } - if (sel) - sel->out = 1; - break; - case XK_Right: - if (text[cursor] != '\0') { - cursor = nextrune(+1); - break; - } - if (lines > 0) - return; - /* fallthrough */ - case XK_Down: - if (sel && sel->right && (sel = sel->right) == next) { - curr = next; - calcoffsets(); - } - break; - case XK_Tab: - if (!sel) - return; - strncpy(text, sel->text, sizeof text - 1); - text[sizeof text - 1] = '\0'; - cursor = strlen(text); - match(); - break; - } - -draw: - drawmenu(); -} - -static void -buttonpress(XEvent *e) -{ - struct item *item; - XButtonPressedEvent *ev = &e->xbutton; - int x = 0, y = 0, h = bh, w; - - if (ev->window != win) - return; - - /* right-click: exit */ - if (ev->button == Button3) - exit(1); - - if (prompt && *prompt) - x += promptw; - - /* input field */ - w = (lines > 0 || !matches) ? mw - x : inputw; - - /* left-click on input: clear input, - * NOTE: if there is no left-arrow the space for < is reserved so - * add that to the input width */ - if (ev->button == Button1 && - ((lines <= 0 && ev->x >= 0 && ev->x <= x + w + - ((!prev || !curr->left) ? TEXTW("<") : 0)) || - (lines > 0 && ev->y >= y && ev->y <= y + h))) { - insert(NULL, -cursor); - drawmenu(); - return; - } - /* middle-mouse click: paste selection */ - if (ev->button == Button2) { - XConvertSelection(dpy, (ev->state & ShiftMask) ? clip : XA_PRIMARY, - utf8, utf8, win, CurrentTime); - drawmenu(); - return; - } - /* scroll up */ - if (ev->button == Button4 && prev) { - sel = curr = prev; - calcoffsets(); - drawmenu(); - return; - } - /* scroll down */ - if (ev->button == Button5 && next) { - sel = curr = next; - calcoffsets(); - drawmenu(); - return; - } - if (ev->button != Button1) - return; - if (ev->state & ~ControlMask) - return; - if (lines > 0) { - /* vertical list: (ctrl)left-click on item */ - w = mw - x; - for (item = curr; item != next; item = item->right) { - y += h; - if (ev->y >= y && ev->y <= (y + h)) { - puts(item->text); - if (!(ev->state & ControlMask)) - exit(0); - sel = item; - if (sel) { - sel->out = 1; - drawmenu(); - } - return; - } - } - } else if (matches) { - /* left-click on left arrow */ - x += inputw; - w = TEXTW("<"); - if (prev && curr->left) { - if (ev->x >= x && ev->x <= x + w) { - sel = curr = prev; - calcoffsets(); - drawmenu(); - return; - } - } - /* horizontal list: (ctrl)left-click on item */ - for (item = curr; item != next; item = item->right) { - x += w; - w = MIN(TEXTW(item->text), mw - x - TEXTW(">")); - if (ev->x >= x && ev->x <= x + w) { - puts(item->text); - if (!(ev->state & ControlMask)) - exit(0); - sel = item; - if (sel) { - sel->out = 1; - drawmenu(); - } - return; - } - } - /* left-click on right arrow */ - w = TEXTW(">"); - x = mw - w; - if (next && ev->x >= x && ev->x <= x + w) { - sel = curr = next; - calcoffsets(); - drawmenu(); - return; - } - } -} - -static void -paste(void) -{ - char *p, *q; - int di; - unsigned long dl; - Atom da; - - /* we have been given the current selection, now insert it into input */ - if (XGetWindowProperty(dpy, win, utf8, 0, (sizeof text / 4) + 1, False, - utf8, &da, &di, &dl, &dl, (unsigned char **)&p) - == Success && p) { - insert(p, (q = strchr(p, '\n')) ? q - p : (ssize_t)strlen(p)); - XFree(p); - } - drawmenu(); -} - -static void -readstdin(void) -{ - char buf[sizeof text], *p; - size_t i, imax = 0, size = 0; - unsigned int tmpmax = 0; - - if(passwd){ - inputw = lines = 0; - return; - } - - /* read each line from stdin and add it to the item list */ - for (i = 0; fgets(buf, sizeof buf, stdin); i++) { - if (i + 1 >= size / sizeof *items) - if (!(items = realloc(items, (size += BUFSIZ)))) - die("cannot realloc %u bytes:", size); - if ((p = strchr(buf, '\n'))) - *p = '\0'; - if (!(items[i].text = strdup(buf))) - die("cannot strdup %u bytes:", strlen(buf) + 1); - items[i].out = 0; - drw_font_getexts(drw->fonts, buf, strlen(buf), &tmpmax, NULL); - if (tmpmax > inputw) { - inputw = tmpmax; - imax = i; - } - } - if (items) - items[i].text = NULL; - inputw = items ? TEXTW(items[imax].text) : 0; - lines = MIN(lines, i); -} - -static void -run(void) -{ - XEvent ev; - - while (!XNextEvent(dpy, &ev)) { - if (XFilterEvent(&ev, win)) - continue; - switch(ev.type) { - case ButtonPress: - buttonpress(&ev); - break; - case DestroyNotify: - if (ev.xdestroywindow.window != win) - break; - cleanup(); - exit(1); - case Expose: - if (ev.xexpose.count == 0) - drw_map(drw, win, 0, 0, mw, mh); - break; - case FocusIn: - /* regrab focus from parent window */ - if (ev.xfocus.window != win) - grabfocus(); - break; - case KeyPress: - keypress(&ev.xkey); - break; - case SelectionNotify: - if (ev.xselection.property == utf8) - paste(); - break; - case VisibilityNotify: - if (ev.xvisibility.state != VisibilityUnobscured) - XRaiseWindow(dpy, win); - break; - } - } -} - -static void -setup(void) -{ - int x, y, i, j; - unsigned int du; - XSetWindowAttributes swa; - XIM xim; - Window w, dw, *dws; - XWindowAttributes wa; - XClassHint ch = {"dmenu", "dmenu"}; -#ifdef XINERAMA - XineramaScreenInfo *info; - Window pw; - int a, di, n, area = 0; -#endif - /* init appearance */ - for (j = 0; j < SchemeLast; j++) - scheme[j] = drw_scm_create(drw, colors[j], alphas[j], 2); - - clip = XInternAtom(dpy, "CLIPBOARD", False); - utf8 = XInternAtom(dpy, "UTF8_STRING", False); - - /* calculate menu geometry */ - bh = drw->fonts->h + 2; - lines = MAX(lines, 0); - mh = (lines + 1) * bh; -#ifdef XINERAMA - i = 0; - if (parentwin == root && (info = XineramaQueryScreens(dpy, &n))) { - XGetInputFocus(dpy, &w, &di); - if (mon >= 0 && mon < n) - i = mon; - else if (w != root && w != PointerRoot && w != None) { - /* find top-level window containing current input focus */ - do { - if (XQueryTree(dpy, (pw = w), &dw, &w, &dws, &du) && dws) - XFree(dws); - } while (w != root && w != pw); - /* find xinerama screen with which the window intersects most */ - if (XGetWindowAttributes(dpy, pw, &wa)) - for (j = 0; j < n; j++) - if ((a = INTERSECT(wa.x, wa.y, wa.width, wa.height, info[j])) > area) { - area = a; - i = j; - } - } - /* no focused window is on screen, so use pointer location instead */ - if (mon < 0 && !area && XQueryPointer(dpy, root, &dw, &dw, &x, &y, &di, &di, &du)) - for (i = 0; i < n; i++) - if (INTERSECT(x, y, 1, 1, info[i])) - break; - - x = info[i].x_org; - y = info[i].y_org + (topbar ? 0 : info[i].height - mh); - mw = info[i].width; - XFree(info); - } else -#endif - { - if (!XGetWindowAttributes(dpy, parentwin, &wa)) - die("could not get embedding window attributes: 0x%lx", - parentwin); - x = 0; - y = topbar ? 0 : wa.height - mh; - mw = wa.width; - } - promptw = (prompt && *prompt) ? TEXTW(prompt) - lrpad / 4 : 0; - inputw = MIN(inputw, mw/3); - match(); - - /* create menu window */ - swa.override_redirect = True; - swa.background_pixel = scheme[SchemeNorm][ColBg].pixel; - swa.border_pixel = 0; - swa.colormap = cmap; - swa.event_mask = ExposureMask | KeyPressMask | VisibilityChangeMask | - ButtonPressMask; - win = XCreateWindow(dpy, parentwin, x, y, mw, mh, 0, - depth, InputOutput, visual, - CWOverrideRedirect | CWBackPixel | CWColormap | CWEventMask | CWBorderPixel, &swa); - XSetClassHint(dpy, win, &ch); - - - /* input methods */ - if ((xim = XOpenIM(dpy, NULL, NULL, NULL)) == NULL) - die("XOpenIM failed: could not open input device"); - - xic = XCreateIC(xim, XNInputStyle, XIMPreeditNothing | XIMStatusNothing, - XNClientWindow, win, XNFocusWindow, win, NULL); - - XMapRaised(dpy, win); - if (embed) { - XSelectInput(dpy, parentwin, FocusChangeMask | SubstructureNotifyMask); - if (XQueryTree(dpy, parentwin, &dw, &w, &dws, &du) && dws) { - for (i = 0; i < du && dws[i] != win; ++i) - XSelectInput(dpy, dws[i], FocusChangeMask); - XFree(dws); - } - grabfocus(); - } - drw_resize(drw, mw, mh); - drawmenu(); -} - -static void -usage(void) -{ - fputs("usage: dmenu [-bfiPrv] [-l lines] [-p prompt] [-fn font] [-m monitor]\n" - " [-nb color] [-nf color] [-sb color] [-sf color] [-w windowid]\n", stderr); - exit(1); -} - -void -read_Xresources(void) { - XrmInitialize(); - - char* xrm; - if ((xrm = XResourceManagerString(drw->dpy))) { - char *type; - XrmDatabase xdb = XrmGetStringDatabase(xrm); - XrmValue xval; - - if (XrmGetResource(xdb, "dmenu.font", "*", &type, &xval) == True) /* font or font set */ - fonts[0] = strdup(xval.addr); - if (XrmGetResource(xdb, "dmenu.color0", "*", &type, &xval) == True) /* normal background color */ - colors[SchemeNorm][ColBg] = strdup(xval.addr); - if (XrmGetResource(xdb, "dmenu.color4", "*", &type, &xval) == True) /* normal foreground color */ - colors[SchemeNorm][ColFg] = strdup(xval.addr); - if (XrmGetResource(xdb, "dmenu.color4", "*", &type, &xval) == True) /* selected background color */ - colors[SchemeSel][ColBg] = strdup(xval.addr); - if (XrmGetResource(xdb, "dmenu.color0", "*", &type, &xval) == True) /* selected foreground color */ - colors[SchemeSel][ColFg] = strdup(xval.addr); - - XrmDestroyDatabase(xdb); - } -} - -int -main(int argc, char *argv[]) -{ - XWindowAttributes wa; - int i, fast = 0; - - for (i = 1; i < argc; i++) - /* these options take no arguments */ - if (!strcmp(argv[i], "-v")) { /* prints version information */ - puts("dmenu-"VERSION); - exit(0); - } else if (!strcmp(argv[i], "-b")) /* appears at the bottom of the screen */ - topbar = 0; - else if (!strcmp(argv[i], "-f")) /* grabs keyboard before reading stdin */ - fast = 1; - else if (!strcmp(argv[i], "-i")) { /* case-insensitive item matching */ - fstrncmp = strncasecmp; - fstrstr = cistrstr; - } else if (!strcmp(argv[i], "-P")) /* is the input a password */ - passwd = 1; - else if (!strcmp(argv[i], "-r")) /* reject input which results in no match */ - reject_no_match = 1; - else if (i + 1 == argc) - usage(); - /* these options take one argument */ - else if (!strcmp(argv[i], "-l")) /* number of lines in vertical list */ - lines = atoi(argv[++i]); - else if (!strcmp(argv[i], "-m")) - mon = atoi(argv[++i]); - else if (!strcmp(argv[i], "-p")) /* adds prompt to left of input field */ - prompt = argv[++i]; - else if (!strcmp(argv[i], "-fn")) /* font or font set */ - fonts[0] = argv[++i]; - else if (!strcmp(argv[i], "-nb")) /* normal background color */ - colors[SchemeNorm][ColBg] = argv[++i]; - else if (!strcmp(argv[i], "-nf")) /* normal foreground color */ - colors[SchemeNorm][ColFg] = argv[++i]; - else if (!strcmp(argv[i], "-sb")) /* selected background color */ - colors[SchemeSel][ColBg] = argv[++i]; - else if (!strcmp(argv[i], "-sf")) /* selected foreground color */ - colors[SchemeSel][ColFg] = argv[++i]; - else if (!strcmp(argv[i], "-w")) /* embedding window id */ - embed = argv[++i]; - else - usage(); - - if (!setlocale(LC_CTYPE, "") || !XSupportsLocale()) - fputs("warning: no locale support\n", stderr); - if (!(dpy = XOpenDisplay(NULL))) - die("cannot open display"); - screen = DefaultScreen(dpy); - root = RootWindow(dpy, screen); - if (!embed || !(parentwin = strtol(embed, NULL, 0))) - parentwin = root; - if (!XGetWindowAttributes(dpy, parentwin, &wa)) - die("could not get embedding window attributes: 0x%lx", - parentwin); - xinitvisual(); - drw = drw_create(dpy, screen, root, wa.width, wa.height, visual, depth, cmap); - read_Xresources(); - if (!drw_fontset_create(drw, fonts, LENGTH(fonts))) - die("no fonts could be loaded."); - lrpad = drw->fonts->h; - -#ifdef __OpenBSD__ - if (pledge("stdio rpath", NULL) == -1) - die("pledge"); -#endif - - if (fast && !isatty(0)) { - grabkeyboard(); - readstdin(); - } else { - readstdin(); - grabkeyboard(); - } - setup(); - run(); - - return 1; /* unreachable */ -} diff --git a/.local/src2/dmenu/dmenu.o b/.local/src2/dmenu/dmenu.o deleted file mode 100644 index 80b23094..00000000 Binary files a/.local/src2/dmenu/dmenu.o and /dev/null differ diff --git a/.local/src2/dmenu/dmenu_path b/.local/src2/dmenu/dmenu_path deleted file mode 100755 index 3a7cda79..00000000 --- a/.local/src2/dmenu/dmenu_path +++ /dev/null @@ -1,13 +0,0 @@ -#!/bin/sh - -cachedir="${XDG_CACHE_HOME:-"$HOME/.cache"}" -cache="$cachedir/dmenu_run" - -[ ! -e "$cachedir" ] && mkdir -p "$cachedir" - -IFS=: -if stest -dqr -n "$cache" $PATH; then - stest -flx $PATH | sort -u | tee "$cache" -else - cat "$cache" -fi diff --git a/.local/src2/dmenu/dmenu_run b/.local/src2/dmenu/dmenu_run deleted file mode 100755 index 834ede54..00000000 --- a/.local/src2/dmenu/dmenu_run +++ /dev/null @@ -1,2 +0,0 @@ -#!/bin/sh -dmenu_path | dmenu "$@" | ${SHELL:-"/bin/sh"} & diff --git a/.local/src2/dmenu/drw.c b/.local/src2/dmenu/drw.c deleted file mode 100644 index 76949555..00000000 --- a/.local/src2/dmenu/drw.c +++ /dev/null @@ -1,424 +0,0 @@ -/* 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 "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->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->drawable) - XFreePixmap(drw->dpy, drw->drawable); - drw->drawable = XCreatePixmap(drw->dpy, drw->root, w, h, drw->depth); -} - -void -drw_free(Drw *drw) -{ - 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 & 0x00FFFFFFFU) | 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, const 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; -} - -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) -{ - char buf[1024]; - int ty; - unsigned int ew; - XftDraw *d = NULL; - Fnt *usedfont, *curfont, *nextfont; - size_t i, len; - 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; - - if (!drw || (render && !drw->scheme) || !text || !drw->fonts) - return 0; - - if (!render) { - w = ~w; - } 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; - while (1) { - 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) { - if (curfont == usedfont) { - utf8strlen += utf8charlen; - text += utf8charlen; - } else { - nextfont = curfont; - } - break; - } - } - - if (!charexists || nextfont) - break; - else - charexists = 0; - } - - if (utf8strlen) { - drw_font_getexts(usedfont, utf8str, utf8strlen, &ew, NULL); - /* shorten text if necessary */ - for (len = MIN(utf8strlen, sizeof(buf) - 1); len && ew > w; len--) - drw_font_getexts(usedfont, utf8str, len, &ew, NULL); - - if (len) { - memcpy(buf, utf8str, len); - buf[len] = '\0'; - if (len < utf8strlen) - for (i = len; i && i > len - 3; buf[--i] = '.') - ; /* NOP */ - - if (render) { - ty = y + (h - usedfont->h) / 2 + usedfont->xfont->ascent; - XftDrawStringUtf8(d, &drw->scheme[invert ? ColBg : ColFg], - usedfont->xfont, x, ty, (XftChar8 *)buf, len); - } - x += ew; - w -= ew; - } - } - - if (!*text) { - 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; - - 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); - FcPatternAddBool(fcpattern, FC_COLOR, FcFalse); - - 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); - usedfont = drw->fonts; - } - } - } - } - if (d) - XftDrawDestroy(d); - - return x + (render ? w : 0); -} - -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); -} - -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/.local/src2/dmenu/drw.h b/.local/src2/dmenu/drw.h deleted file mode 100644 index 4f66f0d6..00000000 --- a/.local/src2/dmenu/drw.h +++ /dev/null @@ -1,60 +0,0 @@ -/* 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 }; /* 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; - 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); -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, const 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); - -/* 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); - -/* Map functions */ -void drw_map(Drw *drw, Window win, int x, int y, unsigned int w, unsigned int h); diff --git a/.local/src2/dmenu/drw.o b/.local/src2/dmenu/drw.o deleted file mode 100644 index 07d5ef0f..00000000 Binary files a/.local/src2/dmenu/drw.o and /dev/null differ diff --git a/.local/src2/dmenu/stest b/.local/src2/dmenu/stest deleted file mode 100755 index 532383f4..00000000 Binary files a/.local/src2/dmenu/stest and /dev/null differ diff --git a/.local/src2/dmenu/stest.1 b/.local/src2/dmenu/stest.1 deleted file mode 100644 index 2667d8aa..00000000 --- a/.local/src2/dmenu/stest.1 +++ /dev/null @@ -1,90 +0,0 @@ -.TH STEST 1 dmenu\-VERSION -.SH NAME -stest \- filter a list of files by properties -.SH SYNOPSIS -.B stest -.RB [ -abcdefghlpqrsuwx ] -.RB [ -n -.IR file ] -.RB [ -o -.IR file ] -.RI [ file ...] -.SH DESCRIPTION -.B stest -takes a list of files and filters by the files' properties, analogous to -.IR test (1). -Files which pass all tests are printed to stdout. If no files are given, stest -reads files from stdin. -.SH OPTIONS -.TP -.B \-a -Test hidden files. -.TP -.B \-b -Test that files are block specials. -.TP -.B \-c -Test that files are character specials. -.TP -.B \-d -Test that files are directories. -.TP -.B \-e -Test that files exist. -.TP -.B \-f -Test that files are regular files. -.TP -.B \-g -Test that files have their set-group-ID flag set. -.TP -.B \-h -Test that files are symbolic links. -.TP -.B \-l -Test the contents of a directory given as an argument. -.TP -.BI \-n " file" -Test that files are newer than -.IR file . -.TP -.BI \-o " file" -Test that files are older than -.IR file . -.TP -.B \-p -Test that files are named pipes. -.TP -.B \-q -No files are printed, only the exit status is returned. -.TP -.B \-r -Test that files are readable. -.TP -.B \-s -Test that files are not empty. -.TP -.B \-u -Test that files have their set-user-ID flag set. -.TP -.B \-v -Invert the sense of tests, only failing files pass. -.TP -.B \-w -Test that files are writable. -.TP -.B \-x -Test that files are executable. -.SH EXIT STATUS -.TP -.B 0 -At least one file passed all tests. -.TP -.B 1 -No files passed all tests. -.TP -.B 2 -An error occurred. -.SH SEE ALSO -.IR dmenu (1), -.IR test (1) diff --git a/.local/src2/dmenu/stest.c b/.local/src2/dmenu/stest.c deleted file mode 100644 index 7a7b0bcf..00000000 --- a/.local/src2/dmenu/stest.c +++ /dev/null @@ -1,109 +0,0 @@ -/* See LICENSE file for copyright and license details. */ -#include <sys/stat.h> - -#include <dirent.h> -#include <limits.h> -#include <stdio.h> -#include <stdlib.h> -#include <string.h> -#include <unistd.h> - -#include "arg.h" -char *argv0; - -#define FLAG(x) (flag[(x)-'a']) - -static void test(const char *, const char *); -static void usage(void); - -static int match = 0; -static int flag[26]; -static struct stat old, new; - -static void -test(const char *path, const char *name) -{ - struct stat st, ln; - - if ((!stat(path, &st) && (FLAG('a') || name[0] != '.') /* hidden files */ - && (!FLAG('b') || S_ISBLK(st.st_mode)) /* block special */ - && (!FLAG('c') || S_ISCHR(st.st_mode)) /* character special */ - && (!FLAG('d') || S_ISDIR(st.st_mode)) /* directory */ - && (!FLAG('e') || access(path, F_OK) == 0) /* exists */ - && (!FLAG('f') || S_ISREG(st.st_mode)) /* regular file */ - && (!FLAG('g') || st.st_mode & S_ISGID) /* set-group-id flag */ - && (!FLAG('h') || (!lstat(path, &ln) && S_ISLNK(ln.st_mode))) /* symbolic link */ - && (!FLAG('n') || st.st_mtime > new.st_mtime) /* newer than file */ - && (!FLAG('o') || st.st_mtime < old.st_mtime) /* older than file */ - && (!FLAG('p') || S_ISFIFO(st.st_mode)) /* named pipe */ - && (!FLAG('r') || access(path, R_OK) == 0) /* readable */ - && (!FLAG('s') || st.st_size > 0) /* not empty */ - && (!FLAG('u') || st.st_mode & S_ISUID) /* set-user-id flag */ - && (!FLAG('w') || access(path, W_OK) == 0) /* writable */ - && (!FLAG('x') || access(path, X_OK) == 0)) != FLAG('v')) { /* executable */ - if (FLAG('q')) - exit(0); - match = 1; - puts(name); - } -} - -static void -usage(void) -{ - fprintf(stderr, "usage: %s [-abcdefghlpqrsuvwx] " - "[-n file] [-o file] [file...]\n", argv0); - exit(2); /* like test(1) return > 1 on error */ -} - -int -main(int argc, char *argv[]) -{ - struct dirent *d; - char path[PATH_MAX], *line = NULL, *file; - size_t linesiz = 0; - ssize_t n; - DIR *dir; - int r; - - ARGBEGIN { - case 'n': /* newer than file */ - case 'o': /* older than file */ - file = EARGF(usage()); - if (!(FLAG(ARGC()) = !stat(file, (ARGC() == 'n' ? &new : &old)))) - perror(file); - break; - default: - /* miscellaneous operators */ - if (strchr("abcdefghlpqrsuvwx", ARGC())) - FLAG(ARGC()) = 1; - else - usage(); /* unknown flag */ - } ARGEND; - - if (!argc) { - /* read list from stdin */ - while ((n = getline(&line, &linesiz, stdin)) > 0) { - if (n && line[n - 1] == '\n') - line[n - 1] = '\0'; - test(line, line); - } - free(line); - } else { - for (; argc; argc--, argv++) { - if (FLAG('l') && (dir = opendir(*argv))) { - /* test directory contents */ - while ((d = readdir(dir))) { - r = snprintf(path, sizeof path, "%s/%s", - *argv, d->d_name); - if (r >= 0 && (size_t)r < sizeof path) - test(path, d->d_name); - } - closedir(dir); - } else { - test(*argv, *argv); - } - } - } - return match ? 0 : 1; -} diff --git a/.local/src2/dmenu/stest.o b/.local/src2/dmenu/stest.o deleted file mode 100644 index 4ffa3578..00000000 Binary files a/.local/src2/dmenu/stest.o and /dev/null differ diff --git a/.local/src2/dmenu/util.c b/.local/src2/dmenu/util.c deleted file mode 100644 index fe044fc7..00000000 --- a/.local/src2/dmenu/util.c +++ /dev/null @@ -1,35 +0,0 @@ -/* See LICENSE file for copyright and license details. */ -#include <stdarg.h> -#include <stdio.h> -#include <stdlib.h> -#include <string.h> - -#include "util.h" - -void * -ecalloc(size_t nmemb, size_t size) -{ - void *p; - - if (!(p = calloc(nmemb, size))) - die("calloc:"); - return p; -} - -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); -} diff --git a/.local/src2/dmenu/util.h b/.local/src2/dmenu/util.h deleted file mode 100644 index f633b517..00000000 --- a/.local/src2/dmenu/util.h +++ /dev/null @@ -1,8 +0,0 @@ -/* 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/.local/src2/dmenu/util.o b/.local/src2/dmenu/util.o deleted file mode 100644 index 3b48c2f6..00000000 Binary files a/.local/src2/dmenu/util.o and /dev/null differ diff --git a/.local/src2/dwm/FUNDING.yml b/.local/src2/dwm/FUNDING.yml deleted file mode 100644 index c7c9a22e..00000000 --- a/.local/src2/dwm/FUNDING.yml +++ /dev/null @@ -1,2 +0,0 @@ -custom: ["https://lukesmith.xyz/donate.html"] -github: lukesmithxyz diff --git a/.local/src2/dwm/LICENSE b/.local/src2/dwm/LICENSE deleted file mode 100644 index 1e1b5a43..00000000 --- a/.local/src2/dwm/LICENSE +++ /dev/null @@ -1,38 +0,0 @@ -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> -© 2019-2020 Luke Smith <luke@lukesmith.xyz> - -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/.local/src2/dwm/Makefile b/.local/src2/dwm/Makefile deleted file mode 100644 index ac1ca634..00000000 --- a/.local/src2/dwm/Makefile +++ /dev/null @@ -1,52 +0,0 @@ -# dwm - dynamic window manager -# See LICENSE file for copyright and license details. - -include config.mk - -SRC = drw.c dwm.c util.c -OBJ = ${SRC:.c=.o} - -all: options dwm - -options: - @echo dwm build options: - @echo "CFLAGS = ${CFLAGS}" - @echo "LDFLAGS = ${LDFLAGS}" - @echo "CC = ${CC}" - -.c.o: - ${CC} -c ${CFLAGS} $< - -${OBJ}: config.h config.mk - -dwm: ${OBJ} - ${CC} -o $@ ${OBJ} ${LDFLAGS} - -clean: - rm -f dwm ${OBJ} dwm-${VERSION}.tar.gz *.orig *.rej - -dist: clean - mkdir -p dwm-${VERSION} - cp -R LICENSE Makefile README config.mk\ - dwm.1 drw.h util.h ${SRC} transient.c dwm-${VERSION} - tar -cf dwm-${VERSION}.tar dwm-${VERSION} - gzip dwm-${VERSION}.tar - rm -rf dwm-${VERSION} - -install: all - mkdir -p ${DESTDIR}${PREFIX}/bin - cp -f dwm ${DESTDIR}${PREFIX}/bin - chmod 755 ${DESTDIR}${PREFIX}/bin/dwm - mkdir -p ${DESTDIR}${MANPREFIX}/man1 - sed "s/VERSION/${VERSION}/g" < dwm.1 > ${DESTDIR}${MANPREFIX}/man1/dwm.1 - chmod 644 ${DESTDIR}${MANPREFIX}/man1/dwm.1 - # mkdir -p ${DESTDIR}${PREFIX}/share/dwm - # cp -f larbs.mom ${DESTDIR}${PREFIX}/share/dwm - # chmod 644 ${DESTDIR}${PREFIX}/share/dwm/larbs.mom - -uninstall: - rm -f ${DESTDIR}${PREFIX}/bin/dwm\ - # ${DESTDIR}${PREFIX}/share/dwm/larbs.mom\ - ${DESTDIR}${MANPREFIX}/man1/dwm.1 - -.PHONY: all options clean dist install uninstall diff --git a/.local/src2/dwm/PKGBUILD b/.local/src2/dwm/PKGBUILD deleted file mode 100644 index ba894886..00000000 --- a/.local/src2/dwm/PKGBUILD +++ /dev/null @@ -1,46 +0,0 @@ -_pkgname=dwm -pkgname=$_pkgname-larbs-git -pkgver=6.2.r1888.0ac09e0 -pkgrel=1 -pkgdesc="Luke's build of dwm" -url=https://github.com/LukeSmithxyz/dwm -arch=(i686 x86_64) -license=(MIT) -makedepends=(git) -depends=(freetype2 libx11 libxft) -optdepends=( - 'libxft-bgra: if dwm crashes when displaying emojis' - 'libxft-bgra-git: if dwm crashes when displaying emojis' - 'dmenu: program launcher' - 'st: terminal emulator') -provides=($_pkgname) -conflicts=($_pkgname) -source=(git+https://github.com/LukeSmithxyz/dwm) -sha256sums=('SKIP') - -pkgver() { - cd "$_pkgname" - echo "$(awk '/^VERSION =/ {print $3}' config.mk)".r"$(git rev-list --count HEAD)"."$(git rev-parse --short HEAD)" -} - -prepare() { - cd "$_pkgname" - echo "CPPFLAGS+=${CPPFLAGS}" >> config.mk - echo "CFLAGS+=${CFLAGS}" >> config.mk - echo "LDFLAGS+=${LDFLAGS}" >> config.mk - # to use a custom config.h, place it in the package directory - if [[ -f ${SRCDEST}/config.h ]]; then - cp "${SRCDEST}/config.h" . - fi -} - -build() { - cd "$_pkgname" - make X11INC=/usr/include/X11 X11LIB=/usr/lib/X11 -} - -package() { - cd "$_pkgname" - make PREFIX=/usr DESTDIR="$pkgdir" install - install -Dm644 LICENSE "$pkgdir/usr/share/licenses/$pkgname/LICENSE" -} diff --git a/.local/src2/dwm/README.md b/.local/src2/dwm/README.md deleted file mode 100644 index 0dd4e321..00000000 --- a/.local/src2/dwm/README.md +++ /dev/null @@ -1,39 +0,0 @@ -# Luke's build of dwm - -## FAQ - -> What are the bindings? - -This is suckless, mmmbud, the source code is the documentation! Check out [config.h](config.h). - -Okay, okay, actually I keep a readme in `larbs.mom` for my whole system, including the binds here. -Press <kbd>super+F1</kbd> to view it in dwm (zathura is required for that binding). -I haven't kept `man dwm`/`dwm.1` updated though. PRs welcome on that, lol. - -## Patches and features - -- [Clickable statusbar](https://dwm.suckless.org/patches/statuscmd/) with my build of [dwmblocks](https://github.com/lukesmithxyz/dwmblocks). -- Reads [xresources](https://dwm.suckless.org/patches/xresources/) colors/variables (i.e. works with `pywal`, etc.). -- scratchpad: Accessible with <kbd>mod+shift+enter</kbd>. -- New layouts: bstack, fibonacci, deck, centered master and more. All bound to keys <kbd>super+(shift+)t/y/u/i</kbd>. -- True fullscreen (<kbd>super+f</kbd>) and prevents focus shifting. -- Windows can be made sticky (<kbd>super+s</kbd>). -- [stacker](https://dwm.suckless.org/patches/stacker/): Move windows up the stack manually (<kbd>super-K/J</kbd>). -- [shiftview](https://dwm.suckless.org/patches/nextprev/): Cycle through tags (<kbd>super+g/;</kbd>). -- [vanitygaps](https://dwm.suckless.org/patches/vanitygaps/): Gaps allowed across all layouts. -- [swallow patch](https://dwm.suckless.org/patches/swallow/): if a program run from a terminal would make it inoperable, it temporarily takes its place to save space. - - -## Installation for newbs - -```bash -git clone https://github.com/LukeSmithxyz/dwm.git -cd dwm -sudo make install -``` - -There is also a `PKGBUILD` usable on distributions with pacman. Run `makepkg -si` instead of `sudo make install`. - -### You must also install `libxft-bgra`! - -This build of dwm does not block color emoji in the status/info bar, so you must install [libxft-bgra](https://aur.archlinux.org/packages/libxft-bgra/), which fixes a libxft color emoji rendering problem, otherwise dwm will crash upon trying to render one. Hopefully this fix will be in all libxft soon enough. diff --git a/.local/src2/dwm/compile_commands.json b/.local/src2/dwm/compile_commands.json deleted file mode 100644 index a3cccb2e..00000000 --- a/.local/src2/dwm/compile_commands.json +++ /dev/null @@ -1,65 +0,0 @@ -[ - { - "arguments": [ - "/usr/bin/cc", - "-c", - "-std=c99", - "-pedantic", - "-Wall", - "-Wno-deprecated-declarations", - "-Os", - "-I/usr/X11R6/include", - "-I/usr/include/freetype2", - "-D_DEFAULT_SOURCE", - "-D_BSD_SOURCE", - "-D_POSIX_C_SOURCE=200809L", - "-DVERSION=\"6.2\"", - "-DXINERAMA", - "drw.c" - ], - "directory": "/home/luca/.local/src/dwm", - "file": "/home/luca/.local/src/dwm/drw.c" - }, - { - "arguments": [ - "/usr/bin/cc", - "-c", - "-std=c99", - "-pedantic", - "-Wall", - "-Wno-deprecated-declarations", - "-Os", - "-I/usr/X11R6/include", - "-I/usr/include/freetype2", - "-D_DEFAULT_SOURCE", - "-D_BSD_SOURCE", - "-D_POSIX_C_SOURCE=200809L", - "-DVERSION=\"6.2\"", - "-DXINERAMA", - "dwm.c" - ], - "directory": "/home/luca/.local/src/dwm", - "file": "/home/luca/.local/src/dwm/dwm.c" - }, - { - "arguments": [ - "/usr/bin/cc", - "-c", - "-std=c99", - "-pedantic", - "-Wall", - "-Wno-deprecated-declarations", - "-Os", - "-I/usr/X11R6/include", - "-I/usr/include/freetype2", - "-D_DEFAULT_SOURCE", - "-D_BSD_SOURCE", - "-D_POSIX_C_SOURCE=200809L", - "-DVERSION=\"6.2\"", - "-DXINERAMA", - "util.c" - ], - "directory": "/home/luca/.local/src/dwm", - "file": "/home/luca/.local/src/dwm/util.c" - } -] diff --git a/.local/src2/dwm/config.h b/.local/src2/dwm/config.h deleted file mode 100644 index 54b7b5ef..00000000 --- a/.local/src2/dwm/config.h +++ /dev/null @@ -1,542 +0,0 @@ -/* See LICENSE file for copyright and license details. */ - -/* Constants */ -#define TERMINAL "kitty" -#define TERMCLASS "kitty" -#define BROWSER "librewolf" - -/* appearance */ -static unsigned int borderpx = 2; /* border pixel of windows */ -static unsigned int snap = 33; /* snap pixel */ -static unsigned int gappih = 10; /* horiz inner gap between windows */ -static unsigned int gappiv = 10; /* vert inner gap between windows */ -static unsigned int gappoh = - 10; /* horiz outer gap between windows and screen edge */ -static unsigned int gappov = - 10; /* vert outer gap between windows and screen edge */ -static int swallowfloating = - 0; /* 1 means swallow floating windows by default */ -static int smartgaps = - 0; /* 1 means no outer gap when there is only one window */ -static int showbar = 1; /* 0 means no bar */ -static int topbar = 1; /* 0 means bottom bar */ -static char *fonts[] = { - "FiraCode Nerd Font Mono:size=10:antialias=true:autohint=true"}; -static char normbgcolor[] = "#222222"; -static char normbordercolor[] = "#444444"; -static char normfgcolor[] = "#bbbbbb"; -static char selfgcolor[] = "#eeeeee"; -static char selbordercolor[] = "#770000"; -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; -const char *spcmd1[] = {TERMINAL, - "--name", - "spterm", - "-o", - "initial_window_width=120c", - "-o", - "initial_window_height=34c", - "-o", - "remember_window_size=no", - "-o", - "background_opacity=0.8", - "-o", - "tab_bar_min_tabs=9001", - NULL}; -const char *spcmd2[] = {TERMINAL, - "--name", - "spcalc", - "-o", - "remember_window_size=no", - "-o", - "font_size=16", - "-o", - "initial_window_width=50c", - "-o", - "initial_window_height=20c", - "-o", - "background_opacity=0.8", - "-o", - "confirm_os_window_close=0", - "-o", - "tab_bar_min_tabs=9001", - "-e", - "bc", - "-lq", - NULL}; -static Sp scratchpads[] = { - /* name cmd */ - {"spterm", spcmd1}, - {"spcalc", spcmd2}, -}; - -/* tagging */ -static const char *tags[] = {"1", "2", "3", "4", "5", "6", "7", "8", "9"}; - -static const Rule rules[] = { - /* xprop(1): - * WM_CLASS(STRING) = instance, class - * WM_NAME(STRING) = title - */ - /* class instance title tags mask isfloating - isterminal noswallow monitor */ - {"Gimp", NULL, NULL, 1 << 8, 0, 0, 0, -1}, - {TERMCLASS, NULL, NULL, 0, 0, 1, 0, -1}, - {NULL, NULL, "Event Tester", 0, 0, 0, 1, -1}, - {NULL, "bg", NULL, 0, 0, 1, 1 << 7, -1}, - {NULL, "spterm", NULL, SPTAG(0), 1, 1, 0, -1}, - {NULL, "spcalc", NULL, SPTAG(1), 1, 1, 0, -1}, -}; - -/* layout(s) */ -static float mfact = 0.6; /* factor of master area size [0.05..0.95] */ -static int nmaster = 1; /* number of clients in master area */ -static int resizehints = 0; /* 1 means respect size hints in tiled resizals */ -#define FORCE_VSPLIT \ - 1 /* nrowgrid layout: force two clients to always split vertically */ -#include "vanitygaps.c" -static const Layout layouts[] = { - /* symbol arrange function */ - {"[]=", tile}, /* Default: Master on left, slaves on right */ - {"TTT", bstack}, /* Master on top, slaves on bottom */ - - {"[@]", spiral}, /* Fibonacci spiral */ - {"[\\]", dwindle}, /* Decreasing in size right and leftward */ - - {"[D]", deck}, /* Master on left, slaves in monocle-like mode on right */ - {"[M]", monocle}, /* All windows on top of eachother */ - - {"|M|", centeredmaster}, /* Master in middle, slaves on sides */ - {">M>", centeredfloatingmaster}, /* Same but master floats */ - - {"><>", NULL}, /* no layout function means floating behavior */ - {NULL, NULL}, -}; - -/* key definitions */ -#define MODKEY Mod4Mask -#define TAGKEYS(KEY, TAG) \ - {MODKEY, KEY, view, {.ui = 1 << TAG}}, \ - {MODKEY | ControlMask, KEY, toggleview, {.ui = 1 << TAG}}, \ - {MODKEY | ShiftMask, KEY, tag, {.ui = 1 << TAG}}, \ - {MODKEY | ControlMask | ShiftMask, KEY, toggletag, {.ui = 1 << TAG}}, -#define STACKKEYS(MOD, ACTION) \ - {MOD, XK_j, ACTION##stack, {.i = INC(+1)}}, \ - {MOD, XK_k, ACTION##stack, {.i = INC(-1)}}, \ - {MOD, \ - XK_v, \ - ACTION##stack, \ - {.i = 0}}, /* { MOD, XK_grave, ACTION##stack, {.i = PREVSEL } }, \ */ - /* { MOD, XK_a, ACTION##stack, {.i = 1 } }, \ */ - /* { MOD, XK_z, ACTION##stack, {.i = 2 } }, \ */ - /* { MOD, XK_x, ACTION##stack, {.i = -1 } }, */ - -/* 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 const char *termcmd[] = {TERMINAL, - "-o", - "background_opacity=0.8", - "-o", - "confirm_os_window_close=0", - "-o", - "tab_bar_min_tabs=9001", - NULL}; - -/* - * Xresources preferences to load at startup - */ -ResourcePref resources[] = { - {"color0", STRING, &normbordercolor}, - {"color8", STRING, &selbordercolor}, - {"color8", STRING, &normbgcolor}, - {"color12", STRING, &normfgcolor}, - {"color0", STRING, &selfgcolor}, - {"color4", STRING, &selbgcolor}, - {"borderpx", INTEGER, &borderpx}, - {"snap", INTEGER, &snap}, - {"showbar", INTEGER, &showbar}, - {"topbar", INTEGER, &topbar}, - {"nmaster", INTEGER, &nmaster}, - {"resizehints", INTEGER, &resizehints}, - {"mfact", FLOAT, &mfact}, - {"gappih", INTEGER, &gappih}, - {"gappiv", INTEGER, &gappiv}, - {"gappoh", INTEGER, &gappoh}, - {"gappov", INTEGER, &gappov}, - {"swallowfloating", INTEGER, &swallowfloating}, - {"smartgaps", INTEGER, &smartgaps}, -}; - -#include "shiftview.c" -#include <X11/XF86keysym.h> - -static Key keys[] = { - /* modifier key function argument */ - STACKKEYS(MODKEY, focus) STACKKEYS(MODKEY | ShiftMask, push) - /* { MODKEY|ShiftMask, XK_Escape, spawn, SHCMD("") }, */ - {MODKEY, - XK_dead_circumflex, - spawn, - {.v = (const char *[]){"dmenuunicode", NULL}}}, - /* { MODKEY|ShiftMask, XK_grave, togglescratch, - * SHCMD("") - * }, - */ - TAGKEYS(XK_1, 0) TAGKEYS(XK_2, 1) TAGKEYS(XK_3, 2) TAGKEYS(XK_4, 3) - TAGKEYS(XK_5, 4) TAGKEYS(XK_6, 5) TAGKEYS(XK_7, 6) TAGKEYS(XK_8, 7) - TAGKEYS(XK_9, 8){MODKEY, XK_0, view, {.ui = ~0}}, - {MODKEY | ShiftMask, XK_0, tag, {.ui = ~0}}, - {MODKEY, XK_ssharp, spawn, - SHCMD("pamixer --allow-boost -d 5; kill -44 $(pidof dwmblocks)")}, - {MODKEY | ShiftMask, XK_ssharp, spawn, - SHCMD("pamixer --allow-boost -d 15; kill -44 $(pidof dwmblocks)")}, - {MODKEY, XK_dead_acute, spawn, - SHCMD("pamixer --allow-boost -i 5; kill -44 $(pidof dwmblocks)")}, - {MODKEY | ShiftMask, XK_dead_acute, spawn, - SHCMD("pamixer --allow-boost -i 15; kill -44 $(pidof dwmblocks)")}, - {MODKEY, XK_BackSpace, spawn, {.v = (const char *[]){"sysact", NULL}}}, - {MODKEY | ShiftMask, - XK_BackSpace, - spawn, - {.v = (const char *[]){"sysact", NULL}}}, - - {MODKEY, XK_Tab, view, {0}}, - /* { MODKEY|ShiftMask, XK_Tab, spawn, - * SHCMD("") - * }, - */ - {MODKEY, XK_q, killclient, {0}}, - {MODKEY | ShiftMask, XK_q, spawn, {.v = (const char *[]){"sysact", NULL}}}, - {MODKEY, XK_w, spawn, {.v = (const char *[]){BROWSER, NULL}}}, - {MODKEY | ShiftMask, - XK_w, - spawn, - {.v = (const char *[]){TERMINAL, "-e", "sudo", "nmtui", NULL}}}, - {MODKEY, XK_e, spawn, - SHCMD( - TERMINAL - " -e neomutt ; pkill -RTMIN+12 dwmblocks; rmdir ~/.abook")}, // REPLACE - {MODKEY | ShiftMask, XK_e, spawn, - SHCMD(TERMINAL " -e abook -C ~/.config/abook/abookrc --datafile " - "~/.config/abook/addressbook")}, // REPLACE - {MODKEY, XK_r, spawn, {.v = (const char *[]){TERMINAL, "-e", "lf", NULL}}}, - {MODKEY | ShiftMask, - XK_r, - spawn, - {.v = (const char *[]){TERMINAL, "-e", "htop", NULL}}}, - {MODKEY, XK_t, setlayout, {.v = &layouts[0]}}, /* tile */ - {MODKEY | ShiftMask, XK_t, setlayout, {.v = &layouts[1]}}, /* bstack */ - {MODKEY, XK_z, setlayout, {.v = &layouts[2]}}, /* spiral */ - {MODKEY | ShiftMask, XK_z, setlayout, {.v = &layouts[3]}}, /* dwindle */ - {MODKEY, XK_u, setlayout, {.v = &layouts[4]}}, /* deck */ - {MODKEY | ShiftMask, XK_u, setlayout, {.v = &layouts[5]}}, /* monocle */ - {MODKEY, XK_i, setlayout, {.v = &layouts[6]}}, /* centeredmaster */ - {MODKEY | ShiftMask, - XK_i, - setlayout, - {.v = &layouts[7]}}, /* centeredfloatingmaster */ - {MODKEY, XK_o, incnmaster, {.i = +1}}, - {MODKEY | ShiftMask, XK_o, incnmaster, {.i = -1}}, - {MODKEY, XK_p, spawn, {.v = (const char *[]){"mpc", "toggle", NULL}}}, - {MODKEY | ShiftMask, XK_p, spawn, SHCMD("mpc pause ; pauseallmpv")}, - {MODKEY, - XK_udiaeresis, - spawn, - {.v = (const char *[]){"mpc", "seek", "-10", NULL}}}, - {MODKEY | ShiftMask, - XK_udiaeresis, - spawn, - {.v = (const char *[]){"mpc", "seek", "-60", NULL}}}, - {MODKEY, - XK_plus, - spawn, - {.v = (const char *[]){"mpc", "seek", "+10", NULL}}}, - {MODKEY | ShiftMask, - XK_plus, - spawn, - {.v = (const char *[]){"mpc", "seek", "+60", NULL}}}, - {MODKEY, - XK_numbersign, - spawn, - {.v = (const char *[]){TERMINAL, "-e", "bc", "-l", NULL}}}, - /* { MODKEY|ShiftMask, XK_backslash, spawn, SHCMD("") - * }, - */ - - {MODKEY, XK_a, togglegaps, {0}}, - {MODKEY | ShiftMask, XK_a, defaultgaps, {0}}, - {MODKEY, XK_s, togglesticky, {0}}, - /* { MODKEY|ShiftMask, XK_s, spawn, - * SHCMD("") - * }, - */ - {MODKEY, XK_d, spawn, {.v = (const char *[]){"dmenu_run", NULL}}}, - {MODKEY | ShiftMask, - XK_d, - spawn, - {.v = (const char *[]){"passmenu", NULL}}}, - {MODKEY, XK_f, togglefullscr, {0}}, - {MODKEY | ShiftMask, XK_f, setlayout, {.v = &layouts[8]}}, - {MODKEY, XK_g, shiftview, {.i = -1}}, - {MODKEY | ShiftMask, XK_g, shifttag, {.i = -1}}, - {MODKEY, XK_h, setmfact, {.f = -0.05}}, - /* J and K are automatically bound above in STACKEYS */ - {MODKEY, XK_l, setmfact, {.f = +0.05}}, - {MODKEY, XK_odiaeresis, shiftview, {.i = 1}}, - {MODKEY | ShiftMask, XK_odiaeresis, shifttag, {.i = 1}}, - {MODKEY, XK_adiaeresis, togglescratch, {.ui = 1}}, - /* { MODKEY|ShiftMask, XK_adiaeresis, spawn, SHCMD("") - * }, - */ - {MODKEY | ShiftMask, XK_adiaeresis, togglesmartgaps, {0}}, - {MODKEY, XK_Return, spawn, {.v = termcmd}}, - {MODKEY | ShiftMask, XK_Return, togglescratch, {.ui = 0}}, - - {MODKEY, XK_y, incrgaps, {.i = +3}}, - /* { MODKEY|ShiftMask, XK_y, spawn, - * SHCMD("") - * }, - */ - {MODKEY, XK_x, incrgaps, {.i = -3}}, - /* { MODKEY|ShiftMask, XK_x, spawn, - * SHCMD("") - * }, - */ - /* { MODKEY, XK_c, spawn, - * SHCMD("") - * }, - */ - /* { MODKEY|ShiftMask, XK_c, spawn, - * SHCMD("") - * }, - */ - /* V is automatically bound above in STACKKEYS */ - {MODKEY, XK_b, togglebar, {0}}, - /* { MODKEY|ShiftMask, XK_b, spawn, - * SHCMD("") - * }, - */ - {MODKEY, - XK_n, - spawn, - {.v = (const char *[]){TERMINAL, "-e", "nvim", "-c", "VimwikiIndex", - NULL}}}, - {MODKEY | ShiftMask, XK_n, spawn, - SHCMD(TERMINAL " -e newsboat; pkill -RTMIN+6 dwmblocks")}, // TODO: replace - {MODKEY, - XK_m, - spawn, - {.v = (const char *[]){TERMINAL, "-e", "ncmpcpp", NULL}}}, - {MODKEY | ShiftMask, XK_m, spawn, - SHCMD("pamixer -t; kill -44 $(pidof dwmblocks)")}, - {MODKEY, XK_comma, spawn, {.v = (const char *[]){"mpc", "prev", NULL}}}, - {MODKEY | ShiftMask, - XK_comma, - spawn, - {.v = (const char *[]){"mpc", "seek", "0%", NULL}}}, - {MODKEY, XK_period, spawn, {.v = (const char *[]){"mpc", "next", NULL}}}, - {MODKEY | ShiftMask, - XK_period, - spawn, - {.v = (const char *[]){"mpc", "repeat", NULL}}}, - - {MODKEY, XK_Left, focusmon, {.i = -1}}, - {MODKEY | ShiftMask, XK_Left, tagmon, {.i = -1}}, - {MODKEY, XK_Right, focusmon, {.i = +1}}, - {MODKEY | ShiftMask, XK_Right, tagmon, {.i = +1}}, - - {MODKEY, XK_Page_Up, shiftview, {.i = -1}}, - {MODKEY | ShiftMask, XK_Page_Up, shifttag, {.i = -1}}, - {MODKEY, XK_Page_Down, shiftview, {.i = +1}}, - {MODKEY | ShiftMask, XK_Page_Down, shifttag, {.i = +1}}, - {MODKEY, XK_Insert, spawn, - SHCMD("xdotool type $(grep -v '^#' ~/.local/share/snippets | dmenu -i -l " - "50 | cut -d' ' -f1)")}, - - {MODKEY, XK_F1, spawn, - SHCMD("groff -mom /usr/local/share/dwm/keybinds.mom -Tpdf | zathura -")}, - {MODKEY, XK_F2, spawn, SHCMD("$TERMINAL -e deluge-gtk")}, - {MODKEY, XK_F3, spawn, SHCMD("librewolf")}, // TODO: replace - {MODKEY, XK_F4, spawn, - SHCMD(TERMINAL " -e pulsemixer; kill -44 $(pidof dwmblocks)")}, - {MODKEY, XK_F5, spawn, SHCMD("")}, - {MODKEY, XK_F6, spawn, SHCMD("")}, - {MODKEY, XK_F7, spawn, SHCMD("")}, - {MODKEY, XK_F8, spawn, SHCMD("")}, - {MODKEY, XK_F9, spawn, SHCMD("")}, - {MODKEY, XK_F10, spawn, {.v = (const char *[]){"dmenumount", NULL}}}, - {MODKEY, XK_F11, spawn, {.v = (const char *[]){"dmenuumount", NULL}}}, - {MODKEY, XK_F12, spawn, - SHCMD("remaps & notify-send \"⌨️ Keyboard remapping...\" \"Re-running " - "keyboard defaults for any newly plugged-in keyboards.\"")}, - {MODKEY, XK_space, zoom, {0}}, - {MODKEY | ShiftMask, XK_space, togglefloating, {0}}, - - {0, XK_Print, spawn, SHCMD("maim pic-full-$(date '+%y%m%d-%H%M-%S').png")}, - {ShiftMask, XK_Print, spawn, {.v = (const char *[]){"maimpick", NULL}}}, - {MODKEY, XK_Print, spawn, {.v = (const char *[]){"dmenurecord", NULL}}}, - {MODKEY | ShiftMask, - XK_Print, - spawn, - {.v = (const char *[]){"dmenurecord", "kill", NULL}}}, - {MODKEY, - XK_Delete, - spawn, - {.v = (const char *[]){"dmenurecord", "kill", NULL}}}, - {MODKEY, XK_Scroll_Lock, spawn, SHCMD("killall screenkey || screenkey &")}, - - {0, XF86XK_AudioMute, spawn, - SHCMD("pamixer -t; kill -44 $(pidof dwmblocks)")}, - {0, XF86XK_AudioRaiseVolume, spawn, - SHCMD("pamixer --allow-boost -i 3; kill -44 $(pidof dwmblocks)")}, - {0, XF86XK_AudioLowerVolume, spawn, - SHCMD("pamixer --allow-boost -d 3; kill -44 $(pidof dwmblocks)")}, - {0, XF86XK_AudioPrev, spawn, {.v = (const char *[]){"mpc", "prev", NULL}}}, - {0, XF86XK_AudioNext, spawn, {.v = (const char *[]){"mpc", "next", NULL}}}, - {0, - XF86XK_AudioPause, - spawn, - {.v = (const char *[]){"mpc", "pause", NULL}}}, - {0, XF86XK_AudioPlay, spawn, {.v = (const char *[]){"mpc", "play", NULL}}}, - {0, XF86XK_AudioStop, spawn, {.v = (const char *[]){"mpc", "stop", NULL}}}, - {0, - XF86XK_AudioRewind, - spawn, - {.v = (const char *[]){"mpc", "seek", "-10", NULL}}}, - {0, - XF86XK_AudioForward, - spawn, - {.v = (const char *[]){"mpc", "seek", "+10", NULL}}}, - {0, - XF86XK_AudioMedia, - spawn, - {.v = (const char *[]){TERMINAL, "-e", "ncmpcpp", NULL}}}, - {0, XF86XK_AudioMicMute, spawn, - SHCMD("pactl set-source-mute @DEFAULT_SOURCE@ toggle")}, - {0, XF86XK_PowerOff, spawn, {.v = (const char *[]){"sysact", NULL}}}, - {0, - XF86XK_Calculator, - spawn, - {.v = (const char *[]){TERMINAL, "-e", "bc", "-l", NULL}}}, - {0, - XF86XK_Sleep, - spawn, - {.v = (const char *[]){"sudo", "-A", "zzz", NULL}}}, - {0, XF86XK_WWW, spawn, {.v = (const char *[]){BROWSER, NULL}}}, - {0, XF86XK_DOS, spawn, {.v = termcmd}}, - {0, XF86XK_ScreenSaver, spawn, - SHCMD("slock & xset dpms force off; mpc pause; pauseallmpv")}, - {0, - XF86XK_TaskPane, - spawn, - {.v = (const char *[]){TERMINAL, "-e", "htop", NULL}}}, - {0, XF86XK_Mail, spawn, - SHCMD(TERMINAL " -e neomutt ; pkill -RTMIN+12 dwmblocks")}, - {0, - XF86XK_MyComputer, - spawn, - {.v = (const char *[]){TERMINAL, "-e", "lfub", "/", NULL}}}, - /* { 0, XF86XK_Battery, spawn, - * SHCMD("") - * }, - */ - {0, - XF86XK_Launch1, - spawn, - {.v = (const char *[]){"xset", "dpms", "force", "off", NULL}}}, - {0, XF86XK_TouchpadToggle, spawn, - SHCMD("(synclient | grep 'TouchpadOff.*1' && synclient TouchpadOff=0) || " - "synclient TouchpadOff=1")}, - {0, - XF86XK_TouchpadOff, - spawn, - {.v = (const char *[]){"synclient", "TouchpadOff=1", NULL}}}, - {0, - XF86XK_TouchpadOn, - spawn, - {.v = (const char *[]){"synclient", "TouchpadOff=0", NULL}}}, - {0, - XF86XK_MonBrightnessUp, - spawn, - {.v = (const char *[]){"xbacklight", "-inc", "15", NULL}}}, - {0, - XF86XK_MonBrightnessDown, - spawn, - {.v = (const char *[]){"xbacklight", "-dec", "15", NULL}}}, - - /* { MODKEY|Mod4Mask, XK_h, incrgaps, {.i = +1 } }, - */ - /* { MODKEY|Mod4Mask, XK_l, incrgaps, {.i = -1 } }, - */ - /* { MODKEY|Mod4Mask|ShiftMask, XK_h, incrogaps, {.i = +1 } }, - */ - /* { MODKEY|Mod4Mask|ShiftMask, XK_l, incrogaps, {.i = -1 } }, - */ - /* { MODKEY|Mod4Mask|ControlMask, XK_h, incrigaps, {.i = +1 } }, - */ - /* { MODKEY|Mod4Mask|ControlMask, XK_l, incrigaps, {.i = -1 } }, - */ - /* { MODKEY|Mod4Mask|ShiftMask, XK_0, defaultgaps, {0} }, */ - /* { MODKEY, XK_y, incrihgaps, {.i = +1 } }, - */ - /* { MODKEY, XK_o, incrihgaps, {.i = -1 } }, - */ - /* { MODKEY|ControlMask, XK_y, incrivgaps, {.i = +1 } }, - */ - /* { MODKEY|ControlMask, XK_o, incrivgaps, {.i = -1 } }, - */ - /* { MODKEY|Mod4Mask, XK_y, incrohgaps, {.i = +1 } }, - */ - /* { MODKEY|Mod4Mask, XK_o, incrohgaps, {.i = -1 } }, - */ - /* { MODKEY|ShiftMask, XK_y, incrovgaps, {.i = +1 } }, - */ - /* { MODKEY|ShiftMask, XK_o, incrovgaps, {.i = -1 } }, - */ - -}; - -/* button definitions */ -/* click can be ClkTagBar, ClkLtSymbol, ClkStatusText, ClkWinTitle, - * ClkClientWin, or ClkRootWin */ -static Button buttons[] = { -/* click event mask button function argument - */ -#ifndef __OpenBSD__ - {ClkWinTitle, 0, Button2, zoom, {0}}, - {ClkStatusText, 0, Button1, sigdwmblocks, {.i = 1}}, - {ClkStatusText, 0, Button2, sigdwmblocks, {.i = 2}}, - {ClkStatusText, 0, Button3, sigdwmblocks, {.i = 3}}, - {ClkStatusText, 0, Button4, sigdwmblocks, {.i = 4}}, - {ClkStatusText, 0, Button5, sigdwmblocks, {.i = 5}}, - {ClkStatusText, ShiftMask, Button1, sigdwmblocks, {.i = 6}}, -#endif - {ClkStatusText, ShiftMask, Button3, spawn, - SHCMD(TERMINAL " -e nvim ~/.local/src/dwmblocks/config.h")}, - {ClkClientWin, MODKEY, Button1, movemouse, {0}}, - {ClkClientWin, MODKEY, Button2, defaultgaps, {0}}, - {ClkClientWin, MODKEY, Button3, resizemouse, {0}}, - {ClkClientWin, MODKEY, Button4, incrgaps, {.i = +1}}, - {ClkClientWin, MODKEY, Button5, incrgaps, {.i = -1}}, - {ClkTagBar, 0, Button1, view, {0}}, - {ClkTagBar, 0, Button3, toggleview, {0}}, - {ClkTagBar, MODKEY, Button1, tag, {0}}, - {ClkTagBar, MODKEY, Button3, toggletag, {0}}, - {ClkTagBar, 0, Button4, shiftview, {.i = -1}}, - {ClkTagBar, 0, Button5, shiftview, {.i = 1}}, - {ClkRootWin, 0, Button2, togglebar, {0}}, -}; diff --git a/.local/src2/dwm/config.mk b/.local/src2/dwm/config.mk deleted file mode 100644 index b77641d6..00000000 --- a/.local/src2/dwm/config.mk +++ /dev/null @@ -1,38 +0,0 @@ -# dwm version -VERSION = 6.2 - -# 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 - -# freetype -FREETYPELIBS = -lfontconfig -lXft -FREETYPEINC = /usr/include/freetype2 -# OpenBSD (uncomment) -#FREETYPEINC = ${X11INC}/freetype2 - -# includes and libs -INCS = -I${X11INC} -I${FREETYPEINC} -LIBS = -L${X11LIB} -lX11 ${XINERAMALIBS} ${FREETYPELIBS} -lX11-xcb -lxcb -lxcb-res - -# flags -CPPFLAGS = -D_DEFAULT_SOURCE -D_BSD_SOURCE -D_POSIX_C_SOURCE=200809L -DVERSION=\"${VERSION}\" ${XINERAMAFLAGS} -#CFLAGS = -g -std=c99 -pedantic -Wall -O0 ${INCS} ${CPPFLAGS} -CFLAGS = -std=c99 -pedantic -Wall -Wno-deprecated-declarations -Os ${INCS} ${CPPFLAGS} -LDFLAGS = ${LIBS} - -# Solaris -#CFLAGS = -fast ${INCS} -DVERSION=\"${VERSION}\" -#LDFLAGS = ${LIBS} - -# compiler and linker -CC = cc diff --git a/.local/src2/dwm/drw.c b/.local/src2/dwm/drw.c deleted file mode 100644 index 56175a83..00000000 --- a/.local/src2/dwm/drw.c +++ /dev/null @@ -1,424 +0,0 @@ -/* 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 "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) -{ - Drw *drw = ecalloc(1, sizeof(Drw)); - - drw->dpy = dpy; - drw->screen = screen; - drw->root = root; - drw->w = w; - drw->h = h; - drw->drawable = XCreatePixmap(dpy, root, w, h, DefaultDepth(dpy, screen)); - drw->gc = XCreateGC(dpy, root, 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->drawable) - XFreePixmap(drw->dpy, drw->drawable); - drw->drawable = XCreatePixmap(drw->dpy, drw->root, w, h, DefaultDepth(drw->dpy, drw->screen)); -} - -void -drw_free(Drw *drw) -{ - XFreePixmap(drw->dpy, drw->drawable); - XFreeGC(drw->dpy, drw->gc); - 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, 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) -{ - if (!drw || !dest || !clrname) - return; - - if (!XftColorAllocName(drw->dpy, DefaultVisual(drw->dpy, drw->screen), - DefaultColormap(drw->dpy, drw->screen), - clrname, dest)) - die("error, cannot allocate color '%s'", clrname); - - dest->pixel |= 0xff << 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[], size_t clrcount) -{ - size_t i; - Clr *ret; - - /* need at least two colors for a scheme */ - if (!drw || !clrnames || clrcount < 2 || !(ret = ecalloc(clrcount, sizeof(XftColor)))) - return NULL; - - for (i = 0; i < clrcount; i++) - drw_clr_create(drw, &ret[i], clrnames[i]); - return ret; -} - -void -drw_setfontset(Drw *drw, Fnt *set) -{ - if (drw) - drw->fonts = set; -} - -void -drw_setscheme(Drw *drw, Clr *scm) -{ - if (drw) - drw->scheme = scm; -} - -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) -{ - char buf[1024]; - int ty; - unsigned int ew; - XftDraw *d = NULL; - Fnt *usedfont, *curfont, *nextfont; - size_t i, len; - 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; - - if (!drw || (render && !drw->scheme) || !text || !drw->fonts) - return 0; - - if (!render) { - w = ~w; - } 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, - DefaultVisual(drw->dpy, drw->screen), - DefaultColormap(drw->dpy, drw->screen)); - x += lpad; - w -= lpad; - } - - usedfont = drw->fonts; - while (1) { - 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) { - if (curfont == usedfont) { - utf8strlen += utf8charlen; - text += utf8charlen; - } else { - nextfont = curfont; - } - break; - } - } - - if (!charexists || nextfont) - break; - else - charexists = 0; - } - - if (utf8strlen) { - drw_font_getexts(usedfont, utf8str, utf8strlen, &ew, NULL); - /* shorten text if necessary */ - for (len = MIN(utf8strlen, sizeof(buf) - 1); len && ew > w; len--) - drw_font_getexts(usedfont, utf8str, len, &ew, NULL); - - if (len) { - memcpy(buf, utf8str, len); - buf[len] = '\0'; - if (len < utf8strlen) - for (i = len; i && i > len - 3; buf[--i] = '.') - ; /* NOP */ - - if (render) { - ty = y + (h - usedfont->h) / 2 + usedfont->xfont->ascent; - XftDrawStringUtf8(d, &drw->scheme[invert ? ColBg : ColFg], - usedfont->xfont, x, ty, (XftChar8 *)buf, len); - } - x += ew; - w -= ew; - } - } - - if (!*text) { - 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; - - 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); - FcPatternAddBool(fcpattern, FC_COLOR, FcFalse); - - 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); - usedfont = drw->fonts; - } - } - } - } - if (d) - XftDrawDestroy(d); - - return x + (render ? w : 0); -} - -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); -} - -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/.local/src2/dwm/drw.h b/.local/src2/dwm/drw.h deleted file mode 100644 index 09617cf9..00000000 --- a/.local/src2/dwm/drw.h +++ /dev/null @@ -1,57 +0,0 @@ -/* 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; - Drawable drawable; - GC gc; - Clr *scheme; - Fnt *fonts; -} Drw; - -/* Drawable abstraction */ -Drw *drw_create(Display *dpy, int screen, Window win, unsigned int w, unsigned int h); -void drw_resize(Drw *drw, unsigned int w, unsigned int h); -void drw_free(Drw *drw); - -/* Fnt abstraction */ -Fnt *drw_fontset_create(Drw* drw, char *fonts[], size_t fontcount); -void drw_fontset_free(Fnt* set); -unsigned int drw_fontset_getwidth(Drw *drw, const char *text); -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); -Clr *drw_scm_create(Drw *drw, char *clrnames[], 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); - -/* 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); - -/* Map functions */ -void drw_map(Drw *drw, Window win, int x, int y, unsigned int w, unsigned int h); diff --git a/.local/src2/dwm/drw.o b/.local/src2/dwm/drw.o deleted file mode 100644 index 209fff1a..00000000 Binary files a/.local/src2/dwm/drw.o and /dev/null differ diff --git a/.local/src2/dwm/dwm b/.local/src2/dwm/dwm deleted file mode 100755 index d81b7bc5..00000000 Binary files a/.local/src2/dwm/dwm and /dev/null differ diff --git a/.local/src2/dwm/dwm.1 b/.local/src2/dwm/dwm.1 deleted file mode 100644 index 94dbd945..00000000 --- a/.local/src2/dwm/dwm.1 +++ /dev/null @@ -1,214 +0,0 @@ -.TH DWM 1 dwm\-VERSION -.SH NAME -dwm \- dynamic window manager (Luke Smith <https://lukesmith.xyz>'s build) -.SH SYNOPSIS -.B dwm -.RB [ \-v ] -.SH DESCRIPTION -dwm is a dynamic window manager for X. -.P -dwm "orders" windows based on recency and primacy, while dwm layouts may -change, the most recent "master" window is shown in the most prominent -position. There are bindings for cycling through and promoting windows to the -master position. -.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 -dwm draws a small border around windows to indicate the focus state. -.P -.I -libxft-bgra -should be installed for this build of dwm. Arch users may install it via the -AUR. Color characters and emoji are enabled, but these will cause crashes -without the fix -.I -libxft-bgra -offers. -.SH OPTIONS -.TP -.B \-v -prints version information to standard output, 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 Left click -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 Right click -click on a tag label adds/removes all windows with that tag to/from the view. -.TP -.B Super\-Left click -click on a tag label applies that tag to the focused window. -.TP -.B Super\-Right click -click on a tag label adds/removes that tag to/from the focused window. -.SS Keyboard commands -.TP -.B Super\-Return -Start terminal, -.BR st(1). -.TP -.B Super\-d -Spawn -.BR dmenu(1) -for launching other programs. -.TP -.B Super\-b -Toggles bar on and off. -.TP -.B Super\-q -Close focused window. -.TP -.B Super\-t/T -Sets tiled/bstack layouts. -.TP -.B Super\-f -Toggle fullscreen window. -.TP -.B Super\-F -Toggle floating layout. -.TP -.B Super\-y/Y -Sets Fibonacci spiral/dwinde layouts. -.TP -.B Super\-u/U -Sets centered master layout. -.TP -.B Super\-i/I -Sets centered master or floating master layouts. -.TP -.B Super\-space -Zooms/cycles focused window to/from master area. -.TP -.B Super\-j/k -Focus next/previous window. -.TP -.B Super\-Shift\-j/k -Move selected window down/up in stack. -.TP -.B Super\-o/O -Increase/decrease number of windows in master area. -.TP -.B Super\-l -Increase master area size. -.TP -.B Super\-h -Decrease master area size. -.TP -.B Super\-Shift\-space -Toggle focused window between tiled and floating state. -.TP -.B Super\-Tab -Toggles to the previously selected tags. -.TP -.B Super\-g -Moves to the previous tag. -.TP -.B Super\-Shift\-g -Moves selected window to the previous tag. -.TP -.B Super\-; -Moves to the next tag. -.TP -.B Super\-Shift\-; -Moves selected window to the next tag. -.TP -.B Super\-PageUp -Moves to the previous tag. -.TP -.B Super\-Shift\-PageUp -Moves selected window to the previous tag. -.TP -.B Super\-Pagedown -Moves to the next tag. -.TP -.B Super\-Shift\-PageDown -Moves selected window to the next tag. -.TP -.B Super\-a -Toggle gaps. -.TP -.B Super\-z -Increase gaps between windows. -.TP -.B Super\-x -Decrease gaps between windows. -.TP -.B Super\-Shift\-[1..n] -Apply nth tag to focused window. -.TP -.B Super\-Shift\-0 -Apply all tags to focused window. -.TP -.B Super\-Control\-Shift\-[1..n] -Add/remove nth tag to/from focused window. -.TP -.B Super\-[1..n] -View all windows with nth tag. -.TP -.B Super\-0 -View all windows with any tag. -.TP -.B Super\-Control\-[1..n] -Add/remove all windows with nth tag to/from the view. -.TP -.B Super\-Shift\-q -Quit dwm. -.TP -.B Mod1\-Control\-Shift\-q -Menu to refresh/quit/reboot/shutdown. -.SS Mouse commands -.TP -.B Super\-Left click -Move focused window while dragging. Tiled windows will be toggled to the floating state. -.TP -.B Super\-Middle click -Toggles focused window between floating and tiled state. -.TP -.B Super\-Right click -Resize focused window while dragging. Tiled windows will be toggled to the floating state. -.SH CUSTOMIZATION -dwm 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 dwm process. -.TP -.B SIGTERM - 15 -Cleanly terminate the dwm 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/.local/src2/dwm/dwm.c b/.local/src2/dwm/dwm.c deleted file mode 100644 index 4f3faff3..00000000 --- a/.local/src2/dwm/dwm.c +++ /dev/null @@ -1,2690 +0,0 @@ -/* See LICENSE file for copyright and license details. - * - * dynamic window manager is designed like any other X client as well. 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 <errno.h> -#include <locale.h> -#include <signal.h> -#include <stdarg.h> -#include <stdio.h> -#include <stdlib.h> -#include <string.h> -#include <unistd.h> -#include <sys/types.h> -#include <sys/wait.h> -#include <X11/cursorfont.h> -#include <X11/keysym.h> -#include <X11/Xatom.h> -#include <X11/Xlib.h> -#include <X11/Xproto.h> -#include <X11/Xresource.h> -#include <X11/Xutil.h> -#include <X11/Xresource.h> -#ifdef XINERAMA -#include <X11/extensions/Xinerama.h> -#endif /* XINERAMA */ -#include <X11/Xft/Xft.h> -#include <X11/Xlib-xcb.h> -#include <xcb/res.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 GETINC(X) ((X) - 2000) -#define INC(X) ((X) + 2000) -#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 ISINC(X) ((X) > 1000 && (X) < 3000) -#define ISVISIBLE(C) ((C->tags & C->mon->tagset[C->mon->seltags]) || C->issticky) -#define PREVSEL 3000 -#define LENGTH(X) (sizeof X / sizeof X[0]) -#define MOUSEMASK (BUTTONMASK|PointerMotionMask) -#define MOD(N,M) ((N)%(M) < 0 ? (N)%(M) + (M) : (N)%(M)) -#define WIDTH(X) ((X)->w + 2 * (X)->bw) -#define HEIGHT(X) ((X)->h + 2 * (X)->bw) -#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 TRUNC(X,A,B) (MAX((A), MIN((X), (B)))) - -/* enums */ -enum { CurNormal, CurResize, CurMove, CurLast }; /* cursor */ -enum { SchemeNorm, SchemeSel }; /* color schemes */ -enum { NetSupported, NetWMName, NetWMState, NetWMCheck, - NetWMFullscreen, NetActiveWindow, NetWMWindowType, - NetWMWindowTypeDialog, NetClientList, NetLast }; /* EWMH atoms */ -enum { WMProtocols, WMDelete, WMState, WMTakeFocus, WMLast }; /* default atoms */ -enum { ClkTagBar, ClkLtSymbol, ClkStatusText, ClkWinTitle, - ClkClientWin, ClkRootWin, ClkLast }; /* clicks */ - -typedef union { - int i; - unsigned int ui; - float f; - const void *v; -} Arg; - -typedef struct { - unsigned int click; - unsigned int mask; - unsigned int button; - void (*func)(const Arg *arg); - const Arg arg; -} Button; - -typedef struct Monitor Monitor; -typedef struct Client Client; -struct Client { - char name[256]; - float mina, maxa; - int x, y, w, h; - int oldx, oldy, oldw, oldh; - int basew, baseh, incw, inch, maxw, maxh, minw, minh; - int bw, oldbw; - unsigned int tags; - int isfixed, isfloating, isurgent, neverfocus, oldstate, isfullscreen, isterminal, noswallow, issticky; - pid_t pid; - Client *next; - Client *snext; - Client *swallowing; - 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 */ - int gappih; /* horizontal gap between windows */ - int gappiv; /* vertical gap between windows */ - int gappoh; /* horizontal outer gaps */ - int gappov; /* vertical outer gaps */ - 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 isterminal; - int noswallow; - int monitor; -} Rule; - -/* Xresources preferences */ -enum resource_type { - STRING = 0, - INTEGER = 1, - FLOAT = 2 -}; - -typedef struct { - char *name; - enum resource_type type; - void *dst; -} ResourcePref; - -/* 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 void copyvalidchars(char *text, char *rawtext); -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 int getrootptr(int *x, int *y); -static long getstate(Window w); -static int gettextprop(Window w, Atom atom, char *text, unsigned int size); -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 *); -static void propertynotify(XEvent *e); -static void pushstack(const Arg *arg); -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 restack(Monitor *m); -static void run(void); -static void runAutostart(void); -static void scan(void); -static int sendevent(Client *c, Atom proto); -static void sendmon(Client *c, Monitor *m); -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 sigchld(int unused); -#ifndef __OpenBSD__ -static int getdwmblockspid(); -static void sigdwmblocks(const Arg *arg); -#endif -static void sighup(int unused); -static void sigterm(int unused); -static void spawn(const Arg *arg); -static int stackpos(const Arg *arg); -static void tag(const Arg *arg); -static void tagmon(const Arg *arg); -static void togglebar(const Arg *arg); -static void togglefloating(const Arg *arg); -static void togglescratch(const Arg *arg); -static void togglesticky(const Arg *arg); -static void togglefullscr(const Arg *arg); -static void toggletag(const Arg *arg); -static void toggleview(const Arg *arg); -static void unfocus(Client *c, int setfocus); -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 updatetitle(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 int xerror(Display *dpy, XErrorEvent *ee); -static int xerrordummy(Display *dpy, XErrorEvent *ee); -static int xerrorstart(Display *dpy, XErrorEvent *ee); -static void xrdb(const Arg *arg); -static void zoom(const Arg *arg); -static void load_xresources(void); -static void resource_load(XrmDatabase db, char *name, enum resource_type rtype, void *dst); - -static pid_t getparentprocess(pid_t p); -static int isdescprocess(pid_t p, pid_t c); -static Client *swallowingclient(Window w); -static Client *termforwin(const Client *c); -static pid_t winpid(Window w); - - -/* variables */ -static const char broken[] = "broken"; -static char stext[256]; -static char rawstext[256]; -static int dwmblockssig; -pid_t dwmblockspid = 0; -static int screen; -static int sw, sh; /* X display screen geometry width, height */ -static int bh, blw = 0; /* bar geometry */ -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, - [UnmapNotify] = unmapnotify -}; -static Atom wmatom[WMLast], netatom[NetLast]; -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 xcb_connection_t *xcon; - -/* 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->isterminal = r->isterminal; - c->isfloating = r->isfloating; - c->noswallow = r->noswallow; - 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) { - /* 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 -swallow(Client *p, Client *c) -{ - if (c->noswallow || c->isterminal) - return; - if (!swallowfloating && c->isfloating) - return; - - detach(c); - detachstack(c); - - setclientstate(c, WithdrawnState); - XUnmapWindow(dpy, p->win); - - p->swallowing = c; - c->mon = p->mon; - - Window w = p->win; - p->win = c->win; - c->win = w; - updatetitle(p); - - XWindowChanges wc; - wc.border_width = p->bw; - XConfigureWindow(dpy, p->win, CWBorderWidth, &wc); - XMoveResizeWindow(dpy, p->win, p->x, p->y, p->w, p->h); - XSetWindowBorder(dpy, p->win, scheme[SchemeNorm][ColBorder].pixel); - - arrange(p->mon); - configure(p); - updateclientlist(); -} - -void -unswallow(Client *c) -{ - c->win = c->swallowing->win; - - free(c->swallowing); - c->swallowing = NULL; - - /* unfullscreen the client */ - setfullscreen(c, 0); - updatetitle(c); - arrange(c->mon); - XMapWindow(dpy, c->win); - - XWindowChanges wc; - wc.border_width = c->bw; - XConfigureWindow(dpy, c->win, CWBorderWidth, &wc); - XMoveResizeWindow(dpy, c->win, c->x, c->y, c->w, c->h); - XSetWindowBorder(dpy, c->win, scheme[SchemeNorm][ColBorder].pixel); - - setclientstate(c, NormalState); - focus(NULL); - arrange(c->mon); -} - -void -buttonpress(XEvent *e) -{ - unsigned int i, x, click, occ = 0; - 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; - for (c = m->clients; c; c = c->next) - occ |= c->tags == 255 ? 0 : c->tags; - do { - /* do not reserve space for vacant tags */ - if (!(occ & 1 << i || m->tagset[m->seltags] & 1 << i)) - continue; - 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 + blw) - click = ClkLtSymbol; - else if (ev->x > (x = selmon->ww - TEXTW(stext) + lrpad)) { - click = ClkStatusText; - - char *text = rawstext; - int i = -1; - char ch; - dwmblockssig = 0; - while (text[++i]) { - if ((unsigned char)text[i] < ' ') { - ch = text[i]; - text[i] = '\0'; - x += TEXTW(text) - lrpad; - text[i] = ch; - text += i+1; - i = -1; - if (x >= ev->x) break; - dwmblockssig = ch; - } - } - } 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); - for (i = 0; i < CurLast; i++) - drw_cur_free(drw, cursor[i]); - for (i = 0; i < LENGTH(colors); i++) - free(scheme[i]); - 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) -{ - XClientMessageEvent *cme = &e->xclient; - Client *c = wintoclient(cme->window); - - 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); -} - -void -copyvalidchars(char *text, char *rawtext) -{ - int i = -1, j = 0; - - while(rawtext[++i]) { - if ((unsigned char)rawtext[i] >= ' ') { - text[j++] = rawtext[i]; - } - } - text[j] = '\0'; -} - -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->gappih = gappih; - m->gappiv = gappiv; - m->gappoh = gappoh; - m->gappov = gappov; - 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 ((c = swallowingclient(ev->window))) - unmanage(c->swallowing, 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; - int boxs = drw->fonts->h / 9; - int boxw = drw->fonts->h / 6 + 2; - unsigned int i, occ = 0, urg = 0; - Client *c; - - /* 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, 0, tw, bh, 0, stext, 0); - } - - for (c = m->clients; c; c = c->next) { - occ |= c->tags == 255 ? 0 : c->tags; - if (c->isurgent) - urg |= c->tags; - } - x = 0; - for (i = 0; i < LENGTH(tags); i++) { - /* do not draw vacant tags */ - if (!(occ & 1 << i || m->tagset[m->seltags] & 1 << i)) - continue; - - 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); - x += w; - } - w = blw = 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 - x) > bh) { - if (m->sel) { - drw_setscheme(drw, scheme[m == selmon ? SchemeSel : SchemeNorm]); - drw_text(drw, x, 0, w, bh, lrpad / 2, m->sel->name, 0); - 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); -} - -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); -} - -void -focus(Client *c) -{ - if (!c || !ISVISIBLE(c)) { - for (c = selmon->stack; c && (!ISVISIBLE(c) || (c->issticky && !selmon->sel->issticky)); c = c->snext); - - if (!c) /* No windows found; check for available stickies */ - 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); -} - -void -focusstack(const Arg *arg) -{ - int i = stackpos(arg); - Client *c, *p; - - if (i < 0 || !selmon->sel || selmon->sel->isfullscreen) - return; - - for(p = NULL, c = selmon->clients; c && (i || !ISVISIBLE(c)); - i -= ISVISIBLE(c) ? 1 : 0, p = c, c = c->next); - focus(c ? c : p); - restack(selmon); -} - -Atom -getatomprop(Client *c, Atom prop) -{ - int di; - unsigned long dl; - unsigned char *p = NULL; - Atom da, atom = None; - - if (XGetWindowProperty(dpy, c->win, prop, 0L, sizeof atom, False, XA_ATOM, - &da, &di, &dl, &dl, &p) == Success && p) { - atom = *(Atom *)p; - XFree(p); - } - return atom; -} - -#ifndef __OpenBSD__ -int -getdwmblockspid() -{ - char buf[16]; - FILE *fp = popen("pidof -s dwmblocks", "r"); - fgets(buf, sizeof(buf), fp); - pid_t pid = strtoul(buf, NULL, 10); - pclose(fp); - dwmblockspid = pid; - return pid != 0 ? 0 : -1; -} -#endif - -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; -} - -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; - unsigned int modifiers[] = { 0, LockMask, numlockmask, numlockmask|LockMask }; - KeyCode code; - - XUngrabKey(dpy, AnyKey, AnyModifier, root); - for (i = 0; i < LENGTH(keys); i++) - if ((code = XKeysymToKeycode(dpy, keys[i].keysym))) - for (j = 0; j < LENGTH(modifiers); j++) - XGrabKey(dpy, code, keys[i].mod | modifiers[j], root, - True, GrabModeAsync, GrabModeAsync); - } -} - -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, wmatom[WMDelete])) { - 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.color0", normbordercolor); - XRDB_LOAD_COLOR("dwm.color0", normbgcolor); - XRDB_LOAD_COLOR("dwm.color4", normfgcolor); - XRDB_LOAD_COLOR("dwm.color8", selbordercolor); - XRDB_LOAD_COLOR("dwm.color4", selbgcolor); - XRDB_LOAD_COLOR("dwm.color0", selfgcolor); - } - } - } - - XCloseDisplay(display); -} - -void -manage(Window w, XWindowAttributes *wa) -{ - Client *c, *t = NULL, *term = NULL; - Window trans = None; - XWindowChanges wc; - - c = ecalloc(1, sizeof(Client)); - c->win = w; - c->pid = winpid(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; - - updatetitle(c); - if (XGetTransientForHint(dpy, w, &trans) && (t = wintoclient(trans))) { - c->mon = t->mon; - c->tags = t->tags; - } else { - c->mon = selmon; - applyrules(c); - term = termforwin(c); - } - - if (c->x + WIDTH(c) > c->mon->mx + c->mon->mw) - c->x = c->mon->mx + c->mon->mw - WIDTH(c); - if (c->y + HEIGHT(c) > c->mon->my + c->mon->mh) - c->y = c->mon->my + c->mon->mh - HEIGHT(c); - c->x = MAX(c->x, c->mon->mx); - /* only fix client y-offset, if the client center might cover the bar */ - c->y = MAX(c->y, ((c->mon->by == c->mon->my) && (c->x + (c->w / 2) >= c->mon->wx) - && (c->x + (c->w / 2) < c->mon->wx + c->mon->ww)) ? bh : c->mon->my); - 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); - c->x = c->mon->mx + (c->mon->mw - WIDTH(c)) / 2; - c->y = c->mon->my + (c->mon->mh - HEIGHT(c)) / 2; - 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(selmon->sel && selmon->sel->isfullscreen && !c->isfloating) - setfullscreen(selmon->sel, 0); - if (c->mon == selmon) - unfocus(selmon->sel, 0); - c->mon->sel = c; - arrange(c->mon); - XMapWindow(dpy, c->win); - if (term) - swallow(term, c); - 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; - - if (!XGetWindowAttributes(dpy, ev->window, &wa)) - return; - if (wa.override_redirect) - return; - if (!wintoclient(ev->window)) - manage(ev->window, &wa); -} - -void -monocle(Monitor *m) -{ - unsigned int n; - int oh, ov, ih, iv; - Client *c; - - getgaps(m, &oh, &ov, &ih, &iv, &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 + ov, m->wy + oh, m->ww - 2 * c->bw - 2 * ov, m->wh - 2 * c->bw - 2 * oh, 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 -pushstack(const Arg *arg) { - int i = stackpos(arg); - Client *sel = selmon->sel, *c, *p; - - if(i < 0 || !sel) - return; - else if(i == 0) { - detach(sel); - attach(sel); - } - else { - for(p = NULL, c = selmon->clients; c; p = c, c = c->next) - if(!(i -= (ISVISIBLE(c) && c != sel))) - break; - c = c ? c : p; - detach(sel); - sel->next = c->next; - c->next = sel; - } - arrange(selmon); -} - -void -propertynotify(XEvent *e) -{ - Client *c; - Window trans; - XPropertyEvent *ev = &e->xproperty; - - 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: - updatesizehints(c); - 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); - } - 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 -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; - - c->oldx = c->x; c->x = wc.x = x; - c->oldy = c->y; c->y = wc.y = y; - c->oldw = c->w; c->w = wc.width = w; - c->oldh = c->h; c->h = wc.height = h; - wc.border_width = c->bw; - 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 -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) { - system("killall -q dwmblocks; dwmblocks &"); -} - -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(Client *c, Atom proto) -{ - int n; - Atom *protocols; - int exists = 0; - XEvent ev; - - if (XGetWMProtocols(dpy, c->win, &protocols, &n)) { - while (!exists && n--) - exists = protocols[n] == proto; - XFree(protocols); - } - if (exists) { - ev.type = ClientMessage; - ev.xclient.window = c->win; - ev.xclient.message_type = wmatom[WMProtocols]; - ev.xclient.format = 32; - ev.xclient.data.l[0] = proto; - ev.xclient.data.l[1] = CurrentTime; - XSendEvent(dpy, c->win, False, NoEventMask, &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, wmatom[WMTakeFocus]); -} - -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); - } -} - -int -stackpos(const Arg *arg) { - int n, i; - Client *c, *l; - - if(!selmon->clients) - return -1; - - if(arg->i == PREVSEL) { - for(l = selmon->stack; l && (!ISVISIBLE(l) || l == selmon->sel); l = l->snext); - if(!l) - return -1; - for(i = 0, c = selmon->clients; c != l; i += ISVISIBLE(c) ? 1 : 0, c = c->next); - return i; - } - else if(ISINC(arg->i)) { - if(!selmon->sel) - return -1; - for(i = 0, c = selmon->clients; c != selmon->sel; i += ISVISIBLE(c) ? 1 : 0, c = c->next); - for(n = i; c; n += ISVISIBLE(c) ? 1 : 0, c = c->next); - return MOD(i + GETINC(arg->i), n); - } - else if(arg->i < 0) { - for(i = 0, c = selmon->clients; c; i += ISVISIBLE(c) ? 1 : 0, c = c->next); - return MAX(i + arg->i, 0); - } - else - return arg->i; -} - -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; - - /* clean up any zombies immediately */ - sigchld(0); - - signal(SIGHUP, sighup); - signal(SIGTERM, sigterm); - - /* init screen */ - screen = DefaultScreen(dpy); - sw = DisplayWidth(dpy, screen); - sh = DisplayHeight(dpy, screen); - root = RootWindow(dpy, screen); - drw = drw_create(dpy, screen, root, sw, sh); - 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[NetWMName] = XInternAtom(dpy, "_NET_WM_NAME", 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[NetWMWindowTypeDialog] = XInternAtom(dpy, "_NET_WM_WINDOW_TYPE_DIALOG", False); - netatom[NetClientList] = XInternAtom(dpy, "_NET_CLIENT_LIST", 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], 3); - /* 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 -sigchld(int unused) -{ - if (signal(SIGCHLD, sigchld) == SIG_ERR) - die("can't install SIGCHLD handler:"); - while (0 < waitpid(-1, NULL, WNOHANG)); -} - -void -sighup(int unused) -{ - Arg a = {.i = 1}; - quit(&a); -} - -void -sigterm(int unused) -{ - Arg a = {.i = 0}; - quit(&a); -} - -#ifndef __OpenBSD__ -void -sigdwmblocks(const Arg *arg) -{ - union sigval sv; - sv.sival_int = 0 | (dwmblockssig << 8) | arg->i; - if (!dwmblockspid) - if (getdwmblockspid() == -1) - return; - - if (sigqueue(dwmblockspid, SIGUSR1, sv) == -1) { - if (errno == ESRCH) { - if (!getdwmblockspid()) - sigqueue(dwmblockspid, SIGUSR1, sv); - } - } -} -#endif - -void -spawn(const Arg *arg) -{ - if (fork() == 0) { - if (dpy) - close(ConnectionNumber(dpy)); - setsid(); - execvp(((char **)arg->v)[0], (char **)arg->v); - fprintf(stderr, "dwm: execvp %s", ((char **)arg->v)[0]); - perror(" failed"); - exit(EXIT_SUCCESS); - } -} - -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 -togglebar(const Arg *arg) -{ - selmon->showbar = !selmon->showbar; - updatebarpos(selmon); - XMoveResizeWindow(dpy, selmon->barwin, selmon->wx, selmon->by, selmon->ww, bh); - 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 -togglefullscr(const Arg *arg) -{ - if(selmon->sel) - setfullscreen(selmon->sel, !selmon->sel->isfullscreen); -} - -void -togglesticky(const Arg *arg) -{ - if (!selmon->sel) - return; - selmon->sel->issticky = !selmon->sel->issticky; - 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 -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; - - if (c->swallowing) { - unswallow(c); - return; - } - - Client *s = swallowingclient(c->win); - if (s) { - free(s->swallowing); - s->swallowing = NULL; - arrange(m); - focus(NULL); - return; - } - - detach(c); - detachstack(c); - if (!destroyed) { - wc.border_width = c->oldbw; - XGrabServer(dpy); /* avoid race conditions */ - XSetErrorHandler(xerrordummy); - 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); - - if (!s) { - arrange(m); - focus(NULL); - updateclientlist(); - } -} - -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); - } -} - -void -updatebars(void) -{ - Monitor *m; - XSetWindowAttributes wa = { - .override_redirect = True, - .background_pixmap = ParentRelative, - .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, DefaultDepth(dpy, screen), - CopyFromParent, DefaultVisual(dpy, screen), - CWOverrideRedirect|CWBackPixmap|CWEventMask, &wa); - XDefineCursor(dpy, m->barwin, cursor[CurNormal]->cursor); - 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; - if (n <= nn) { /* new monitors available */ - for (i = 0; i < (nn - n); 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); - } - } else { /* less monitors available nn < n */ - 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); -} - -void -updatestatus(void) -{ - if (!gettextprop(root, XA_WM_NAME, rawstext, sizeof(rawstext))) - strcpy(stext, "dwm-"VERSION); - else - copyvalidchars(stext, rawstext); - drawbar(selmon); -} - -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 -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); -} - -pid_t -winpid(Window w) -{ - pid_t result = 0; - - xcb_res_client_id_spec_t spec = {0}; - spec.client = w; - spec.mask = XCB_RES_CLIENT_ID_MASK_LOCAL_CLIENT_PID; - - xcb_generic_error_t *e = NULL; - xcb_res_query_client_ids_cookie_t c = xcb_res_query_client_ids(xcon, 1, &spec); - xcb_res_query_client_ids_reply_t *r = xcb_res_query_client_ids_reply(xcon, c, &e); - - if (!r) - return (pid_t)0; - - xcb_res_client_id_value_iterator_t i = xcb_res_query_client_ids_ids_iterator(r); - for (; i.rem; xcb_res_client_id_value_next(&i)) { - spec = i.data->spec; - if (spec.mask & XCB_RES_CLIENT_ID_MASK_LOCAL_CLIENT_PID) { - uint32_t *t = xcb_res_client_id_value_value(i.data); - result = *t; - break; - } - } - - free(r); - - if (result == (pid_t)-1) - result = 0; - return result; -} - -pid_t -getparentprocess(pid_t p) -{ - unsigned int v = 0; - -#if defined(__linux__) - FILE *f; - char buf[256]; - snprintf(buf, sizeof(buf) - 1, "/proc/%u/stat", (unsigned)p); - - if (!(f = fopen(buf, "r"))) - return (pid_t)0; - - if (fscanf(f, "%*u %*s %*c %u", (unsigned *)&v) != 1) - v = (pid_t)0; - fclose(f); -#elif defined(__FreeBSD__) - struct kinfo_proc *proc = kinfo_getproc(p); - if (!proc) - return (pid_t)0; - - v = proc->ki_ppid; - free(proc); -#endif - return (pid_t)v; -} - -int -isdescprocess(pid_t p, pid_t c) -{ - while (p != c && c != 0) - c = getparentprocess(c); - - return (int)c; -} - -Client * -termforwin(const Client *w) -{ - Client *c; - Monitor *m; - - if (!w->pid || w->isterminal) - return NULL; - - for (m = mons; m; m = m->next) { - for (c = m->clients; c; c = c->next) { - if (c->isterminal && !c->swallowing && c->pid && isdescprocess(c->pid, w->pid)) - return c; - } - } - - return NULL; -} - -Client * -swallowingclient(Window w) -{ - Client *c; - Monitor *m; - - for (m = mons; m; m = m->next) { - for (c = m->clients; c; c = c->next) { - if (c->swallowing && c->swallowing->win == w) - return c; - } - } - - return NULL; -} - -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; -} - -/* 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("dwm: another window manager is already running"); - return -1; -} - -void -xrdb(const Arg *arg) -{ - loadxrdb(); - int i; - for (i = 0; i < LENGTH(colors); i++) - scheme[i] = drw_scm_create(drw, colors[i], 3); - focus(NULL); - arrange(NULL); -} - -void -zoom(const Arg *arg) -{ - Client *c = selmon->sel; - - if (!selmon->lt[selmon->sellt]->arrange - || (selmon->sel && selmon->sel->isfloating)) - return; - if (c == nexttiled(selmon->clients)) - if (!c || !(c = nexttiled(c->next))) - return; - pop(c); -} - -void -resource_load(XrmDatabase db, char *name, enum resource_type rtype, void *dst) -{ - char *sdst = NULL; - int *idst = NULL; - float *fdst = NULL; - - sdst = dst; - idst = dst; - fdst = dst; - - char fullname[256]; - char *type; - XrmValue ret; - - snprintf(fullname, sizeof(fullname), "%s.%s", "dwm", name); - fullname[sizeof(fullname) - 1] = '\0'; - - XrmGetResource(db, fullname, "*", &type, &ret); - if (!(ret.addr == NULL || strncmp("String", type, 64))) - { - switch (rtype) { - case STRING: - strcpy(sdst, ret.addr); - break; - case INTEGER: - *idst = strtoul(ret.addr, NULL, 10); - break; - case FLOAT: - *fdst = strtof(ret.addr, NULL); - break; - } - } -} - -void -load_xresources(void) -{ - Display *display; - char *resm; - XrmDatabase db; - ResourcePref *p; - - display = XOpenDisplay(NULL); - resm = XResourceManagerString(display); - if (!resm) - return; - - db = XrmGetStringDatabase(resm); - for (p = resources; p < resources + LENGTH(resources); p++) - resource_load(db, p->name, p->type, p->dst); - XCloseDisplay(display); -} - -int -main(int argc, char *argv[]) -{ - if (argc == 2 && !strcmp("-v", argv[1])) - die("dwm-"VERSION); - else if (argc != 1) - die("usage: dwm [-v]"); - if (!setlocale(LC_CTYPE, "") || !XSupportsLocale()) - fputs("warning: no locale support\n", stderr); - if (!(dpy = XOpenDisplay(NULL))) - die("dwm: cannot open display"); - if (!(xcon = XGetXCBConnection(dpy))) - die("dwm: cannot get xcb connection\n"); - checkotherwm(); - XrmInitialize(); - load_xresources(); - 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/.local/src2/dwm/dwm.o b/.local/src2/dwm/dwm.o deleted file mode 100644 index 86866f27..00000000 Binary files a/.local/src2/dwm/dwm.o and /dev/null differ diff --git a/.local/src2/dwm/shiftview.c b/.local/src2/dwm/shiftview.c deleted file mode 100644 index 3d2706b8..00000000 --- a/.local/src2/dwm/shiftview.c +++ /dev/null @@ -1,64 +0,0 @@ -/** Function to shift the current view to the left/right - * - * @param: "arg->i" stores the number of tags to shift right (positive value) - * or left (negative value) - */ -void -shiftview(const Arg *arg) -{ - Arg shifted; - Client *c; - unsigned int tagmask = 0; - - for (c = selmon->clients; c; c = c->next) - if (!(c->tags & SPTAGMASK)) - tagmask = tagmask | c->tags; - - shifted.ui = selmon->tagset[selmon->seltags] & ~SPTAGMASK; - if (arg->i > 0) /* left circular shift */ - do { - shifted.ui = (shifted.ui << arg->i) - | (shifted.ui >> (LENGTH(tags) - arg->i)); - shifted.ui &= ~SPTAGMASK; - } while (tagmask && !(shifted.ui & tagmask)); - else /* right circular shift */ - do { - shifted.ui = (shifted.ui >> (- arg->i) - | shifted.ui << (LENGTH(tags) + arg->i)); - shifted.ui &= ~SPTAGMASK; - } while (tagmask && !(shifted.ui & tagmask)); - - view(&shifted); -} - -void -shifttag(const Arg *arg) -{ - Arg a; - Client *c; - unsigned visible = 0; - int i = arg->i; - int count = 0; - int nextseltags, curseltags = selmon->tagset[selmon->seltags]; - - do { - if(i > 0) // left circular shift - nextseltags = (curseltags << i) | (curseltags >> (LENGTH(tags) - i)); - - else // right circular shift - nextseltags = curseltags >> (- i) | (curseltags << (LENGTH(tags) + i)); - - // Check if tag is visible - for (c = selmon->clients; c && !visible; c = c->next) - if (nextseltags & c->tags) { - visible = 1; - break; - } - i += arg->i; - } while (!visible && ++count < 10); - - if (count < 10) { - a.i = nextseltags; - tag(&a); - } -} diff --git a/.local/src2/dwm/transient.c b/.local/src2/dwm/transient.c deleted file mode 100644 index 040adb5b..00000000 --- a/.local/src2/dwm/transient.c +++ /dev/null @@ -1,42 +0,0 @@ -/* 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/.local/src2/dwm/util.c b/.local/src2/dwm/util.c deleted file mode 100644 index fe044fc7..00000000 --- a/.local/src2/dwm/util.c +++ /dev/null @@ -1,35 +0,0 @@ -/* See LICENSE file for copyright and license details. */ -#include <stdarg.h> -#include <stdio.h> -#include <stdlib.h> -#include <string.h> - -#include "util.h" - -void * -ecalloc(size_t nmemb, size_t size) -{ - void *p; - - if (!(p = calloc(nmemb, size))) - die("calloc:"); - return p; -} - -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); -} diff --git a/.local/src2/dwm/util.h b/.local/src2/dwm/util.h deleted file mode 100644 index f633b517..00000000 --- a/.local/src2/dwm/util.h +++ /dev/null @@ -1,8 +0,0 @@ -/* 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/.local/src2/dwm/util.o b/.local/src2/dwm/util.o deleted file mode 100644 index b1b45c32..00000000 Binary files a/.local/src2/dwm/util.o and /dev/null differ diff --git a/.local/src2/dwm/vanitygaps.c b/.local/src2/dwm/vanitygaps.c deleted file mode 100644 index 4c98e694..00000000 --- a/.local/src2/dwm/vanitygaps.c +++ /dev/null @@ -1,550 +0,0 @@ -/* Key binding functions */ -static void defaultgaps(const Arg *arg); -static void incrgaps(const Arg *arg); -/* static void incrigaps(const Arg *arg); */ -/* static void incrogaps(const Arg *arg); */ -/* static void incrohgaps(const Arg *arg); */ -/* static void incrovgaps(const Arg *arg); */ -/* static void incrihgaps(const Arg *arg); */ -/* static void incrivgaps(const Arg *arg); */ -static void togglegaps(const Arg *arg); -static void togglesmartgaps(const Arg *arg); - -/* Layouts */ -static void bstack(Monitor *m); -static void centeredmaster(Monitor *m); -static void centeredfloatingmaster(Monitor *m); -static void deck(Monitor *m); -static void dwindle(Monitor *m); -static void fibonacci(Monitor *m, int s); -static void spiral(Monitor *m); -static void tile(Monitor *); - -/* Internals */ -static void getgaps(Monitor *m, int *oh, int *ov, int *ih, int *iv, unsigned int *nc); -static void setgaps(int oh, int ov, int ih, int iv); - -/* Settings */ -static int enablegaps = 1; - -static void -setgaps(int oh, int ov, int ih, int iv) -{ - if (oh < 0) oh = 0; - if (ov < 0) ov = 0; - if (ih < 0) ih = 0; - if (iv < 0) iv = 0; - - selmon->gappoh = oh; - selmon->gappov = ov; - selmon->gappih = ih; - selmon->gappiv = iv; - arrange(selmon); -} - -static void -togglegaps(const Arg *arg) -{ - enablegaps = !enablegaps; - arrange(NULL); -} - -static void -togglesmartgaps(const Arg *arg) -{ - smartgaps = !smartgaps; - arrange(NULL); -} - -static void -defaultgaps(const Arg *arg) -{ - setgaps(gappoh, gappov, gappih, gappiv); -} - -static void -incrgaps(const Arg *arg) -{ - setgaps( - selmon->gappoh + arg->i, - selmon->gappov + arg->i, - selmon->gappih + arg->i, - selmon->gappiv + arg->i - ); -} - -/* static void */ -/* incrigaps(const Arg *arg) */ -/* { */ -/* setgaps( */ -/* selmon->gappoh, */ -/* selmon->gappov, */ -/* selmon->gappih + arg->i, */ -/* selmon->gappiv + arg->i */ -/* ); */ -/* } */ - -/* static void */ -/* incrogaps(const Arg *arg) */ -/* { */ -/* setgaps( */ -/* selmon->gappoh + arg->i, */ -/* selmon->gappov + arg->i, */ -/* selmon->gappih, */ -/* selmon->gappiv */ -/* ); */ -/* } */ - -/* static void */ -/* incrohgaps(const Arg *arg) */ -/* { */ -/* setgaps( */ -/* selmon->gappoh + arg->i, */ -/* selmon->gappov, */ -/* selmon->gappih, */ -/* selmon->gappiv */ -/* ); */ -/* } */ - -/* static void */ -/* incrovgaps(const Arg *arg) */ -/* { */ -/* setgaps( */ -/* selmon->gappoh, */ -/* selmon->gappov + arg->i, */ -/* selmon->gappih, */ -/* selmon->gappiv */ -/* ); */ -/* } */ - -/* static void */ -/* incrihgaps(const Arg *arg) */ -/* { */ -/* setgaps( */ -/* selmon->gappoh, */ -/* selmon->gappov, */ -/* selmon->gappih + arg->i, */ -/* selmon->gappiv */ -/* ); */ -/* } */ - -/* static void */ -/* incrivgaps(const Arg *arg) */ -/* { */ -/* setgaps( */ -/* selmon->gappoh, */ -/* selmon->gappov, */ -/* selmon->gappih, */ -/* selmon->gappiv + arg->i */ -/* ); */ -/* } */ - -static void -getgaps(Monitor *m, int *oh, int *ov, int *ih, int *iv, unsigned int *nc) -{ - unsigned int n, oe, ie; - oe = ie = enablegaps; - Client *c; - - for (n = 0, c = nexttiled(m->clients); c; c = nexttiled(c->next), n++); - if (smartgaps && n == 1) { - oe = 0; // outer gaps disabled when only one client - } - - *oh = m->gappoh*oe; // outer horizontal gap - *ov = m->gappov*oe; // outer vertical gap - *ih = m->gappih*ie; // inner horizontal gap - *iv = m->gappiv*ie; // inner vertical gap - *nc = n; // number of clients -} - -void -getfacts(Monitor *m, int msize, int ssize, float *mf, float *sf, int *mr, int *sr) -{ - unsigned int n; - float mfacts, sfacts; - int mtotal = 0, stotal = 0; - Client *c; - - for (n = 0, c = nexttiled(m->clients); c; c = nexttiled(c->next), n++); - mfacts = MIN(n, m->nmaster); - sfacts = n - m->nmaster; - - for (n = 0, c = nexttiled(m->clients); c; c = nexttiled(c->next), n++) - if (n < m->nmaster) - mtotal += msize / mfacts; - else - stotal += ssize / sfacts; - - *mf = mfacts; // total factor of master area - *sf = sfacts; // total factor of stack area - *mr = msize - mtotal; // the remainder (rest) of pixels after an even master split - *sr = ssize - stotal; // the remainder (rest) of pixels after an even stack split -} - -/*** - * Layouts - */ - -/* - * Bottomstack layout + gaps - * https://dwm.suckless.org/patches/bottomstack/ - */ - -static void -bstack(Monitor *m) -{ - unsigned int i, n; - int mx = 0, my = 0, mh = 0, mw = 0; - int sx = 0, sy = 0, sh = 0, sw = 0; - float mfacts, sfacts; - int mrest, srest; - Client *c; - - int oh, ov, ih, iv; - getgaps(m, &oh, &ov, &ih, &iv, &n); - - if (n == 0) - return; - - sx = mx = m->wx + ov; - sy = my = m->wy + oh; - sh = mh = m->wh - 2*oh; - mw = m->ww - 2*ov - iv * (MIN(n, m->nmaster) - 1); - sw = m->ww - 2*ov - iv * (n - m->nmaster - 1); - - if (m->nmaster && n > m->nmaster) { - sh = (mh - ih) * (1 - m->mfact); - mh = (mh - ih) * m->mfact; - sx = mx; - sy = my + mh + ih; - } - - getfacts(m, mw, sw, &mfacts, &sfacts, &mrest, &srest); - - for (i = 0, c = nexttiled(m->clients); c; c = nexttiled(c->next), i++) { - if (i < m->nmaster) { - resize(c, mx, my, (mw / mfacts) + (i < mrest ? 1 : 0) - (2*c->bw), mh - (2*c->bw), 0); - mx += WIDTH(c) + iv; - } else { - resize(c, sx, sy, (sw / sfacts) + ((i - m->nmaster) < srest ? 1 : 0) - (2*c->bw), sh - (2*c->bw), 0); - sx += WIDTH(c) + iv; - } - } -} - -/* - * Centred master layout + gaps - * https://dwm.suckless.org/patches/centeredmaster/ - */ - -void -centeredmaster(Monitor *m) -{ - unsigned int i, n; - int mx = 0, my = 0, mh = 0, mw = 0; - int lx = 0, ly = 0, lw = 0, lh = 0; - int rx = 0, ry = 0, rw = 0, rh = 0; - float mfacts = 0, lfacts = 0, rfacts = 0; - int mtotal = 0, ltotal = 0, rtotal = 0; - int mrest = 0, lrest = 0, rrest = 0; - Client *c; - - int oh, ov, ih, iv; - getgaps(m, &oh, &ov, &ih, &iv, &n); - - if (n == 0) - return; - - /* initialize areas */ - mx = m->wx + ov; - my = m->wy + oh; - mh = m->wh - 2*oh - ih * ((!m->nmaster ? n : MIN(n, m->nmaster)) - 1); - mw = m->ww - 2*ov; - lh = m->wh - 2*oh - ih * (((n - m->nmaster) / 2) - 1); - rh = m->wh - 2*oh - ih * (((n - m->nmaster) / 2) - ((n - m->nmaster) % 2 ? 0 : 1)); - - if (m->nmaster && n > m->nmaster) { - /* go mfact box in the center if more than nmaster clients */ - if (n - m->nmaster > 1) { - /* ||<-S->|<---M--->|<-S->|| */ - mw = (m->ww - 2*ov - 2*iv) * m->mfact; - lw = (m->ww - mw - 2*ov - 2*iv) / 2; - mx += lw + iv; - } else { - /* ||<---M--->|<-S->|| */ - mw = (mw - iv) * m->mfact; - lw = m->ww - mw - iv - 2*ov; - } - rw = lw; - lx = m->wx + ov; - ly = m->wy + oh; - rx = mx + mw + iv; - ry = m->wy + oh; - } - - /* calculate facts */ - for (n = 0, c = nexttiled(m->clients); c; c = nexttiled(c->next), n++) { - if (!m->nmaster || n < m->nmaster) - mfacts += 1; - else if ((n - m->nmaster) % 2) - lfacts += 1; // total factor of left hand stack area - else - rfacts += 1; // total factor of right hand stack area - } - - for (n = 0, c = nexttiled(m->clients); c; c = nexttiled(c->next), n++) - if (!m->nmaster || n < m->nmaster) - mtotal += mh / mfacts; - else if ((n - m->nmaster) % 2) - ltotal += lh / lfacts; - else - rtotal += rh / rfacts; - - mrest = mh - mtotal; - lrest = lh - ltotal; - rrest = rh - rtotal; - - for (i = 0, c = nexttiled(m->clients); c; c = nexttiled(c->next), i++) { - if (!m->nmaster || i < m->nmaster) { - /* nmaster clients are stacked vertically, in the center of the screen */ - resize(c, mx, my, mw - (2*c->bw), (mh / mfacts) + (i < mrest ? 1 : 0) - (2*c->bw), 0); - my += HEIGHT(c) + ih; - } else { - /* stack clients are stacked vertically */ - if ((i - m->nmaster) % 2 ) { - resize(c, lx, ly, lw - (2*c->bw), (lh / lfacts) + ((i - 2*m->nmaster) < 2*lrest ? 1 : 0) - (2*c->bw), 0); - ly += HEIGHT(c) + ih; - } else { - resize(c, rx, ry, rw - (2*c->bw), (rh / rfacts) + ((i - 2*m->nmaster) < 2*rrest ? 1 : 0) - (2*c->bw), 0); - ry += HEIGHT(c) + ih; - } - } - } -} - -void -centeredfloatingmaster(Monitor *m) -{ - unsigned int i, n; - float mfacts, sfacts; - int mrest, srest; - int mx = 0, my = 0, mh = 0, mw = 0; - int sx = 0, sy = 0, sh = 0, sw = 0; - Client *c; - - float mivf = 1.0; // master inner vertical gap factor - int oh, ov, ih, iv; - getgaps(m, &oh, &ov, &ih, &iv, &n); - - if (n == 0) - return; - - sx = mx = m->wx + ov; - sy = my = m->wy + oh; - sh = mh = m->wh - 2*oh; - mw = m->ww - 2*ov - iv*(n - 1); - sw = m->ww - 2*ov - iv*(n - m->nmaster - 1); - - if (m->nmaster && n > m->nmaster) { - mivf = 0.8; - /* go mfact box in the center if more than nmaster clients */ - if (m->ww > m->wh) { - mw = m->ww * m->mfact - iv*mivf*(MIN(n, m->nmaster) - 1); - mh = m->wh * 0.9 - 2*oh; - } else { - mw = m->ww * 0.9 - iv*mivf*(MIN(n, m->nmaster) - 1); - mh = m->wh * m->mfact; - } - mx = m->wx + (m->ww - mw) / 2; - my = m->wy + (m->wh - mh) / 2; - - sx = m->wx + ov; - sy = m->wy + oh; - sh = m->wh - 2*oh; - } - - getfacts(m, mw, sw, &mfacts, &sfacts, &mrest, &srest); - - for (i = 0, c = nexttiled(m->clients); c; c = nexttiled(c->next), i++) - if (i < m->nmaster) { - /* nmaster clients are stacked horizontally, in the center of the screen */ - resize(c, mx, my, (mw / mfacts) + (i < mrest ? 1 : 0) - (2*c->bw), mh - (2*c->bw), 0); - mx += WIDTH(c) + iv*mivf; - } else { - /* stack clients are stacked horizontally */ - resize(c, sx, sy, (sw / sfacts) + ((i - m->nmaster) < srest ? 1 : 0) - (2*c->bw), sh - (2*c->bw), 0); - sx += WIDTH(c) + iv; - } -} - -/* - * Deck layout + gaps - * https://dwm.suckless.org/patches/deck/ - */ - -static void -deck(Monitor *m) -{ - unsigned int i, n; - int mx = 0, my = 0, mh = 0, mw = 0; - int sx = 0, sy = 0, sh = 0, sw = 0; - float mfacts, sfacts; - int mrest, srest; - Client *c; - - int oh, ov, ih, iv; - getgaps(m, &oh, &ov, &ih, &iv, &n); - - if (n == 0) - return; - - sx = mx = m->wx + ov; - sy = my = m->wy + oh; - sh = mh = m->wh - 2*oh - ih * (MIN(n, m->nmaster) - 1); - sw = mw = m->ww - 2*ov; - - if (m->nmaster && n > m->nmaster) { - sw = (mw - iv) * (1 - m->mfact); - mw = (mw - iv) * m->mfact; - sx = mx + mw + iv; - sh = m->wh - 2*oh; - } - - getfacts(m, mh, sh, &mfacts, &sfacts, &mrest, &srest); - - if (n - m->nmaster > 0) /* override layout symbol */ - snprintf(m->ltsymbol, sizeof m->ltsymbol, "D %d", n - m->nmaster); - - for (i = 0, c = nexttiled(m->clients); c; c = nexttiled(c->next), i++) - if (i < m->nmaster) { - resize(c, mx, my, mw - (2*c->bw), (mh / mfacts) + (i < mrest ? 1 : 0) - (2*c->bw), 0); - my += HEIGHT(c) + ih; - } else { - resize(c, sx, sy, sw - (2*c->bw), sh - (2*c->bw), 0); - } -} - -/* - * Fibonacci layout + gaps - * https://dwm.suckless.org/patches/fibonacci/ - */ - -static void -fibonacci(Monitor *m, int s) -{ - unsigned int i, n; - int nx, ny, nw, nh; - int oh, ov, ih, iv; - Client *c; - - getgaps(m, &oh, &ov, &ih, &iv, &n); - - if (n == 0) - return; - - nx = m->wx + ov; - ny = oh; - nw = m->ww - 2*ov; - nh = m->wh - 2*oh; - - for (i = 0, c = nexttiled(m->clients); c; c = nexttiled(c->next)) { - if ((i % 2 && nh / 2 > 2*c->bw) - || (!(i % 2) && nw / 2 > 2*c->bw)) { - if (i < n - 1) { - if (i % 2) - nh = (nh - ih) / 2; - else - nw = (nw - iv) / 2; - - if ((i % 4) == 2 && !s) - nx += nw + iv; - else if ((i % 4) == 3 && !s) - ny += nh + ih; - } - if ((i % 4) == 0) { - if (s) - ny += nh + ih; - else - ny -= nh + ih; - } - else if ((i % 4) == 1) - nx += nw + iv; - else if ((i % 4) == 2) - ny += nh + ih; - else if ((i % 4) == 3) { - if (s) - nx += nw + iv; - else - nx -= nw + iv; - } - if (i == 0) { - if (n != 1) - nw = (m->ww - 2*ov - iv) * m->mfact; - ny = m->wy + oh; - } - else if (i == 1) - nw = m->ww - nw - iv - 2*ov; - i++; - } - - resize(c, nx, ny, nw - (2*c->bw), nh - (2*c->bw), False); - } -} - -static void -dwindle(Monitor *m) -{ - fibonacci(m, 1); -} - -static void -spiral(Monitor *m) -{ - fibonacci(m, 0); -} - -/* - * Default tile layout + gaps - */ - -static void -tile(Monitor *m) -{ - unsigned int i, n; - int mx = 0, my = 0, mh = 0, mw = 0; - int sx = 0, sy = 0, sh = 0, sw = 0; - float mfacts, sfacts; - int mrest, srest; - Client *c; - - - int oh, ov, ih, iv; - getgaps(m, &oh, &ov, &ih, &iv, &n); - - if (n == 0) - return; - - sx = mx = m->wx + ov; - sy = my = m->wy + oh; - mh = m->wh - 2*oh - ih * (MIN(n, m->nmaster) - 1); - sh = m->wh - 2*oh - ih * (n - m->nmaster - 1); - sw = mw = m->ww - 2*ov; - - if (m->nmaster && n > m->nmaster) { - sw = (mw - iv) * (1 - m->mfact); - mw = (mw - iv) * m->mfact; - sx = mx + mw + iv; - } - - getfacts(m, mh, sh, &mfacts, &sfacts, &mrest, &srest); - - for (i = 0, c = nexttiled(m->clients); c; c = nexttiled(c->next), i++) - if (i < m->nmaster) { - resize(c, mx, my, mw - (2*c->bw), (mh / mfacts) + (i < mrest ? 1 : 0) - (2*c->bw), 0); - my += HEIGHT(c) + ih; - } else { - resize(c, sx, sy, sw - (2*c->bw), (sh / sfacts) + ((i - m->nmaster) < srest ? 1 : 0) - (2*c->bw), 0); - sy += HEIGHT(c) + ih; - } -} diff --git a/.local/src2/dwmblocks/.gitignore b/.local/src2/dwmblocks/.gitignore deleted file mode 100644 index c4bb9708..00000000 --- a/.local/src2/dwmblocks/.gitignore +++ /dev/null @@ -1,53 +0,0 @@ -# Prerequisites -*.d - -# Object files -*.o -*.ko -*.obj -*.elf - -# Linker output -*.ilk -*.map -*.exp - -# Precompiled Headers -*.gch -*.pch - -# Libraries -*.lib -*.a -*.la -*.lo - -# Shared objects (inc. Windows DLLs) -*.dll -*.so -*.so.* -*.dylib - -# Executables -*.exe -*.out -*.app -*.i*86 -*.x86_64 -*.hex -dwmblocks - -# Debug files -*.dSYM/ -*.su -*.idb -*.pdb - -# Kernel Module Compile Results -*.mod* -*.cmd -.tmp_versions/ -modules.order -Module.symvers -Mkfile.old -dkms.conf diff --git a/.local/src2/dwmblocks/FUNDING.yml b/.local/src2/dwmblocks/FUNDING.yml deleted file mode 100644 index f8e60767..00000000 --- a/.local/src2/dwmblocks/FUNDING.yml +++ /dev/null @@ -1,3 +0,0 @@ -github: lukesmithxyz -custom: ["https://lukesmith.xyz/donate", "https://paypal.me/lukemsmith", "https://lukesmith.xyz/crypto"] -patreon: lukesmith diff --git a/.local/src2/dwmblocks/LICENSE b/.local/src2/dwmblocks/LICENSE deleted file mode 100644 index d159169d..00000000 --- a/.local/src2/dwmblocks/LICENSE +++ /dev/null @@ -1,339 +0,0 @@ - GNU GENERAL PUBLIC LICENSE - Version 2, June 1991 - - Copyright (C) 1989, 1991 Free Software Foundation, Inc., - 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - Everyone is permitted to copy and distribute verbatim copies - of this license document, but changing it is not allowed. - - Preamble - - The licenses for most software are designed to take away your -freedom to share and change it. By contrast, the GNU General Public -License is intended to guarantee your freedom to share and change free -software--to make sure the software is free for all its users. This -General Public License applies to most of the Free Software -Foundation's software and to any other program whose authors commit to -using it. (Some other Free Software Foundation software is covered by -the GNU Lesser General Public License instead.) You can apply it to -your programs, too. - - When we speak of free software, we are referring to freedom, not -price. Our General Public Licenses are designed to make sure that you -have the freedom to distribute copies of free software (and charge for -this service if you wish), that you receive source code or can get it -if you want it, that you can change the software or use pieces of it -in new free programs; and that you know you can do these things. - - To protect your rights, we need to make restrictions that forbid -anyone to deny you these rights or to ask you to surrender the rights. -These restrictions translate to certain responsibilities for you if you -distribute copies of the software, or if you modify it. - - For example, if you distribute copies of such a program, whether -gratis or for a fee, you must give the recipients all the rights that -you have. You must make sure that they, too, receive or can get the -source code. And you must show them these terms so they know their -rights. - - We protect your rights with two steps: (1) copyright the software, and -(2) offer you this license which gives you legal permission to copy, -distribute and/or modify the software. - - Also, for each author's protection and ours, we want to make certain -that everyone understands that there is no warranty for this free -software. If the software is modified by someone else and passed on, we -want its recipients to know that what they have is not the original, so -that any problems introduced by others will not reflect on the original -authors' reputations. - - Finally, any free program is threatened constantly by software -patents. We wish to avoid the danger that redistributors of a free -program will individually obtain patent licenses, in effect making the -program proprietary. To prevent this, we have made it clear that any -patent must be licensed for everyone's free use or not licensed at all. - - The precise terms and conditions for copying, distribution and -modification follow. - - GNU GENERAL PUBLIC LICENSE - TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION - - 0. This License applies to any program or other work which contains -a notice placed by the copyright holder saying it may be distributed -under the terms of this General Public License. The "Program", below, -refers to any such program or work, and a "work based on the Program" -means either the Program or any derivative work under copyright law: -that is to say, a work containing the Program or a portion of it, -either verbatim or with modifications and/or translated into another -language. (Hereinafter, translation is included without limitation in -the term "modification".) Each licensee is addressed as "you". - -Activities other than copying, distribution and modification are not -covered by this License; they are outside its scope. The act of -running the Program is not restricted, and the output from the Program -is covered only if its contents constitute a work based on the -Program (independent of having been made by running the Program). -Whether that is true depends on what the Program does. - - 1. You may copy and distribute verbatim copies of the Program's -source code as you receive it, in any medium, provided that you -conspicuously and appropriately publish on each copy an appropriate -copyright notice and disclaimer of warranty; keep intact all the -notices that refer to this License and to the absence of any warranty; -and give any other recipients of the Program a copy of this License -along with the Program. - -You may charge a fee for the physical act of transferring a copy, and -you may at your option offer warranty protection in exchange for a fee. - - 2. You may modify your copy or copies of the Program or any portion -of it, thus forming a work based on the Program, and copy and -distribute such modifications or work under the terms of Section 1 -above, provided that you also meet all of these conditions: - - a) You must cause the modified files to carry prominent notices - stating that you changed the files and the date of any change. - - b) You must cause any work that you distribute or publish, that in - whole or in part contains or is derived from the Program or any - part thereof, to be licensed as a whole at no charge to all third - parties under the terms of this License. - - c) If the modified program normally reads commands interactively - when run, you must cause it, when started running for such - interactive use in the most ordinary way, to print or display an - announcement including an appropriate copyright notice and a - notice that there is no warranty (or else, saying that you provide - a warranty) and that users may redistribute the program under - these conditions, and telling the user how to view a copy of this - License. (Exception: if the Program itself is interactive but - does not normally print such an announcement, your work based on - the Program is not required to print an announcement.) - -These requirements apply to the modified work as a whole. If -identifiable sections of that work are not derived from the Program, -and can be reasonably considered independent and separate works in -themselves, then this License, and its terms, do not apply to those -sections when you distribute them as separate works. But when you -distribute the same sections as part of a whole which is a work based -on the Program, the distribution of the whole must be on the terms of -this License, whose permissions for other licensees extend to the -entire whole, and thus to each and every part regardless of who wrote it. - -Thus, it is not the intent of this section to claim rights or contest -your rights to work written entirely by you; rather, the intent is to -exercise the right to control the distribution of derivative or -collective works based on the Program. - -In addition, mere aggregation of another work not based on the Program -with the Program (or with a work based on the Program) on a volume of -a storage or distribution medium does not bring the other work under -the scope of this License. - - 3. You may copy and distribute the Program (or a work based on it, -under Section 2) in object code or executable form under the terms of -Sections 1 and 2 above provided that you also do one of the following: - - a) Accompany it with the complete corresponding machine-readable - source code, which must be distributed under the terms of Sections - 1 and 2 above on a medium customarily used for software interchange; or, - - b) Accompany it with a written offer, valid for at least three - years, to give any third party, for a charge no more than your - cost of physically performing source distribution, a complete - machine-readable copy of the corresponding source code, to be - distributed under the terms of Sections 1 and 2 above on a medium - customarily used for software interchange; or, - - c) Accompany it with the information you received as to the offer - to distribute corresponding source code. (This alternative is - allowed only for noncommercial distribution and only if you - received the program in object code or executable form with such - an offer, in accord with Subsection b above.) - -The source code for a work means the preferred form of the work for -making modifications to it. For an executable work, complete source -code means all the source code for all modules it contains, plus any -associated interface definition files, plus the scripts used to -control compilation and installation of the executable. However, as a -special exception, the source code distributed need not include -anything that is normally distributed (in either source or binary -form) with the major components (compiler, kernel, and so on) of the -operating system on which the executable runs, unless that component -itself accompanies the executable. - -If distribution of executable or object code is made by offering -access to copy from a designated place, then offering equivalent -access to copy the source code from the same place counts as -distribution of the source code, even though third parties are not -compelled to copy the source along with the object code. - - 4. You may not copy, modify, sublicense, or distribute the Program -except as expressly provided under this License. Any attempt -otherwise to copy, modify, sublicense or distribute the Program is -void, and will automatically terminate your rights under this License. -However, parties who have received copies, or rights, from you under -this License will not have their licenses terminated so long as such -parties remain in full compliance. - - 5. You are not required to accept this License, since you have not -signed it. However, nothing else grants you permission to modify or -distribute the Program or its derivative works. These actions are -prohibited by law if you do not accept this License. Therefore, by -modifying or distributing the Program (or any work based on the -Program), you indicate your acceptance of this License to do so, and -all its terms and conditions for copying, distributing or modifying -the Program or works based on it. - - 6. Each time you redistribute the Program (or any work based on the -Program), the recipient automatically receives a license from the -original licensor to copy, distribute or modify the Program subject to -these terms and conditions. You may not impose any further -restrictions on the recipients' exercise of the rights granted herein. -You are not responsible for enforcing compliance by third parties to -this License. - - 7. If, as a consequence of a court judgment or allegation of patent -infringement or for any other reason (not limited to patent issues), -conditions are imposed on you (whether by court order, agreement or -otherwise) that contradict the conditions of this License, they do not -excuse you from the conditions of this License. If you cannot -distribute so as to satisfy simultaneously your obligations under this -License and any other pertinent obligations, then as a consequence you -may not distribute the Program at all. For example, if a patent -license would not permit royalty-free redistribution of the Program by -all those who receive copies directly or indirectly through you, then -the only way you could satisfy both it and this License would be to -refrain entirely from distribution of the Program. - -If any portion of this section is held invalid or unenforceable under -any particular circumstance, the balance of the section is intended to -apply and the section as a whole is intended to apply in other -circumstances. - -It is not the purpose of this section to induce you to infringe any -patents or other property right claims or to contest validity of any -such claims; this section has the sole purpose of protecting the -integrity of the free software distribution system, which is -implemented by public license practices. Many people have made -generous contributions to the wide range of software distributed -through that system in reliance on consistent application of that -system; it is up to the author/donor to decide if he or she is willing -to distribute software through any other system and a licensee cannot -impose that choice. - -This section is intended to make thoroughly clear what is believed to -be a consequence of the rest of this License. - - 8. If the distribution and/or use of the Program is restricted in -certain countries either by patents or by copyrighted interfaces, the -original copyright holder who places the Program under this License -may add an explicit geographical distribution limitation excluding -those countries, so that distribution is permitted only in or among -countries not thus excluded. In such case, this License incorporates -the limitation as if written in the body of this License. - - 9. The Free Software Foundation may publish revised and/or new versions -of the General Public License from time to time. Such new versions will -be similar in spirit to the present version, but may differ in detail to -address new problems or concerns. - -Each version is given a distinguishing version number. If the Program -specifies a version number of this License which applies to it and "any -later version", you have the option of following the terms and conditions -either of that version or of any later version published by the Free -Software Foundation. If the Program does not specify a version number of -this License, you may choose any version ever published by the Free Software -Foundation. - - 10. If you wish to incorporate parts of the Program into other free -programs whose distribution conditions are different, write to the author -to ask for permission. For software which is copyrighted by the Free -Software Foundation, write to the Free Software Foundation; we sometimes -make exceptions for this. Our decision will be guided by the two goals -of preserving the free status of all derivatives of our free software and -of promoting the sharing and reuse of software generally. - - NO WARRANTY - - 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY -FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN -OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES -PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED -OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF -MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS -TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE -PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, -REPAIR OR CORRECTION. - - 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING -WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR -REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, -INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING -OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED -TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY -YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER -PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE -POSSIBILITY OF SUCH DAMAGES. - - END OF TERMS AND CONDITIONS - - How to Apply These Terms to Your New Programs - - If you develop a new program, and you want it to be of the greatest -possible use to the public, the best way to achieve this is to make it -free software which everyone can redistribute and change under these terms. - - To do so, attach the following notices to the program. It is safest -to attach them to the start of each source file to most effectively -convey the exclusion of warranty; and each file should have at least -the "copyright" line and a pointer to where the full notice is found. - - <one line to give the program's name and a brief idea of what it does.> - Copyright (C) <year> <name of author> - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License along - with this program; if not, write to the Free Software Foundation, Inc., - 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - -Also add information on how to contact you by electronic and paper mail. - -If the program is interactive, make it output a short notice like this -when it starts in an interactive mode: - - Gnomovision version 69, Copyright (C) year name of author - Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. - This is free software, and you are welcome to redistribute it - under certain conditions; type `show c' for details. - -The hypothetical commands `show w' and `show c' should show the appropriate -parts of the General Public License. Of course, the commands you use may -be called something other than `show w' and `show c'; they could even be -mouse-clicks or menu items--whatever suits your program. - -You should also get your employer (if you work as a programmer) or your -school, if any, to sign a "copyright disclaimer" for the program, if -necessary. Here is a sample; alter the names: - - Yoyodyne, Inc., hereby disclaims all copyright interest in the program - `Gnomovision' (which makes passes at compilers) written by James Hacker. - - <signature of Ty Coon>, 1 April 1989 - Ty Coon, President of Vice - -This General Public License does not permit incorporating your program into -proprietary programs. If your program is a subroutine library, you may -consider it more useful to permit linking proprietary applications with the -library. If this is what you want to do, use the GNU Lesser General -Public License instead of this License. diff --git a/.local/src2/dwmblocks/Makefile b/.local/src2/dwmblocks/Makefile deleted file mode 100644 index 5cfbb5a8..00000000 --- a/.local/src2/dwmblocks/Makefile +++ /dev/null @@ -1,19 +0,0 @@ -.POSIX: - -PREFIX = /usr/local -CC = gcc - -dwmblocks: dwmblocks.o - $(CC) dwmblocks.o -lX11 -o dwmblocks -dwmblocks.o: dwmblocks.c config.h - $(CC) -c dwmblocks.c -clean: - rm -f *.o *.gch dwmblocks -install: dwmblocks - mkdir -p $(DESTDIR)$(PREFIX)/bin - cp -f dwmblocks $(DESTDIR)$(PREFIX)/bin - chmod 755 $(DESTDIR)$(PREFIX)/bin/dwmblocks -uninstall: - rm -f $(DESTDIR)$(PREFIX)/bin/dwmblocks - -.PHONY: clean install uninstall diff --git a/.local/src2/dwmblocks/README.md b/.local/src2/dwmblocks/README.md deleted file mode 100644 index 7d21e309..00000000 --- a/.local/src2/dwmblocks/README.md +++ /dev/null @@ -1,44 +0,0 @@ -# dwmblocks - -Modular status bar for dwm written in c. - -# Modifying blocks - -The statusbar is made from text output from commandline programs. Blocks are -added and removed by editing the config.h file. - -# Luke's build - -I have dwmblocks read my preexisting scripts -[here in my dotfiles repo](https://github.com/LukeSmithxyz/voidrice/tree/master/.local/bin/statusbar). -So if you want my build out of the box, download those and put them in your -`$PATH`. I do this to avoid redundancy in LARBS, both i3 and dwm use the same -statusbar scripts. - -# Signaling changes - -Most statusbars constantly rerun every script every several seconds to update. -This is an option here, but a superior choice is giving your module a signal -that you can signal to it to update on a relevant event, rather than having it -rerun idly. - -For example, the audio module has the update signal 10 by default. Thus, -running `pkill -RTMIN+10 dwmblocks` will update it. - -You can also run `kill -44 $(pidof dwmblocks)` which will have the same effect, -but is faster. Just add 34 to your typical signal number. - -My volume module *never* updates on its own, instead I have this command run -along side my volume shortcuts in dwm to only update it when relevant. - -Note that all modules must have different signal numbers. - -# Clickable modules - -Like i3blocks, this build allows you to build in additional actions into your -scripts in response to click events. See the above linked scripts for examples -of this using the `$BLOCK_BUTTON` variable. - -For this feature to work, you need the appropriate patch in dwm as well. See -[here](https://dwm.suckless.org/patches/statuscmd/). -Credit for those patches goes to Daniel Bylinka (daniel.bylinka@gmail.com). diff --git a/.local/src2/dwmblocks/config.h b/.local/src2/dwmblocks/config.h deleted file mode 100644 index 5287e789..00000000 --- a/.local/src2/dwmblocks/config.h +++ /dev/null @@ -1,32 +0,0 @@ -//Modify this file to change what commands output to your statusbar, and recompile using the make command. -static const Block blocks[] = { - /*Icon*//*Command*/ /*Update Interval*/ /*Update Signal*/ - // {"⌨","sb-kbselect", 0, 30}, - {"", "cat /tmp/recordingicon 2>/dev/null", 0, 9}, - {"", "sb-tasks", 10, 26}, - {"", "sb-music", 0, 11}, - {"", "sb-pacpackages", 0, 8}, - {"", "sb-news", 0, 6}, - // {"", "sb-price btc Bitcoin ", 9000, 21}, - {"", "sb-torrent", 20, 7}, - // {"", "sb-memory", 10, 14}, - // {"", "sb-cpu", 10, 18}, - // {"", "sb-moonphase", 21600, 17}, - {"", "sb-mailbox", 180, 12}, - {"", "sb-forecast", 3600, 5}, - // {"", "sb-nettraf", 1, 16}, - // {"", "sb-battery", 5, 3}, - {"", "sb-volume", 0, 10}, - {"", "sb-clock", 60, 1}, - {"", "sb-internet", 5, 4}, - // {"", "sb-help-icon", 0, 15}, -}; - -//Sets delimiter between status commands. NULL character ('\0') means no delimiter. -static char *delim = " │ "; - -// Have dwmblocks automatically recompile and run when you edit this file in -// vim with the following line in your vimrc/init.vim: - -// autocmd BufWritePost ~/.local/src/dwmblocks/config.h !cd ~/.local/src/dwmblocks/; sudo make install && { killall -q dwmblocks;setsid dwmblocks & } - diff --git a/.local/src2/dwmblocks/dwmblocks.c b/.local/src2/dwmblocks/dwmblocks.c deleted file mode 100644 index 0969ed7a..00000000 --- a/.local/src2/dwmblocks/dwmblocks.c +++ /dev/null @@ -1,294 +0,0 @@ -#include <stdlib.h> -#include <stdio.h> -#include <string.h> -#include <unistd.h> -#include <time.h> -#include <signal.h> -#include <errno.h> -#include <X11/Xlib.h> -#define LENGTH(X) (sizeof(X) / sizeof (X[0])) -#define CMDLENGTH 50 - -typedef struct { - char* icon; - char* command; - unsigned int interval; - unsigned int signal; -} Block; -void sighandler(int num); -void buttonhandler(int sig, siginfo_t *si, void *ucontext); -void replace(char *str, char old, char new); -void remove_all(char *str, char to_remove); -void getcmds(int time); -#ifndef __OpenBSD__ -void getsigcmds(int signal); -void setupsignals(); -void sighandler(int signum); -#endif -int getstatus(char *str, char *last); -void setroot(); -void statusloop(); -void termhandler(int signum); - - -#include "config.h" - -static Display *dpy; -static int screen; -static Window root; -static char statusbar[LENGTH(blocks)][CMDLENGTH] = {0}; -static char statusstr[2][256]; -static int statusContinue = 1; -static void (*writestatus) () = setroot; - -void replace(char *str, char old, char new) -{ - for(char * c = str; *c; c++) - if(*c == old) - *c = new; -} - -// the previous function looked nice but unfortunately it didnt work if to_remove was in any position other than the last character -// theres probably still a better way of doing this -void remove_all(char *str, char to_remove) { - char *read = str; - char *write = str; - while (*read) { - if (*read != to_remove) { - *write++ = *read; - } - ++read; - } - *write = '\0'; -} - -int gcd(int a, int b) -{ - int temp; - while (b > 0){ - temp = a % b; - - a = b; - b = temp; - } - return a; -} - - -//opens process *cmd and stores output in *output -void getcmd(const Block *block, char *output) -{ - if (block->signal) - { - output[0] = block->signal; - output++; - } - char *cmd = block->command; - FILE *cmdf = popen(cmd,"r"); - if (!cmdf){ - //printf("failed to run: %s, %d\n", block->command, errno); - return; - } - char tmpstr[CMDLENGTH] = ""; - // TODO decide whether its better to use the last value till next time or just keep trying while the error was the interrupt - // this keeps trying to read if it got nothing and the error was an interrupt - // could also just read to a separate buffer and not move the data over if interrupted - // this way will take longer trying to complete 1 thing but will get it done - // the other way will move on to keep going with everything and the part that failed to read will be wrong till its updated again - // either way you have to save the data to a temp buffer because when it fails it writes nothing and then then it gets displayed before this finishes - char * s; - int e; - do { - errno = 0; - s = fgets(tmpstr, CMDLENGTH-(strlen(delim)+1), cmdf); - e = errno; - } while (!s && e == EINTR); - pclose(cmdf); - int i = strlen(block->icon); - strcpy(output, block->icon); - strcpy(output+i, tmpstr); - remove_all(output, '\n'); - i = strlen(output); - if ((i > 0 && block != &blocks[LENGTH(blocks) - 1])){ - strcat(output, delim); - } - i+=strlen(delim); - output[i++] = '\0'; -} - -void getcmds(int time) -{ - const Block* current; - for(int i = 0; i < LENGTH(blocks); i++) - { - current = blocks + i; - if ((current->interval != 0 && time % current->interval == 0) || time == -1){ - getcmd(current,statusbar[i]); - } - } -} - -#ifndef __OpenBSD__ -void getsigcmds(int signal) -{ - const Block *current; - for (int i = 0; i < LENGTH(blocks); i++) - { - current = blocks + i; - if (current->signal == signal){ - getcmd(current,statusbar[i]); - } - } -} - -void setupsignals() -{ - struct sigaction sa; - - for(int i = SIGRTMIN; i <= SIGRTMAX; i++) - signal(i, SIG_IGN); - - for(int i = 0; i < LENGTH(blocks); i++) - { - if (blocks[i].signal > 0) - { - signal(SIGRTMIN+blocks[i].signal, sighandler); - sigaddset(&sa.sa_mask, SIGRTMIN+blocks[i].signal); - } - } - sa.sa_sigaction = buttonhandler; - sa.sa_flags = SA_SIGINFO; - sigaction(SIGUSR1, &sa, NULL); - struct sigaction sigchld_action = { - .sa_handler = SIG_DFL, - .sa_flags = SA_NOCLDWAIT - }; - sigaction(SIGCHLD, &sigchld_action, NULL); - -} -#endif - -int getstatus(char *str, char *last) -{ - strcpy(last, str); - str[0] = '\0'; - for(int i = 0; i < LENGTH(blocks); i++) { - strcat(str, statusbar[i]); - if (i == LENGTH(blocks) - 1) - strcat(str, " "); - } - str[strlen(str)-1] = '\0'; - return strcmp(str, last);//0 if they are the same -} - -void setroot() -{ - if (!getstatus(statusstr[0], statusstr[1]))//Only set root if text has changed. - return; - Display *d = XOpenDisplay(NULL); - if (d) { - dpy = d; - } - screen = DefaultScreen(dpy); - root = RootWindow(dpy, screen); - XStoreName(dpy, root, statusstr[0]); - XCloseDisplay(dpy); -} - -void pstdout() -{ - if (!getstatus(statusstr[0], statusstr[1]))//Only write out if text has changed. - return; - printf("%s\n",statusstr[0]); - fflush(stdout); -} - - -void statusloop() -{ -#ifndef __OpenBSD__ - setupsignals(); -#endif - // first figure out the default wait interval by finding the - // greatest common denominator of the intervals - unsigned int interval = -1; - for(int i = 0; i < LENGTH(blocks); i++){ - if(blocks[i].interval){ - interval = gcd(blocks[i].interval, interval); - } - } - unsigned int i = 0; - int interrupted = 0; - const struct timespec sleeptime = {interval, 0}; - struct timespec tosleep = sleeptime; - getcmds(-1); - while(statusContinue) - { - // sleep for tosleep (should be a sleeptime of interval seconds) and put what was left if interrupted back into tosleep - interrupted = nanosleep(&tosleep, &tosleep); - // if interrupted then just go sleep again for the remaining time - if(interrupted == -1){ - continue; - } - // if not interrupted then do the calling and writing - getcmds(i); - writestatus(); - // then increment since its actually been a second (plus the time it took the commands to run) - i += interval; - // set the time to sleep back to the sleeptime of 1s - tosleep = sleeptime; - } -} - -#ifndef __OpenBSD__ -void sighandler(int signum) -{ - getsigcmds(signum-SIGRTMIN); - writestatus(); -} - -void buttonhandler(int sig, siginfo_t *si, void *ucontext) -{ - char button[2] = {'0' + si->si_value.sival_int & 0xff, '\0'}; - pid_t process_id = getpid(); - sig = si->si_value.sival_int >> 8; - if (fork() == 0) - { - const Block *current; - for (int i = 0; i < LENGTH(blocks); i++) - { - current = blocks + i; - if (current->signal == sig) - break; - } - char shcmd[1024]; - sprintf(shcmd,"%s && kill -%d %d",current->command, current->signal+34,process_id); - char *command[] = { "/bin/sh", "-c", shcmd, NULL }; - setenv("BLOCK_BUTTON", button, 1); - setsid(); - execvp(command[0], command); - exit(EXIT_SUCCESS); - } -} - -#endif - -void termhandler(int signum) -{ - statusContinue = 0; - exit(0); -} - -int main(int argc, char** argv) -{ - for(int i = 0; i < argc; i++) - { - if (!strcmp("-d",argv[i])) - delim = argv[++i]; - else if(!strcmp("-p",argv[i])) - writestatus = pstdout; - } - signal(SIGTERM, termhandler); - signal(SIGINT, termhandler); - statusloop(); -} diff --git a/.local/src2/dwmblocks/patches/dwmblocks-statuscmd-fork.diff b/.local/src2/dwmblocks/patches/dwmblocks-statuscmd-fork.diff deleted file mode 100644 index 1ae7d7a1..00000000 --- a/.local/src2/dwmblocks/patches/dwmblocks-statuscmd-fork.diff +++ /dev/null @@ -1,77 +0,0 @@ -diff --git a/dwmblocks.c b/dwmblocks.c -index 7d7a564..e2c5dd0 100644 ---- a/dwmblocks.c -+++ b/dwmblocks.c -@@ -34,8 +34,6 @@ static int screen; - static Window root; - static char statusbar[LENGTH(blocks)][CMDLENGTH] = {0}; - static char statusstr[2][256]; --static char exportstring[CMDLENGTH + 22] = "export BLOCK_BUTTON=-;"; --static int button = 0; - static int statusContinue = 1; - static void (*writestatus) () = setroot; - -@@ -55,21 +53,8 @@ void getcmd(const Block *block, char *output) - output[0] = block->signal; - output++; - } -- char* cmd; -- FILE *cmdf; -- if (button) -- { -- cmd = strcat(exportstring, block->command); -- cmd[20] = '0' + button; -- button = 0; -- cmdf = popen(cmd,"r"); -- cmd[22] = '\0'; -- } -- else -- { -- cmd = block->command; -- cmdf = popen(cmd,"r"); -- } -+ char *cmd = block->command; -+ FILE *cmdf = popen(cmd,"r"); - if (!cmdf) - return; - fgets(output, CMDLENGTH, cmdf); -@@ -117,6 +102,7 @@ void setupsignals() - sa.sa_sigaction = buttonhandler; - sa.sa_flags = SA_SIGINFO; - sigaction(SIGUSR1, &sa, NULL); -+ signal(SIGCHLD, SIG_IGN); - - } - #endif -@@ -179,9 +165,29 @@ void sighandler(int signum) - - void buttonhandler(int sig, siginfo_t *si, void *ucontext) - { -- button = si->si_value.sival_int & 0xff; -- getsigcmds(si->si_value.sival_int >> 8); -+ int button = si->si_value.sival_int & 0xff; -+ sig = si->si_value.sival_int >> 8; -+ getsigcmds(sig); - writestatus(); -+ if (fork() == 0) -+ { -+ static char exportstring[CMDLENGTH + 22] = "export BLOCK_BUTTON=-;"; -+ const Block *current; -+ int i; -+ for (i = 0; i < LENGTH(blocks); i++) -+ { -+ current = blocks + i; -+ if (current->signal == sig) -+ break; -+ } -+ char *cmd = strcat(exportstring, blocks[i].command); -+ cmd[20] = '0' + button; -+ char *command[] = { "/bin/sh", "-c", cmd, NULL }; -+ setsid(); -+ execvp(command[0], command); -+ exit(EXIT_SUCCESS); -+ cmd[22] = '\0'; -+ } - } - - #endif diff --git a/.local/src2/dwmblocks/patches/dwmblocks-statuscmd-signal.diff b/.local/src2/dwmblocks/patches/dwmblocks-statuscmd-signal.diff deleted file mode 100644 index c2092e77..00000000 --- a/.local/src2/dwmblocks/patches/dwmblocks-statuscmd-signal.diff +++ /dev/null @@ -1,93 +0,0 @@ -diff --git a/dwmblocks.c b/dwmblocks.c -index 88bdfb0..7bd14df 100644 ---- a/dwmblocks.c -+++ b/dwmblocks.c -@@ -14,6 +14,7 @@ typedef struct { - unsigned int signal; - } Block; - void sighandler(int num); -+void buttonhandler(int sig, siginfo_t *si, void *ucontext); - void replace(char *str, char old, char new); - void getcmds(int time); - #ifndef __OpenBSD__ -@@ -34,6 +35,8 @@ static int screen; - static Window root; - static char statusbar[LENGTH(blocks)][CMDLENGTH] = {0}; - static char statusstr[2][256]; -+static char exportstring[CMDLENGTH + 16] = "export BUTTON=-;"; -+static int button = 0; - static int statusContinue = 1; - static void (*writestatus) () = setroot; - -@@ -48,16 +51,34 @@ void replace(char *str, char old, char new) - //opens process *cmd and stores output in *output - void getcmd(const Block *block, char *output) - { -+ if (block->signal) -+ { -+ output[0] = block->signal; -+ output++; -+ } - strcpy(output, block->icon); -- char *cmd = block->command; -- FILE *cmdf = popen(cmd,"r"); -+ char* cmd; -+ FILE *cmdf; -+ if (button) -+ { -+ cmd = strcat(exportstring, block->command); -+ cmd[14] = '0' + button; -+ button = 0; -+ cmdf = popen(cmd,"r"); -+ cmd[16] = '\0'; -+ } -+ else -+ { -+ cmd = block->command; -+ cmdf = popen(cmd,"r"); -+ } - if (!cmdf) - return; - char c; - int i = strlen(block->icon); - fgets(output+i, CMDLENGTH-i, cmdf); - i = strlen(output); -- if (delim != '\0' && --i) -+ if (delim != '\0' && i) - output[i++] = delim; - output[i++] = '\0'; - pclose(cmdf); -@@ -88,11 +106,18 @@ void getsigcmds(int signal) - - void setupsignals() - { -+ struct sigaction sa; - for(int i = 0; i < LENGTH(blocks); i++) - { - if (blocks[i].signal > 0) -+ { - signal(SIGRTMIN+blocks[i].signal, sighandler); -+ sigaddset(&sa.sa_mask, SIGRTMIN+blocks[i].signal); -+ } - } -+ sa.sa_sigaction = buttonhandler; -+ sa.sa_flags = SA_SIGINFO; -+ sigaction(SIGUSR1, &sa, NULL); - - } - #endif -@@ -152,6 +177,14 @@ void sighandler(int signum) - getsigcmds(signum-SIGRTMIN); - writestatus(); - } -+ -+void buttonhandler(int sig, siginfo_t *si, void *ucontext) -+{ -+ button = si->si_value.sival_int & 0xff; -+ getsigcmds(si->si_value.sival_int >> 8); -+ writestatus(); -+} -+ - #endif - - void termhandler(int signum) diff --git a/.local/src2/slock/LICENSE b/.local/src2/slock/LICENSE deleted file mode 100644 index 2e4419b7..00000000 --- a/.local/src2/slock/LICENSE +++ /dev/null @@ -1,24 +0,0 @@ -MIT/X Consortium License - -© 2015-2016 Markus Teich <markus.teich@stusta.mhn.de> -© 2014 Dimitris Papastamos <sin@2f30.org> -© 2006-2014 Anselm R Garbe <anselm@garbe.us> -© 2014-2016 Laslo Hunhold <dev@frign.de> - -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/.local/src2/slock/Makefile b/.local/src2/slock/Makefile deleted file mode 100644 index 0d211fb8..00000000 --- a/.local/src2/slock/Makefile +++ /dev/null @@ -1,60 +0,0 @@ -# slock - simple screen locker -# See LICENSE file for copyright and license details. - -include config.mk - -SRC = slock.c ${COMPATSRC} -OBJ = ${SRC:.c=.o} - -all: options slock - -options: - @echo slock build options: - @echo "CFLAGS = ${CFLAGS}" - @echo "LDFLAGS = ${LDFLAGS}" - @echo "CC = ${CC}" - -.c.o: - @echo CC $< - @${CC} -c ${CFLAGS} $< - -${OBJ}: config.h config.mk arg.h util.h - -config.h: - @echo creating $@ from config.def.h - @cp config.def.h $@ - -slock: ${OBJ} - @echo CC -o $@ - @${CC} -o $@ ${OBJ} ${LDFLAGS} - -clean: - @echo cleaning - @rm -f slock ${OBJ} slock-${VERSION}.tar.gz - -dist: clean - @echo creating dist tarball - @mkdir -p slock-${VERSION} - @cp -R LICENSE Makefile README slock.1 config.mk \ - ${SRC} explicit_bzero.c config.def.h arg.h util.h slock-${VERSION} - @tar -cf slock-${VERSION}.tar slock-${VERSION} - @gzip slock-${VERSION}.tar - @rm -rf slock-${VERSION} - -install: all - @echo installing executable file to ${DESTDIR}${PREFIX}/bin - @mkdir -p ${DESTDIR}${PREFIX}/bin - @cp -f slock ${DESTDIR}${PREFIX}/bin - @chmod 755 ${DESTDIR}${PREFIX}/bin/slock - @echo installing manual page to ${DESTDIR}${MANPREFIX}/man1 - @mkdir -p ${DESTDIR}${MANPREFIX}/man1 - @sed "s/VERSION/${VERSION}/g" <slock.1 >${DESTDIR}${MANPREFIX}/man1/slock.1 - @chmod 644 ${DESTDIR}${MANPREFIX}/man1/slock.1 - -uninstall: - @echo removing executable file from ${DESTDIR}${PREFIX}/bin - @rm -f ${DESTDIR}${PREFIX}/bin/slock - @echo removing manual page from ${DESTDIR}${MANPREFIX}/man1 - @rm -f ${DESTDIR}${MANPREFIX}/man1/slock.1 - -.PHONY: all options clean dist install uninstall diff --git a/.local/src2/slock/README b/.local/src2/slock/README deleted file mode 100644 index dcacd01b..00000000 --- a/.local/src2/slock/README +++ /dev/null @@ -1,24 +0,0 @@ -slock - simple screen locker -============================ -simple screen locker utility for X. - - -Requirements ------------- -In order to build slock you need the Xlib header files. - - -Installation ------------- -Edit config.mk to match your local setup (slock is installed into -the /usr/local namespace by default). - -Afterwards enter the following command to build and install slock -(if necessary as root): - - make clean install - - -Running slock -------------- -Simply invoke the 'slock' command. To get out of it, enter your password. diff --git a/.local/src2/slock/arg.h b/.local/src2/slock/arg.h deleted file mode 100644 index 0b23c53a..00000000 --- a/.local/src2/slock/arg.h +++ /dev/null @@ -1,65 +0,0 @@ -/* - * Copy me if you can. - * by 20h - */ - -#ifndef ARG_H__ -#define ARG_H__ - -extern char *argv0; - -/* use main(int argc, char *argv[]) */ -#define ARGBEGIN for (argv0 = *argv, argv++, argc--;\ - argv[0] && argv[0][0] == '-'\ - && argv[0][1];\ - argc--, argv++) {\ - char argc_;\ - char **argv_;\ - int brk_;\ - if (argv[0][1] == '-' && argv[0][2] == '\0') {\ - argv++;\ - argc--;\ - break;\ - }\ - for (brk_ = 0, argv[0]++, argv_ = argv;\ - argv[0][0] && !brk_;\ - argv[0]++) {\ - if (argv_ != argv)\ - break;\ - argc_ = argv[0][0];\ - switch (argc_) - -/* Handles obsolete -NUM syntax */ -#define ARGNUM case '0':\ - case '1':\ - case '2':\ - case '3':\ - case '4':\ - case '5':\ - case '6':\ - case '7':\ - case '8':\ - case '9' - -#define ARGEND }\ - } - -#define ARGC() argc_ - -#define ARGNUMF() (brk_ = 1, estrtonum(argv[0], 0, INT_MAX)) - -#define EARGF(x) ((argv[0][1] == '\0' && argv[1] == NULL)?\ - ((x), abort(), (char *)0) :\ - (brk_ = 1, (argv[0][1] != '\0')?\ - (&argv[0][1]) :\ - (argc--, argv++, argv[0]))) - -#define ARGF() ((argv[0][1] == '\0' && argv[1] == NULL)?\ - (char *)0 :\ - (brk_ = 1, (argv[0][1] != '\0')?\ - (&argv[0][1]) :\ - (argc--, argv++, argv[0]))) - -#define LNGARG() &argv[0][0] - -#endif diff --git a/.local/src2/slock/config.h b/.local/src2/slock/config.h deleted file mode 100644 index fd902409..00000000 --- a/.local/src2/slock/config.h +++ /dev/null @@ -1,38 +0,0 @@ -/* user and group to drop privileges to */ -static const char *user = "nobody"; -static const char *group = "nogroup"; - -static const char *colorname[NUMCOLS] = { - [INIT] = "black", /* after initialization */ - [INPUT] = "#005577", /* during input */ - [FAILED] = "#CC3333", /* wrong password */ - [PAM] = "#9400D3", /* waiting for PAM */ -}; - -/* Xresources preferences to load at startup */ -ResourcePref resources[] = { - { "color0", STRING, &colorname[INIT] }, - { "color4", STRING, &colorname[INPUT] }, - { "color1", STRING, &colorname[FAILED] }, - { "color5", STRING, &colorname[PAM] }, -}; - -/* treat a cleared input like a wrong password (color) */ -static const int failonclear = 1; - -/* Offset for the lockscreen message in pixels */ -static const int xoffset = 1920; -static const int yoffset = 0; - -/* PAM service that's used for authentication */ -static const char * pam_service = "login"; - -/* default message */ -static const char * message = "Check your xsidle.sh and xinitrc to make sure you're properly running slock"; - -/* text color */ -static const char * text_color = "#ffffff"; - -/* text size (must be a valid size) */ -static const char * font_name = "6x13"; - diff --git a/.local/src2/slock/config.mk b/.local/src2/slock/config.mk deleted file mode 100644 index 0524807b..00000000 --- a/.local/src2/slock/config.mk +++ /dev/null @@ -1,32 +0,0 @@ -# slock version -VERSION = 1.4 - -# Customize below to fit your system - -# paths -PREFIX = /usr/local -MANPREFIX = ${PREFIX}/share/man - -X11INC = /usr/X11R6/include -X11LIB = /usr/X11R6/lib - -# includes and libs -INCS = -I. -I/usr/include -I${X11INC} -LIBS = -L/usr/lib -lc -lcrypt -L${X11LIB} -lX11 -lXext -lXrandr -lXinerama -lpam - -# flags -CPPFLAGS = -DVERSION=\"${VERSION}\" -D_DEFAULT_SOURCE -DHAVE_SHADOW_H -CFLAGS = -std=c99 -pedantic -Wall -Os ${INCS} ${CPPFLAGS} -LDFLAGS = -s ${LIBS} -COMPATSRC = explicit_bzero.c - -# On OpenBSD and Darwin remove -lcrypt from LIBS -#LIBS = -L/usr/lib -lc -L${X11LIB} -lX11 -lXext -lXrandr -# On *BSD remove -DHAVE_SHADOW_H from CPPFLAGS -# On NetBSD add -D_NETBSD_SOURCE to CPPFLAGS -#CPPFLAGS = -DVERSION=\"${VERSION}\" -D_BSD_SOURCE -D_NETBSD_SOURCE -# On OpenBSD set COMPATSRC to empty -#COMPATSRC = - -# compiler and linker -CC = cc diff --git a/.local/src2/slock/explicit_bzero.c b/.local/src2/slock/explicit_bzero.c deleted file mode 100644 index 3e33ca85..00000000 --- a/.local/src2/slock/explicit_bzero.c +++ /dev/null @@ -1,19 +0,0 @@ -/* $OpenBSD: explicit_bzero.c,v 1.3 2014/06/21 02:34:26 matthew Exp $ */ -/* - * Public domain. - * Written by Matthew Dempsky. - */ - -#include <string.h> - -__attribute__((weak)) void -__explicit_bzero_hook(void *buf, size_t len) -{ -} - -void -explicit_bzero(void *buf, size_t len) -{ - memset(buf, 0, len); - __explicit_bzero_hook(buf, len); -} diff --git a/.local/src2/slock/explicit_bzero.o b/.local/src2/slock/explicit_bzero.o deleted file mode 100644 index 64dc4a35..00000000 Binary files a/.local/src2/slock/explicit_bzero.o and /dev/null differ diff --git a/.local/src2/slock/slock b/.local/src2/slock/slock deleted file mode 100755 index f43efc87..00000000 Binary files a/.local/src2/slock/slock and /dev/null differ diff --git a/.local/src2/slock/slock-colormessage-20200210-35633d4.diff b/.local/src2/slock/slock-colormessage-20200210-35633d4.diff deleted file mode 100644 index 0ef08474..00000000 --- a/.local/src2/slock/slock-colormessage-20200210-35633d4.diff +++ /dev/null @@ -1,284 +0,0 @@ -From 53ba5a8d3608ca9c9c406b12c51c2bfdfb3e01d3 Mon Sep 17 00:00:00 2001 -From: Guy Shefy <guyshefyb@gmail.com> -Date: Wed, 10 Feb 2021 00:17:46 +0200 -Subject: [PATCH] Add a message command with 24 bit color support - ---- - config.def.h | 9 +++ - config.mk | 2 +- - slock.1 | 7 +++ - slock.c | 154 +++++++++++++++++++++++++++++++++++++++++++++++++-- - 4 files changed, 167 insertions(+), 5 deletions(-) - -diff --git a/config.def.h b/config.def.h -index 9855e21..c2a0ab2 100644 ---- a/config.def.h -+++ b/config.def.h -@@ -10,3 +10,12 @@ static const char *colorname[NUMCOLS] = { - - /* treat a cleared input like a wrong password (color) */ - static const int failonclear = 1; -+ -+/* default message */ -+static const char * message = "Suckless: Software that sucks less."; -+ -+/* text color */ -+static const char * text_color = "#ffffff"; -+ -+/* text size (must be a valid size) */ -+static const char * font_name = "6x10"; -diff --git a/config.mk b/config.mk -index 74429ae..c4ccf66 100644 ---- a/config.mk -+++ b/config.mk -@@ -12,7 +12,7 @@ X11LIB = /usr/X11R6/lib - - # includes and libs - INCS = -I. -I/usr/include -I${X11INC} --LIBS = -L/usr/lib -lc -lcrypt -L${X11LIB} -lX11 -lXext -lXrandr -+LIBS = -L/usr/lib -lc -lcrypt -L${X11LIB} -lX11 -lXext -lXrandr -lXinerama - - # flags - CPPFLAGS = -DVERSION=\"${VERSION}\" -D_DEFAULT_SOURCE -DHAVE_SHADOW_H -diff --git a/slock.1 b/slock.1 -index 82cdcd6..946165f 100644 ---- a/slock.1 -+++ b/slock.1 -@@ -6,6 +6,8 @@ - .Sh SYNOPSIS - .Nm - .Op Fl v -+.Op Fl f -+.Op Fl m Ar message - .Op Ar cmd Op Ar arg ... - .Sh DESCRIPTION - .Nm -@@ -16,6 +18,11 @@ is executed after the screen has been locked. - .Bl -tag -width Ds - .It Fl v - Print version information to stdout and exit. -+.It Fl f -+List all valid X fonts and exit. -+.It Fl m Ar message -+Overrides default slock lock message. -+.TP - .El - .Sh SECURITY CONSIDERATIONS - To make sure a locked screen can not be bypassed by switching VTs -diff --git a/slock.c b/slock.c -index 5ae738c..b8b7fe4 100644 ---- a/slock.c -+++ b/slock.c -@@ -15,6 +15,7 @@ - #include <unistd.h> - #include <sys/types.h> - #include <X11/extensions/Xrandr.h> -+#include <X11/extensions/Xinerama.h> - #include <X11/keysym.h> - #include <X11/Xlib.h> - #include <X11/Xutil.h> -@@ -24,6 +25,9 @@ - - char *argv0; - -+/* global count to prevent repeated error messages */ -+int count_error = 0; -+ - enum { - INIT, - INPUT, -@@ -83,6 +87,132 @@ dontkillme(void) - } - #endif - -+static int -+readescapedint(const char *str, int *i) { -+ int n = 0; -+ if (str[*i]) -+ ++*i; -+ while(str[*i] && str[*i] != ';' && str[*i] != 'm') { -+ n = 10 * n + str[*i] - '0'; -+ ++*i; -+ } -+ return n; -+} -+ -+static void -+writemessage(Display *dpy, Window win, int screen) -+{ -+ int len, line_len, width, height, s_width, s_height, i, k, tab_size, r, g, b, escaped_int, curr_line_len; -+ XGCValues gr_values; -+ XFontStruct *fontinfo; -+ XColor color, dummy; -+ XineramaScreenInfo *xsi; -+ GC gc; -+ fontinfo = XLoadQueryFont(dpy, font_name); -+ -+ if (fontinfo == NULL) { -+ if (count_error == 0) { -+ fprintf(stderr, "slock: Unable to load font \"%s\"\n", font_name); -+ fprintf(stderr, "slock: Try listing fonts with 'slock -f'\n"); -+ count_error++; -+ } -+ return; -+ } -+ -+ tab_size = 8 * XTextWidth(fontinfo, " ", 1); -+ -+ XAllocNamedColor(dpy, DefaultColormap(dpy, screen), -+ text_color, &color, &dummy); -+ -+ gr_values.font = fontinfo->fid; -+ gr_values.foreground = color.pixel; -+ gc=XCreateGC(dpy,win,GCFont+GCForeground, &gr_values); -+ -+ /* To prevent "Uninitialized" warnings. */ -+ xsi = NULL; -+ -+ /* -+ * Start formatting and drawing text -+ */ -+ -+ len = strlen(message); -+ -+ /* Max max line length (cut at '\n') */ -+ line_len = curr_line_len = 0; -+ k = 0; -+ for (i = 0; i < len; i++) { -+ if (message[i] == '\n') { -+ curr_line_len = 0; -+ k++; -+ } else if (message[i] == 0x1b) { -+ while (i < len && message[i] != 'm') { -+ i++; -+ } -+ if (i == len) -+ die("slock: unclosed escape sequence\n"); -+ } else { -+ curr_line_len += XTextWidth(fontinfo, message + i, 1); -+ if (curr_line_len > line_len) -+ line_len = curr_line_len; -+ } -+ } -+ /* If there is only one line */ -+ if (line_len == 0) -+ line_len = len; -+ -+ if (XineramaIsActive(dpy)) { -+ xsi = XineramaQueryScreens(dpy, &i); -+ s_width = xsi[0].width; -+ s_height = xsi[0].height; -+ } else { -+ s_width = DisplayWidth(dpy, screen); -+ s_height = DisplayHeight(dpy, screen); -+ } -+ height = s_height*3/7 - (k*20)/3; -+ width = (s_width - line_len)/2; -+ -+ line_len = 0; -+ /* print the text while parsing 24 bit color ANSI escape codes*/ -+ for (i = k = 0; i < len; i++) { -+ switch (message[i]) { -+ case '\n': -+ line_len = 0; -+ while (message[i + 1] == '\t') { -+ line_len += tab_size; -+ i++; -+ } -+ k++; -+ break; -+ case 0x1b: -+ i++; -+ if (message[i] == '[') { -+ escaped_int = readescapedint(message, &i); -+ if (escaped_int == 39) -+ continue; -+ if (escaped_int != 38) -+ die("slock: unknown escape sequence%d\n", escaped_int); -+ if (readescapedint(message, &i) != 2) -+ die("slock: only 24 bit color supported\n"); -+ r = readescapedint(message, &i) & 0xff; -+ g = readescapedint(message, &i) & 0xff; -+ b = readescapedint(message, &i) & 0xff; -+ XSetForeground(dpy, gc, r << 16 | g << 8 | b); -+ } else -+ die("slock: unknown escape sequence\n"); -+ break; -+ default: -+ XDrawString(dpy, win, gc, width + line_len, height + 20 * k, message + i, 1); -+ line_len += XTextWidth(fontinfo, message + i, 1); -+ } -+ } -+ -+ /* xsi should not be NULL anyway if Xinerama is active, but to be safe */ -+ if (XineramaIsActive(dpy) && xsi != NULL) -+ XFree(xsi); -+} -+ -+ -+ - static const char * - gethash(void) - { -@@ -194,6 +324,7 @@ readpw(Display *dpy, struct xrandr *rr, struct lock **locks, int nscreens, - locks[screen]->win, - locks[screen]->colors[color]); - XClearWindow(dpy, locks[screen]->win); -+ writemessage(dpy, locks[screen]->win, screen); - } - oldc = color; - } -@@ -300,7 +431,7 @@ lockscreen(Display *dpy, struct xrandr *rr, int screen) - static void - usage(void) - { -- die("usage: slock [-v] [cmd [arg ...]]\n"); -+ die("usage: slock [-v] [-f] [-m message] [cmd [arg ...]]\n"); - } - - int -@@ -313,12 +444,25 @@ main(int argc, char **argv) { - gid_t dgid; - const char *hash; - Display *dpy; -- int s, nlocks, nscreens; -+ int i, s, nlocks, nscreens; -+ int count_fonts; -+ char **font_names; - - ARGBEGIN { - case 'v': - fprintf(stderr, "slock-"VERSION"\n"); - return 0; -+ case 'm': -+ message = EARGF(usage()); -+ break; -+ case 'f': -+ if (!(dpy = XOpenDisplay(NULL))) -+ die("slock: cannot open display\n"); -+ font_names = XListFonts(dpy, "*", 10000 /* list 10000 fonts*/, &count_fonts); -+ for (i=0; i<count_fonts; i++) { -+ fprintf(stderr, "%s\n", *(font_names+i)); -+ } -+ return 0; - default: - usage(); - } ARGEND -@@ -363,10 +507,12 @@ main(int argc, char **argv) { - if (!(locks = calloc(nscreens, sizeof(struct lock *)))) - die("slock: out of memory\n"); - for (nlocks = 0, s = 0; s < nscreens; s++) { -- if ((locks[s] = lockscreen(dpy, &rr, s)) != NULL) -+ if ((locks[s] = lockscreen(dpy, &rr, s)) != NULL) { -+ writemessage(dpy, locks[s]->win, s); - nlocks++; -- else -+ } else { - break; -+ } - } - XSync(dpy, 0); - --- -2.30.0 - diff --git a/.local/src2/slock/slock-pam_auth-20190207-35633d4.diff b/.local/src2/slock/slock-pam_auth-20190207-35633d4.diff deleted file mode 100644 index 136f4b57..00000000 --- a/.local/src2/slock/slock-pam_auth-20190207-35633d4.diff +++ /dev/null @@ -1,154 +0,0 @@ -diff --git a/config.def.h b/config.def.h -index 9855e21..19e7f62 100644 ---- a/config.def.h -+++ b/config.def.h -@@ -6,7 +6,11 @@ static const char *colorname[NUMCOLS] = { - [INIT] = "black", /* after initialization */ - [INPUT] = "#005577", /* during input */ - [FAILED] = "#CC3333", /* wrong password */ -+ [PAM] = "#9400D3", /* waiting for PAM */ - }; - - /* treat a cleared input like a wrong password (color) */ - static const int failonclear = 1; -+ -+/* PAM service that's used for authentication */ -+static const char* pam_service = "login"; -diff --git a/config.mk b/config.mk -index 74429ae..6e82074 100644 ---- a/config.mk -+++ b/config.mk -@@ -12,7 +12,7 @@ X11LIB = /usr/X11R6/lib - - # includes and libs - INCS = -I. -I/usr/include -I${X11INC} --LIBS = -L/usr/lib -lc -lcrypt -L${X11LIB} -lX11 -lXext -lXrandr -+LIBS = -L/usr/lib -lc -lcrypt -L${X11LIB} -lX11 -lXext -lXrandr -lpam - - # flags - CPPFLAGS = -DVERSION=\"${VERSION}\" -D_DEFAULT_SOURCE -DHAVE_SHADOW_H -diff --git a/slock.c b/slock.c -index 5ae738c..3a8da42 100644 ---- a/slock.c -+++ b/slock.c -@@ -18,16 +18,22 @@ - #include <X11/keysym.h> - #include <X11/Xlib.h> - #include <X11/Xutil.h> -+#include <security/pam_appl.h> -+#include <security/pam_misc.h> - - #include "arg.h" - #include "util.h" - - char *argv0; -+static int pam_conv(int num_msg, const struct pam_message **msg, struct pam_response **resp, void *appdata_ptr); -+struct pam_conv pamc = {pam_conv, NULL}; -+char passwd[256]; - - enum { - INIT, - INPUT, - FAILED, -+ PAM, - NUMCOLS - }; - -@@ -57,6 +63,31 @@ die(const char *errstr, ...) - exit(1); - } - -+static int -+pam_conv(int num_msg, const struct pam_message **msg, -+ struct pam_response **resp, void *appdata_ptr) -+{ -+ int retval = PAM_CONV_ERR; -+ for(int i=0; i<num_msg; i++) { -+ if (msg[i]->msg_style == PAM_PROMPT_ECHO_OFF && -+ strncmp(msg[i]->msg, "Password: ", 10) == 0) { -+ struct pam_response *resp_msg = malloc(sizeof(struct pam_response)); -+ if (!resp_msg) -+ die("malloc failed\n"); -+ char *password = malloc(strlen(passwd) + 1); -+ if (!password) -+ die("malloc failed\n"); -+ memset(password, 0, strlen(passwd) + 1); -+ strcpy(password, passwd); -+ resp_msg->resp_retcode = 0; -+ resp_msg->resp = password; -+ resp[i] = resp_msg; -+ retval = PAM_SUCCESS; -+ } -+ } -+ return retval; -+} -+ - #ifdef __linux__ - #include <fcntl.h> - #include <linux/oom.h> -@@ -121,6 +152,8 @@ gethash(void) - } - #endif /* HAVE_SHADOW_H */ - -+ /* pam, store user name */ -+ hash = pw->pw_name; - return hash; - } - -@@ -129,11 +162,12 @@ readpw(Display *dpy, struct xrandr *rr, struct lock **locks, int nscreens, - const char *hash) - { - XRRScreenChangeNotifyEvent *rre; -- char buf[32], passwd[256], *inputhash; -- int num, screen, running, failure, oldc; -+ char buf[32]; -+ int num, screen, running, failure, oldc, retval; - unsigned int len, color; - KeySym ksym; - XEvent ev; -+ pam_handle_t *pamh; - - len = 0; - running = 1; -@@ -160,10 +194,26 @@ readpw(Display *dpy, struct xrandr *rr, struct lock **locks, int nscreens, - case XK_Return: - passwd[len] = '\0'; - errno = 0; -- if (!(inputhash = crypt(passwd, hash))) -- fprintf(stderr, "slock: crypt: %s\n", strerror(errno)); -+ retval = pam_start(pam_service, hash, &pamc, &pamh); -+ color = PAM; -+ for (screen = 0; screen < nscreens; screen++) { -+ XSetWindowBackground(dpy, locks[screen]->win, locks[screen]->colors[color]); -+ XClearWindow(dpy, locks[screen]->win); -+ XRaiseWindow(dpy, locks[screen]->win); -+ } -+ XSync(dpy, False); -+ -+ if (retval == PAM_SUCCESS) -+ retval = pam_authenticate(pamh, 0); -+ if (retval == PAM_SUCCESS) -+ retval = pam_acct_mgmt(pamh, 0); -+ -+ running = 1; -+ if (retval == PAM_SUCCESS) -+ running = 0; - else -- running = !!strcmp(inputhash, hash); -+ fprintf(stderr, "slock: %s\n", pam_strerror(pamh, retval)); -+ pam_end(pamh, retval); - if (running) { - XBell(dpy, 100); - failure = 1; -@@ -339,10 +389,9 @@ main(int argc, char **argv) { - dontkillme(); - #endif - -+ /* the contents of hash are used to transport the current user name */ - hash = gethash(); - errno = 0; -- if (!crypt("", hash)) -- die("slock: crypt: %s\n", strerror(errno)); - - if (!(dpy = XOpenDisplay(NULL))) - die("slock: cannot open display\n"); diff --git a/.local/src2/slock/slock-xresources-20191126-53e56c7.diff b/.local/src2/slock/slock-xresources-20191126-53e56c7.diff deleted file mode 100644 index d49d39b0..00000000 --- a/.local/src2/slock/slock-xresources-20191126-53e56c7.diff +++ /dev/null @@ -1,158 +0,0 @@ -From 53e56c751b3f2be4154760788850c51dbffc0add Mon Sep 17 00:00:00 2001 -From: Arnas Udovicius <zordsdavini@gmail.com> -Date: Tue, 26 Nov 2019 16:16:15 +0200 -Subject: [PATCH] Read colors from Xresources - ---- - config.def.h | 14 +++++++++-- - slock.c | 68 ++++++++++++++++++++++++++++++++++++++++++++++++++++ - util.h | 3 +++ - 3 files changed, 83 insertions(+), 2 deletions(-) - -diff --git a/config.def.h b/config.def.h -index 6288856..bfc1ba0 100644 ---- a/config.def.h -+++ b/config.def.h -@@ -3,11 +3,21 @@ static const char *user = "nobody"; - static const char *group = "nogroup"; - - static const char *colorname[NUMCOLS] = { -- [INIT] = "black", /* after initialization */ -- [INPUT] = "#005577", /* during input */ -+ [INIT] = "black", /* after initialization */ -+ [INPUT] = "#005577", /* during input */ - [FAILED] = "#CC3333", /* wrong password */ - [CAPS] = "red", /* CapsLock on */ - }; - -+/* -+ * Xresources preferences to load at startup -+ */ -+ResourcePref resources[] = { -+ { "color0", STRING, &colorname[INIT] }, -+ { "color4", STRING, &colorname[INPUT] }, -+ { "color1", STRING, &colorname[FAILED] }, -+ { "color3", STRING, &colorname[CAPS] }, -+}; -+ - /* treat a cleared input like a wrong password (color) */ - static const int failonclear = 1; -diff --git a/slock.c b/slock.c -index 5f4fb7a..2395547 100644 ---- a/slock.c -+++ b/slock.c -@@ -6,6 +6,7 @@ - - #include <ctype.h> - #include <errno.h> -+#include <math.h> - #include <grp.h> - #include <pwd.h> - #include <stdarg.h> -@@ -19,6 +20,7 @@ - #include <X11/Xlib.h> - #include <X11/Xutil.h> - #include <X11/XKBlib.h> -+#include <X11/Xresource.h> - - #include "arg.h" - #include "util.h" -@@ -46,6 +48,19 @@ struct xrandr { - int errbase; - }; - -+/* Xresources preferences */ -+enum resource_type { -+ STRING = 0, -+ INTEGER = 1, -+ FLOAT = 2 -+}; -+ -+typedef struct { -+ char *name; -+ enum resource_type type; -+ void *dst; -+} ResourcePref; -+ - #include "config.h" - - static void -@@ -306,6 +321,57 @@ lockscreen(Display *dpy, struct xrandr *rr, int screen) - return NULL; - } - -+int -+resource_load(XrmDatabase db, char *name, enum resource_type rtype, void *dst) -+{ -+ char **sdst = dst; -+ int *idst = dst; -+ float *fdst = dst; -+ -+ char fullname[256]; -+ char fullclass[256]; -+ char *type; -+ XrmValue ret; -+ -+ snprintf(fullname, sizeof(fullname), "%s.%s", "slock", name); -+ snprintf(fullclass, sizeof(fullclass), "%s.%s", "Slock", name); -+ fullname[sizeof(fullname) - 1] = fullclass[sizeof(fullclass) - 1] = '\0'; -+ -+ XrmGetResource(db, fullname, fullclass, &type, &ret); -+ if (ret.addr == NULL || strncmp("String", type, 64)) -+ return 1; -+ -+ switch (rtype) { -+ case STRING: -+ *sdst = ret.addr; -+ break; -+ case INTEGER: -+ *idst = strtoul(ret.addr, NULL, 10); -+ break; -+ case FLOAT: -+ *fdst = strtof(ret.addr, NULL); -+ break; -+ } -+ return 0; -+} -+ -+void -+config_init(Display *dpy) -+{ -+ char *resm; -+ XrmDatabase db; -+ ResourcePref *p; -+ -+ XrmInitialize(); -+ resm = XResourceManagerString(dpy); -+ if (!resm) -+ return; -+ -+ db = XrmGetStringDatabase(resm); -+ for (p = resources; p < resources + LEN(resources); p++) -+ resource_load(db, p->name, p->type, p->dst); -+} -+ - static void - usage(void) - { -@@ -364,6 +430,8 @@ main(int argc, char **argv) { - if (setuid(duid) < 0) - die("slock: setuid: %s\n", strerror(errno)); - -+ config_init(dpy); -+ - /* check for Xrandr support */ - rr.active = XRRQueryExtension(dpy, &rr.evbase, &rr.errbase); - -diff --git a/util.h b/util.h -index 6f748b8..148dbc1 100644 ---- a/util.h -+++ b/util.h -@@ -1,2 +1,5 @@ -+/* macros */ -+#define LEN(a) (sizeof(a) / sizeof(a)[0]) -+ - #undef explicit_bzero - void explicit_bzero(void *, size_t); --- -2.24.0 diff --git a/.local/src2/slock/slock.1 b/.local/src2/slock/slock.1 deleted file mode 100644 index 946165fa..00000000 --- a/.local/src2/slock/slock.1 +++ /dev/null @@ -1,46 +0,0 @@ -.Dd 2016-08-23 -.Dt SLOCK 1 -.Sh NAME -.Nm slock -.Nd simple X screen locker -.Sh SYNOPSIS -.Nm -.Op Fl v -.Op Fl f -.Op Fl m Ar message -.Op Ar cmd Op Ar arg ... -.Sh DESCRIPTION -.Nm -is a simple X screen locker. If provided, -.Ar cmd Op Ar arg ... -is executed after the screen has been locked. -.Sh OPTIONS -.Bl -tag -width Ds -.It Fl v -Print version information to stdout and exit. -.It Fl f -List all valid X fonts and exit. -.It Fl m Ar message -Overrides default slock lock message. -.TP -.El -.Sh SECURITY CONSIDERATIONS -To make sure a locked screen can not be bypassed by switching VTs -or killing the X server with Ctrl+Alt+Backspace, it is recommended -to disable both in -.Xr xorg.conf 5 -for maximum security: -.Bd -literal -offset left -Section "ServerFlags" - Option "DontVTSwitch" "True" - Option "DontZap" "True" -EndSection -.Ed -.Sh EXAMPLES -$ -.Nm -/usr/sbin/s2ram -.Sh CUSTOMIZATION -.Nm -can be customized by creating a custom config.h from config.def.h and -(re)compiling the source code. This keeps it fast, secure and simple. diff --git a/.local/src2/slock/slock.c b/.local/src2/slock/slock.c deleted file mode 100644 index 04f32ebe..00000000 --- a/.local/src2/slock/slock.c +++ /dev/null @@ -1,579 +0,0 @@ -/* See LICENSE file for license details. */ -#define _XOPEN_SOURCE 500 -#if HAVE_SHADOW_H -#include <shadow.h> -#endif - -#include <ctype.h> -#include <errno.h> -#include <math.h> -#include <grp.h> -#include <pwd.h> -#include <stdarg.h> -#include <stdlib.h> -#include <stdio.h> -#include <string.h> -#include <unistd.h> -#include <sys/types.h> -#include <X11/extensions/Xrandr.h> -#include <X11/extensions/Xinerama.h> -#include <X11/keysym.h> -#include <X11/Xlib.h> -#include <X11/Xutil.h> -#include <X11/Xresource.h> -#include <security/pam_appl.h> -#include <security/pam_misc.h> - -#include "arg.h" -#include "util.h" - -char *argv0; -static int pam_conv(int num_msg, const struct pam_message **msg, struct pam_response **resp, void *appdata_ptr); -struct pam_conv pamc = {pam_conv, NULL}; -char passwd[256]; - -/* global count to prevent repeated error messages */ -int count_error = 0; - -enum { - INIT, - INPUT, - FAILED, - PAM, - NUMCOLS -}; - -struct lock { - int screen; - Window root, win; - Pixmap pmap; - unsigned long colors[NUMCOLS]; -}; - -struct xrandr { - int active; - int evbase; - int errbase; -}; - -/* Xresources preferences */ -enum resource_type { - STRING = 0, - INTEGER = 1, - FLOAT = 2 -}; - -typedef struct { - char *name; - enum resource_type type; - void *dst; -} ResourcePref; - -#include "config.h" - -static void -die(const char *errstr, ...) -{ - va_list ap; - - va_start(ap, errstr); - vfprintf(stderr, errstr, ap); - va_end(ap); - exit(1); -} - -static int -pam_conv(int num_msg, const struct pam_message **msg, - struct pam_response **resp, void *appdata_ptr) -{ - int retval = PAM_CONV_ERR; - for(int i=0; i<num_msg; i++) { - if (msg[i]->msg_style == PAM_PROMPT_ECHO_OFF && - strncmp(msg[i]->msg, "Password: ", 10) == 0) { - struct pam_response *resp_msg = malloc(sizeof(struct pam_response)); - if (!resp_msg) - die("malloc failed\n"); - char *password = malloc(strlen(passwd) + 1); - if (!password) - die("malloc failed\n"); - memset(password, 0, strlen(passwd) + 1); - strcpy(password, passwd); - resp_msg->resp_retcode = 0; - resp_msg->resp = password; - resp[i] = resp_msg; - retval = PAM_SUCCESS; - } - } - return retval; -} - -static int -readescapedint(const char *str, int *i) { - int n = 0; - if (str[*i]) - ++*i; - while(str[*i] && str[*i] != ';' && str[*i] != 'm') { - n = 10 * n + str[*i] - '0'; - ++*i; - } - return n; -} - -static void -writemessage(Display *dpy, Window win, int screen) -{ - int len, line_len, width, height, s_width, s_height, i, k, tab_size, r, g, b, escaped_int, curr_line_len; - XGCValues gr_values; - XFontStruct *fontinfo; - XColor color, dummy; - XineramaScreenInfo *xsi; - GC gc; - fontinfo = XLoadQueryFont(dpy, font_name); - - if (fontinfo == NULL) { - if (count_error == 0) { - fprintf(stderr, "slock: Unable to load font \"%s\"\n", font_name); - fprintf(stderr, "slock: Try listing fonts with 'slock -f'\n"); - count_error++; - } - return; - } - - tab_size = 8 * XTextWidth(fontinfo, " ", 1); - - XAllocNamedColor(dpy, DefaultColormap(dpy, screen), - text_color, &color, &dummy); - - gr_values.font = fontinfo->fid; - gr_values.foreground = color.pixel; - gc=XCreateGC(dpy,win,GCFont+GCForeground, &gr_values); - - /* To prevent "Uninitialized" warnings. */ - xsi = NULL; - - /* - * Start formatting and drawing text - */ - - len = strlen(message); - - /* Max max line length (cut at '\n') */ - line_len = curr_line_len = 0; - k = 0; - for (i = 0; i < len; i++) { - if (message[i] == '\n') { - curr_line_len = 0; - k++; - } else if (message[i] == 0x1b) { - while (i < len && message[i] != 'm') { - i++; - } - if (i == len) - die("slock: unclosed escape sequence\n"); - } else { - curr_line_len += XTextWidth(fontinfo, message + i, 1); - if (curr_line_len > line_len) - line_len = curr_line_len; - } - } - /* If there is only one line */ - if (line_len == 0) - line_len = len; - - if (XineramaIsActive(dpy)) { - xsi = XineramaQueryScreens(dpy, &i); - s_width = xsi[0].width; - s_height = xsi[0].height; - } else { - s_width = DisplayWidth(dpy, screen); - s_height = DisplayHeight(dpy, screen); - } - height = s_height*3/7 - (k*20)/3; - width = (s_width - line_len)/2; - - line_len = 0; - /* print the text while parsing 24 bit color ANSI escape codes*/ - for (i = k = 0; i < len; i++) { - switch (message[i]) { - case '\n': - line_len = 0; - while (message[i + 1] == '\t') { - line_len += tab_size; - i++; - } - k++; - break; - case 0x1b: - i++; - if (message[i] == '[') { - escaped_int = readescapedint(message, &i); - if (escaped_int == 39) - continue; - if (escaped_int != 38) - die("slock: unknown escape sequence%d\n", escaped_int); - if (readescapedint(message, &i) != 2) - die("slock: only 24 bit color supported\n"); - r = readescapedint(message, &i) & 0xff; - g = readescapedint(message, &i) & 0xff; - b = readescapedint(message, &i) & 0xff; - XSetForeground(dpy, gc, r << 16 | g << 8 | b); - } else - die("slock: unknown escape sequence\n"); - break; - default: - XDrawString(dpy, win, gc, width + line_len + xoffset, height + 20 * k + yoffset, message + i, 1); - line_len += XTextWidth(fontinfo, message + i, 1); - } - } - - /* xsi should not be NULL anyway if Xinerama is active, but to be safe */ - if (XineramaIsActive(dpy) && xsi != NULL) - XFree(xsi); -} - -static const char * -gethash(void) -{ - struct passwd *pw; - - /* Check if the current user has a password entry */ - errno = 0; - if (!(pw = getpwuid(getuid()))) { - if (errno) - die("slock: getpwuid: %s\n", strerror(errno)); - else - die("slock: cannot retrieve password entry\n"); - } - return pw->pw_name; -} - -static void -readpw(Display *dpy, struct xrandr *rr, struct lock **locks, int nscreens, - const char *hash) -{ - XRRScreenChangeNotifyEvent *rre; - char buf[32]; - int num, screen, running, failure, oldc, retval; - - unsigned int len, color; - KeySym ksym; - XEvent ev; - pam_handle_t *pamh; - - len = 0; - running = 1; - failure = 0; - oldc = INIT; - - while (running && !XNextEvent(dpy, &ev)) { - if (ev.type == KeyPress) { - explicit_bzero(&buf, sizeof(buf)); - num = XLookupString(&ev.xkey, buf, sizeof(buf), &ksym, 0); - if (IsKeypadKey(ksym)) { - if (ksym == XK_KP_Enter) - ksym = XK_Return; - else if (ksym >= XK_KP_0 && ksym <= XK_KP_9) - ksym = (ksym - XK_KP_0) + XK_0; - } - if (IsFunctionKey(ksym) || - IsKeypadKey(ksym) || - IsMiscFunctionKey(ksym) || - IsPFKey(ksym) || - IsPrivateKeypadKey(ksym)) - continue; - switch (ksym) { - case XK_Return: - passwd[len] = '\0'; - errno = 0; - retval = pam_start(pam_service, hash, &pamc, &pamh); - color = PAM; - for (screen = 0; screen < nscreens; screen++) { - XSetWindowBackground(dpy, locks[screen]->win, locks[screen]->colors[color]); - XClearWindow(dpy, locks[screen]->win); - XRaiseWindow(dpy, locks[screen]->win); - } - XSync(dpy, False); - - if (retval == PAM_SUCCESS) - retval = pam_authenticate(pamh, 0); - if (retval == PAM_SUCCESS) - retval = pam_acct_mgmt(pamh, 0); - - running = 1; - if (retval == PAM_SUCCESS) - running = 0; - else - fprintf(stderr, "slock: %s\n", pam_strerror(pamh, retval)); - pam_end(pamh, retval); - if (running) { - XBell(dpy, 100); - failure = 1; - } - explicit_bzero(&passwd, sizeof(passwd)); - len = 0; - break; - case XK_Escape: - explicit_bzero(&passwd, sizeof(passwd)); - len = 0; - break; - case XK_BackSpace: - if (len) - passwd[--len] = '\0'; - break; - default: - if (num && !iscntrl((int)buf[0]) && - (len + num < sizeof(passwd))) { - memcpy(passwd + len, buf, num); - len += num; - } - break; - } - color = len ? INPUT : ((failure || failonclear) ? FAILED : INIT); - if (running && oldc != color) { - for (screen = 0; screen < nscreens; screen++) { - XSetWindowBackground(dpy, - locks[screen]->win, - locks[screen]->colors[color]); - XClearWindow(dpy, locks[screen]->win); - writemessage(dpy, locks[screen]->win, screen); - } - oldc = color; - } - } else if (rr->active && ev.type == rr->evbase + RRScreenChangeNotify) { - rre = (XRRScreenChangeNotifyEvent*)&ev; - for (screen = 0; screen < nscreens; screen++) { - if (locks[screen]->win == rre->window) { - if (rre->rotation == RR_Rotate_90 || - rre->rotation == RR_Rotate_270) - XResizeWindow(dpy, locks[screen]->win, - rre->height, rre->width); - else - XResizeWindow(dpy, locks[screen]->win, - rre->width, rre->height); - XClearWindow(dpy, locks[screen]->win); - break; - } - } - } else { - for (screen = 0; screen < nscreens; screen++) - XRaiseWindow(dpy, locks[screen]->win); - } - } -} - -static struct lock * -lockscreen(Display *dpy, struct xrandr *rr, int screen) -{ - char curs[] = {0, 0, 0, 0, 0, 0, 0, 0}; - int i, ptgrab, kbgrab; - struct lock *lock; - XColor color, dummy; - XSetWindowAttributes wa; - Cursor invisible; - - if (dpy == NULL || screen < 0 || !(lock = malloc(sizeof(struct lock)))) - return NULL; - - lock->screen = screen; - lock->root = RootWindow(dpy, lock->screen); - - for (i = 0; i < NUMCOLS; i++) { - XAllocNamedColor(dpy, DefaultColormap(dpy, lock->screen), - colorname[i], &color, &dummy); - lock->colors[i] = color.pixel; - } - - /* init */ - wa.override_redirect = 1; - wa.background_pixel = lock->colors[INIT]; - lock->win = XCreateWindow(dpy, lock->root, 0, 0, - DisplayWidth(dpy, lock->screen), - DisplayHeight(dpy, lock->screen), - 0, DefaultDepth(dpy, lock->screen), - CopyFromParent, - DefaultVisual(dpy, lock->screen), - CWOverrideRedirect | CWBackPixel, &wa); - lock->pmap = XCreateBitmapFromData(dpy, lock->win, curs, 8, 8); - invisible = XCreatePixmapCursor(dpy, lock->pmap, lock->pmap, - &color, &color, 0, 0); - XDefineCursor(dpy, lock->win, invisible); - - /* Try to grab mouse pointer *and* keyboard for 600ms, else fail the lock */ - for (i = 0, ptgrab = kbgrab = -1; i < 6; i++) { - if (ptgrab != GrabSuccess) { - ptgrab = XGrabPointer(dpy, lock->root, False, - ButtonPressMask | ButtonReleaseMask | - PointerMotionMask, GrabModeAsync, - GrabModeAsync, None, invisible, CurrentTime); - } - if (kbgrab != GrabSuccess) { - kbgrab = XGrabKeyboard(dpy, lock->root, True, - GrabModeAsync, GrabModeAsync, CurrentTime); - } - - /* input is grabbed: we can lock the screen */ - if (ptgrab == GrabSuccess && kbgrab == GrabSuccess) { - XMapRaised(dpy, lock->win); - if (rr->active) - XRRSelectInput(dpy, lock->win, RRScreenChangeNotifyMask); - - XSelectInput(dpy, lock->root, SubstructureNotifyMask); - return lock; - } - - /* retry on AlreadyGrabbed but fail on other errors */ - if ((ptgrab != AlreadyGrabbed && ptgrab != GrabSuccess) || - (kbgrab != AlreadyGrabbed && kbgrab != GrabSuccess)) - break; - - usleep(100000); - } - - /* we couldn't grab all input: fail out */ - if (ptgrab != GrabSuccess) - fprintf(stderr, "slock: unable to grab mouse pointer for screen %d\n", - screen); - if (kbgrab != GrabSuccess) - fprintf(stderr, "slock: unable to grab keyboard for screen %d\n", - screen); - return NULL; -} - -int -resource_load(XrmDatabase db, char *name, enum resource_type rtype, void *dst) -{ - char **sdst = dst; - int *idst = dst; - float *fdst = dst; - - char fullname[256]; - char fullclass[256]; - char *type; - XrmValue ret; - - snprintf(fullname, sizeof(fullname), "%s.%s", "slock", name); - snprintf(fullclass, sizeof(fullclass), "%s.%s", "Slock", name); - fullname[sizeof(fullname) - 1] = fullclass[sizeof(fullclass) - 1] = '\0'; - - XrmGetResource(db, fullname, fullclass, &type, &ret); - if (ret.addr == NULL || strncmp("String", type, 64)) - return 1; - - switch (rtype) { - case STRING: - *sdst = ret.addr; - break; - case INTEGER: - *idst = strtoul(ret.addr, NULL, 10); - break; - case FLOAT: - *fdst = strtof(ret.addr, NULL); - break; - } - return 0; -} - -void -config_init(Display *dpy) -{ - char *resm; - XrmDatabase db; - ResourcePref *p; - - XrmInitialize(); - resm = XResourceManagerString(dpy); - if (!resm) - return; - - db = XrmGetStringDatabase(resm); - for (p = resources; p < resources + LEN(resources); p++) - resource_load(db, p->name, p->type, p->dst); -} - -static void -usage(void) -{ - die("usage: slock [-v] [-f] [-m message] [cmd [arg ...]]\n"); -} - -int -main(int argc, char **argv) { - struct xrandr rr; - struct lock **locks; - struct passwd *pwd; - struct group *grp; - uid_t duid; - gid_t dgid; - const char *hash; - Display *dpy; - int i, s, nlocks, nscreens; - int count_fonts; - char **font_names; - - ARGBEGIN { - case 'v': - fprintf(stderr, "slock-"VERSION"\n"); - return 0; - case 'm': - message = EARGF(usage()); - break; - case 'f': - if (!(dpy = XOpenDisplay(NULL))) - die("slock: cannot open display\n"); - font_names = XListFonts(dpy, "*", 10000 /* list 10000 fonts*/, &count_fonts); - for (i=0; i<count_fonts; i++) { - fprintf(stderr, "%s\n", *(font_names+i)); - } - return 0; - default: - usage(); - } ARGEND - - /* the contents of hash are used to transport the current user name */ - hash = gethash(); - errno = 0; - - if (!(dpy = XOpenDisplay(NULL))) - die("slock: cannot open display\n"); - - /* check for Xrandr support */ - rr.active = XRRQueryExtension(dpy, &rr.evbase, &rr.errbase); - - /* get number of screens in display "dpy" and blank them */ - nscreens = ScreenCount(dpy); - if (!(locks = calloc(nscreens, sizeof(struct lock *)))) - die("slock: out of memory\n"); - for (nlocks = 0, s = 0; s < nscreens; s++) { - if ((locks[s] = lockscreen(dpy, &rr, s)) != NULL) { - writemessage(dpy, locks[s]->win, s); - nlocks++; - } else { - break; - } - } - XSync(dpy, 0); - - /* did we manage to lock everything? */ - if (nlocks != nscreens) - return 1; - - /* run post-lock command */ - if (argc > 0) { - switch (fork()) { - case -1: - die("slock: fork failed: %s\n", strerror(errno)); - case 0: - if (close(ConnectionNumber(dpy)) < 0) - die("slock: close: %s\n", strerror(errno)); - execvp(argv[0], argv); - fprintf(stderr, "slock: execvp %s: %s\n", argv[0], strerror(errno)); - _exit(1); - } - } - - /* everything is now blank. Wait for the correct password */ - readpw(dpy, &rr, locks, nscreens, hash); - - return 0; -} - diff --git a/.local/src2/slock/slock.o b/.local/src2/slock/slock.o deleted file mode 100644 index 771d94b4..00000000 Binary files a/.local/src2/slock/slock.o and /dev/null differ diff --git a/.local/src2/slock/util.h b/.local/src2/slock/util.h deleted file mode 100644 index 6b2d31db..00000000 --- a/.local/src2/slock/util.h +++ /dev/null @@ -1,6 +0,0 @@ -/* macros */ -#define LEN(a) (sizeof(a) / sizeof(a)[0]) - -#undef explicit_bzero -void explicit_bzero(void *, size_t); - diff --git a/dwm b/dwm new file mode 160000 index 00000000..20484bf4 --- /dev/null +++ b/dwm @@ -0,0 +1 @@ +Subproject commit 20484bf4c8f136fa5a30e8bd5b4cc84ae5b2300c