sowm

An itsy bitsy floating window manager (220~ sloc!).
git clone git://mfeller.io/sowm.git
Log | Files | Refs | README | LICENSE

commit d46b541050b44fc664eace6f695511cbda3b581c
parent 56bdacaa8477ab67312f2eab275dec9ad26b0d88
Author: Mark Feller <mfeller@recurly.com>
Date:   Mon, 13 Apr 2020 20:29:57 -0600

personal customizations

Signed-off-by: Mark Feller <mfeller@recurly.com>

Diffstat:
D.gitignore | 3---
RLICENSE.md -> LICENSE | 0
MMakefile | 15+++++++++------
AREADME | 50++++++++++++++++++++++++++++++++++++++++++++++++++
DREADME.md | 98-------------------------------------------------------------------------------
Mconfig.def.h | 37+++++++++++++++++++------------------
Asowm.1 | 71+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Msowm.c | 20+++++++++++++++++++-
Msowm.h | 1+
9 files changed, 169 insertions(+), 126 deletions(-)

diff --git a/.gitignore b/.gitignore @@ -1,3 +0,0 @@ -sowm -sowm.o -config.h diff --git a/LICENSE.md b/LICENSE diff --git a/Makefile b/Makefile @@ -1,8 +1,9 @@ -CFLAGS += -std=c99 -Wall -Wextra -pedantic -Wold-style-declaration -CFLAGS += -Wmissing-prototypes -Wno-unused-parameter -PREFIX ?= /usr -BINDIR ?= $(PREFIX)/bin -CC ?= gcc +CFLAGS += -std=c99 -Wall -Wextra -pedantic -Wold-style-declaration +CFLAGS += -Wmissing-prototypes -Wno-unused-parameter +PREFIX ?= /usr/local +MANPREFIX ?= ${PREFIX}/share/man +BINDIR ?= $(PREFIX)/bin +CC ?= gcc all: config.h sowm @@ -14,9 +15,11 @@ sowm: install: all install -Dm755 sowm $(DESTDIR)$(BINDIR)/sowm + install -Dm644 sowm $(DESTDIR)$(MANPREFIX)/man1/sowm.1 uninstall: - rm -f $(DESTDIR)$(BINDIR)/sowm + rm -f $(DESTDIR)$(BINDIR)/sowm \ + $(DESTDIR)$(MANPREFIX)/man1/sowm.1 clean: rm -f sowm *.o diff --git a/README b/README @@ -0,0 +1,50 @@ +sowm (*Simple Opinionated Window Manager*) +========================================== + +An itsy bitsy floating window manager (*220~ sloc / 24kb compiled!*). + +- Floating only. +- Fullscreen toggle. +- Window centering. +- Mix of mouse and keyboard workflow. +- Focus with cursor. +- Alt-Tab window focusing. +- All windows die on exit. +- No window borders. +- No ICCCM ttps://web.archive.org/web/20190617214524/https://raw.githubusercontent.com/kfish/xsel/1a1c5edf0dc129055f7764c666da2dd468df6016/rant.txt +- No EWMH. +- etc etc etc + +Dependencies +------------ + +- `xlib` (*usually `libX11`*). + + +Installation +------------ + +1) Copy `config.def.h` to `config.h` and modify it to suit your needs. +2) Run `make` to build `sowm`. +3) Copy it to your path or run `make install`. + - `DESTDIR` and `PREFIX` are supported. +4) (Optional) Apply patch with `git apply patches/patch-name` + - In case of applying multiple patches, it has to be done **manually**. + +If you are using GDM, save the following to `/usr/share/xsessions/sowm.desktop`. It is still recommended to start `sowm` from `.xinitrc` or through +[your own xinit implementation](https://github.com/dylanaraps/bin/blob/dfd9a9ff4555efb1cc966f8473339f37d13698ba/x). + +Thanks +------ + +- 2bwm +- SmallWM +- berry +- catwm +- dminiwm +- dwm +- monsterwm +- openbox +- possumwm +- swm +- tinywm diff --git a/README.md b/README.md @@ -1,98 +0,0 @@ -# sowm (*Simple Opinionated Window Manager*) - -<a href="https://user-images.githubusercontent.com/6799467/66687576-9747c200-ec72-11e9-947d-5b96753eab03.jpg"><img src="https://user-images.githubusercontent.com/6799467/66687576-9747c200-ec72-11e9-947d-5b96753eab03.jpg" width="43%" align="right"></a> - -An itsy bitsy floating window manager (*220~ sloc / 24kb compiled!*). - -- Floating only. -- Fullscreen toggle. -- Window centering. -- Mix of mouse and keyboard workflow. -- Focus with cursor. -- Rounded corners (*[through patch](https://github.com/dylanaraps/sowm/pull/58)*) -- Titlebars (*[through patch](https://github.com/dylanaraps/sowm/pull/57)*) - -<a href="https://user-images.githubusercontent.com/6799467/66687814-8cd9f800-ec73-11e9-97b8-6ae77876bd1b.jpg"><img src="https://user-images.githubusercontent.com/6799467/66687814-8cd9f800-ec73-11e9-97b8-6ae77876bd1b.jpg" width="43%" align="right"></a> - -- Alt-Tab window focusing. -- All windows die on exit. -- No window borders. -- [No ICCCM](https://web.archive.org/web/20190617214524/https://raw.githubusercontent.com/kfish/xsel/1a1c5edf0dc129055f7764c666da2dd468df6016/rant.txt). -- No EWMH. -- etc etc etc - - -<br> - -Patches available here: https://github.com/dylanaraps/sowm/pulls - -## Default Keybindings - -**Window Management** - -| combo | action | -| -------------------------- | -----------------------| -| `Mouse` | focus under cursor | -| `MOD4` + `Left Mouse` | move window | -| `MOD4` + `Right Mouse` | resize window | -| `MOD4` + `f` | maximize toggle | -| `MOD4` + `c` | center window | -| `MOD4` + `q` | kill window | -| `MOD4` + `1-9` | desktop swap | -| `MOD4` + `Shift` +`1-9` | send window to desktop | -| `MOD1` + `TAB` (*alt-tab*) | focus cycle | - -**Programs** - -| combo | action | program | -| ------------------------ | ---------------- | -------------- | -| `MOD4` + `Return` | terminal | `st` | -| `MOD4` + `d` | dmenu | `dmenu_run` | -| `MOD4` + `p` | scrot | `scr` | -| `MOD4` + `w` | wallpaper cycler | `bud` | -| `XF86_AudioLowerVolume` | volume down | `amixer` | -| `XF86_AudioRaiseVolume` | volume up | `amixer` | -| `XF86_AudioMute` | volume toggle | `amixer` | -| `XF86_MonBrightnessUp` | brightness up | `bri` | -| `XF86_MonBrightnessDown` | brightness down | `bri` | - - -## Dependencies - -- `xlib` (*usually `libX11`*). - - -## Installation - -1) Copy `config.def.h` to `config.h` and modify it to suit your needs. -2) Run `make` to build `sowm`. -3) Copy it to your path or run `make install`. - - `DESTDIR` and `PREFIX` are supported. -4) (Optional) Apply patch with `git apply patches/patch-name` - - In case of applying multiple patches, it has to be done **manually**. - -If you are using GDM, save the following to `/usr/share/xsessions/sowm.desktop`. It is still recommended to start `sowm` from `.xinitrc` or through -[your own xinit implementation](https://github.com/dylanaraps/bin/blob/dfd9a9ff4555efb1cc966f8473339f37d13698ba/x). - -``` -[Desktop Entry] -Name=sowm -Comment=This session runs sowm as desktop manager -Exec=sowm -Type=Application -``` - - -## Thanks - -- 2bwm -- SmallWM -- berry -- catwm -- dminiwm -- dwm -- monsterwm -- openbox -- possumwm -- swm -- tinywm diff --git a/config.def.h b/config.def.h @@ -1,36 +1,37 @@ #ifndef CONFIG_H #define CONFIG_H +#define BorderWidth 15 #define MOD Mod4Mask -const char* menu[] = {"dmenu_run", 0}; -const char* term[] = {"st", 0}; -const char* scrot[] = {"scr", 0}; -const char* briup[] = {"bri", "10", "+", 0}; -const char* bridown[] = {"bri", "10", "-", 0}; -const char* voldown[] = {"amixer", "sset", "Master", "5%-", 0}; -const char* volup[] = {"amixer", "sset", "Master", "5%+", 0}; -const char* volmute[] = {"amixer", "sset", "Master", "toggle", 0}; -const char* colors[] = {"bud", "/home/goldie/Pictures/Wallpapers", 0}; +const char* menu[] = {"dmenu_run", 0}; +const char* term[] = {"st", 0}; +const char* surf[] = {"tabbed", "-c", "surf", "-e", 0}; +const char* music[] = {"popup", "ncmpcpp", 0}; +const char* audio[] = {"popup", "pulsemixer", 0}; static struct key keys[] = { {MOD, XK_q, win_kill, {0}}, {MOD, XK_c, win_center, {0}}, {MOD, XK_f, win_fs, {0}}, + {MOD, XK_k, win_move, {.com = (const char*[]){"move", "n"}, .i = 40}}, + {MOD, XK_j, win_move, {.com = (const char*[]){"move", "s"}, .i = 40}}, + {MOD, XK_l, win_move, {.com = (const char*[]){"move", "e"}, .i = 40}}, + {MOD, XK_h, win_move, {.com = (const char*[]){"move", "w"}, .i = 40}}, + + {MOD|ShiftMask, XK_k, win_move, {.com = (const char*[]){"resize", "n"}, .i = 40}}, + {MOD|ShiftMask, XK_j, win_move, {.com = (const char*[]){"resize", "s"}, .i = 40}}, + {MOD|ShiftMask, XK_l, win_move, {.com = (const char*[]){"resize", "e"}, .i = 40}}, + {MOD|ShiftMask, XK_h, win_move, {.com = (const char*[]){"resize", "w"}, .i = 40}}, + {Mod1Mask, XK_Tab, win_next, {0}}, {Mod1Mask|ShiftMask, XK_Tab, win_prev, {0}}, {MOD, XK_d, run, {.com = menu}}, - {MOD, XK_w, run, {.com = colors}}, - {MOD, XK_p, run, {.com = scrot}}, - {MOD, XK_Return, run, {.com = term}}, - - {0, XF86XK_AudioLowerVolume, run, {.com = voldown}}, - {0, XF86XK_AudioRaiseVolume, run, {.com = volup}}, - {0, XF86XK_AudioMute, run, {.com = volmute}}, - {0, XF86XK_MonBrightnessUp, run, {.com = briup}}, - {0, XF86XK_MonBrightnessDown, run, {.com = bridown}}, + {MOD, XK_m, run, {.com = music}}, + {MOD, XK_w, run, {.com = surf}}, + {MOD, XK_p, run, {.com = audio}}, {MOD, XK_1, ws_go, {.i = 1}}, {MOD|ShiftMask, XK_1, win_to_ws, {.i = 1}}, diff --git a/sowm.1 b/sowm.1 @@ -0,0 +1,71 @@ +.TH SOWM 1 sowm\-VERSION +.SH NAME +sowm \- Simple Opinionated Window Manager +.SH SYNOPSIS +.B dwm +.RB [ \-v ] +.SH DESCRIPTION +sowm is an itsy bitsy floating window manager (220~ sloc / 24kb compiled!). +.SH USAGE +.SS Keyboard commands +.TP +.B Mod4\-Return +Start +.BR st(1). +.TP +.B Mod4\-d +Spawn +.BR dmenu(1) +for launching other programs. +.TP +.B Mod4\m, +lauchs ncmpcpp. +.TP +.B Mod4\p. +lauches pulsemixer. +.TP +.B Mod4\-h +move focused window to the left. +.TP +.B Mod4\-j +move focused window to down. +.TP +.B Mod4\-k +move focused window to up. +.TP +.B Mod4\-l +move focused window to the right. +.TP +.B Mod4\-Shift\-h +shrink the window from the right. +.TP +.B Mod4\-Shift\-j +shrink the window from the top. +.TP +.B Mod4\-Shift\-k +grow the window from the top. +.TP +.B Mod4\-Shift\-l +grow the window from the right. +.TP +.B Mod4\-Tab +Send focused window to next screen, if any. +.TP +.B Mod4\-Shift\-Tab +Send focused window to previous screen, if any. +.TP +.B Mod4\-Shift\-q +Kill focused window +.SS Mouse commands +.TP +.B Mod4\-Button1 +Drag window. +.TP +.B Mod1\-Button2 +Resize window. +.SH CUSTOMIZATION +sowm is customized by creating a custom config.h and (re)compiling the source +code. +.SH SEE ALSO +.BR dmenu (1), +.BR st (1) diff --git a/sowm.c b/sowm.c @@ -36,6 +36,19 @@ void win_focus(client *c) { XSetInputFocus(d, cur->w, RevertToParent, CurrentTime); } +void win_move(const Arg arg) { + int r = arg.com[0][0] == 'r'; + char m = arg.com[1][0]; + + win_size(cur->w, &wx, &wy, &ww, &wh); + + XMoveResizeWindow(d, cur->w, \ + wx + (r ? 0 : m == 'e' ? arg.i : m == 'w' ? -arg.i : 0), + wy + (r ? 0 : m == 'n' ? -arg.i : m == 's' ? arg.i : 0), + MAX(10, ww + (r ? m == 'e' ? arg.i : m == 'w' ? -arg.i : 0 : 0)), + MAX(10, wh + (r ? m == 'n' ? -arg.i : m == 's' ? arg.i : 0 : 0))); +} + void notify_destroy(XEvent *e) { win_del(e->xdestroywindow.window); @@ -87,12 +100,17 @@ void button_release(XEvent *e) { void win_add(Window w) { client *c; + XWindowChanges wc; if (!(c = (client *) calloc(1, sizeof(client)))) exit(1); c->w = w; + wc.border_width = BorderWidth; + XConfigureWindow(d, w, (1<<4), &wc); + XSetWindowBorder(d, w, 240 + (240<<8) + (240<<16)); + if (list) { list->prev->next = c; c->prev = list->prev; @@ -138,7 +156,7 @@ void win_fs(const Arg arg) { if ((cur->f = cur->f ? 0 : 1)) { win_size(cur->w, &cur->wx, &cur->wy, &cur->ww, &cur->wh); - XMoveResizeWindow(d, cur->w, 0, 0, sw, sh); + XMoveResizeWindow(d, cur->w, -BorderWidth, -BorderWidth, sw, sh); } else { XMoveResizeWindow(d, cur->w, cur->wx, cur->wy, cur->ww, cur->wh); diff --git a/sowm.h b/sowm.h @@ -51,6 +51,7 @@ void win_focus(client *c); void win_kill(const Arg arg); void win_prev(const Arg arg); void win_next(const Arg arg); +void win_move(const Arg arg); void win_to_ws(const Arg arg); void ws_go(const Arg arg);