Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 9731383
Showing
5 changed files
with
180 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,3 @@ | ||
/.vscode/ | ||
/dapper | ||
/dapperc |
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,7 @@ | ||
default: server client | ||
|
||
server: | ||
g++ -std=c++14 dapper.cpp -o dapper | ||
|
||
client: | ||
g++ -std=c++14 dapperc.cpp -o dapperc |
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,59 @@ | ||
#include <cstdio> | ||
#include <iostream> | ||
#include <sys/socket.h> | ||
#include <sys/un.h> | ||
#include <unistd.h> | ||
|
||
static const char *SOCKET_PATH = "/tmp/dapper.socket"; | ||
|
||
void err(std::string msg) { | ||
std::cerr << msg << std::endl; | ||
std::exit(1); | ||
} | ||
|
||
int main() { | ||
struct sockaddr_un sock_address; | ||
sock_address.sun_family = AF_UNIX; | ||
std::snprintf(sock_address.sun_path, sizeof(sock_address.sun_path), "%s", | ||
SOCKET_PATH); | ||
|
||
int sock_fd = socket(AF_UNIX, SOCK_STREAM, 0); | ||
|
||
if (sock_fd == -1) { | ||
err("Couldn't create the socket"); | ||
} | ||
|
||
unlink(SOCKET_PATH); | ||
if (bind(sock_fd, (struct sockaddr *)&sock_address, sizeof(sock_address)) == | ||
-1) { | ||
err("Couldn't bind a name to the socket"); | ||
} | ||
|
||
if (listen(sock_fd, SOMAXCONN) == -1) { | ||
err("Couldn't listen to the socket"); | ||
} | ||
|
||
bool running = true; | ||
int max_fd = sock_fd; | ||
char msg[1024]; | ||
|
||
while (running) { | ||
fd_set descriptors; | ||
FD_ZERO(&descriptors); | ||
FD_SET(sock_fd, &descriptors); | ||
|
||
if (select(max_fd + 1, &descriptors, NULL, NULL, NULL) > 0) { | ||
if (FD_ISSET(sock_fd, &descriptors)) { | ||
int cli_fd = accept(sock_fd, NULL, 0); | ||
if (cli_fd > 0) { | ||
int n = recv(cli_fd, msg, sizeof(msg), 0); | ||
if (n > 0) { | ||
msg[n] = '\0'; | ||
|
||
std::cout << std::string(msg) << std::endl; | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} |
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,67 @@ | ||
// Sockets code largely stolen from bspc | ||
|
||
#include <cstdio> | ||
#include <iostream> | ||
#include <poll.h> | ||
#include <sstream> | ||
#include <sys/socket.h> | ||
#include <sys/un.h> | ||
#include <unistd.h> | ||
|
||
static const char *SOCKET_PATH = "/tmp/dapper.socket"; | ||
|
||
void err(std::string msg) { | ||
std::cerr << msg << std::endl; | ||
std::exit(1); | ||
} | ||
|
||
int main(int argc, char *argv[]) { | ||
if (argc < 2) { | ||
err("No arguments given"); | ||
} | ||
|
||
struct sockaddr_un sock_address; | ||
|
||
sock_address.sun_family = AF_UNIX; | ||
|
||
int sock_fd = socket(AF_UNIX, SOCK_STREAM, 0); | ||
if (sock_fd == -1) { | ||
err("Failed to create the socket"); | ||
} | ||
|
||
std::snprintf(sock_address.sun_path, sizeof(sock_address.sun_path), "%s", | ||
SOCKET_PATH); | ||
|
||
if (connect(sock_fd, (struct sockaddr *)&sock_address, | ||
sizeof(sock_address)) == -1) { | ||
err("Failed to connect to the socket"); | ||
} | ||
|
||
// Concat args into single string | ||
std::stringstream arg_buf; | ||
for (int arg = 1; arg < argc - 1; arg++) { | ||
arg_buf << argv[arg] << ' '; | ||
} | ||
arg_buf << argv[argc - 1]; | ||
std::string arg_str = arg_buf.str(); | ||
size_t msg_size = arg_str.size() * sizeof(arg_str[0]); | ||
|
||
if (send(sock_fd, arg_str.c_str(), msg_size, 0) == -1) { | ||
err("Failed to send the data"); | ||
} | ||
|
||
// struct pollfd poll_fd = {sock_fd, POLLIN, 0}; | ||
|
||
// struct pollfd fds[] = { | ||
// {sock_fd, POLLIN, 0}, | ||
// {STDOUT_FILENO, POLLHUP, 0}, | ||
// }; | ||
|
||
// while (poll(fds, 2, -1) > 0) { | ||
// if (fds[1].revents & (POLLERR | POLLHUP)) { | ||
// break; | ||
// } | ||
// } | ||
|
||
close(sock_fd); | ||
} |
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,44 @@ | ||
# toggle redshift | ||
|
||
pkill -x -USR1 redshift | ||
|
||
# todo | ||
|
||
Remove systray | ||
Write dapper.cpp | ||
Configure tmux | ||
New vim statusbar? | ||
Move statusbar to bottom? | ||
st instead of gnome-terminal for popups? | ||
|
||
# ideas | ||
|
||
implement on top of bspwm for sanity | ||
|
||
internal workspaces | ||
1: monocle main viewing workspace | ||
2: non-monocle workspace for split viewing | ||
3: dummy workspace for gnome-terminal instance | ||
4+: "special" workspaces for other apps | ||
|
||
When an app's keybinding is pressed | ||
launch the app if it doesn't already exist | ||
move it to workspace 1 | ||
move all windows off workspace 2 | ||
focus it | ||
When shift + app's keybinding pressed | ||
launch app if doesn't exist | ||
move to workspace 1 | ||
move to workspace 2 | ||
Other apps: | ||
move to one of workspace 4+, depending on whether they are occupied | ||
1 workspace per application class | ||
|
||
App bindings: | ||
web browser: i | ||
terminal: n | ||
virtual programs: d and w | ||
|
||
# dapper.cpp | ||
|
||
arranges apps across desktops as requested |