From 6ec95b52a55b4a24f0925b33fc9bed3993a3f5df Mon Sep 17 00:00:00 2001 From: DreamMaoMao <2523610504@qq.com> Date: Tue, 25 Mar 2025 08:30:56 +0800 Subject: [PATCH 01/14] opt: scroller layout not cross monitor --- maomao.c | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/maomao.c b/maomao.c index d7986c00..5a10d19c 100644 --- a/maomao.c +++ b/maomao.c @@ -254,6 +254,7 @@ struct Client { // struct wl_event_source *timer_tick; pid_t pid; Client *swallowing, *swallowedby; + bool is_clip_to_hide; }; @@ -1045,7 +1046,9 @@ void apply_border(Client *c, struct wlr_box clip_box, int offsetx, wlr_scene_node_set_position(&c->border[3]->node, clip_box.width - c->bw, c->bw); - if (c->animation.running && c->animation.action != MOVE) { + if ((c->animation.running && c->animation.action != MOVE) || + (c->istiled && strcmp(c->mon->pertag->ltidxs[c->mon->pertag->curtag]->name, + "scroller") == 0)) { if (c->animation.current.x < c->mon->m.x) { set_rect_size(c->border[2], 0, 0); } else if (c->animation.current.x + c->animation.current.width > @@ -1104,7 +1107,9 @@ void client_apply_clip(Client *c) { } // // make tagout tagin animations not visible in other monitors - if (c->animation.running && c->animation.action != MOVE) { + if ((c->animation.running && c->animation.action != MOVE) || + (c->istiled && strcmp(c->mon->pertag->ltidxs[c->mon->pertag->curtag]->name, + "scroller") == 0)) { if (c->animation.current.x <= c->mon->m.x) { offsetx = c->mon->m.x - c->animation.current.x; clip_box.x = clip_box.x + offsetx; @@ -1129,6 +1134,14 @@ void client_apply_clip(Client *c) { } animationScale scale_data; + if(clip_box.width <= 0 || clip_box.height <= 0) { + c->is_clip_to_hide = true; + wlr_scene_node_set_enabled(&c->scene->node, 0); + return; + } else if(c->is_clip_to_hide) { + c->is_clip_to_hide = false; + wlr_scene_node_set_enabled(&c->scene->node, 1); + } scale_data.width = clip_box.width - 2 * c->bw; scale_data.height = clip_box.height - 2 * c->bw; wlr_scene_subsurface_tree_set_clip(&c->scene_surface->node, &clip_box); From 5c7dfa41b5e0357eb4568a2ebce778a96210d6f8 Mon Sep 17 00:00:00 2001 From: DreamMaoMao <2523610504@qq.com> Date: Tue, 25 Mar 2025 10:15:54 +0800 Subject: [PATCH 02/14] feat: add option focus_cross_monitor --- config.conf | 1 + maomao.c | 4 ++-- parse_config.h | 5 +++++ preset_config.h | 1 + 4 files changed, 9 insertions(+), 2 deletions(-) diff --git a/config.conf b/config.conf index 4910f69d..dc01b2a6 100644 --- a/config.conf +++ b/config.conf @@ -19,6 +19,7 @@ animation_curve_close=0.08,0.92,0,1 scroller_structs=20 scroller_default_proportion=0.8 scoller_focus_center=0 +focus_cross_monitor=0 scroller_proportion_preset=0.5,0.8,1.0 # Master-Stack Layout Setting (tile,spiral,dwindle) diff --git a/maomao.c b/maomao.c index 5a10d19c..b3f2d65e 100644 --- a/maomao.c +++ b/maomao.c @@ -1697,7 +1697,7 @@ Client *direction_select(const Arg *arg) { // 第一次遍历,计算客户端数量 wl_list_for_each(c, &clients, link) { - if (c && (c->tags & c->mon->tagset[c->mon->seltags])) { + if (c && (focus_cross_monitor || c->mon == selmon) && (c->tags & c->mon->tagset[c->mon->seltags])) { last++; } } @@ -1716,7 +1716,7 @@ Client *direction_select(const Arg *arg) { // 第二次遍历,填充 tempClients last = -1; wl_list_for_each(c, &clients, link) { - if (c && (c->tags & c->mon->tagset[c->mon->seltags])) { + if (c && (focus_cross_monitor || c->mon == selmon) && (c->tags & c->mon->tagset[c->mon->seltags])) { last++; tempClients[last] = c; } diff --git a/parse_config.h b/parse_config.h index 5706053e..7c79ca16 100644 --- a/parse_config.h +++ b/parse_config.h @@ -93,6 +93,7 @@ typedef struct { int scroller_structs; float scroller_default_proportion; int scoller_focus_center; + int focus_cross_monitor; float *scroller_proportion_preset; int scroller_proportion_preset_count; @@ -552,6 +553,8 @@ void parse_config_line(Config *config, const char *line) { config->scroller_default_proportion = atof(value); } else if (strcmp(key, "scoller_focus_center") == 0) { config->scoller_focus_center = atoi(value); + } else if (strcmp(key, "focus_cross_monitor") == 0) { + config->focus_cross_monitor = atoi(value); } else if (strcmp(key, "scroller_proportion_preset") == 0) { // 1. 统计 value 中有多少个逗号,确定需要解析的浮点数个数 int count = 0; // 初始化为 0 @@ -1130,6 +1133,7 @@ void override_config(void) { scroller_structs = config.scroller_structs; scroller_default_proportion = config.scroller_default_proportion; scoller_focus_center = config.scoller_focus_center; + focus_cross_monitor = config.focus_cross_monitor; new_is_master = config.new_is_master; default_mfact = config.default_mfact; @@ -1208,6 +1212,7 @@ void set_value_default() { config.scroller_structs = 20; config.scroller_default_proportion = 0.9; config.scoller_focus_center = 0; + config.focus_cross_monitor = 0; config.bypass_surface_visibility = 0; /* 1 means idle inhibitors will disable idle tracking even if it's diff --git a/preset_config.h b/preset_config.h index 848593fd..535655cd 100644 --- a/preset_config.h +++ b/preset_config.h @@ -46,6 +46,7 @@ unsigned int gappov = 10; /* vert outer gap between windows and screen edge */ int scroller_structs = 20; float scroller_default_proportion = 0.9; int scoller_focus_center = 0; +int focus_cross_monitor = 0; int bypass_surface_visibility = 0; /* 1 means idle inhibitors will disable idle tracking even if it's From 1700ae40bf661c8803ede1deee4c72bf703c72b5 Mon Sep 17 00:00:00 2001 From: DreamMaoMao <2523610504@qq.com> Date: Tue, 25 Mar 2025 10:23:07 +0800 Subject: [PATCH 03/14] fix: only current monitor frame event to flush animaiton --- maomao.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/maomao.c b/maomao.c index b3f2d65e..18b83298 100644 --- a/maomao.c +++ b/maomao.c @@ -4266,10 +4266,12 @@ void rendermon(struct wl_listener *listener, void *data) { // Draw frames for all clients wl_list_for_each(c, &clients, link) { + if(c->mon != m) continue; need_more_frames = client_draw_frame(c) || need_more_frames; } wl_list_for_each_safe(c, tmp, &fadeout_clients, fadeout_link) { + if(c->mon != m) continue; need_more_frames = client_draw_fadeout_frame(c) || need_more_frames; } From 6566262f8e113810587a156acea8a650aea1fc86 Mon Sep 17 00:00:00 2001 From: DreamMaoMao <2523610504@qq.com> Date: Tue, 25 Mar 2025 10:31:07 +0800 Subject: [PATCH 04/14] opt: change some value to bool type --- maomao.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/maomao.c b/maomao.c index 18b83298..ae6b06be 100644 --- a/maomao.c +++ b/maomao.c @@ -1136,11 +1136,11 @@ void client_apply_clip(Client *c) { animationScale scale_data; if(clip_box.width <= 0 || clip_box.height <= 0) { c->is_clip_to_hide = true; - wlr_scene_node_set_enabled(&c->scene->node, 0); + wlr_scene_node_set_enabled(&c->scene->node, false); return; } else if(c->is_clip_to_hide) { c->is_clip_to_hide = false; - wlr_scene_node_set_enabled(&c->scene->node, 1); + wlr_scene_node_set_enabled(&c->scene->node, true); } scale_data.width = clip_box.width - 2 * c->bw; scale_data.height = clip_box.height - 2 * c->bw; @@ -1347,8 +1347,8 @@ swallow(Client *c, Client *w) if(w->foreign_toplevel) remove_foreign_topleve(w); - wlr_scene_node_set_enabled(&w->scene->node, 0); - wlr_scene_node_set_enabled(&c->scene->node, 1); + wlr_scene_node_set_enabled(&w->scene->node, false); + wlr_scene_node_set_enabled(&c->scene->node, true); if(!c->foreign_toplevel && c->mon) add_foreign_toplevel(c); @@ -2792,7 +2792,7 @@ void destroylock(SessionLock *lock, int unlock) { if ((locked = !unlock)) goto destroy; - wlr_scene_node_set_enabled(&locked_bg->node, 0); + wlr_scene_node_set_enabled(&locked_bg->node, false); focusclient(focustop(selmon), 0); motionnotify(0, NULL, 0, 0, 0, 0); @@ -3692,7 +3692,7 @@ void killclient(const Arg *arg) { void locksession(struct wl_listener *listener, void *data) { struct wlr_session_lock_v1 *session_lock = data; SessionLock *lock; - wlr_scene_node_set_enabled(&locked_bg->node, 1); + wlr_scene_node_set_enabled(&locked_bg->node, true); if (cur_lock) { wlr_session_lock_v1_destroy(session_lock); return; @@ -5208,7 +5208,7 @@ void setup(void) { locked_bg = wlr_scene_rect_create(layers[LyrBlock], sgeom.width, sgeom.height, (float[4]){0.1, 0.1, 0.1, 1.0}); - wlr_scene_node_set_enabled(&locked_bg->node, 0); + wlr_scene_node_set_enabled(&locked_bg->node, false); /* Use decoration protocols to negotiate server-side decorations */ wlr_server_decoration_manager_set_default_mode( @@ -6097,7 +6097,7 @@ void unmaplayersurfacenotify(struct wl_listener *listener, void *data) { LayerSurface *l = wl_container_of(listener, l, unmap); l->mapped = 0; - wlr_scene_node_set_enabled(&l->scene->node, 0); + wlr_scene_node_set_enabled(&l->scene->node, false); if (l == exclusive_focus) exclusive_focus = NULL; if (l->layer_surface->output && (l->mon = l->layer_surface->output->data)) From d76235e6da0ed256e3d639168ae7bb423f880bce Mon Sep 17 00:00:00 2001 From: DreamMaoMao <2523610504@qq.com> Date: Tue, 25 Mar 2025 10:31:40 +0800 Subject: [PATCH 05/14] fix: not enable node in arrange when it is clip_to_hide --- maomao.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/maomao.c b/maomao.c index ae6b06be..6a51a47c 100644 --- a/maomao.c +++ b/maomao.c @@ -1599,7 +1599,8 @@ arrange(Monitor *m, bool want_animation) { if (c->mon == m) { if (VISIBLEON(c, m)) { - wlr_scene_node_set_enabled(&c->scene->node, true); + if(!c->is_clip_to_hide) + wlr_scene_node_set_enabled(&c->scene->node, true); client_set_suspended(c, false); if (!c->animation.from_rule && want_animation && m->pertag->prevtag != 0 && m->pertag->curtag != 0 && animations) { From 763f52316624c911f7da87d9a36263b8607aa970 Mon Sep 17 00:00:00 2001 From: DreamMaoMao <2523610504@qq.com> Date: Tue, 25 Mar 2025 10:36:53 +0800 Subject: [PATCH 06/14] opt:warp cursor to new mon after foucsmon --- maomao.c | 1 + 1 file changed, 1 insertion(+) diff --git a/maomao.c b/maomao.c index 6a51a47c..96198fcb 100644 --- a/maomao.c +++ b/maomao.c @@ -3228,6 +3228,7 @@ void focusmon(const Arg *arg) { selmon = dirtomon(arg->i); while (!selmon->wlr_output->enabled && i++ < nmons); } + warp_cursor_to_selmon(selmon); focusclient(focustop(selmon), 1); } From 60d9c3b23a85fb8ac57f739265c55ec439f90184 Mon Sep 17 00:00:00 2001 From: DreamMaoMao <2523610504@qq.com> Date: Tue, 25 Mar 2025 10:47:38 +0800 Subject: [PATCH 07/14] fix: error node enable when clip --- maomao.c | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/maomao.c b/maomao.c index 96198fcb..932579be 100644 --- a/maomao.c +++ b/maomao.c @@ -1046,9 +1046,7 @@ void apply_border(Client *c, struct wlr_box clip_box, int offsetx, wlr_scene_node_set_position(&c->border[3]->node, clip_box.width - c->bw, c->bw); - if ((c->animation.running && c->animation.action != MOVE) || - (c->istiled && strcmp(c->mon->pertag->ltidxs[c->mon->pertag->curtag]->name, - "scroller") == 0)) { + if (c->istiled) { if (c->animation.current.x < c->mon->m.x) { set_rect_size(c->border[2], 0, 0); } else if (c->animation.current.x + c->animation.current.width > @@ -1107,9 +1105,7 @@ void client_apply_clip(Client *c) { } // // make tagout tagin animations not visible in other monitors - if ((c->animation.running && c->animation.action != MOVE) || - (c->istiled && strcmp(c->mon->pertag->ltidxs[c->mon->pertag->curtag]->name, - "scroller") == 0)) { + if (c->istiled) { if (c->animation.current.x <= c->mon->m.x) { offsetx = c->mon->m.x - c->animation.current.x; clip_box.x = clip_box.x + offsetx; @@ -1133,15 +1129,15 @@ void client_apply_clip(Client *c) { } } - animationScale scale_data; - if(clip_box.width <= 0 || clip_box.height <= 0) { + if((clip_box.width <= 0 || clip_box.height <= 0) && (c->istiled)) { c->is_clip_to_hide = true; wlr_scene_node_set_enabled(&c->scene->node, false); return; - } else if(c->is_clip_to_hide) { + } else if(c->is_clip_to_hide && VISIBLEON(c, c->mon)) { c->is_clip_to_hide = false; wlr_scene_node_set_enabled(&c->scene->node, true); } + animationScale scale_data; scale_data.width = clip_box.width - 2 * c->bw; scale_data.height = clip_box.height - 2 * c->bw; wlr_scene_subsurface_tree_set_clip(&c->scene_surface->node, &clip_box); From 73ebdb0fddd55acb6f270cc6e3117a94ca51a64d Mon Sep 17 00:00:00 2001 From: DreamMaoMao <2523610504@qq.com> Date: Tue, 25 Mar 2025 12:12:36 +0800 Subject: [PATCH 08/14] fix: tagmon miss scan window size --- maomao.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/maomao.c b/maomao.c index 932579be..d924b2c9 100644 --- a/maomao.c +++ b/maomao.c @@ -5442,14 +5442,14 @@ void tagmon(const Arg *arg) { if (c) { setmon(c, dirtomon(arg->i), 0); reset_foreign_tolevel(c); - selmon = c->mon; - c->geom.width = (int)(c->geom.width * selmon->m.width / c->mon->m.width); + c->geom.width = (int)(c->geom.width * c->mon->w.width / selmon->w.width); c->geom.height = - (int)(c->geom.height * selmon->m.height / c->mon->m.height); + (int)(c->geom.height * c->mon->w.height / selmon->w.height); + selmon = c->mon; // 重新计算居中的坐标 if (c->isfloating) { c->geom = setclient_coordinate_center(c->geom); - resize(c, c->geom, 0); + resize(c, c->geom, 1); } warp_cursor_to_selmon(c->mon); focusclient(c, 1); From 54109d3bf68519eca9f716f47914668958c95bfc Mon Sep 17 00:00:00 2001 From: DreamMaoMao <2523610504@qq.com> Date: Tue, 25 Mar 2025 13:00:42 +0800 Subject: [PATCH 09/14] fix: only scroller layout support is_clip_to_hide --- maomao.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/maomao.c b/maomao.c index d924b2c9..590d9c5f 100644 --- a/maomao.c +++ b/maomao.c @@ -1595,7 +1595,8 @@ arrange(Monitor *m, bool want_animation) { if (c->mon == m) { if (VISIBLEON(c, m)) { - if(!c->is_clip_to_hide) + if(!c->is_clip_to_hide || strcmp(c->mon->pertag->ltidxs[c->mon->pertag->curtag]->name, + "scroller") != 0) wlr_scene_node_set_enabled(&c->scene->node, true); client_set_suspended(c, false); if (!c->animation.from_rule && want_animation && From beeee7ec7dd5965871656cd4de4c5acad5375124 Mon Sep 17 00:00:00 2001 From: DreamMaoMao <2523610504@qq.com> Date: Tue, 25 Mar 2025 13:02:50 +0800 Subject: [PATCH 10/14] fix: tagmon miss arrange --- maomao.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/maomao.c b/maomao.c index 590d9c5f..53e6f746 100644 --- a/maomao.c +++ b/maomao.c @@ -5443,14 +5443,17 @@ void tagmon(const Arg *arg) { if (c) { setmon(c, dirtomon(arg->i), 0); reset_foreign_tolevel(c); - c->geom.width = (int)(c->geom.width * c->mon->w.width / selmon->w.width); - c->geom.height = - (int)(c->geom.height * c->mon->w.height / selmon->w.height); - selmon = c->mon; // 重新计算居中的坐标 if (c->isfloating) { + c->geom.width = (int)(c->geom.width * c->mon->w.width / selmon->w.width); + c->geom.height = + (int)(c->geom.height * c->mon->w.height / selmon->w.height); + selmon = c->mon; c->geom = setclient_coordinate_center(c->geom); resize(c, c->geom, 1); + } else { + selmon = c->mon; + arrange(selmon, false); } warp_cursor_to_selmon(c->mon); focusclient(c, 1); From 2d304075627874edbfb9dfad97d9b86022c6fbed Mon Sep 17 00:00:00 2001 From: DreamMaoMao <2523610504@qq.com> Date: Tue, 25 Mar 2025 15:23:56 +0800 Subject: [PATCH 11/14] opt:opt tag anim init position --- maomao.c | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/maomao.c b/maomao.c index 53e6f746..bd23a6c5 100644 --- a/maomao.c +++ b/maomao.c @@ -7,6 +7,7 @@ #include #include #include +#include #include #include #include @@ -1132,6 +1133,14 @@ void client_apply_clip(Client *c) { if((clip_box.width <= 0 || clip_box.height <= 0) && (c->istiled)) { c->is_clip_to_hide = true; wlr_scene_node_set_enabled(&c->scene->node, false); + if(c->animation.tagouting) { + c->animation.tagouting = false; + c->animation.current = c->geom; + c->animation.tagouted = true; + c->current = c->geom; + } + c->animation.running = false; + c->need_output_flush = false; return; } else if(c->is_clip_to_hide && VISIBLEON(c, c->mon)) { c->is_clip_to_hide = false; @@ -1596,8 +1605,9 @@ arrange(Monitor *m, bool want_animation) { if (c->mon == m) { if (VISIBLEON(c, m)) { if(!c->is_clip_to_hide || strcmp(c->mon->pertag->ltidxs[c->mon->pertag->curtag]->name, - "scroller") != 0) + "scroller") != 0) { wlr_scene_node_set_enabled(&c->scene->node, true); + } client_set_suspended(c, false); if (!c->animation.from_rule && want_animation && m->pertag->prevtag != 0 && m->pertag->curtag != 0 && animations) { @@ -1606,7 +1616,7 @@ arrange(Monitor *m, bool want_animation) { c->animainit_geom.x = c->animation.running ? c->animation.current.x - : c->geom.x + c->mon->m.width - (c->geom.x - c->mon->m.x); + : c->mon->m.x + c->mon->m.width; } else { c->animainit_geom.x = c->animation.running ? c->animation.current.x : m->m.x - c->geom.width; @@ -1631,7 +1641,7 @@ arrange(Monitor *m, bool want_animation) { } else { c->pending = c->geom; c->pending.x = - c->geom.x + c->mon->m.width - (c->geom.x - c->mon->m.x); + c->mon->m.x + c->mon->m.width; resize(c, c->geom, 0); } } else { From 3c7991b11ebfd81535132fa352384bf6ed25b8ce Mon Sep 17 00:00:00 2001 From: DreamMaoMao <2523610504@qq.com> Date: Tue, 25 Mar 2025 15:37:52 +0800 Subject: [PATCH 12/14] fix: flash when tag in the bug due to only current monitor frame event flush animation --- maomao.c | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/maomao.c b/maomao.c index bd23a6c5..9cd43535 100644 --- a/maomao.c +++ b/maomao.c @@ -1133,14 +1133,6 @@ void client_apply_clip(Client *c) { if((clip_box.width <= 0 || clip_box.height <= 0) && (c->istiled)) { c->is_clip_to_hide = true; wlr_scene_node_set_enabled(&c->scene->node, false); - if(c->animation.tagouting) { - c->animation.tagouting = false; - c->animation.current = c->geom; - c->animation.tagouted = true; - c->current = c->geom; - } - c->animation.running = false; - c->need_output_flush = false; return; } else if(c->is_clip_to_hide && VISIBLEON(c, c->mon)) { c->is_clip_to_hide = false; @@ -4275,12 +4267,10 @@ void rendermon(struct wl_listener *listener, void *data) { // Draw frames for all clients wl_list_for_each(c, &clients, link) { - if(c->mon != m) continue; need_more_frames = client_draw_frame(c) || need_more_frames; } wl_list_for_each_safe(c, tmp, &fadeout_clients, fadeout_link) { - if(c->mon != m) continue; need_more_frames = client_draw_fadeout_frame(c) || need_more_frames; } From 0c2b2a4f54ffdbf6fc340d489f70ebe3a9bc3f48 Mon Sep 17 00:00:00 2001 From: DreamMaoMao <2523610504@qq.com> Date: Tue, 25 Mar 2025 15:42:23 +0800 Subject: [PATCH 13/14] fix: avoid use another monitor clients to caculate view found --- maomao.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/maomao.c b/maomao.c index 9cd43535..b4c35cbf 100644 --- a/maomao.c +++ b/maomao.c @@ -6467,7 +6467,7 @@ void viewtoright_have_client(const Arg *arg) { for (target <<= 1; target & TAGMASK; target <<= 1, n++) { wl_list_for_each(c, &clients, link) { - if (target & c->tags) { + if (target & c->tags && c->mon == selmon) { found = 1; break; } @@ -6541,7 +6541,7 @@ void viewtoleft_have_client(const Arg *arg) { for (target >>= 1; target > 0; target >>= 1, n++) { wl_list_for_each(c, &clients, link) { - if (target & c->tags) { + if (target & c->tags && c->mon == selmon) { found = 1; break; } From ade3905e05767f2bbcce8fe4dc488fa88ccdd63b Mon Sep 17 00:00:00 2001 From: DreamMaoMao <2523610504@qq.com> Date: Tue, 25 Mar 2025 15:48:56 +0800 Subject: [PATCH 14/14] update nix --- flake.lock | 55 ++++++++++++++++++++++++++++++++++ flake.nix | 10 ++++++- nix/default.nix | 4 +++ nix/nixos-modules.nix | 68 +++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 136 insertions(+), 1 deletion(-) create mode 100644 nix/nixos-modules.nix diff --git a/flake.lock b/flake.lock index 620452fb..6bce6d69 100644 --- a/flake.lock +++ b/flake.lock @@ -18,6 +18,45 @@ "type": "github" } }, + "flake-parts_2": { + "inputs": { + "nixpkgs-lib": "nixpkgs-lib_2" + }, + "locked": { + "lastModified": 1741352980, + "narHash": "sha256-+u2UunDA4Cl5Fci3m7S643HzKmIDAe+fiXrLqYsR2fs=", + "owner": "hercules-ci", + "repo": "flake-parts", + "rev": "f4330d22f1c5d2ba72d3d22df5597d123fdb60a9", + "type": "github" + }, + "original": { + "owner": "hercules-ci", + "repo": "flake-parts", + "type": "github" + } + }, + "mmsg": { + "inputs": { + "flake-parts": "flake-parts_2", + "nixpkgs": [ + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1742777868, + "narHash": "sha256-MdHiygQjBoM22LUJSjeW87t7eDkfRLI2F4Nd64xdLX4=", + "owner": "DreamMaoMao", + "repo": "mmsg", + "rev": "6c9dc91e86a0eb89db3ef8f8290530441cb7b658", + "type": "github" + }, + "original": { + "owner": "DreamMaoMao", + "repo": "mmsg", + "type": "github" + } + }, "nixpkgs": { "locked": { "lastModified": 1740019556, @@ -46,9 +85,25 @@ "url": "https://github.com/NixOS/nixpkgs/archive/072a6db25e947df2f31aab9eccd0ab75d5b2da11.tar.gz" } }, + "nixpkgs-lib_2": { + "locked": { + "lastModified": 1740877520, + "narHash": "sha256-oiwv/ZK/2FhGxrCkQkB83i7GnWXPPLzoqFHpDD3uYpk=", + "owner": "nix-community", + "repo": "nixpkgs.lib", + "rev": "147dee35aab2193b174e4c0868bd80ead5ce755c", + "type": "github" + }, + "original": { + "owner": "nix-community", + "repo": "nixpkgs.lib", + "type": "github" + } + }, "root": { "inputs": { "flake-parts": "flake-parts", + "mmsg": "mmsg", "nixpkgs": "nixpkgs", "treefmt-nix": "treefmt-nix" } diff --git a/flake.nix b/flake.nix index 866bb7fc..6b52aed6 100644 --- a/flake.nix +++ b/flake.nix @@ -6,10 +6,15 @@ url = "github:numtide/treefmt-nix"; inputs.nixpkgs.follows = "nixpkgs"; }; + mmsg = { + url = "github:DreamMaoMao/mmsg"; + inputs.nixpkgs.follows = "nixpkgs"; + }; }; outputs = { + self, flake-parts, treefmt-nix, ... @@ -19,7 +24,10 @@ inputs.flake-parts.flakeModules.easyOverlay ]; - flake.hmModules.maomaowm = import ./nix/hm-modules.nix; + flake = { + hmModules.maomaowm = import ./nix/hm-modules.nix; + nixosModules.maomaowm = import ./nix/nixos-modules.nix { inherit inputs self; }; + }; perSystem = { diff --git a/nix/default.nix b/nix/default.nix index 8cca30b1..d76f4af3 100644 --- a/nix/default.nix +++ b/nix/default.nix @@ -49,6 +49,10 @@ stdenv.mkDerivation { xwayland ]; + passthru = { + providedSessions = [ "maomao" ]; + }; + meta = { mainProgram = "maomao"; description = "A streamlined but feature-rich Wayland compositor"; diff --git a/nix/nixos-modules.nix b/nix/nixos-modules.nix new file mode 100644 index 00000000..fc570b94 --- /dev/null +++ b/nix/nixos-modules.nix @@ -0,0 +1,68 @@ +{ inputs, self }: +{ + config, + lib, + pkgs, + ... +}: +let + cfg = config.programs.maomaowm; + mmsg = lib.types.submodule { + options = { + enable = lib.mkEnableOption "Enable mmsg, the ipc for maomaowm"; + package = lib.mkOption { + type = lib.types.package; + default = inputs.mmsg.packages.${pkgs.system}.mmsg; + description = "The mmsg package to use"; + }; + }; + }; +in +{ + options = { + programs.maomaowm = { + enable = lib.mkEnableOption "maomaowm, a wayland compositor based on dwl"; + package = lib.mkOption { + type = lib.types.package; + default = self.packages.${pkgs.system}.maomaowm; + description = "The maomaowm package to use"; + }; + mmsg = lib.mkOption { + type = mmsg; + default = { + enable = true; + }; + description = "Options for mmsg, the ipc for maomaowm"; + }; + }; + }; + + config = lib.mkMerge [ + (lib.mkIf cfg.enable { + environment.systemPackages = [ cfg.package ]; + + xdg.portal = { + enable = lib.mkDefault true; + + wlr.enable = lib.mkDefault true; + + configPackages = [ cfg.package ]; + }; + + security.polkit.enable = lib.mkDefault true; + + programs.xwayland.enable = lib.mkDefault true; + + services = { + displayManager.sessionPackages = [ cfg.package ]; + + graphical-desktop.enable = lib.mkDefault true; + }; + + }) + + (lib.mkIf cfg.mmsg.enable { + environment.systemPackages = [ cfg.mmsg.package ]; + }) + ]; +}