Add NeoNet Yabasic networking FFI library, fix fcitx5 service and WM context menus, install yabasic-doc and mandoc

This commit is contained in:
Luxferre committed 2026-10-27 07:39:07 +02:00
1 parent fb3723fab4
commit 726500085a
33 files changed
+2617 -69

No files matched your search

+110 -15
View File
@@ -816,6 +816,26 @@ trigger_plugin_open(const char *plugin_spec)
spawn_detached_sh(cmd);
}
static void
send_dwm_cmd(long op, long argval)
{
if (!dpy)
return;
Atom cmd_atom = XInternAtom(dpy, "_BANANARCHY_DWM_CMD", False);
XClientMessageEvent cme;
memset(&cme, 0, sizeof(cme));
cme.type = ClientMessage;
cme.display = dpy;
cme.window = root;
cme.message_type = cmd_atom;
cme.format = 32;
cme.data.l[0] = op;
cme.data.l[1] = argval;
XSetErrorHandler(ignore_xerror);
XSendEvent(dpy, root, False, SubstructureRedirectMask | SubstructureNotifyMask, (XEvent *)&cme);
XSync(dpy, False);
}
static void
send_key_to_window(Window target, KeySym ksym, unsigned int mod_state)
{
@@ -1208,6 +1228,29 @@ activate_selection(unsigned int ev_state)
}
return;
}
if (strncmp(act, "@wm:", 4) == 0) {
const char *wm_act = act + 4;
hide_menu();
menu_mode = MODE_NONE;
if (strncmp(wm_act, "move:", 5) == 0) {
send_dwm_cmd(1, atoi(wm_act + 5));
} else if (strncmp(wm_act, "view:", 5) == 0) {
send_dwm_cmd(2, atoi(wm_act + 5));
} else if (strcmp(wm_act, "focusnext") == 0) {
send_dwm_cmd(3, 1);
} else if (strcmp(wm_act, "togglelayout") == 0) {
send_dwm_cmd(4, 1);
} else if (strcmp(wm_act, "kill") == 0) {
send_dwm_cmd(5, (long)target_win);
} else if (strcmp(wm_act, "pushstack") == 0) {
send_dwm_cmd(6, 1);
} else if (strncmp(wm_act, "shiftview:", 10) == 0) {
send_dwm_cmd(7, atoi(wm_act + 10));
} else if (strncmp(wm_act, "tagpush:", 8) == 0) {
send_dwm_cmd(8, atoi(wm_act + 8));
}
return;
}
if (loop) {
spawn_detached_sh(act);
@@ -2212,12 +2255,12 @@ open_builtin_menu(const char *menu_name, int keep_idx)
if (!cls[0] || strcmp(cls, "sys") == 0) {
menu_name = "sys";
} else if (strcmp(cls, "st") == 0 || strncmp(cls, "st-", 3) == 0) {
/* launched from a terminal: also show the exact same Sys menu */
menu_name = "sys";
}
else {
/* launched from an app: show the exact same Sys menu as the desktop */
menu_name = "sys";
if (strstr(ttl, "nano"))
menu_name = "nano";
else
menu_name = "st";
} else {
menu_name = "wm";
}
}
@@ -2454,15 +2497,22 @@ open_builtin_menu(const char *menu_name, int keep_idx)
reset_session_defaults(1, "WM Menu");
for (int ws = 1; ws <= 4; ws++) {
snprintf(label, sizeof(label), "%d Move to WS %d", ws, ws);
snprintf(cmd, sizeof(cmd), "sxmo_wm.sh moveworkspace %d", ws);
add_menu_item(label, cmd, 1);
snprintf(cmd, sizeof(cmd), "@wm:move:%d", ws);
add_menu_item(label, cmd, 0);
}
snprintf(label, sizeof(label), "%s Shift stack", ICON_RLD);
add_menu_item(label, "sxmo_wm.sh switchfocus", 1);
add_menu_item(label, "@wm:focusnext", 0);
snprintf(label, sizeof(label), "%s Swap stack", ICON_A2X);
add_menu_item(label, "@wm:pushstack", 0);
snprintf(label, sizeof(label), "%s Toggle Layout", ICON_GRD);
add_menu_item(label, "sxmo_wm.sh togglelayout", 1);
add_menu_item(label, "@wm:togglelayout", 0);
snprintf(label, sizeof(label), "%s Kill window", ICON_CLS);
add_menu_item(label, "sxmo_killwindow.sh", 0);
add_menu_item(label, "@wm:kill", 0);
for (int ws = 1; ws <= 4; ws++) {
snprintf(label, sizeof(label), "%s Go to WS %d", ICON_WIN, ws);
snprintf(cmd, sizeof(cmd), "@wm:view:%d", ws);
add_menu_item(label, cmd, 0);
}
snprintf(label, sizeof(label), "%s System Menu", ICON_MNU);
add_menu_item(label, "@menu:sys", 1);
snprintf(label, sizeof(label), "%s Close Menu", ICON_CLS);
@@ -2556,7 +2606,9 @@ open_builtin_menu(const char *menu_name, int keep_idx)
snprintf(label, sizeof(label), "%s New Terminal", ICON_TRM);
add_menu_item(label, "sxmo_terminal.sh", 0);
snprintf(label, sizeof(label), "%s Close Terminal", ICON_CLS);
add_menu_item(label, "sxmo_killwindow.sh", 0);
add_menu_item(label, "@wm:kill", 0);
snprintf(label, sizeof(label), "%s Windows", ICON_WIN);
add_menu_item(label, "@menu:wm", 1);
snprintf(label, sizeof(label), "%s Type complete", ICON_ITM);
add_menu_item(label, "@key:ctrl_shift:u", 0);
snprintf(label, sizeof(label), "%s Toggle Selmode", ICON_ITM);
@@ -2606,6 +2658,8 @@ open_builtin_menu(const char *menu_name, int keep_idx)
add_menu_item(label, "@key:none:Next", 1);
snprintf(label, sizeof(label), "%s Terminal menu", ICON_MNU);
add_menu_item(label, "@menu:st", 1);
snprintf(label, sizeof(label), "%s Windows", ICON_WIN);
add_menu_item(label, "@menu:wm", 1);
snprintf(label, sizeof(label), "%s System Menu", ICON_MNU);
add_menu_item(label, "@menu:sys", 1);
snprintf(label, sizeof(label), "%s Close Menu", ICON_CLS);
@@ -2655,6 +2709,7 @@ any_other_plugin_active(void)
"xnetworks.pid",
"xringtones.pid",
"xwallpapers.pid",
"xmusic.pid",
};
const char *rdir = getenv("XDG_RUNTIME_DIR");
const char *base = (rdir && rdir[0]) ? rdir : "/run/user/10000";
@@ -2698,6 +2753,7 @@ close_other_active_plugins(void)
{ "xnetworks.pid", "/tmp/dwm_plugin_networks.fifo" },
{ "xringtones.pid", "/tmp/dwm_plugin_ringtones.fifo" },
{ "xwallpapers.pid", "/tmp/dwm_plugin_wallpapers.fifo" },
{ "xmusic.pid", "/tmp/dwm_plugin_music.fifo" },
};
const char *rdir = getenv("XDG_RUNTIME_DIR");
const char *base = (rdir && rdir[0]) ? rdir : "/run/user/10000";
@@ -2942,8 +2998,24 @@ show_menu(void)
Window fw = None;
int rev = 0;
XGetInputFocus(dpy, &fw, &rev);
if (fw != None && fw != PointerRoot && fw != win)
if (fw != None && fw != PointerRoot && fw != root && fw != win)
prevfocuswin = fw;
if (prevfocuswin == None) {
Atom net_active = XInternAtom(dpy, "_NET_ACTIVE_WINDOW", False);
Atom actual_type = None;
int actual_fmt = 0;
unsigned long nitems = 0, bytes_after = 0;
unsigned char *prop = NULL;
if (XGetWindowProperty(dpy, root, net_active, 0L, 1L, False, XA_WINDOW,
&actual_type, &actual_fmt, &nitems, &bytes_after, &prop) == Success && prop) {
if (actual_type == XA_WINDOW && actual_fmt == 32 && nitems >= 1) {
Window aw = *(Window *)prop;
if (aw != None && aw != PointerRoot && aw != root && aw != win)
prevfocuswin = aw;
}
XFree(prop);
}
}
XEvent ev;
while (XPending(dpy))
@@ -2996,13 +3068,13 @@ hide_menu(void)
XUnsetICFocus(xic);
}
XUngrabKeyboard(dpy, CurrentTime);
XUnmapWindow(dpy, win);
XSetErrorHandler(ignore_xerror);
if (!daemon_mode && prevfocuswin && prevfocuswin != win && prevfocuswin != PointerRoot) {
if (prevfocuswin && prevfocuswin != win && prevfocuswin != PointerRoot) {
XWindowAttributes wa;
if (XGetWindowAttributes(dpy, prevfocuswin, &wa) && wa.map_state == IsViewable)
XSetInputFocus(dpy, prevfocuswin, RevertToParent, CurrentTime);
}
XUnmapWindow(dpy, win);
prevfocuswin = None;
XSync(dpy, False);
@@ -3722,6 +3794,29 @@ dmenu_run_main(int argc, char *argv[])
(cur_path && cur_path[0]) ? cur_path : "/usr/local/bin:/usr/bin:/bin:/sbin:/usr/sbin");
setenv("PATH", new_path, 1);
}
if (!getenv("DISPLAY"))
setenv("DISPLAY", ":0", 0);
if (!getenv("XDG_RUNTIME_DIR"))
setenv("XDG_RUNTIME_DIR", "/run/user/10000", 0);
if (!getenv("SXMO_WM"))
setenv("SXMO_WM", "dwm", 0);
if (!getenv("SXMO_MENU"))
setenv("SXMO_MENU", "dmenu", 0);
if (!getenv("SXMO_TERMINAL"))
setenv("SXMO_TERMINAL", "st", 0);
setenv("LANG", "C.UTF-8", 1);
setenv("LC_ALL", "C.UTF-8", 1);
setenv("XMODIFIERS", "@im=fcitx", 1);
setenv("GTK_IM_MODULE", "fcitx", 1);
setenv("QT_IM_MODULE", "fcitx", 1);
if (!getenv("DBUS_SESSION_BUS_ADDRESS")) {
const char *rdir = getenv("XDG_RUNTIME_DIR");
char bpath[256], bbuf[256];
snprintf(bpath, sizeof(bpath), "%s/dbus.bus",
(rdir && rdir[0]) ? rdir : "/run/user/10000");
if (read_first_line(bpath, bbuf, sizeof(bbuf)) && bbuf[0])
setenv("DBUS_SESSION_BUS_ADDRESS", bbuf, 1);
}
int lock_fd = -1;
int fifo_fd = -1;