mirror of
https://github.com/dylanaraps/sowm.git
synced 2025-08-04 06:01:58 -07:00
Compare commits
1 Commits
Author | SHA1 | Date | |
---|---|---|---|
|
7e731ccb4c |
8
Makefile
8
Makefile
@@ -4,13 +4,13 @@ PREFIX ?= /usr
|
|||||||
BINDIR ?= $(PREFIX)/bin
|
BINDIR ?= $(PREFIX)/bin
|
||||||
CC ?= gcc
|
CC ?= gcc
|
||||||
|
|
||||||
all: sowm
|
all: config.h sowm
|
||||||
|
|
||||||
config.h:
|
config.h:
|
||||||
cp config.def.h config.h
|
cp config.def.h config.h
|
||||||
|
|
||||||
sowm: sowm.c sowm.h config.h Makefile
|
sowm:
|
||||||
$(CC) -O3 $(CFLAGS) -o $@ $< -lX11 $(LDFLAGS)
|
$(CC) -O3 $(CFLAGS) -lX11 $(LDFLAGS) -o sowm sowm.c
|
||||||
|
|
||||||
install: all
|
install: all
|
||||||
install -Dm755 sowm $(DESTDIR)$(BINDIR)/sowm
|
install -Dm755 sowm $(DESTDIR)$(BINDIR)/sowm
|
||||||
@@ -20,5 +20,3 @@ uninstall:
|
|||||||
|
|
||||||
clean:
|
clean:
|
||||||
rm -f sowm *.o
|
rm -f sowm *.o
|
||||||
|
|
||||||
.PHONY: all install uninstall clean
|
|
||||||
|
41
README.md
41
README.md
@@ -1,8 +1,8 @@
|
|||||||
# sowm (*~~Simple~~ Shitty Opinionated Window Manager*)
|
# 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>
|
<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!*).
|
An itsy bitsy floating window manager (*220~ sloc / 24kb compiled!*).
|
||||||
|
|
||||||
- Floating only.
|
- Floating only.
|
||||||
- Fullscreen toggle.
|
- Fullscreen toggle.
|
||||||
@@ -38,8 +38,8 @@ Patches available here: https://github.com/dylanaraps/sowm/pulls
|
|||||||
| `MOD4` + `f` | maximize toggle |
|
| `MOD4` + `f` | maximize toggle |
|
||||||
| `MOD4` + `c` | center window |
|
| `MOD4` + `c` | center window |
|
||||||
| `MOD4` + `q` | kill window |
|
| `MOD4` + `q` | kill window |
|
||||||
| `MOD4` + `1-6` | desktop swap |
|
| `MOD4` + `1-9` | desktop swap |
|
||||||
| `MOD4` + `Shift` +`1-6` | send window to desktop |
|
| `MOD4` + `Shift` +`1-9` | send window to desktop |
|
||||||
| `MOD1` + `TAB` (*alt-tab*) | focus cycle |
|
| `MOD1` + `TAB` (*alt-tab*) | focus cycle |
|
||||||
|
|
||||||
**Programs**
|
**Programs**
|
||||||
@@ -71,28 +71,17 @@ Patches available here: https://github.com/dylanaraps/sowm/pulls
|
|||||||
4) (Optional) Apply patch with `git apply patches/patch-name`
|
4) (Optional) Apply patch with `git apply patches/patch-name`
|
||||||
- In case of applying multiple patches, it has to be done **manually**.
|
- 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
|
## Thanks
|
||||||
|
|
||||||
- [2bwm](https://github.com/venam/2bwm)
|
- 2bwm
|
||||||
- [SmallWM](https://github.com/adamnew123456/SmallWM)
|
- SmallWM
|
||||||
- [berry](https://github.com/JLErvin/berry)
|
- berry
|
||||||
- [catwm](https://github.com/pyknite/catwm)
|
- catwm
|
||||||
- [dminiwm](https://github.com/moetunes/dminiwm)
|
- dminiwm
|
||||||
- [dwm](https://dwm.suckless.org)
|
- dwm
|
||||||
- [monsterwm](https://github.com/c00kiemon5ter/monsterwm)
|
- monsterwm
|
||||||
- [openbox](https://github.com/danakj/openbox)
|
- openbox
|
||||||
- [possum-wm](https://github.com/duckinator/possum-wm)
|
- possumwm
|
||||||
- [swm](https://github.com/dcat/swm)
|
- swm
|
||||||
- [tinywm](http://incise.org/tinywm.html)
|
- tinywm
|
||||||
|
@@ -2,6 +2,8 @@
|
|||||||
#define CONFIG_H
|
#define CONFIG_H
|
||||||
|
|
||||||
#define MOD Mod4Mask
|
#define MOD Mod4Mask
|
||||||
|
#define TH 90
|
||||||
|
#define TC 255 + (255<<8) + (255<<16)
|
||||||
|
|
||||||
const char* menu[] = {"dmenu_run", 0};
|
const char* menu[] = {"dmenu_run", 0};
|
||||||
const char* term[] = {"st", 0};
|
const char* term[] = {"st", 0};
|
||||||
|
73
sowm.c
73
sowm.c
@@ -1,12 +1,14 @@
|
|||||||
// sowm - An itsy bitsy floating window manager.
|
// sowm - An itsy bitsy floating window manager.
|
||||||
|
|
||||||
#include <X11/Xlib.h>
|
#include <X11/Xlib.h>
|
||||||
|
#include <X11/Xutil.h>
|
||||||
#include <X11/XF86keysym.h>
|
#include <X11/XF86keysym.h>
|
||||||
#include <X11/keysym.h>
|
#include <X11/keysym.h>
|
||||||
#include <X11/XKBlib.h>
|
#include <X11/XKBlib.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <signal.h>
|
#include <signal.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
|
#include <string.h>
|
||||||
|
|
||||||
#include "sowm.h"
|
#include "sowm.h"
|
||||||
|
|
||||||
@@ -24,7 +26,6 @@ static void (*events[LASTEvent])(XEvent *e) = {
|
|||||||
[ConfigureRequest] = configure_request,
|
[ConfigureRequest] = configure_request,
|
||||||
[KeyPress] = key_press,
|
[KeyPress] = key_press,
|
||||||
[MapRequest] = map_request,
|
[MapRequest] = map_request,
|
||||||
[MappingNotify] = mapping_notify,
|
|
||||||
[DestroyNotify] = notify_destroy,
|
[DestroyNotify] = notify_destroy,
|
||||||
[EnterNotify] = notify_enter,
|
[EnterNotify] = notify_enter,
|
||||||
[MotionNotify] = notify_motion
|
[MotionNotify] = notify_motion
|
||||||
@@ -32,6 +33,27 @@ static void (*events[LASTEvent])(XEvent *e) = {
|
|||||||
|
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
|
|
||||||
|
void title_add(client *c) {
|
||||||
|
if (c->t) return;
|
||||||
|
|
||||||
|
XClassHint cl;
|
||||||
|
XGetClassHint(d, c->w, &cl);
|
||||||
|
|
||||||
|
if (!strcmp(cl.res_name, "no-title")) return;
|
||||||
|
|
||||||
|
win_size(c->w, &wx, &wy, &ww, &wh);
|
||||||
|
c->t = XCreateSimpleWindow(d, root, wx, wy - TH, ww, TH, 0, TC, TC);
|
||||||
|
XMapWindow(d, c->t);
|
||||||
|
}
|
||||||
|
|
||||||
|
void title_del(client *c) {
|
||||||
|
if (!c->t) return;
|
||||||
|
|
||||||
|
XUnmapWindow(d, c->t);
|
||||||
|
XDestroyWindow(d, c->t);
|
||||||
|
c->t = 0;
|
||||||
|
}
|
||||||
|
|
||||||
void win_focus(client *c) {
|
void win_focus(client *c) {
|
||||||
cur = c;
|
cur = c;
|
||||||
XSetInputFocus(d, cur->w, RevertToParent, CurrentTime);
|
XSetInputFocus(d, cur->w, RevertToParent, CurrentTime);
|
||||||
@@ -52,6 +74,11 @@ void notify_enter(XEvent *e) {
|
|||||||
void notify_motion(XEvent *e) {
|
void notify_motion(XEvent *e) {
|
||||||
if (!mouse.subwindow || cur->f) return;
|
if (!mouse.subwindow || cur->f) return;
|
||||||
|
|
||||||
|
if (mouse.subwindow == cur->t) {
|
||||||
|
mouse.subwindow = cur->w;
|
||||||
|
win_size(cur->w, &wx, &wy, &ww, &wh);
|
||||||
|
}
|
||||||
|
|
||||||
while(XCheckTypedEvent(d, MotionNotify, e));
|
while(XCheckTypedEvent(d, MotionNotify, e));
|
||||||
|
|
||||||
int xd = e->xbutton.x_root - mouse.x_root;
|
int xd = e->xbutton.x_root - mouse.x_root;
|
||||||
@@ -62,6 +89,11 @@ void notify_motion(XEvent *e) {
|
|||||||
wy + (mouse.button == 1 ? yd : 0),
|
wy + (mouse.button == 1 ? yd : 0),
|
||||||
MAX(1, ww + (mouse.button == 3 ? xd : 0)),
|
MAX(1, ww + (mouse.button == 3 ? xd : 0)),
|
||||||
MAX(1, wh + (mouse.button == 3 ? yd : 0)));
|
MAX(1, wh + (mouse.button == 3 ? yd : 0)));
|
||||||
|
|
||||||
|
if (cur->t) XMoveResizeWindow(d, cur->t,
|
||||||
|
wx + (mouse.button == 1 ? xd : 0),
|
||||||
|
wy + (mouse.button == 1 ? yd : 0) - TH,
|
||||||
|
MAX(1, ww + (mouse.button == 3 ? xd : 0)), TH);
|
||||||
}
|
}
|
||||||
|
|
||||||
void key_press(XEvent *e) {
|
void key_press(XEvent *e) {
|
||||||
@@ -118,6 +150,7 @@ void win_del(Window w) {
|
|||||||
if (x->next) x->next->prev = x->prev;
|
if (x->next) x->next->prev = x->prev;
|
||||||
if (x->prev) x->prev->next = x->next;
|
if (x->prev) x->prev->next = x->next;
|
||||||
|
|
||||||
|
title_del(x);
|
||||||
free(x);
|
free(x);
|
||||||
ws_save(ws);
|
ws_save(ws);
|
||||||
}
|
}
|
||||||
@@ -131,6 +164,8 @@ void win_center(const Arg arg) {
|
|||||||
|
|
||||||
win_size(cur->w, &(int){0}, &(int){0}, &ww, &wh);
|
win_size(cur->w, &(int){0}, &(int){0}, &ww, &wh);
|
||||||
XMoveWindow(d, cur->w, (sw - ww) / 2, (sh - wh) / 2);
|
XMoveWindow(d, cur->w, (sw - ww) / 2, (sh - wh) / 2);
|
||||||
|
|
||||||
|
if (cur->t) XMoveWindow(d, cur->t, (sw - ww) / 2, (sh - wh - TH * 2) / 2);
|
||||||
}
|
}
|
||||||
|
|
||||||
void win_fs(const Arg arg) {
|
void win_fs(const Arg arg) {
|
||||||
@@ -139,9 +174,12 @@ void win_fs(const Arg arg) {
|
|||||||
if ((cur->f = cur->f ? 0 : 1)) {
|
if ((cur->f = cur->f ? 0 : 1)) {
|
||||||
win_size(cur->w, &cur->wx, &cur->wy, &cur->ww, &cur->wh);
|
win_size(cur->w, &cur->wx, &cur->wy, &cur->ww, &cur->wh);
|
||||||
XMoveResizeWindow(d, cur->w, 0, 0, sw, sh);
|
XMoveResizeWindow(d, cur->w, 0, 0, sw, sh);
|
||||||
|
XRaiseWindow(d, cur->w);
|
||||||
|
title_del(cur);
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
XMoveResizeWindow(d, cur->w, cur->wx, cur->wy, cur->ww, cur->wh);
|
XMoveResizeWindow(d, cur->w, cur->wx, cur->wy, cur->ww, cur->wh);
|
||||||
|
title_add(cur);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -157,6 +195,7 @@ void win_to_ws(const Arg arg) {
|
|||||||
ws_sel(tmp);
|
ws_sel(tmp);
|
||||||
win_del(cur->w);
|
win_del(cur->w);
|
||||||
XUnmapWindow(d, cur->w);
|
XUnmapWindow(d, cur->w);
|
||||||
|
title_del(cur);
|
||||||
ws_save(tmp);
|
ws_save(tmp);
|
||||||
|
|
||||||
if (list) win_focus(list);
|
if (list) win_focus(list);
|
||||||
@@ -166,6 +205,10 @@ void win_prev(const Arg arg) {
|
|||||||
if (!cur) return;
|
if (!cur) return;
|
||||||
|
|
||||||
XRaiseWindow(d, cur->prev->w);
|
XRaiseWindow(d, cur->prev->w);
|
||||||
|
|
||||||
|
if (cur->prev->t)
|
||||||
|
XRaiseWindow(d, cur->prev->t);
|
||||||
|
|
||||||
win_focus(cur->prev);
|
win_focus(cur->prev);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -173,6 +216,10 @@ void win_next(const Arg arg) {
|
|||||||
if (!cur) return;
|
if (!cur) return;
|
||||||
|
|
||||||
XRaiseWindow(d, cur->next->w);
|
XRaiseWindow(d, cur->next->w);
|
||||||
|
|
||||||
|
if (cur->next->t)
|
||||||
|
XRaiseWindow(d, cur->next->t);
|
||||||
|
|
||||||
win_focus(cur->next);
|
win_focus(cur->next);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -184,11 +231,17 @@ void ws_go(const Arg arg) {
|
|||||||
ws_save(ws);
|
ws_save(ws);
|
||||||
ws_sel(arg.i);
|
ws_sel(arg.i);
|
||||||
|
|
||||||
for win XMapWindow(d, c->w);
|
for win {
|
||||||
|
XMapWindow(d, c->w);
|
||||||
|
title_add(c);
|
||||||
|
}
|
||||||
|
|
||||||
ws_sel(tmp);
|
ws_sel(tmp);
|
||||||
|
|
||||||
for win XUnmapWindow(d, c->w);
|
for win {
|
||||||
|
XUnmapWindow(d, c->w);
|
||||||
|
title_del(c);
|
||||||
|
}
|
||||||
|
|
||||||
ws_sel(arg.i);
|
ws_sel(arg.i);
|
||||||
|
|
||||||
@@ -220,15 +273,7 @@ void map_request(XEvent *e) {
|
|||||||
|
|
||||||
XMapWindow(d, w);
|
XMapWindow(d, w);
|
||||||
win_focus(list->prev);
|
win_focus(list->prev);
|
||||||
}
|
title_add(cur);
|
||||||
|
|
||||||
void mapping_notify(XEvent *e) {
|
|
||||||
XMappingEvent *ev = &e->xmapping;
|
|
||||||
|
|
||||||
if (ev->request == MappingKeyboard || ev->request == MappingModifier) {
|
|
||||||
XRefreshKeyboardMapping(ev);
|
|
||||||
input_grab(root);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void run(const Arg arg) {
|
void run(const Arg arg) {
|
||||||
@@ -250,8 +295,6 @@ void input_grab(Window root) {
|
|||||||
== XKeysymToKeycode(d, 0xff7f))
|
== XKeysymToKeycode(d, 0xff7f))
|
||||||
numlock = (1 << i);
|
numlock = (1 << i);
|
||||||
|
|
||||||
XUngrabKey(d, AnyKey, AnyModifier, root);
|
|
||||||
|
|
||||||
for (i = 0; i < sizeof(keys)/sizeof(*keys); i++)
|
for (i = 0; i < sizeof(keys)/sizeof(*keys); i++)
|
||||||
if ((code = XKeysymToKeycode(d, keys[i].keysym)))
|
if ((code = XKeysymToKeycode(d, keys[i].keysym)))
|
||||||
for (j = 0; j < sizeof(modifiers)/sizeof(*modifiers); j++)
|
for (j = 0; j < sizeof(modifiers)/sizeof(*modifiers); j++)
|
||||||
@@ -284,6 +327,6 @@ int main(void) {
|
|||||||
XDefineCursor(d, root, XCreateFontCursor(d, 68));
|
XDefineCursor(d, root, XCreateFontCursor(d, 68));
|
||||||
input_grab(root);
|
input_grab(root);
|
||||||
|
|
||||||
while (1 && !XNextEvent(d, &ev)) // 1 && will forever be here.
|
while (1 && !XNextEvent(d, &ev))
|
||||||
if (events[ev.type]) events[ev.type](&ev);
|
if (events[ev.type]) events[ev.type](&ev);
|
||||||
}
|
}
|
||||||
|
5
sowm.h
5
sowm.h
@@ -30,7 +30,7 @@ typedef struct client {
|
|||||||
struct client *next, *prev;
|
struct client *next, *prev;
|
||||||
int f, wx, wy;
|
int f, wx, wy;
|
||||||
unsigned int ww, wh;
|
unsigned int ww, wh;
|
||||||
Window w;
|
Window w, t;
|
||||||
} client;
|
} client;
|
||||||
|
|
||||||
void button_press(XEvent *e);
|
void button_press(XEvent *e);
|
||||||
@@ -39,11 +39,12 @@ void configure_request(XEvent *e);
|
|||||||
void input_grab(Window root);
|
void input_grab(Window root);
|
||||||
void key_press(XEvent *e);
|
void key_press(XEvent *e);
|
||||||
void map_request(XEvent *e);
|
void map_request(XEvent *e);
|
||||||
void mapping_notify(XEvent *e);
|
|
||||||
void notify_destroy(XEvent *e);
|
void notify_destroy(XEvent *e);
|
||||||
void notify_enter(XEvent *e);
|
void notify_enter(XEvent *e);
|
||||||
void notify_motion(XEvent *e);
|
void notify_motion(XEvent *e);
|
||||||
void run(const Arg arg);
|
void run(const Arg arg);
|
||||||
|
void title_add(client *c);
|
||||||
|
void title_del(client *c);
|
||||||
void win_add(Window w);
|
void win_add(Window w);
|
||||||
void win_center(const Arg arg);
|
void win_center(const Arg arg);
|
||||||
void win_del(Window w);
|
void win_del(Window w);
|
||||||
|
Reference in New Issue
Block a user