commit 23bbfb27d469c98fcc0e4ce4d01e6e955a31ea58
parent a713260b2fa07792324c5b49f6216971ef52dd03
Author: mrgrouse <mrgrouse@mrgrouse.com>
Date: Wed, 21 Oct 2026 19:25:20 -0400
main.c: format code
Diffstat:
| M | main.c | | | 68 | +++++++++++++++++++++++++++++++++++--------------------------------- |
1 file changed, 35 insertions(+), 33 deletions(-)
diff --git a/main.c b/main.c
@@ -1,52 +1,54 @@
#include <errno.h>
-#include <stdio.h>
#include <stdint.h>
+#include <stdio.h>
#include <stdlib.h>
-#include <sys/un.h>
#include <sys/socket.h>
+#include <sys/un.h>
#include "types.h"
-static int
-wayland_display_connect(string *wsp) {
+static int wayland_display_connect(string *wsp) {
- struct sockaddr_un addr = { .sun_family = AF_UNIX };
- memcpy(addr.sun_path, wsp->data, wsp->len); // only way to assign our path to the addr .sun_path[], compiler expects length at runtime but it is variable
+ struct sockaddr_un addr = {.sun_family = AF_UNIX};
+ memcpy(addr.sun_path, wsp->data,
+ wsp->len); // only way to assign our path to the addr .sun_path[],
+ // compiler expects length at runtime but it is variable
- int fd = socket(AF_UNIX, SOCK_STREAM, 0);
+ int fd = socket(AF_UNIX, SOCK_STREAM, 0);
- if (fd == -1)
- exit(errno);
- // int connect(int sockfd, const struct sockaddr *addr, socklen_t addrlen)
- if (connect(fd, (struct sockaddr*)&addr, sizeof(addr)) == -1)
- exit(errno);
+ if (fd == -1)
+ exit(errno);
+ // int connect(int sockfd, const struct sockaddr *addr, socklen_t addrlen)
+ if (connect(fd, (struct sockaddr *)&addr, sizeof(addr)) == -1)
+ exit(errno);
- return fd;
+ return fd;
}
-int
-main(void) {
+int main(void) {
- string xdg_runtime_dir = {
- .data = getenv("XDG_RUNTIME_DIR"),
- .len = strlen(xdg_runtime_dir.data),
- }; // we can keep this data for future use (temporary logs, pipewire, mpd, etc)
+ string xdg_runtime_dir = {
+ .data = getenv("XDG_RUNTIME_DIR"),
+ .len = strlen(xdg_runtime_dir.data),
+ }; // we can keep this data for future use (temporary logs, pipewire, mpd,
+ // etc)
- string wayland_display = {
- .data = getenv("WAYLAND_DISPLAY"),
- .len = strlen(wayland_display.data),
- }; // might be of use later idk yet
+ string wayland_display = {
+ .data = getenv("WAYLAND_DISPLAY"),
+ .len = strlen(wayland_display.data),
+ }; // might be of use later idk yet
- string wl_sock_path = {
- .data = strcat(strcat(xdg_runtime_dir.data, "/"), wayland_display.data), // convoluted to make it a path
- .len = strlen(wl_sock_path.data),
- };
+ string wl_sock_path = {
+ .data = strcat(strcat(xdg_runtime_dir.data, "/"),
+ wayland_display.data), // convoluted to make it a path
+ .len = strlen(wl_sock_path.data),
+ };
- if (wayland_display.data == NULL || xdg_runtime_dir.data == NULL) {
- puts("Ensure XDG_RUNTIME_DIR and/or WAYLAND_DISPLAY are set.");
- return 1;
- }
+ if (wayland_display.data == NULL || xdg_runtime_dir.data == NULL) {
+ puts("Ensure XDG_RUNTIME_DIR and/or WAYLAND_DISPLAY are set.");
+ return 1;
+ }
- wayland_display_connect(&wl_sock_path);
- return 0;
+ wayland_display_connect(&wl_sock_path);
+ return 0;
}