Add NeoNet Yabasic networking FFI library, fix fcitx5 service and WM context menus, install yabasic-doc and mandoc
This commit is contained in:
1 parent
fb3723fab4
commit
726500085a
33 files changed
+2617
-69
No files matched your search
@@ -322,6 +322,44 @@ static int list_plugins(void) {
|
||||
|
||||
int main(int argc, char **argv) {
|
||||
signal(SIGPIPE, SIG_IGN);
|
||||
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("FCITX_ADDON_DIRS")) {
|
||||
if (access("/home/user/.local/x11", F_OK) == 0)
|
||||
setenv("FCITX_ADDON_DIRS", "/home/user/.local/lib/fcitx5:/home/user/.local/x11:/usr/lib/fcitx5", 0);
|
||||
else
|
||||
setenv("FCITX_ADDON_DIRS", "/home/user/.local/lib/fcitx5:/usr/lib/fcitx5", 0);
|
||||
}
|
||||
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");
|
||||
FILE *bf = fopen(bpath, "r");
|
||||
if (bf) {
|
||||
if (fgets(bbuf, sizeof(bbuf), bf)) {
|
||||
char *nl = strpbrk(bbuf, "\r\n");
|
||||
if (nl)
|
||||
*nl = '\0';
|
||||
if (bbuf[0])
|
||||
setenv("DBUS_SESSION_BUS_ADDRESS", bbuf, 1);
|
||||
}
|
||||
fclose(bf);
|
||||
}
|
||||
}
|
||||
const char *plugin_name = resolve_plugin_name_from_argv0(argv[0]);
|
||||
int sub_argc = argc;
|
||||
char **sub_argv = argv;
|
||||
|
||||
@@ -1393,6 +1393,8 @@ bool NeoWindow::create(const char* resName, const char* resClass,
|
||||
ch.res_class = const_cast<char*>(rClass.c_str());
|
||||
XSetClassHint(dpy, win, &ch);
|
||||
XStoreName(dpy, win, (title && title[0]) ? title : rClass.c_str());
|
||||
Atom wmDelete = XInternAtom(dpy, "WM_DELETE_WINDOW", False);
|
||||
XSetWMProtocols(dpy, win, &wmDelete, 1);
|
||||
|
||||
pix = XCreatePixmap(dpy, win, width, height, DefaultDepth(dpy, screen));
|
||||
gc = XCreateGC(dpy, pix, 0, nullptr);
|
||||
@@ -2660,6 +2662,14 @@ int neoui_poll_event(int timeout_ms) {
|
||||
ctx->lastEventType = NEO_EV_EXPOSE;
|
||||
return NEO_EV_EXPOSE;
|
||||
}
|
||||
if (ev.type == ClientMessage) {
|
||||
Atom wmDelete = XInternAtom(dpy, "WM_DELETE_WINDOW", False);
|
||||
if (static_cast<Atom>(ev.xclient.data.l[0]) == wmDelete) {
|
||||
ctx->lastEventType = NEO_EV_CLOSE_REQ;
|
||||
return NEO_EV_CLOSE_REQ;
|
||||
}
|
||||
continue;
|
||||
}
|
||||
if (ev.type == VisibilityNotify && ctx->visible) {
|
||||
if (ev.xvisibility.state != VisibilityUnobscured) {
|
||||
XRaiseWindow(dpy, ctx->w->win);
|
||||
|
||||
+110
-15
@@ -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;
|
||||
|
||||
+69
-2
@@ -73,7 +73,7 @@ enum { CurNormal, CurResize, CurMove, CurLast }; /* cursor */
|
||||
enum { SchemeNorm, SchemeSel, SchemeTabActive, SchemeTabInactive }; /* color schemes */
|
||||
enum { NetSupported, NetWMName, NetWMState, NetWMCheck,
|
||||
NetWMFullscreen, NetActiveWindow, NetWMWindowType,
|
||||
NetWMWindowTypeDialog, NetClientList, NetLast }; /* EWMH atoms */
|
||||
NetWMWindowTypeDialog, NetClientList, NetDwmCmd, NetLast }; /* EWMH atoms */
|
||||
enum { WMProtocols, WMDelete, WMState, WMTakeFocus, WMLast }; /* default atoms */
|
||||
enum { ClkTagBar, ClkLtSymbol, ClkStatusText, ClkWinTitle,
|
||||
ClkClientWin, ClkRootWin, ClkLast }; /* clicks */
|
||||
@@ -276,6 +276,7 @@ static void readxresources(void);
|
||||
static void reload_dwm_theme(void);
|
||||
static void load_plugins(void);
|
||||
static void unload_plugins(void);
|
||||
static long long dwm_now_ms(void);
|
||||
|
||||
static pid_t getparentprocess(pid_t p);
|
||||
static int isdescprocess(pid_t p, pid_t c);
|
||||
@@ -784,8 +785,73 @@ void
|
||||
clientmessage(XEvent *e)
|
||||
{
|
||||
XClientMessageEvent *cme = &e->xclient;
|
||||
Client *c = wintoclient(cme->window);
|
||||
Client *c;
|
||||
|
||||
if (cme->message_type == netatom[NetDwmCmd]) {
|
||||
long op = cme->data.l[0];
|
||||
long argval = cme->data.l[1];
|
||||
if (op == 1 && argval >= 1 && argval <= 9) {
|
||||
Arg a = { .ui = 1U << (argval - 1) };
|
||||
tag(&a);
|
||||
} else if (op == 2 && argval >= 1 && argval <= 9) {
|
||||
Arg a = { .ui = 1U << (argval - 1) };
|
||||
view(&a);
|
||||
} else if (op == 3) {
|
||||
Arg a = { .i = (argval != 0) ? (int)argval : +1 };
|
||||
focusstack(&a);
|
||||
} else if (op == 4) {
|
||||
Arg a = { .i = +1 };
|
||||
cyclelayout(&a);
|
||||
} else if (op == 5) {
|
||||
static Window last_kill_win = None;
|
||||
static long long last_kill_ms = 0;
|
||||
Client *tc = (argval != 0) ? wintoclient((Window)argval) : NULL;
|
||||
if (!tc && selmon)
|
||||
tc = selmon->sel;
|
||||
if (tc) {
|
||||
if (selmon && selmon->sel != tc)
|
||||
focus(tc);
|
||||
long long now = dwm_now_ms();
|
||||
int force = (tc->win == last_kill_win && (now - last_kill_ms) < 3000LL);
|
||||
last_kill_win = tc->win;
|
||||
last_kill_ms = now;
|
||||
if (force || !sendevent(tc, wmatom[WMDelete])) {
|
||||
XGrabServer(dpy);
|
||||
XSetErrorHandler(xerrordummy);
|
||||
XSetCloseDownMode(dpy, DestroyAll);
|
||||
XKillClient(dpy, tc->win);
|
||||
XSync(dpy, False);
|
||||
XSetErrorHandler(xerror);
|
||||
XUngrabServer(dpy);
|
||||
}
|
||||
} else if (argval != 0 && (Window)argval != root &&
|
||||
(!selmon || ((Window)argval != selmon->barwin &&
|
||||
(Window)argval != selmon->softwin))) {
|
||||
XGrabServer(dpy);
|
||||
XSetErrorHandler(xerrordummy);
|
||||
XSetCloseDownMode(dpy, DestroyAll);
|
||||
XKillClient(dpy, (Window)argval);
|
||||
XSync(dpy, False);
|
||||
XSetErrorHandler(xerror);
|
||||
XUngrabServer(dpy);
|
||||
}
|
||||
} else if (op == 6) {
|
||||
Arg a = { .i = +1 };
|
||||
if (argval < 0)
|
||||
pushup(&a);
|
||||
else
|
||||
pushdown(&a);
|
||||
} else if (op == 7) {
|
||||
Arg a = { .i = (argval < 0) ? -1 : +1 };
|
||||
shiftview(&a);
|
||||
} else if (op == 8) {
|
||||
Arg a = { .i = (argval < 0) ? -1 : +1 };
|
||||
clienttagpush(&a);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
c = wintoclient(cme->window);
|
||||
if (!c)
|
||||
return;
|
||||
if (cme->message_type == netatom[NetWMState]) {
|
||||
@@ -2694,6 +2760,7 @@ setup(void)
|
||||
netatom[NetWMWindowType] = XInternAtom(dpy, "_NET_WM_WINDOW_TYPE", False);
|
||||
netatom[NetWMWindowTypeDialog] = XInternAtom(dpy, "_NET_WM_WINDOW_TYPE_DIALOG", False);
|
||||
netatom[NetClientList] = XInternAtom(dpy, "_NET_CLIENT_LIST", False);
|
||||
netatom[NetDwmCmd] = XInternAtom(dpy, "_BANANARCHY_DWM_CMD", False);
|
||||
/* init cursors */
|
||||
cursor[CurNormal] = drw_cur_create(drw, XC_left_ptr);
|
||||
cursor[CurResize] = drw_cur_create(drw, XC_sizing);
|
||||
|
||||
@@ -2029,6 +2029,11 @@ run(void)
|
||||
while (XPending(xw.dpy)) {
|
||||
xev = 1;
|
||||
XNextEvent(xw.dpy, &ev);
|
||||
if (ev.type == ClientMessage &&
|
||||
(Atom)ev.xclient.data.l[0] == xw.wmdeletewin) {
|
||||
cmessage(&ev);
|
||||
continue;
|
||||
}
|
||||
if (XFilterEvent(&ev, None))
|
||||
continue;
|
||||
if (handler[ev.type])
|
||||
@@ -2254,6 +2259,35 @@ run:
|
||||
if (!opt_title)
|
||||
opt_title = (opt_line || !opt_cmd) ? "st" : opt_cmd[0];
|
||||
|
||||
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);
|
||||
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");
|
||||
FILE *bf = fopen(bpath, "r");
|
||||
if (bf) {
|
||||
if (fgets(bbuf, sizeof(bbuf), bf)) {
|
||||
char *nl = strpbrk(bbuf, "\r\n");
|
||||
if (nl)
|
||||
*nl = '\0';
|
||||
if (bbuf[0])
|
||||
setenv("DBUS_SESSION_BUS_ADDRESS", bbuf, 1);
|
||||
}
|
||||
fclose(bf);
|
||||
}
|
||||
}
|
||||
|
||||
setlocale(LC_CTYPE, "");
|
||||
XSetLocaleModifiers("");
|
||||
|
||||
|
||||
+20
-9
@@ -31,6 +31,7 @@
|
||||
#include <sstream>
|
||||
#include <string>
|
||||
#include <sys/stat.h>
|
||||
#include <sys/wait.h>
|
||||
#include <unistd.h>
|
||||
#include <vector>
|
||||
|
||||
@@ -108,18 +109,24 @@ bool writeIntFile(const std::string& path, int value) {
|
||||
void runAsyncCmd(const std::string& cmd) {
|
||||
pid_t pid = ::fork();
|
||||
if (pid == 0) {
|
||||
::setsid();
|
||||
int nullfd = ::open("/dev/null", O_RDWR);
|
||||
if (nullfd >= 0) {
|
||||
::dup2(nullfd, STDIN_FILENO);
|
||||
::dup2(nullfd, STDOUT_FILENO);
|
||||
::dup2(nullfd, STDERR_FILENO);
|
||||
if (nullfd > 2) {
|
||||
::close(nullfd);
|
||||
if (::fork() == 0) {
|
||||
::setsid();
|
||||
int nullfd = ::open("/dev/null", O_RDWR);
|
||||
if (nullfd >= 0) {
|
||||
::dup2(nullfd, STDIN_FILENO);
|
||||
::dup2(nullfd, STDOUT_FILENO);
|
||||
::dup2(nullfd, STDERR_FILENO);
|
||||
if (nullfd > 2) {
|
||||
::close(nullfd);
|
||||
}
|
||||
}
|
||||
execl("/bin/sh", "sh", "-c", cmd.c_str(), static_cast<char*>(nullptr));
|
||||
_exit(0);
|
||||
}
|
||||
execl("/bin/sh", "sh", "-c", cmd.c_str(), static_cast<char*>(nullptr));
|
||||
_exit(0);
|
||||
} else if (pid > 0) {
|
||||
int st = 0;
|
||||
(void)::waitpid(pid, &st, 0);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -674,6 +681,8 @@ static int xdrawer_run_main(int argc, char** argv) {
|
||||
sigemptyset(&sa.sa_mask);
|
||||
sigaction(SIGTERM, &sa, nullptr);
|
||||
sigaction(SIGINT, &sa, nullptr);
|
||||
signal(SIGCHLD, SIG_IGN);
|
||||
signal(SIGPIPE, SIG_IGN);
|
||||
|
||||
bananarchy::NeoWindow neo;
|
||||
if (!neo.create("xdrawer", "XDrawer", "XDrawer", kWinX, kWinY, kWinWidth,
|
||||
@@ -863,6 +872,7 @@ static int xdrawer_run_main(int argc, char** argv) {
|
||||
"xdialer.pid", "xcalllog.pid", "xcallscreen.pid", "xcontacts.pid",
|
||||
"xsms.pid", "xfiles.pid", "xcamera.pid", "xthemes.pid",
|
||||
"xmodem.pid", "xnetworks.pid", "xringtones.pid", "xwallpapers.pid",
|
||||
"xmusic.pid",
|
||||
};
|
||||
for (const char* pf : kPids) {
|
||||
int p = readIntFile(getRuntimeFile(pf), -1);
|
||||
@@ -893,6 +903,7 @@ static int xdrawer_run_main(int argc, char** argv) {
|
||||
closeOtherPlugin("xnetworks.pid", "/tmp/dwm_plugin_networks.fifo");
|
||||
closeOtherPlugin("xringtones.pid", "/tmp/dwm_plugin_ringtones.fifo");
|
||||
closeOtherPlugin("xwallpapers.pid", "/tmp/dwm_plugin_wallpapers.fifo");
|
||||
closeOtherPlugin("xmusic.pid", "/tmp/dwm_plugin_music.fifo");
|
||||
if (::access("/tmp/dwm_plugin_dmenu.active", F_OK) == 0) {
|
||||
int dfd = ::open("/tmp/dwm_plugin_dmenu.fifo", O_WRONLY | O_NONBLOCK | O_CLOEXEC);
|
||||
if (dfd >= 0) {
|
||||
|
||||
Reference in new issue
Block a user