Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 21 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ CC ?= cc
CFLAGS ?= -O2
PKG_CONFIG ?= pkg-config

all: $(BUILD)/wvkbd-mobintl $(BUILD)/wtype $(BUILD)/omarchy-powerd $(BUILD)/omarchy-mute-switch $(BUILD)/omarchy-powerctl $(BUILD)/omarchy-keyboard $(BUILD)/arch-ipad-rotate-output $(BUILD)/arch-ipad-auto-brightness
all: $(BUILD)/wvkbd-mobintl $(BUILD)/wtype $(BUILD)/omarchy-powerd $(BUILD)/omarchy-mute-switch $(BUILD)/omarchy-powerctl $(BUILD)/omarchy-keyboard $(BUILD)/arch-ipad-rotate-output $(BUILD)/arch-ipad-auto-brightness $(BUILD)/omarchy-desktop-ready $(BUILD)/omarchy-rotation-lock $(BUILD)/omarchy-launcher-recent-files $(BUILD)/omarchy-render-labwc-theme $(BUILD)/omarchy-render-labwc-buttons

$(BUILD)/omarchy-powerd: desktop/configuration/powerd.c
mkdir -p $(BUILD)
Expand All @@ -44,6 +44,26 @@ $(BUILD)/arch-ipad-auto-brightness: desktop/configuration/auto-brightness.c
mkdir -p $(BUILD)
$(CC) $(CPPFLAGS) $(CFLAGS) -Wall -Wextra -Werror -std=c99 $< $(LDFLAGS) -lm -o $@

$(BUILD)/omarchy-desktop-ready: desktop/configuration/desktop-ready.c
mkdir -p $(BUILD)
$(CC) $(CPPFLAGS) $(CFLAGS) -Wall -Wextra -Werror -std=c99 $< $(LDFLAGS) -o $@

$(BUILD)/omarchy-rotation-lock: desktop/configuration/rotation-lock.c
mkdir -p $(BUILD)
$(CC) $(CPPFLAGS) $(CFLAGS) -Wall -Wextra -Werror -std=c99 $< $(LDFLAGS) -o $@

$(BUILD)/omarchy-launcher-recent-files: desktop/configuration/launcher-recent-files.c
mkdir -p $(BUILD)
$(CC) $(CPPFLAGS) $(CFLAGS) -Wall -Wextra -Werror -std=c99 $< $(LDFLAGS) -o $@

$(BUILD)/omarchy-render-labwc-theme: desktop/configuration/render-labwc-theme.c
mkdir -p $(BUILD)
$(CC) $(CPPFLAGS) $(CFLAGS) -Wall -Wextra -Werror -std=c99 $< $(LDFLAGS) -o $@

$(BUILD)/omarchy-render-labwc-buttons: desktop/configuration/render-labwc-buttons.c
mkdir -p $(BUILD)
$(CC) $(CPPFLAGS) $(CFLAGS) -Wall -Wextra -Werror -std=c99 $< $(LDFLAGS) -o $@

$(BUILD)/wvkbd-mobintl:
@test -d "$(WVKBD)" || { echo 'Set WVKBD to the wvkbd v0.20 source' >&2; exit 1; }
@grep -q preferred_buffer_scale /usr/include/wayland-client-protocol.h || \
Expand Down
120 changes: 120 additions & 0 deletions desktop/configuration/desktop-ready.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,120 @@
/*
* omarchy-desktop-ready: record Wayland session readiness for the installer
* and desktop session.
*
* Without an argument, writes $XDG_RUNTIME_DIR/omarchy-desktop-ready.json.
* With "pin-screen", writes /run/omarchy-session/ready.json.
*
* Build: cc -O2 -Wall -Wextra -Werror -std=c99 desktop-ready.c -o omarchy-desktop-ready
*/
#define _POSIX_C_SOURCE 200809L

#include <errno.h>
#include <fcntl.h>
#include <limits.h>
#include <pwd.h>
#include <stdbool.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/stat.h>
#include <unistd.h>

static void die(const char *msg)
{
fprintf(stderr, "%s\n", msg);
exit(1);
}

static void write_json_str(FILE *fp, const char *s)
{
fputc('"', fp);
for (; *s; s++) {
unsigned char c = (unsigned char)*s;

if (c == '"' || c == '\\') {
fputc('\\', fp);
fputc(c, fp);
} else if (c < 0x20) {
fprintf(fp, "\\u%04x", c);
} else {
fputc(c, fp);
}
}
fputc('"', fp);
}

int main(int argc, char **argv)
{
struct passwd *pw;
bool pin_screen = false;
const char *xdg_runtime, *wayland_display, *target, *name;
char sock_path[PATH_MAX], tmp_path[PATH_MAX], final_path[PATH_MAX];
char boot_id[128];
struct stat st_sock, st_target;
FILE *fp;
size_t n;
int fd;

pw = getpwuid(getuid());
if (!pw || strcmp(pw->pw_name, "tablet") != 0)
die("Readiness comes from the tablet session");

if (argc == 2 && strcmp(argv[1], "pin-screen") == 0)
pin_screen = true;
else if (argc != 1)
die("Usage: omarchy-desktop-ready [pin-screen]");

xdg_runtime = getenv("XDG_RUNTIME_DIR");
wayland_display = getenv("WAYLAND_DISPLAY");
if (!xdg_runtime || !*xdg_runtime || !wayland_display || !*wayland_display)
die("No owned Wayland session");

target = pin_screen ? "/run/omarchy-session" : xdg_runtime;
if (snprintf(sock_path, sizeof(sock_path), "%s/%s",
xdg_runtime, wayland_display) >= (int)sizeof(sock_path))
die("No owned Wayland session");

if (stat(sock_path, &st_sock) != 0 || !S_ISSOCK(st_sock.st_mode) ||
stat(target, &st_target) != 0 || st_target.st_uid != getuid())
die("No owned Wayland session");

fp = fopen("/proc/sys/kernel/random/boot_id", "r");
if (!fp)
die("Failed to read boot_id");
n = fread(boot_id, 1, sizeof(boot_id) - 1, fp);
fclose(fp);
boot_id[n] = '\0';
while (n > 0 && (boot_id[n - 1] == '\n' || boot_id[n - 1] == '\r' ||
boot_id[n - 1] == ' ' || boot_id[n - 1] == '\t'))
boot_id[--n] = '\0';

name = pin_screen ? "ready.json" : "omarchy-desktop-ready.json";
if (snprintf(tmp_path, sizeof(tmp_path), "%s/%s.pending",
target, name) >= (int)sizeof(tmp_path) ||
snprintf(final_path, sizeof(final_path), "%s/%s",
target, name) >= (int)sizeof(final_path))
die("Path too long");

fd = open(tmp_path, O_WRONLY | O_CREAT | O_TRUNC, 0644);
if (fd < 0)
die(strerror(errno));
fp = fdopen(fd, "w");
if (!fp) {
close(fd);
die(strerror(errno));
}

fputs("{\"boot_id\": ", fp);
write_json_str(fp, boot_id);
fprintf(fp, ", \"shell_pid\": %ld, \"wayland_socket\": ", (long)getppid());
write_json_str(fp, sock_path);
fputs("}", fp);

if (fflush(fp) != 0 || fchmod(fd, 0644) != 0 || fclose(fp) != 0)
die(strerror(errno));
if (rename(tmp_path, final_path) != 0)
die(strerror(errno));

return 0;
}
4 changes: 2 additions & 2 deletions desktop/configuration/first-theme
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ if [[ ! -s "$state/theme.name" ]]; then
background=$(find "$state/theme/backgrounds" -maxdepth 1 -type f -name '*.webp' -printf '%f\n' | sort | head -n1)
[[ -n "$background" ]] || exit 1
ln -s "$state/theme/backgrounds/$background" "$state/background"
python3 "$OMARCHY_PATH/render-labwc-theme.py" "$state/theme/colors.toml" "$state/theme/shell.toml" > "$HOME/.local/share/themes/Omarchy-Current/labwc/themerc"
python3 "$OMARCHY_PATH/render-labwc-buttons.py" "$state/theme/colors.toml" "$HOME/.local/share/themes/Omarchy-Current/labwc"
/usr/libexec/omarchy-render-labwc-theme "$state/theme/colors.toml" "$state/theme/shell.toml" > "$HOME/.local/share/themes/Omarchy-Current/labwc/themerc"
/usr/libexec/omarchy-render-labwc-buttons "$state/theme/colors.toml" "$HOME/.local/share/themes/Omarchy-Current/labwc"
fi
[[ -s "$state/theme/colors.toml" && -s "$state/theme/shell.toml" && -e "$state/background" ]] || exit 1
# Render the KDE palette for installations initialized before this template.
Expand Down
Loading
Loading