mirror of
https://github.com/dylanaraps/sowm.git
synced 2025-05-19 01:20:23 -07:00
Compare commits
26 Commits
Author | SHA1 | Date | |
---|---|---|---|
|
f4cb48d7af | ||
|
ccb96521c1 | ||
|
5663175d57 | ||
|
95596f43aa | ||
|
e595bfb365 | ||
|
d327a0978a | ||
|
0964d47d07 | ||
|
6ca1ff91a4 | ||
|
dabe77272b | ||
|
ea47780ab0 | ||
|
0ed080b99c | ||
|
7e4466e38e | ||
|
56bdacaa84 | ||
|
e22087856b | ||
|
f201a467ea | ||
|
7821aac0d2 | ||
|
a1c80d9b23 | ||
|
0df345e1da | ||
|
b5087acaac | ||
|
3ed647f467 | ||
|
e491a637fe | ||
|
21a35be863 | ||
|
5547cc3a51 | ||
|
67d323458c | ||
|
0004ff3e18 | ||
|
5cc5d25823 |
11
Makefile
11
Makefile
@ -4,16 +4,21 @@ PREFIX ?= /usr
|
||||
BINDIR ?= $(PREFIX)/bin
|
||||
CC ?= gcc
|
||||
|
||||
all: config.h sowm
|
||||
all: sowm
|
||||
|
||||
config.h:
|
||||
cp config.def.h config.h
|
||||
|
||||
sowm: sowm.o
|
||||
$(CC) $(LDFLAGS) -O3 -o $@ $+ -lX11
|
||||
sowm: sowm.c sowm.h config.h Makefile
|
||||
$(CC) -O3 $(CFLAGS) -o $@ $< -lX11 $(LDFLAGS)
|
||||
|
||||
install: all
|
||||
install -Dm755 sowm $(DESTDIR)$(BINDIR)/sowm
|
||||
|
||||
uninstall:
|
||||
rm -f $(DESTDIR)$(BINDIR)/sowm
|
||||
|
||||
clean:
|
||||
rm -f sowm *.o
|
||||
|
||||
.PHONY: all install uninstall clean
|
||||
|
46
README.md
46
README.md
@ -1,15 +1,16 @@
|
||||
# sowm (*Simple Opinionated Window Manager*)
|
||||
# sowm (*~~Simple~~ Shitty 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!*).
|
||||
An itsy bitsy floating window manager (*220~ sloc!*).
|
||||
|
||||
- Floating only.
|
||||
- Fullscreen toggle.
|
||||
- Window centering.
|
||||
- Mix of mouse and keyboard workflow.
|
||||
- Focus with cursor.
|
||||
- Rounded corners (*[through patch](https://github.com/dylanaraps/sowm-patches)*)
|
||||
- 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>
|
||||
|
||||
@ -23,7 +24,7 @@ An itsy bitsy floating window manager (*220~ sloc / 24kb compiled!*).
|
||||
|
||||
<br>
|
||||
|
||||
Patches available here: https://github.com/dylanaraps/sowm-patches
|
||||
Patches available here: https://github.com/dylanaraps/sowm/pulls
|
||||
|
||||
## Default Keybindings
|
||||
|
||||
@ -37,8 +38,8 @@ Patches available here: https://github.com/dylanaraps/sowm-patches
|
||||
| `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 |
|
||||
| `MOD4` + `1-6` | desktop swap |
|
||||
| `MOD4` + `Shift` +`1-6` | send window to desktop |
|
||||
| `MOD1` + `TAB` (*alt-tab*) | focus cycle |
|
||||
|
||||
**Programs**
|
||||
@ -70,17 +71,28 @@ Patches available here: https://github.com/dylanaraps/sowm-patches
|
||||
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
|
||||
- [2bwm](https://github.com/venam/2bwm)
|
||||
- [SmallWM](https://github.com/adamnew123456/SmallWM)
|
||||
- [berry](https://github.com/JLErvin/berry)
|
||||
- [catwm](https://github.com/pyknite/catwm)
|
||||
- [dminiwm](https://github.com/moetunes/dminiwm)
|
||||
- [dwm](https://dwm.suckless.org)
|
||||
- [monsterwm](https://github.com/c00kiemon5ter/monsterwm)
|
||||
- [openbox](https://github.com/danakj/openbox)
|
||||
- [possum-wm](https://github.com/duckinator/possum-wm)
|
||||
- [swm](https://github.com/dcat/swm)
|
||||
- [tinywm](http://incise.org/tinywm.html)
|
||||
|
30
sowm.c
30
sowm.c
@ -16,6 +16,7 @@ static unsigned int ww, wh;
|
||||
|
||||
static Display *d;
|
||||
static XButtonEvent mouse;
|
||||
static Window root;
|
||||
|
||||
static void (*events[LASTEvent])(XEvent *e) = {
|
||||
[ButtonPress] = button_press,
|
||||
@ -23,6 +24,7 @@ static void (*events[LASTEvent])(XEvent *e) = {
|
||||
[ConfigureRequest] = configure_request,
|
||||
[KeyPress] = key_press,
|
||||
[MapRequest] = map_request,
|
||||
[MappingNotify] = mapping_notify,
|
||||
[DestroyNotify] = notify_destroy,
|
||||
[EnterNotify] = notify_enter,
|
||||
[MotionNotify] = notify_motion
|
||||
@ -58,8 +60,8 @@ void notify_motion(XEvent *e) {
|
||||
XMoveResizeWindow(d, mouse.subwindow,
|
||||
wx + (mouse.button == 1 ? xd : 0),
|
||||
wy + (mouse.button == 1 ? yd : 0),
|
||||
ww + (mouse.button == 3 ? xd : 0),
|
||||
wh + (mouse.button == 3 ? yd : 0));
|
||||
MAX(1, ww + (mouse.button == 3 ? xd : 0)),
|
||||
MAX(1, wh + (mouse.button == 3 ? yd : 0)));
|
||||
}
|
||||
|
||||
void key_press(XEvent *e) {
|
||||
@ -138,8 +140,9 @@ void win_fs(const Arg arg) {
|
||||
win_size(cur->w, &cur->wx, &cur->wy, &cur->ww, &cur->wh);
|
||||
XMoveResizeWindow(d, cur->w, 0, 0, sw, sh);
|
||||
|
||||
} else
|
||||
} else {
|
||||
XMoveResizeWindow(d, cur->w, cur->wx, cur->wy, cur->ww, cur->wh);
|
||||
}
|
||||
}
|
||||
|
||||
void win_to_ws(const Arg arg) {
|
||||
@ -219,6 +222,15 @@ void map_request(XEvent *e) {
|
||||
win_focus(list->prev);
|
||||
}
|
||||
|
||||
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) {
|
||||
if (fork()) return;
|
||||
if (d) close(ConnectionNumber(d));
|
||||
@ -238,6 +250,8 @@ void input_grab(Window root) {
|
||||
== XKeysymToKeycode(d, 0xff7f))
|
||||
numlock = (1 << i);
|
||||
|
||||
XUngrabKey(d, AnyKey, AnyModifier, root);
|
||||
|
||||
for (i = 0; i < sizeof(keys)/sizeof(*keys); i++)
|
||||
if ((code = XKeysymToKeycode(d, keys[i].keysym)))
|
||||
for (j = 0; j < sizeof(modifiers)/sizeof(*modifiers); j++)
|
||||
@ -261,15 +275,15 @@ int main(void) {
|
||||
signal(SIGCHLD, SIG_IGN);
|
||||
XSetErrorHandler(xerror);
|
||||
|
||||
int s = DefaultScreen(d);
|
||||
Window root = RootWindow(d, s);
|
||||
sw = XDisplayWidth(d, s);
|
||||
sh = XDisplayHeight(d, s);
|
||||
int s = DefaultScreen(d);
|
||||
root = RootWindow(d, s);
|
||||
sw = XDisplayWidth(d, s);
|
||||
sh = XDisplayHeight(d, s);
|
||||
|
||||
XSelectInput(d, root, SubstructureRedirectMask);
|
||||
XDefineCursor(d, root, XCreateFontCursor(d, 68));
|
||||
input_grab(root);
|
||||
|
||||
while (1 && !XNextEvent(d, &ev))
|
||||
while (1 && !XNextEvent(d, &ev)) // 1 && will forever be here.
|
||||
if (events[ev.type]) events[ev.type](&ev);
|
||||
}
|
||||
|
7
sowm.h
7
sowm.h
@ -3,6 +3,7 @@
|
||||
#define win (client *t=0, *c=list; c && t!=list->prev; t=c, c=c->next)
|
||||
#define ws_save(W) ws_list[W] = list
|
||||
#define ws_sel(W) list = ws_list[ws = W]
|
||||
#define MAX(a, b) ((a) > (b) ? (a) : (b))
|
||||
|
||||
#define win_size(W, gx, gy, gw, gh) \
|
||||
XGetGeometry(d, W, &(Window){0}, gx, gy, gw, gh, \
|
||||
@ -12,7 +13,7 @@
|
||||
#define mod_clean(mask) (mask & ~(numlock|LockMask) & \
|
||||
(ShiftMask|ControlMask|Mod1Mask|Mod2Mask|Mod3Mask|Mod4Mask|Mod5Mask))
|
||||
|
||||
typedef union {
|
||||
typedef struct {
|
||||
const char** com;
|
||||
const int i;
|
||||
const Window w;
|
||||
@ -38,6 +39,7 @@ void configure_request(XEvent *e);
|
||||
void input_grab(Window root);
|
||||
void key_press(XEvent *e);
|
||||
void map_request(XEvent *e);
|
||||
void mapping_notify(XEvent *e);
|
||||
void notify_destroy(XEvent *e);
|
||||
void notify_enter(XEvent *e);
|
||||
void notify_motion(XEvent *e);
|
||||
@ -52,4 +54,5 @@ void win_prev(const Arg arg);
|
||||
void win_next(const Arg arg);
|
||||
void win_to_ws(const Arg arg);
|
||||
void ws_go(const Arg arg);
|
||||
int xerror() { return 0; }
|
||||
|
||||
static int xerror() { return 0; }
|
||||
|
Loading…
x
Reference in New Issue
Block a user