-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
the wm itself is currently configured at compile time in config.h
- Loading branch information
Tudor
committed
Sep 2, 2016
0 parents
commit 7e76b1b
Showing
16 changed files
with
2,533 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
super + {h,j,k,l} | ||
waitron window_move {-20 0, 0 20, 0 -20, 20 0} | ||
|
||
super + alt + {h,j,k,l} | ||
waitron window_resize {-20 0, 0 20, 0 -20, 20 0} | ||
|
||
super + shift + {h,j,k,l} | ||
waitron window_move {-50 0, 0 50, 0 -50, 50 0} | ||
|
||
super + shift + alt + {h,j,k,l} | ||
waitron window_resize {-50 0, 0 50, 0 -50, 50 0} | ||
|
||
super + alt + Escape | ||
waitron wm_quit 0 | ||
|
||
super + f | ||
waitron window_maximize | ||
|
||
super + w | ||
waitron window_close | ||
|
||
super + b | ||
waitron window_hor_maximize | ||
|
||
super + v | ||
waitron window_ver_maximize | ||
|
||
alt + Tab | ||
waitron window_cycle | ||
|
||
alt + shift + Tab | ||
waitron window_rev_cycle | ||
|
||
super + {_,shift +}{1-6} | ||
waitron {group_toggle,group_add_window} {1-6} | ||
|
||
super + ctrl + r | ||
waitron group_remove_window | ||
|
||
super + Return | ||
urxvt |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
sxhkd -c .sxhkdrc & | ||
|
||
exec ./stwm |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
ISC License | ||
|
||
Copyright (c) 2016, Tudor Roman <[email protected]> | ||
|
||
Permission to use, copy, modify, and/or distribute this software for | ||
any purpose with or without fee is hereby granted, provided that the | ||
above copyright notice and this permission notice appear in all | ||
copies. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH | ||
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF | ||
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR ANY | ||
SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES | ||
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN | ||
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT | ||
OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
include config.mk | ||
|
||
__NAME__ = windowchef | ||
__NAME_CLIENT__ = waitron | ||
NAME_DEFINES = -D__NAME__=\"$(__NAME__)\" \ | ||
-D__NAME_CLIENT__=\"$(__NAME_CLIENT__)\" | ||
|
||
SRC = list.c wm.c client.c | ||
OBJ = $(SRC:.c=.o) | ||
BIN = $(__NAME__) $(__NAME_CLIENT__) | ||
CFLAGS += $(NAME_DEFINES) -DD | ||
|
||
all: $(BIN) | ||
|
||
$(__NAME__): wm.o list.o | ||
@echo $@ | ||
@$(CC) -o $@ $^ $(LDFLAGS) | ||
|
||
$(__NAME_CLIENT__): client.o | ||
@echo $@ | ||
@$(CC) -o $@ $^ $(LDFLAGS) | ||
|
||
%.o: %.c | ||
@echo $@ | ||
@$(CC) -o $@ -c $(CFLAGS) $< | ||
|
||
$(OBJ): common.h list.h ipc.h types.h config.h | ||
|
||
install: all | ||
install $(__NAME__) $(DESTDIR)$(PREFIX)/bin/$(__NAME__) | ||
install $(__NAME_CLIENT__) $(DESTDIR)$(PREFIX)/bin/$(__NAME_CLIENT__) | ||
|
||
clean: | ||
rm -f $(OBJ) $(BIN) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
Windowchef | ||
========== | ||
|
||
Cooking windows since 2016 | ||
-------------------------- | ||
|
||
### Building and installing | ||
|
||
```bash | ||
make | ||
sudo make install | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
- Unlimited borders |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,179 @@ | ||
#include <stdio.h> | ||
#include <stdlib.h> | ||
#include <string.h> | ||
#include <stdbool.h> | ||
#include <xcb/xcb.h> | ||
#include <err.h> | ||
#include <errno.h> | ||
|
||
#include "ipc.h" | ||
|
||
#ifndef __NAME_CLIENT__ | ||
#define __NAME_CLIENT__ "client" | ||
#endif | ||
|
||
static bool | ||
fn_offset(uint32_t *data, int argc, char **argv) | ||
{ | ||
int i = 0; | ||
do { | ||
errno = 0; | ||
int c = strtol(argv[i], NULL, 10); | ||
if (c >= 0) | ||
data[i] = IPC_MUL_PLUS; | ||
else | ||
data[i] = IPC_MUL_MINUS; | ||
data[i + 2] = abs(c); | ||
i++; | ||
} while (i < argc && errno == 0); | ||
|
||
if (errno != 0) | ||
return false; | ||
else | ||
return true; | ||
} | ||
|
||
static bool | ||
fn_naturals(uint32_t *data, int argc, char **argv) | ||
{ | ||
int i = 0; | ||
do { | ||
errno = 0; | ||
data[i] = strtol(argv[i], NULL, 10); | ||
i++; | ||
} while (i < argc && errno == 0); | ||
|
||
if (errno != 0) | ||
return false; | ||
else | ||
return true; | ||
} | ||
|
||
struct Command { | ||
char *string_command; | ||
enum IPCCommand command; | ||
int argc; | ||
bool (*handler)(uint32_t *, int , char **); | ||
}; | ||
|
||
/* vim-tabularize is cool, i swear */ | ||
static struct Command c[] = { | ||
{ "window_move" , IPCWindowMove , 2 , fn_offset } , | ||
{ "window_move_absolute" , IPCWindowMoveAbsolute , 2 , fn_offset } , | ||
{ "window_resize" , IPCWindowResize , 2 , fn_offset } , | ||
{ "window_resize_absolute" , IPCWindowResizeAbsolute , 2 , fn_naturals } , | ||
{ "window_maximize" , IPCWindowMaximize , 0 , NULL } , | ||
{ "window_hor_maximize" , IPCWindowHorMaximize , 0 , NULL } , | ||
{ "window_ver_maximize" , IPCWindowVerMaximize , 0 , NULL } , | ||
{ "window_close" , IPCWindowClose , 0 , NULL } , | ||
{ "window_put_in_grid" , IPCWindowPutInGrid , 4 , fn_naturals } , | ||
{ "window_snap" , IPCWindowSnap , 1 , fn_naturals } , | ||
{ "window_cycle" , IPCWindowCycle , 0 , NULL } , | ||
{ "window_rev_cycle" , IPCWindowRevCycle , 0 , NULL } , | ||
{ "group_add_window" , IPCGroupAddWindow , 1 , fn_naturals } , | ||
{ "group_remove_window" , IPCGroupRemoveWindow , 0 , NULL } , | ||
{ "group_activate" , IPCGroupActivate , 1 , fn_naturals } , | ||
{ "group_deactivate" , IPCGroupDeactivate , 1 , fn_naturals } , | ||
{ "group_toggle" , IPCGroupToggle , 1 , fn_naturals } , | ||
{ "wm_quit" , IPCWMQuit , 1 , fn_naturals } , | ||
{ "wm_change_nr_of_groups" , IPCWMChangeNrOfGroups , 1 , fn_naturals } , | ||
|
||
}; | ||
|
||
xcb_connection_t *conn; | ||
xcb_screen_t *scr; | ||
|
||
static void | ||
init_xcb(xcb_connection_t **conn) | ||
{ | ||
*conn = xcb_connect(NULL, NULL); | ||
if (xcb_connection_has_error(*conn)) | ||
errx(EXIT_FAILURE, "unable to connect to X server"); | ||
scr = xcb_setup_roots_iterator(xcb_get_setup(*conn)).data; | ||
} | ||
|
||
static xcb_atom_t | ||
get_atom(char *name) | ||
{ | ||
xcb_intern_atom_cookie_t cookie = xcb_intern_atom(conn, 0, strlen(name), name); | ||
xcb_intern_atom_reply_t *reply = xcb_intern_atom_reply(conn, cookie, NULL); | ||
|
||
if (!reply) | ||
return XCB_ATOM_STRING; | ||
|
||
return reply->atom; | ||
} | ||
|
||
static void | ||
send_command(struct Command *c, int argc, char **argv) | ||
{ | ||
xcb_client_message_event_t msg; | ||
xcb_client_message_data_t data; | ||
xcb_generic_error_t *err; | ||
xcb_void_cookie_t cookie; | ||
bool status = true; | ||
size_t str_size; | ||
|
||
msg.response_type = XCB_CLIENT_MESSAGE; | ||
msg.type = get_atom(ATOM_COMMAND); | ||
msg.format = 32; | ||
data.data32[0] = c->command; | ||
if (c->handler != NULL) | ||
status = (c->handler)(data.data32 + 1, argc, argv); | ||
if (status == false) | ||
errx(EXIT_FAILURE, "malformed input"); | ||
|
||
msg.data = data; | ||
|
||
cookie = xcb_send_event_checked(conn, false, scr->root, | ||
XCB_EVENT_MASK_SUBSTRUCTURE_REDIRECT, (char *)&msg); | ||
|
||
err = xcb_request_check(conn, cookie); | ||
if (err) | ||
fprintf(stderr, "oops %d\n", err->error_code); | ||
xcb_flush(conn); | ||
} | ||
|
||
void | ||
usage() | ||
{ | ||
fprintf(stderr, "Usage: %s <command> [args]...\n", __NAME_CLIENT__); | ||
|
||
exit(1); | ||
} | ||
|
||
int main(int argc, char **argv) | ||
{ | ||
int i; | ||
int command_argc; | ||
char **command_argv; | ||
init_xcb(&conn); | ||
|
||
if (argc == 1) | ||
usage(); | ||
|
||
/* argc - program name - command to send */ | ||
command_argc = argc - 2; | ||
command_argv = argv + 2; | ||
|
||
i = 0; | ||
while (i < NR_IPC_COMMANDS && strcmp(argv[1], c[i].string_command) != 0) | ||
i++; | ||
|
||
if (i < NR_IPC_COMMANDS) { | ||
if (command_argc < c[i].argc) | ||
errx(EXIT_FAILURE, "not enough argmuents"); | ||
else if (command_argc > c[i].argc) | ||
warnx("too many arguments"); | ||
else | ||
send_command(&c[i], command_argc, command_argv); | ||
|
||
} else { | ||
errx(EXIT_FAILURE, "no such command"); | ||
} | ||
|
||
if (conn != NULL) | ||
xcb_disconnect(conn); | ||
|
||
return 0; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
#ifndef _COMMON_H | ||
#define _COMMON_H | ||
|
||
#ifdef D | ||
#define DMSG(fmt, ...) fprintf(stderr, fmt, ##__VA_ARGS__) | ||
#else | ||
#define DMSG | ||
#endif | ||
|
||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
#ifndef _CONFIG_H | ||
#define _CONFIG_H | ||
|
||
#define BORDER_WIDTH 3 | ||
#define COLOR_FOCUS 0x3d637d | ||
#define COLOR_UNFOCUS 0x003b4f | ||
#define GAP 20 | ||
#define CURSOR_POSITION CENTER | ||
#define GROUPS 4 | ||
|
||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
PREFIX = /usr/local | ||
MANPREFIX = /usr/local/share | ||
MANDIR = $(MANPREFIX)/man/man1 | ||
|
||
CFLAGS += -std=c99 -Wextra -g | ||
LDFLAGS += -lxcb -lxcb-ewmh -lxcb-icccm -lxcb-randr |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
#ifndef _WM_IPC_H | ||
#define _WM_IPC_H | ||
|
||
#define ATOM_COMMAND "__WM_IPC_COMMAND" | ||
|
||
#define IPC_MUL_PLUS 0 | ||
#define IPC_MUL_MINUS 1 | ||
|
||
enum IPCCommand { | ||
IPCWindowMove, | ||
IPCWindowMoveAbsolute, | ||
IPCWindowResize, | ||
IPCWindowResizeAbsolute, | ||
IPCWindowMaximize, | ||
IPCWindowHorMaximize, | ||
IPCWindowVerMaximize, | ||
IPCWindowClose, | ||
IPCWindowPutInGrid, | ||
IPCWindowSnap, | ||
IPCWindowCycle, | ||
IPCWindowRevCycle, | ||
IPCGroupAddWindow, | ||
IPCGroupRemoveWindow, | ||
IPCGroupActivate, | ||
IPCGroupDeactivate, | ||
IPCGroupToggle, | ||
IPCWMQuit, | ||
IPCWMChangeNrOfGroups, | ||
NR_IPC_COMMANDS, | ||
}; | ||
|
||
enum SnapPosition { | ||
SnapTopLeft = 0, | ||
SnapTopRight, | ||
SnapBottomLeft, | ||
SnapBottomRight, | ||
SnapMiddle, | ||
}; | ||
|
||
#endif |
Oops, something went wrong.