diff options
Diffstat (limited to 'taro')
| -rw-r--r-- | taro/config.h | 12 | ||||
| -rw-r--r-- | taro/daemon.c | 131 | ||||
| -rw-r--r-- | taro/db.c | 26 | ||||
| -rw-r--r-- | taro/file_ext.c | 28 | ||||
| -rw-r--r-- | taro/file_ext.h | 10 | ||||
| -rw-r--r-- | taro/meson.build | 6 | ||||
| -rw-r--r-- | taro/tests/meson.build | 1 | ||||
| -rw-r--r-- | taro/tests/notcurses_ffmpeg.c | 6 | ||||
| -rw-r--r-- | taro/ui.c | 44 |
9 files changed, 132 insertions, 132 deletions
diff --git a/taro/config.h b/taro/config.h index a8fffd1..0357d70 100644 --- a/taro/config.h +++ b/taro/config.h @@ -80,26 +80,26 @@ static bool open_config(struct config *conf, bool create) al_str_from(&conf->config_dir, envhome); al_str_cat(&conf->config_dir, al_str_c(CONFIG_PATH)); - if (!aki_dir_exists(&conf->config_dir)) { - if (!create || !aki_dir_create(&conf->config_dir)) { + if (!nn_dir_exists(&conf->config_dir)) { + if (!create || !nn_dir_create(&conf->config_dir)) { goto err; } } al_str_clone(&conf->config_path, &conf->config_dir); al_str_cat(&conf->config_path, al_str_c("/config.json")); - if (!aki_file_exists(&conf->config_path)) { - if (aki_file_create(&conf->config_path)) { + if (!nn_file_exists(&conf->config_path)) { + if (nn_file_create(&conf->config_path)) { json_t *blank = json_object(); json_t *directories = json_object(); json_object_set_new(directories, "assets", json_string_nocheck("")); json_object_set_new(directories, "wallpapers", json_string_nocheck("")); json_object_set_new(blank, "directories", directories); - aki_dump_json_and_decref(&conf->config_path, blank); + nn_dump_json_and_decref(&conf->config_path, blank); } } - json_t *root = aki_file_open_as_json(&conf->config_path); + json_t *root = nn_file_open_as_json(&conf->config_path); if (!root) goto err; parse_config_json(conf, envhome, root); diff --git a/taro/daemon.c b/taro/daemon.c index 3eec7e1..6641b0b 100644 --- a/taro/daemon.c +++ b/taro/daemon.c @@ -3,11 +3,11 @@ #include <al/array.h> #include <al/log.h> #include <al/str.h> -#include <aki/common.h> -#include <aki/event_loop.h> -#include <aki/signal.h> -#include <aki/fs_event.h> -#include <aki/socket.h> +#include <nnwt/common.h> +#include <nnwt/event_loop.h> +#include <nnwt/signal.h> +#include <nnwt/fs_event.h> +#include <nnwt/socket.h> #include <stl/window.h> #include <jansson.h> @@ -18,7 +18,7 @@ struct monitor { struct stl_monitor *os; str config_dir; str selection_path; - struct aki_fs_event selection_event; + struct nn_fs_event selection_event; bool self_event_skip; pid_t pid; bool paused; @@ -30,15 +30,15 @@ struct monitor { #define SWAY_IPC_SUBSCRIBE 2 struct daemon { - struct aki_event_loop loop; - struct aki_signal quit_signal; + struct nn_event_loop loop; + struct nn_signal quit_signal; s32 context_poll_fd; - struct aki_poll context_poll; + struct nn_poll context_poll; array(struct monitor *) monitors; - struct aki_socket ipc_socket; + struct nn_socket ipc_socket; bool ipc_connected; bool ipc_errored; - struct aki_poll ipc_poll; + struct nn_poll ipc_poll; struct { u8 *buf; ssize_t index; @@ -51,7 +51,7 @@ struct daemon { ssize_t alloc; } ipc; struct config conf; - struct aki_fs_event conf_event; + struct nn_fs_event conf_event; }; static s32 parse_and_set_props(str *selection, str *wallpaper_path, bool *is_package) @@ -85,7 +85,7 @@ static s32 parse_and_set_props(str *selection, str *wallpaper_path, bool *is_pac static bool send_signal_to_pid(pid_t pid, s32 signal) { if (kill(pid, signal) != 0) { - al_log_error("tarod", "kill(%d) failed (%s)", pid, aki_strerror(errno)); + al_log_error("tarod", "kill(%d) failed (%s)", pid, nn_strerror(errno)); return false; } return true; @@ -142,7 +142,7 @@ static bool run_wallpaper(struct daemon *dmon, struct monitor *monitor) str selection; monitor->self_event_skip = true; - if (!aki_file_open_and_read_wholly(&monitor->selection_path, &selection, true)) { + if (!nn_file_open_and_read_wholly(&monitor->selection_path, &selection, true)) { monitor->self_event_skip = false; return false; } @@ -171,7 +171,7 @@ static bool run_wallpaper(struct daemon *dmon, struct monitor *monitor) al_str_cat(&wallpaper_path, al_str_c("/scene.pkg")); } - if ((is_package && !aki_file_exists(&wallpaper_path)) || (!is_package && !aki_dir_exists(&wallpaper_path))) { + if ((is_package && !nn_file_exists(&wallpaper_path)) || (!is_package && !nn_dir_exists(&wallpaper_path))) { al_log_error("tarod", "wallpaper doesn't exist at %.*s", AL_STR_PRINTF(&wallpaper_path)); al_str_free(&wallpaper_path); return false; @@ -234,8 +234,8 @@ static void output_discovered_callback(void *userdata, struct stl_monitor *os_mo al_str_cat(&monitor_dir, al_str_c("/")); al_str_cat(&monitor_dir, al_str_cr(os_monitor->name)); - if (!aki_dir_exists(&monitor_dir)) { - if (!aki_dir_create(&monitor_dir)) return; + if (!nn_dir_exists(&monitor_dir)) { + if (!nn_dir_create(&monitor_dir)) return; } monitor = al_alloc_object(struct monitor); @@ -249,9 +249,9 @@ static void output_discovered_callback(void *userdata, struct stl_monitor *os_mo al_str_clone(&monitor->selection_path, &monitor->config_dir); al_str_cat(&monitor->selection_path, al_str_c("/selection")); - if (!aki_file_exists(&monitor->selection_path)) { - aki_file_create(&monitor->selection_path); - aki_file_open_and_replace(&monitor->selection_path, al_str_c("||"), false); + if (!nn_file_exists(&monitor->selection_path)) { + nn_file_create(&monitor->selection_path); + nn_file_open_and_replace(&monitor->selection_path, al_str_c("||"), false); } monitor->pid = -1; @@ -261,9 +261,9 @@ static void output_discovered_callback(void *userdata, struct stl_monitor *os_mo run_wallpaper(dmon, monitor); monitor->self_event_skip = false; - aki_fs_event_init(&monitor->selection_event, &monitor->selection_path, - AKI_CLOSE_WRITE, selection_fs_event_callback, monitor); - aki_fs_event_start(&monitor->selection_event, &monitor->dmon->loop); + nn_fs_event_init(&monitor->selection_event, &monitor->selection_path, + NNWT_CLOSE_WRITE, selection_fs_event_callback, monitor); + nn_fs_event_start(&monitor->selection_event, &monitor->dmon->loop); } // https://vi.stackexchange.com/questions/25030/vim-not-firing-inotify-events-when-writing-file @@ -286,7 +286,7 @@ static void close_monitor(struct monitor *monitor) { al_str_free(&monitor->config_dir); al_str_free(&monitor->selection_path); - aki_fs_event_free(&monitor->selection_event); + nn_fs_event_free(&monitor->selection_event); } static void ipc_handle_subscribe_success(json_t *root) @@ -348,32 +348,32 @@ static void ipc_poll_callback(void *userdata, s32 revents) { struct daemon *dmon = (struct daemon *)userdata; - if (revents & AKI_POLL_WRITE) { + if (revents & NNWT_POLL_WRITE) { al_assert(!dmon->ipc_connected); if (!dmon->ipc_connected) { al_log_info("tarod", "connected to sway ipc socket"); dmon->ipc_connected = true; } - ssize_t ret = aki_socket_write(&dmon->ipc_socket, + ssize_t ret = nn_socket_write(&dmon->ipc_socket, dmon->out.buf + dmon->out.index, dmon->out.size - dmon->out.index); if (ret <= 0) { - aki_signal_send(&dmon->quit_signal); + nn_signal_send(&dmon->quit_signal); return; } dmon->out.index += ret; if (dmon->out.index == dmon->out.size) { - aki_poll_stop(&dmon->ipc_poll); - aki_poll_set(&dmon->ipc_poll, aki_socket_get_fd(&dmon->ipc_socket), AKI_POLL_READ); - aki_poll_start(&dmon->ipc_poll, &dmon->loop); + nn_poll_stop(&dmon->ipc_poll); + nn_poll_set(&dmon->ipc_poll, nn_socket_get_fd(&dmon->ipc_socket), NNWT_POLL_READ); + nn_poll_start(&dmon->ipc_poll, &dmon->loop); } } - if (revents & AKI_POLL_READ) { + if (revents & NNWT_POLL_READ) { if (dmon->ipc.index < SWAY_IPC_HEADER_LENGTH) { - ssize_t ret = aki_socket_read(&dmon->ipc_socket, + ssize_t ret = nn_socket_read(&dmon->ipc_socket, dmon->ipc.buf + dmon->ipc.index, SWAY_IPC_HEADER_LENGTH - dmon->ipc.index); if (ret <= 0) { - aki_signal_send(&dmon->quit_signal); + nn_signal_send(&dmon->quit_signal); return; } dmon->ipc.index += ret; @@ -383,10 +383,10 @@ static void ipc_poll_callback(void *userdata, s32 revents) ensure_ipc_buf_size(dmon, dmon->ipc.size); } if (dmon->ipc.size) { - ssize_t ret = aki_socket_read(&dmon->ipc_socket, + ssize_t ret = nn_socket_read(&dmon->ipc_socket, dmon->ipc.buf + dmon->ipc.index, dmon->ipc.size - dmon->ipc.index); if (ret <= 0) { - aki_signal_send(&dmon->quit_signal); + nn_signal_send(&dmon->quit_signal); return; } dmon->ipc.index += ret; @@ -403,7 +403,7 @@ static void ipc_poll_callback(void *userdata, s32 revents) static void context_poll_callback(void *userdata, s32 revents) { (void)userdata; - al_assert(revents & AKI_POLL_READ); + al_assert(revents & NNWT_POLL_READ); stl_global_process_events(); } @@ -412,17 +412,17 @@ static void quit_signal_callback(void *userdata) struct daemon *dmon = (struct daemon *)userdata; struct monitor *monitor; al_array_foreach(dmon->monitors, i, monitor) { - aki_fs_event_stop(&monitor->selection_event); + nn_fs_event_stop(&monitor->selection_event); maybe_kill_wallpaper(monitor); } - aki_fs_event_stop(&dmon->conf_event); + nn_fs_event_stop(&dmon->conf_event); if (!dmon->ipc_errored) { - aki_poll_stop(&dmon->ipc_poll); + nn_poll_stop(&dmon->ipc_poll); } if (dmon->context_poll_fd != -1) { - aki_poll_stop(&dmon->context_poll); + nn_poll_stop(&dmon->context_poll); } - aki_signal_stop(&dmon->quit_signal); + nn_signal_stop(&dmon->quit_signal); } static struct daemon dmon = { 0 }; @@ -439,31 +439,31 @@ static void sigchld_handler(s32 signum) static void sigint_handler(s32 signum) { (void)signum; - aki_signal_send(&dmon.quit_signal); + nn_signal_send(&dmon.quit_signal); } s32 main(void) { - if (!aki_common_init() || !open_config(&dmon.conf, true)) return EXIT_FAILURE; + if (!nn_common_init() || !open_config(&dmon.conf, true)) return EXIT_FAILURE; signal(SIGINT, sigint_handler); signal(SIGCHLD, sigchld_handler); s32 ret = EXIT_FAILURE; - aki_event_loop_init(&dmon.loop); + nn_event_loop_init(&dmon.loop); - aki_signal_init(&dmon.quit_signal, quit_signal_callback, &dmon); - aki_signal_start(&dmon.quit_signal, &dmon.loop); + nn_signal_init(&dmon.quit_signal, &dmon.loop, quit_signal_callback, &dmon); + nn_signal_start(&dmon.quit_signal); al_array_init(dmon.monitors); stl_set_output_discovered_callback(output_discovered_callback, &dmon); if (!stl_global_init(true)) goto out; dmon.context_poll_fd = stl_global_get_poll_fd(); if (dmon.context_poll_fd != -1) { - aki_poll_init(&dmon.context_poll, context_poll_callback, &dmon); - aki_poll_set(&dmon.context_poll, dmon.context_poll_fd, AKI_POLL_READ); - aki_poll_start(&dmon.context_poll, &dmon.loop); + nn_poll_init(&dmon.context_poll, context_poll_callback, &dmon); + nn_poll_set(&dmon.context_poll, dmon.context_poll_fd, NNWT_POLL_READ); + nn_poll_start(&dmon.context_poll, &dmon.loop); } str monitors; @@ -477,9 +477,9 @@ s32 main(void) str monitors_path; al_str_clone(&monitors_path, &dmon.conf.config_dir); al_str_cat(&monitors_path, al_str_c("/monitors")); - bool monitors_exists = aki_file_exists(&monitors_path) || aki_file_create(&monitors_path); + bool monitors_exists = nn_file_exists(&monitors_path) || nn_file_create(&monitors_path); if (monitors_exists) { - aki_file_open_and_replace(&monitors_path, &monitors, false); + nn_file_open_and_replace(&monitors_path, &monitors, false); } al_str_free(&monitors_path); al_str_free(&monitors); @@ -507,26 +507,25 @@ s32 main(void) dmon.out.size = SWAY_IPC_HEADER_LENGTH + len; dmon.out.index = 0; - dmon.ipc_socket.type = AKI_SOCKET_UNIX; - aki_socket_init(&dmon.ipc_socket); - aki_socket_set_blocking(&dmon.ipc_socket, false); - aki_poll_init(&dmon.ipc_poll, ipc_poll_callback, &dmon); - aki_poll_set(&dmon.ipc_poll, aki_socket_get_fd(&dmon.ipc_socket), AKI_POLL_WRITE); + dmon.ipc_socket.type = NNWT_SOCKET_UNIX; + nn_socket_init(&dmon.ipc_socket, NNWT_SOCKET_NONBLOCKING); + nn_poll_init(&dmon.ipc_poll, ipc_poll_callback, &dmon); + nn_poll_set(&dmon.ipc_poll, nn_socket_get_fd(&dmon.ipc_socket), NNWT_POLL_WRITE); dmon.ipc_connected = false; dmon.ipc_errored = false; char *swaysock = getenv("SWAYSOCK"); - if (swaysock && aki_socket_connect(&dmon.ipc_socket, al_str_cr(swaysock), 0)) { - aki_poll_start(&dmon.ipc_poll, &dmon.loop); + if (swaysock && nn_socket_connect(&dmon.ipc_socket, al_str_cr(swaysock), 0)) { + nn_poll_start(&dmon.ipc_poll, &dmon.loop); } else { dmon.ipc_errored = true; al_log_warn("tarod", "couldn't connect to sway ipc socket"); } - aki_fs_event_init(&dmon.conf_event, &dmon.conf.config_path, - AKI_CLOSE_WRITE, conf_fs_event_callback, &dmon); - aki_fs_event_start(&dmon.conf_event, &dmon.loop); + nn_fs_event_init(&dmon.conf_event, &dmon.conf.config_path, + NNWT_CLOSE_WRITE, conf_fs_event_callback, &dmon); + nn_fs_event_start(&dmon.conf_event, &dmon.loop); - aki_event_loop_run(&dmon.loop); + nn_event_loop_run(&dmon.loop); al_array_foreach(dmon.monitors, i, monitor) { close_monitor(monitor); @@ -534,13 +533,13 @@ s32 main(void) } al_array_free(dmon.monitors); - aki_fs_event_free(&dmon.conf_event); + nn_fs_event_free(&dmon.conf_event); al_free(dmon.out.buf); al_free(dmon.ipc.buf); - aki_socket_close(&dmon.ipc_socket); + nn_socket_close(&dmon.ipc_socket); - aki_event_loop_destroy(&dmon.loop); + nn_event_loop_destroy(&dmon.loop); ret = EXIT_SUCCESS; @@ -548,7 +547,7 @@ out: close_config(&dmon.conf); stl_global_close(); - aki_common_close(); + nn_common_close(); return ret; } @@ -8,11 +8,11 @@ static bool load_entry(struct entry *e) { - struct aki_dir dir; - if (!aki_dir_open(&dir, &e->path)) return false; + struct nn_dir dir; + if (!nn_dir_open(&dir, &e->path)) return false; - struct aki_dir_entry entry; - while (aki_dir_read(&dir, &entry)) { + struct nn_dir_entry entry; + while (nn_dir_read(&dir, &entry)) { if (entry.entry->d_type != DT_REG) { continue; } @@ -26,7 +26,7 @@ static bool load_entry(struct entry *e) str package_path; al_str_clone(&package_path, &e->path); al_str_cat(&package_path, al_str_c("/scene.pkg")); - e->has_package = aki_file_exists(&package_path); + e->has_package = nn_file_exists(&package_path); al_str_free(&package_path); str project_path; @@ -34,7 +34,7 @@ static bool load_entry(struct entry *e) al_str_cat(&project_path, al_str_c("/")); al_str_cat(&project_path, al_str_cr(entry.entry->d_name)); - json_t *root = aki_file_open_as_json(&project_path); + json_t *root = nn_file_open_as_json(&project_path); al_str_free(&project_path); if (!root) continue; e->loaded = true; @@ -49,7 +49,7 @@ static bool load_entry(struct entry *e) al_str_clone(&e->preview_path, &e->path); al_str_cat(&e->preview_path, al_str_c("/")); al_str_cat(&e->preview_path, al_str_cr(json_string_value(preview))); - e->has_preview = aki_file_exists(&e->preview_path); + e->has_preview = nn_file_exists(&e->preview_path); } json_t *general = json_object_get(root, "general"); @@ -127,7 +127,7 @@ static bool load_entry(struct entry *e) } } - aki_dir_close(&dir); + nn_dir_close(&dir); return e->loaded; } @@ -159,12 +159,12 @@ static s32 wallpaper_id_compare(const void *a, const void *b) bool db_load_entries(struct db *db, str *path) { - struct aki_dir dir; - if (!aki_dir_open(&dir, path)) return false; + struct nn_dir dir; + if (!nn_dir_open(&dir, path)) return false; al_array_init(db->entries); - struct aki_dir_entry entry; - while (aki_dir_read(&dir, &entry)) { + struct nn_dir_entry entry; + while (nn_dir_read(&dir, &entry)) { if (!(entry.entry->d_type == DT_DIR || entry.entry->d_type == DT_UNKNOWN)) { continue; } @@ -178,7 +178,7 @@ bool db_load_entries(struct db *db, str *path) al_str_clone(&e.path, path); al_str_cat(&e.path, al_str_c("/")); al_str_cat(&e.path, &e.id); - if (!aki_dir_exists(&e.path)) { + if (!nn_dir_exists(&e.path)) { al_str_free(&e.id); al_str_free(&e.path); continue; diff --git a/taro/file_ext.c b/taro/file_ext.c index 3091fa4..1d1bbdc 100644 --- a/taro/file_ext.c +++ b/taro/file_ext.c @@ -2,32 +2,32 @@ #include "file_ext.h" -bool aki_file_open_and_read_wholly(str *path, str *out, bool lock) +bool nn_file_open_and_read_wholly(str *path, str *out, bool lock) { - struct aki_file file; - if (!aki_file_open(&file, path, lock ? AKI_FILE_LOCK : AKI_FILE_READONLY)) { + struct nn_file file; + if (!nn_file_open(&file, path, lock ? NNWT_FILE_LOCK : NNWT_FILE_READONLY)) { return false; } - s32 ret = aki_file_read_as_str(&file, out); - aki_file_close(&file); + s32 ret = nn_file_read_as_str(&file, out); + nn_file_close(&file); return ret != -1; } -bool aki_file_open_and_replace(str *path, str *buf, bool lock) +bool nn_file_open_and_replace(str *path, str *buf, bool lock) { - struct aki_file file; - if (!aki_file_open(&file, path, lock ? AKI_FILE_LOCK : 0)) { + struct nn_file file; + if (!nn_file_open(&file, path, lock ? NNWT_FILE_LOCK : 0)) { return false; } - s32 ret = aki_file_replace(&file, buf); - aki_file_close(&file); + s32 ret = nn_file_replace(&file, buf); + nn_file_close(&file); return ret != -1; } -json_t *aki_file_open_as_json(str *path) +json_t *nn_file_open_as_json(str *path) { str s; - if (!aki_file_open_and_read_wholly(path, &s, false)) { + if (!nn_file_open_and_read_wholly(path, &s, false)) { return NULL; } json_error_t error; @@ -39,7 +39,7 @@ json_t *aki_file_open_as_json(str *path) return root; } -bool aki_dump_json_and_decref(str *path, json_t *root) +bool nn_dump_json_and_decref(str *path, json_t *root) { str s; size_t size = json_dumpb(root, NULL, 0, JSON_INDENT(4)); @@ -49,7 +49,7 @@ bool aki_dump_json_and_decref(str *path, json_t *root) json_decref(root); return false; } - bool ret = aki_file_open_and_replace(path, &s, false); + bool ret = nn_file_open_and_replace(path, &s, false); al_str_free(&s); json_decref(root); return ret; diff --git a/taro/file_ext.h b/taro/file_ext.h index 9398eb3..8ff69dd 100644 --- a/taro/file_ext.h +++ b/taro/file_ext.h @@ -1,7 +1,7 @@ -#include <aki/file.h> +#include <nnwt/file.h> #include <jansson.h> -bool aki_file_open_and_read_wholly(str *path, str *out, bool lock); -bool aki_file_open_and_replace(str *path, str *buf, bool lock); -json_t *aki_file_open_as_json(str *path); -bool aki_dump_json_and_decref(str *path, json_t *root); +bool nn_file_open_and_read_wholly(str *path, str *out, bool lock); +bool nn_file_open_and_replace(str *path, str *buf, bool lock); +json_t *nn_file_open_as_json(str *path); +bool nn_dump_json_and_decref(str *path, json_t *root); diff --git a/taro/meson.build b/taro/meson.build index cbac318..487c671 100644 --- a/taro/meson.build +++ b/taro/meson.build @@ -14,13 +14,13 @@ if not notcurses.found() or not notcurses_core.found() notcurses_core = notcurses_proj.dependency('notcurses-core') endif -taro_deps = [akiyo, notcurses, notcurses_core] +taro_deps = [naunet, notcurses, notcurses_core] taro_src = ['ui.c', 'db.c', 'file_ext.c'] -tarod_deps = [akiyo, stela] +tarod_deps = [naunet, stela] tarod_src = ['daemon.c', 'file_ext.c'] executable('taro', taro_src, dependencies: taro_deps, install: true) executable('tarod', tarod_src, dependencies: tarod_deps, install: true) -executable('notcurses_test', ['tests/notcurses_ffmpeg.c'], dependencies: [akiyo, notcurses, notcurses_core]) +subdir('tests') diff --git a/taro/tests/meson.build b/taro/tests/meson.build new file mode 100644 index 0000000..00ecb00 --- /dev/null +++ b/taro/tests/meson.build @@ -0,0 +1 @@ +executable('notcurses_test', ['notcurses_ffmpeg.c'], dependencies: [naunet, notcurses, notcurses_core]) diff --git a/taro/tests/notcurses_ffmpeg.c b/taro/tests/notcurses_ffmpeg.c index dd798c9..adf9689 100644 --- a/taro/tests/notcurses_ffmpeg.c +++ b/taro/tests/notcurses_ffmpeg.c @@ -1,11 +1,11 @@ #include <al/types.h> -#include <aki/common.h> +#include <nnwt/common.h> #include <notcurses/notcurses.h> #include <notcurses/nckeys.h> s32 main(void) { - if (!aki_common_init()) return EXIT_FAILURE; + if (!nn_common_init()) return EXIT_FAILURE; struct notcurses *nc = notcurses_init(NULL, stdin); @@ -29,7 +29,7 @@ s32 main(void) out: notcurses_stop(nc); - aki_common_close(); + nn_common_close(); return EXIT_SUCCESS; } @@ -1,9 +1,9 @@ #include <al/log.h> #include <al/lib.h> #include <al/random.h> -#include <aki/common.h> -#include <aki/event_loop.h> -#include <aki/timer.h> +#include <nnwt/common.h> +#include <nnwt/event_loop.h> +#include <nnwt/timer.h> #include <notcurses/notcurses.h> #include <notcurses/nckeys.h> @@ -114,10 +114,10 @@ enum { struct ui { struct notcurses *nc; - struct aki_event_loop loop; - struct aki_poll input_poll; + struct nn_event_loop loop; + struct nn_poll input_poll; u64 delay; - struct aki_timer timer; + struct nn_timer timer; bool layed_out; f32 text_update; u32 term_rows; @@ -140,7 +140,7 @@ static s32 get_entry_from_config(struct ui *u) { s32 ret = -1; str config; - if (aki_file_open_and_read_wholly(&u->m.selection_path, &config, false)) { + if (nn_file_open_and_read_wholly(&u->m.selection_path, &config, false)) { s32 index = al_str_find(&config, '|'); if (index > 2) { str *id = al_str_substr(&config, 0, index - 2); @@ -200,7 +200,7 @@ static void write_selected_entry_to_config(struct ui *u) config.len--; } } - aki_file_open_and_replace(&u->m.selection_path, &config, true); + nn_file_open_and_replace(&u->m.selection_path, &config, true); } // --------- @@ -302,7 +302,7 @@ static bool init_monitors(struct ui *u, struct monitors *m) al_str_clone(&monitors_path, &u->conf.config_dir); al_str_cat(&monitors_path, al_str_c("/monitors")); str monitors; - bool ret = aki_file_open_and_read_wholly(&monitors_path, &monitors, false); + bool ret = nn_file_open_and_read_wholly(&monitors_path, &monitors, false); al_str_free(&monitors_path); if (!ret) { al_log_error("taro", "failed to open monitor list, has `tarod` run?"); @@ -314,7 +314,7 @@ static bool init_monitors(struct ui *u, struct monitors *m) al_str_clone(&monitor_dir, &u->conf.config_dir); al_str_cat(&monitor_dir, al_str_c("/")); al_str_cat(&monitor_dir, &monitor); - if (aki_dir_exists(&monitor_dir)) { + if (nn_dir_exists(&monitor_dir)) { char *c_str = al_str_to_c_str(&monitor); al_array_push(m->monitors, c_str); } @@ -1121,7 +1121,7 @@ static void input_poll_callback(void *userdata, s32 revents) draw_grid_tiles(u, &u->g, false); should_render = true; } else if (input.id == 'q') { - aki_event_loop_break(&u->loop); + nn_event_loop_break(&u->loop); } switch (u->selected_menu) { case MENU_GRID: @@ -1139,7 +1139,7 @@ static void input_poll_callback(void *userdata, s32 revents) if (should_render) notcurses_render(u->nc); } -static void timer_callback(void *userdata, struct aki_timer *timer) +static void timer_callback(void *userdata, struct nn_timer *timer) { struct ui *u = (struct ui *)userdata; (void)timer; @@ -1163,15 +1163,15 @@ static void timer_callback(void *userdata, struct aki_timer *timer) notcurses_render(u->nc); - aki_timer_set_repeat(&u->timer, AKI_TS_FROM_USEC(u->delay)); - aki_timer_again(&u->timer); + nn_timer_set_repeat(&u->timer, NNWT_TS_FROM_USEC(u->delay)); + nn_timer_again(&u->timer); } static struct ui u = { 0 }; s32 main(void) { - if (!aki_common_init()) return EXIT_FAILURE; + if (!nn_common_init()) return EXIT_FAILURE; if (!open_config(&u.conf, false)) { al_log_error("taro", "failed to open config, run `tarod` at least once to generate needed config"); @@ -1201,17 +1201,17 @@ s32 main(void) u.layed_out = true; draw_monitors(&u, &u.m); - aki_event_loop_init(&u.loop); + nn_event_loop_init(&u.loop); - aki_poll_init(&u.input_poll, input_poll_callback, &u); - aki_poll_set(&u.input_poll, notcurses_inputready_fd(u.nc), AKI_POLL_READ); - aki_poll_start(&u.input_poll, &u.loop); + nn_poll_init(&u.input_poll, input_poll_callback, &u); + nn_poll_set(&u.input_poll, notcurses_inputready_fd(u.nc), NNWT_POLL_READ); + nn_poll_start(&u.input_poll, &u.loop); - aki_timer_init(&u.timer, &u.loop, timer_callback, &u); + nn_timer_init(&u.timer, &u.loop, timer_callback, &u); u.delay = 1000000; // 1fps. timer_callback(&u, NULL); - aki_event_loop_run(&u.loop); + nn_event_loop_run(&u.loop); notcurses_stop(u.nc); @@ -1220,7 +1220,7 @@ s32 main(void) out: close_config(&u.conf); - aki_common_close(); + nn_common_close(); return ret; } |