Integrate dmenu as a preloaded zero-lag DWM plugin (dmenu.so)

This commit is contained in:
Luxferre
2026-10-21 17:37:51 +03:00
parent 7da7352a6d
commit d240f25131
34 changed files with 2835 additions and 1232 deletions
+2 -2
View File
@@ -27,9 +27,9 @@ This manual covers flashing, operating, and customizing **Bananarchy Linux** (`v
- **Cross-compiled Xlibre (`X11Libre/xserver` 25.2.0)**: compiled specifically for ARMv7 Cortex-A7 (`-O2 -march=armv7-a -mtune=cortex-a7 -mfpu=neon-vfpv4 -mfloat-abi=hard -fno-plt -fomit-frame-pointer`) with all 3D/GLX/Glamor/VGA/DGA/XVideo bloat stripped out, rootless `elogind` device management, and `modesetting` KMS + `ShadowFB` (`drmModeDirtyFB` partial rectangle SPI updates) with automatic software cursor fallback on `/dev/dri/card0` (`panel-mipi-dbi`).
- **Non-Nerd `Fira Code` with OpenType ligatures**: `Fira Code` (`font-fira-code`) is configured as the primary system and terminal font across Fontconfig, Xft, `st`, `dmenu`, `dwm`, `conky`, and `dunst`, with `DejaVu SansM Nerd Font` used strictly as a fallback for Private Use Area icon glyphs.
- **Patched `sxmo-st` (`st`) with HarfBuzz ligatures & XIM**: patched with `libharfbuzz` (`hb.c`/`hb.h`) shaping (`liga`, `calt`, `clig`, `dlig`) so multi-character programming operators (`->`, `=>`, `!=`, `<=`, `>=`, `===`, `::`, `//`, `/*`) render as continuous ligatures at `pixelsize=18`, alongside full `XIM` (`fcitx5-t9`) input support.
- **Patched `sxmo-dmenu` (`dmenu`) (`< 15 ms` startup)**: full-screen `240x296` 10-line vertical menu (positioned flush at `Y = 24..320` right below the 24px `dwm` bar, with a `26px` search bar and ten `27px` item rows) with a `#383838` top search bar, `#005577` prompt badge, `#1c1c1c` item list, `XIM` (`XSetLocaleModifiers("")`, `XSetICFocus`, `Xutf8LookupString`) for live `fcitx5-t9` search filtering and `#` mode switching, C-level focus preservation (`prevfocuswin`), and direct Nokia keypad bindings.
- **Patched `sxmo-dmenu` plugin (`dmenu.so` / `dmenu` / `xdmenu`) (`< 2 ms` popup/close)**: preloaded resident DWM plugin rendering a full-screen `240x296` 10-line vertical menu (positioned flush at `Y = 24..320` right below the 24px `dwm` bar, with a `26px` search bar and ten `27px` item rows) with a `#383838` top search bar, `#005577` prompt badge, `#1c1c1c` item list, `XIM` (`XSetLocaleModifiers("")`, `XSetICFocus`, `Xutf8LookupString`) for live `fcitx5-t9` search filtering and `#` mode switching, C-level focus preservation (`prevfocuswin`), built-in `< 0.5 ms` in-place Sxmo menu transitions (`Sys`, `Apps`, `Scripts`, `Modem`, `Config`, `Power`, `St`, `Nano`), and a `/tmp/dwm_plugin_dmenu.sock` IPC server for all `/usr/bin/dmenu` and `sxmo_dmenu.sh` calls.
- **Patched `sxmo-dwm` (`dwm`) (`< 2 ms` display wake/unlock & native plugin system)**: configured for `240x320` (`bh = 24`, `#323232` top bar, `#005577` active tag/border, vertical `bstack` layout default, overflow-protected Pango status bar rendering keeping the right-aligned clock always visible, and a transparent-backgrounded bottom desktop softkey bar displaying `"Menu"` and `"Names"` over the wallpaper). Directly polls `/dev/input/by-path/platform-gpio-keys-event` (`SW_LID`) and intercepts locked-state wake keys (`XF86PowerOff`, `XF86PickupPhone`, `XF86KbdLcdMenu1`, `XF86KbdLcdMenu2`) in C to toggle `/sys/class/backlight/backlight/brightness` and `/sys/class/leds/white:kbd_backlight/brightness` in `< 2 ms` before running Sxmo state hooks asynchronously.
- **Preloaded DWM plugins (`src/dwm-plugins/` & `src/xdrawer/`, `< 10 ms` FIFO wakeup)**: `dwm` dynamically loads `.so` plugins from `/usr/lib/dwm/plugins/` and `~/.local/lib/dwm/plugins/` (`xdrawer.so`, `dialer.so`, `calllog.so`, `contacts.so`) and preloads them as resident background daemons (`dwm-plugin <name> --preload`) at startup. Each daemon keeps its X11 window, offscreen `Pixmap`, Xft/Pango layouts (`15px` `Fira Code, DejaVuSansM Nerd Font`), and `stat()`-cached Sxmo TSV state initialized in memory while sleeping at 0% CPU on `/tmp/dwm_plugin_<name>.fifo`.
- **Preloaded DWM plugins (`src/sxmo-dmenu/`, `src/dwm-plugins/` & `src/xdrawer/`, `< 2 ms` FIFO/socket wakeup)**: `dwm` dynamically loads `.so` plugins from `/usr/lib/dwm/plugins/` and `~/.local/lib/dwm/plugins/` (`dmenu.so`, `xdrawer.so`, `dialer.so`, `calllog.so`, `contacts.so`, `sms.so`, `files.so`, `camera.so`) and preloads them as resident background daemons (`dwm-plugin <name> --preload`) at startup. Each daemon keeps its X11 window, offscreen `Pixmap`, Xft/Pango layouts, and `stat()`-cached Sxmo TSV state initialized in memory while sleeping at 0% CPU on `/tmp/dwm_plugin_<name>.fifo`.
2. **Multi-mode `fcitx5-t9` keypad engine (`src/fcitx5-t9/`)**:
- Supports 6 input modes cycled with `#` (`XF86NumericPound`): `abc`, `Abc`, `ABC`, `Sym`, `Ctl`, and `123`, updating the live top-bar status indicator (`[abc]`, `[Abc]`, `[ABC]`, `[Sym]`, `[Ctl]`, `[123]`) in real time.
- Locks the candidate popup bar to the bottom of the screen (`X = 1, Y = 290, W = 238, H = 30`) with fixed-width 28-character monospace formatting (`Fira Code 9.5`), so neither the popup window nor individual letters ever jump when cycling through candidates.
+2 -2
View File
@@ -10,7 +10,8 @@ Bananarchy targets an ultra-lightweight **Sxmo X11 (`sxmo-de-dwm`)** environment
- **Cross-compiled Xlibre (`X11Libre/xserver` 25.2.0) display server**: `modesetting` KMS + `ShadowFB` Damage partial-rectangle SPI transfers, software cursor fallback, and rootless `elogind` integration.
- **Patched `sxmo-dwm` with native C/C++ plugin architecture**: `240x320` vertical `bstack` layout, 24px Pango status bar with an overflow-protected right-aligned clock, transparent-backgrounded `"Menu"` and `"Names"` desktop softkey labels, direct C `SW_LID` slider and locked-key wake handling in `< 2 ms`, and a dynamic `.so` plugin API (`dwm_plugin.h`) with preloaded resident daemons (`--preload`) and non-blocking FIFO IPC (`< 10 ms` wakeup latency).
- **Preloaded `240x320` keypad-driven DWM plugins (`xdrawer`, `dialer`, `calllog`, `contacts`, `sms`, `files`, `camera`)**:
- **Preloaded `240x320` keypad-driven DWM plugins (`dmenu`, `xdrawer`, `dialer`, `calllog`, `contacts`, `sms`, `files`, `camera`)**:
- **`DMenu` (`dmenu.so` / `dmenu` / `xdmenu`)**: zero-lag (`< 2 ms` popup/close) resident `240x320` full-screen 10-line vertical menu (`240x296` flush below the 24px top bar) with a `#383838` search bar, `#005577` prompt badge, `XIM` `fcitx5-t9` text input, in-place `< 0.5 ms` native Sxmo submenu transitions (`Sys`, `Apps`, `Scripts`, `Modem`, `Config`, `Power`, `St`, `Nano`), and a `/tmp/dwm_plugin_dmenu.sock` client interface serving all `/usr/bin/dmenu` and `sxmo_dmenu.sh` pipes instantaneously.
- **`XDrawer` (`xdrawer.so` / `xdrawer`)**: global phone controls overlay invoked from anywhere by pressing **both softkeys simultaneously**, providing instant sliders and toggles for speaker volume, earpiece volume, flashlight, sound mute, microphone mute, screen brightness, and keypad backlight.
- **`Dialer` (`dialer.so` / `xdialer`)**: opens automatically from the idle desktop when pressing any **`0`–`9`, `*`, or `#` key** (inserting that character immediately), with live T9/number contact filtering, hold-`0` for `+`, and single-press **Call** dialing.
- **`Call Log` (`calllog.so` / `xcalllog`)**: opens automatically from the idle desktop when pressing the **Call (green)** button, with `All` / `Missed` / `In` / `Out` tabs, contact resolution, call durations, and instant redial.
@@ -18,7 +19,6 @@ Bananarchy targets an ultra-lightweight **Sxmo X11 (`sxmo-de-dwm`)** environment
- **`SMS Manager` (`sms.so` / `xsms`)**: conversation thread manager, bubble message history reader, and multi-tap keypad SMS composer/draft editor integrated with `$SXMO_LOGDIR/<number>/sms.txt`, `draft.txt`, `modemlog.tsv`, and `sxmo_modemsendsms.sh`.
- **`File Manager` (`files.so` / `xfiles`)**: graphical directory browser with live T9/number filtering, dotfiles toggle (`*`), sort mode cycle (`#`), file operations (new folder/file, rename, copy, cut/move, paste, delete, properties, edit in `nano`, open terminal here), built-in text viewer, and built-in `libjpeg`/`libpng` image previewer.
- **`Camera` (`camera.so` / `xcamera`)**: live V4L2 `/dev/video0` (`800x600` `RGB24` -> `240x180` 4:3) viewfinder with auto-flash (`*`/`1`), continuous torch (`0`/`2`), digital zoom (`1x`/`2x`/`4x` via `Up`/`Down`), 3-second self-timer (`#`/`3`), direct `libjpeg` photo capture to `~/Pictures/photo-YYYYMMDD-HHMMSS.jpg`, and built-in photo gallery.
- **Patched `sxmo-dmenu`**: `240x320` full-screen 10-line vertical menu (`240x296` flush below the 24px top bar) with a `#383838` search bar, `#005577` prompt badge, and `XIM` `fcitx5-t9` text input in `< 15 ms`.
- **Patched `sxmo-st` terminal (`pixelsize=18`)**: **HarfBuzz (`libharfbuzz`) OpenType ligature shaping** (`liga`, `calt`, `clig`, `dlig`) and `XIM` support.
- **Typography**: non-Nerd **`Fira Code` (`font-fira-code`) with ligatures** as the primary system and terminal font (with `DejaVu SansM Nerd Font` used strictly as an icon fallback).
- **Custom 6-mode `fcitx5-t9` input engine**: fixed bottom candidate bar (`X=1, Y=290, W=238, H=30`) with a constant 28-character monospace preedit layout supporting lowercase, one-shot Shift, Caps Lock, all 32 ASCII punctuation symbols, terminal control codes (`^A`-`^Z`, `Esc`, `Tab`, `F1`-`F12`), and direct numeric entry with live top-bar mode indication (`[abc]`, `[Abc]`, `[ABC]`, `[Sym]`, `[Ctl]`, `[123]`).
Binary file not shown.
+1
View File
@@ -0,0 +1 @@
dwm-plugin
Binary file not shown.
Binary file not shown.
+10
View File
@@ -2,6 +2,16 @@
# SPDX-License-Identifier: AGPL-3.0-only
# Copyright 2022 Sxmo Contributors
if [ "${1:-}" = "--fallback" ]; then
shift
elif [ -p /tmp/dwm_plugin_dmenu.fifo ]; then
case "${1:-}" in
""|sys|applications|scripts|modem|config|power|sthotkeys)
exec dmenu "${1:-ctx}"
;;
esac
fi
# include common definitions
# shellcheck source=configs/default_hooks/sxmo_hook_icons.sh
. sxmo_hook_icons.sh
+3 -4
View File
@@ -2,8 +2,6 @@
# SPDX-License-Identifier: AGPL-3.0-only
# Copyright 2022 Sxmo Contributors
. sxmo_common.sh
unalias dmenu 2>/dev/null || true
case "$1" in
@@ -12,10 +10,11 @@ case "$1" in
shift
;;
"isopen")
exec pidof -s dmenu >/dev/null
[ -e /tmp/dwm_plugin_dmenu.active ]
exit $?
;;
"close")
pkill dmenu 2>/dev/null || true
dmenu close 2>/dev/null || true
exit 0
;;
esac
+1
View File
@@ -0,0 +1 @@
dwm-plugin
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
+1
View File
@@ -0,0 +1 @@
dwm-plugin
Binary file not shown.
Binary file not shown.
+1
View File
@@ -0,0 +1 @@
dwm-plugin
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
+7 -4
View File
@@ -77,18 +77,19 @@ EOF
st.c x.c hb.c $ST_LIBS -o /bananarchy/prebuilt/sxmo-x11/usr/bin/st
$STRIP --strip-unneeded /bananarchy/prebuilt/sxmo-x11/usr/bin/st
echo "[4/5] Compiling patched sxmo-dmenu (with XIM + 240x320 vertical layout + Fira Code)..."
echo "[4/6] Compiling patched sxmo-dmenu plugin (dmenu.so with XIM + 240x320 vertical layout + Fira Code)..."
mkdir -p /bananarchy/prebuilt/sxmo-x11/usr/lib/dwm/plugins
cd /bananarchy/src/sxmo-dmenu
cp -f config.def.h config.h
DMENU_INCS="$(pkgconf --cflags x11 xinerama xft fontconfig freetype2)"
DMENU_LIBS="$(pkgconf --libs x11 xinerama xft fontconfig freetype2)"
$CC $OPT_CFLAGS -D_DEFAULT_SOURCE -D_BSD_SOURCE -D_XOPEN_SOURCE=700 -D_POSIX_C_SOURCE=200809L -DVERSION=\"5.0.14-bananarchy\" -DXINERAMA $DMENU_INCS \
dmenu.c drw.c util.c $DMENU_LIBS -o /bananarchy/prebuilt/sxmo-x11/usr/bin/dmenu
$CC $OPT_CFLAGS -fPIC -shared -D_DEFAULT_SOURCE -D_BSD_SOURCE -D_XOPEN_SOURCE=700 -D_POSIX_C_SOURCE=200809L -DVERSION=\"5.0.14-bananarchy\" -DXINERAMA $DMENU_INCS \
dmenu.c drw.c util.c $DMENU_LIBS -o /bananarchy/prebuilt/sxmo-x11/usr/lib/dwm/plugins/dmenu.so
$CC $OPT_CFLAGS -D_DEFAULT_SOURCE -DVERSION=\"5.0.14-bananarchy\" \
stest.c -o /bananarchy/prebuilt/sxmo-x11/usr/bin/stest
cp -f dmenu_path dmenu_run /bananarchy/prebuilt/sxmo-x11/usr/bin/
chmod 755 /bananarchy/prebuilt/sxmo-x11/usr/bin/dmenu_path /bananarchy/prebuilt/sxmo-x11/usr/bin/dmenu_run
$STRIP --strip-unneeded /bananarchy/prebuilt/sxmo-x11/usr/bin/dmenu /bananarchy/prebuilt/sxmo-x11/usr/bin/stest
$STRIP --strip-unneeded /bananarchy/prebuilt/sxmo-x11/usr/lib/dwm/plugins/dmenu.so /bananarchy/prebuilt/sxmo-x11/usr/bin/stest
echo "[5/6] Compiling patched sxmo-dwm (240x320 + Fira Code + Pango statusbar + Plugin API)..."
cd /bananarchy/src/sxmo-dwm
@@ -147,6 +148,8 @@ EOF
-o /bananarchy/prebuilt/sxmo-x11/usr/bin/dwm-plugin
$STRIP --strip-unneeded /bananarchy/prebuilt/sxmo-x11/usr/bin/dwm-plugin
ln -sf dwm-plugin /bananarchy/prebuilt/sxmo-x11/usr/bin/dmenu
ln -sf dwm-plugin /bananarchy/prebuilt/sxmo-x11/usr/bin/xdmenu
ln -sf dwm-plugin /bananarchy/prebuilt/sxmo-x11/usr/bin/xdrawer
ln -sf dwm-plugin /bananarchy/prebuilt/sxmo-x11/usr/bin/XDrawer
ln -sf dwm-plugin /bananarchy/prebuilt/sxmo-x11/usr/bin/xdialer
+151 -1
View File
@@ -1,15 +1,131 @@
#include <dirent.h>
#include <dlfcn.h>
#include <errno.h>
#include <fcntl.h>
#include <signal.h>
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <strings.h>
#include <sys/socket.h>
#include <sys/un.h>
#include <unistd.h>
#include "../sxmo-dwm/dwm_plugin.h"
static int write_all(int fd, const void *buf, size_t len) {
const char *p = (const char *)buf;
while (len > 0) {
ssize_t n = write(fd, p, len);
if (n < 0) {
if (errno == EINTR)
continue;
return -1;
}
p += n;
len -= (size_t)n;
}
return 0;
}
static int is_dmenu_builtin_arg(const char *arg) {
if (!arg || !arg[0])
return 0;
return strcmp(arg, "sys") == 0 ||
strcmp(arg, "ctx") == 0 ||
strcmp(arg, "applications") == 0 ||
strcmp(arg, "scripts") == 0 ||
strcmp(arg, "modem") == 0 ||
strcmp(arg, "config") == 0 ||
strcmp(arg, "power") == 0 ||
strcmp(arg, "st") == 0 ||
strcmp(arg, "nano") == 0 ||
strcmp(arg, "sthotkeys") == 0;
}
static int try_dmenu_socket_client(int sub_argc, char **sub_argv, int *exit_code_out) {
FILE *pf = fopen("/tmp/dwm_plugin_dmenu.pid", "r");
if (!pf)
return 0;
int pid = 0;
int ok = (fscanf(pf, "%d", &pid) == 1 && pid > 1 && kill((pid_t)pid, 0) == 0);
fclose(pf);
if (!ok)
return 0;
int sock = socket(AF_UNIX, SOCK_STREAM | SOCK_CLOEXEC, 0);
if (sock < 0)
return 0;
struct sockaddr_un addr;
memset(&addr, 0, sizeof(addr));
addr.sun_family = AF_UNIX;
strncpy(addr.sun_path, "/tmp/dwm_plugin_dmenu.sock", sizeof(addr.sun_path) - 1);
if (connect(sock, (struct sockaddr *)&addr, sizeof(addr)) != 0) {
close(sock);
return 0;
}
uint32_t c_argc = (uint32_t)sub_argc;
if (write_all(sock, &c_argc, sizeof(c_argc)) != 0) {
close(sock);
return 0;
}
for (int i = 0; i < sub_argc; i++) {
const char *s = sub_argv[i] ? sub_argv[i] : "";
uint32_t slen = (uint32_t)strlen(s);
if (write_all(sock, &slen, sizeof(slen)) != 0 ||
(slen > 0 && write_all(sock, s, slen) != 0)) {
close(sock);
return 0;
}
}
char buf[4096];
for (;;) {
ssize_t n = read(STDIN_FILENO, buf, sizeof(buf));
if (n < 0) {
if (errno == EINTR)
continue;
break;
}
if (n == 0)
break;
if (write_all(sock, buf, (size_t)n) != 0) {
close(sock);
return 0;
}
}
shutdown(sock, SHUT_WR);
uint8_t status_byte = 1;
ssize_t first = read(sock, &status_byte, 1);
if (first <= 0) {
close(sock);
*exit_code_out = 1;
return 1;
}
for (;;) {
ssize_t n = read(sock, buf, sizeof(buf));
if (n < 0) {
if (errno == EINTR)
continue;
break;
}
if (n == 0)
break;
(void)write_all(STDOUT_FILENO, buf, (size_t)n);
}
close(sock);
*exit_code_out = (int)status_byte;
return 1;
}
static int try_send_plugin_fifo(const char *plugin_name, int sub_argc, char **sub_argv) {
if (sub_argc >= 2 && sub_argv[1] && strcmp(sub_argv[1], "--preload") == 0) {
return 0;
@@ -38,6 +154,9 @@ static int try_send_plugin_fifo(const char *plugin_name, int sub_argc, char **su
int len = 0;
if (strcmp(plugin_name, "xdrawer") == 0) {
len = snprintf(cmd, sizeof(cmd), "TOGGLE\n");
} else if (strcmp(plugin_name, "dmenu") == 0 && sub_argc >= 2 && sub_argv[1] &&
strcmp(sub_argv[1], "close") == 0) {
len = snprintf(cmd, sizeof(cmd), "CLOSE\n");
} else if (sub_argc >= 2 && sub_argv[1] && strcmp(sub_argv[1], "newcontact") == 0) {
const char *num = (sub_argc >= 3 && sub_argv[2]) ? sub_argv[2] : "";
len = snprintf(cmd, sizeof(cmd), "OPEN new:%s\n", num);
@@ -69,6 +188,9 @@ static const char *const kPluginDirs[] = {
static const char *resolve_plugin_name_from_argv0(const char *argv0) {
const char *base = strrchr(argv0, '/');
base = base ? (base + 1) : argv0;
if (strcasecmp(base, "dmenu") == 0 || strcasecmp(base, "xdmenu") == 0) {
return "dmenu";
}
if (strcasecmp(base, "xdrawer") == 0) {
return "xdrawer";
}
@@ -126,6 +248,7 @@ static int list_plugins(void) {
}
int main(int argc, char **argv) {
signal(SIGPIPE, SIG_IGN);
const char *plugin_name = resolve_plugin_name_from_argv0(argv[0]);
int sub_argc = argc;
char **sub_argv = argv;
@@ -143,7 +266,34 @@ int main(int argc, char **argv) {
sub_argv = argv + 1;
}
if (try_send_plugin_fifo(plugin_name, sub_argc, sub_argv)) {
if (strcmp(plugin_name, "dmenu") == 0) {
if (sub_argc >= 2 && sub_argv[1]) {
if (strcmp(sub_argv[1], "-v") == 0) {
puts("dmenu-5.0.14-bananarchy");
return 0;
}
if (strcmp(sub_argv[1], "isopen") == 0) {
return access("/tmp/dwm_plugin_dmenu.active", F_OK) == 0 ? 0 : 1;
}
if (strcmp(sub_argv[1], "close") == 0) {
try_send_plugin_fifo("dmenu", sub_argc, sub_argv);
unlink("/tmp/dwm_plugin_dmenu.active");
return 0;
}
if (is_dmenu_builtin_arg(sub_argv[1])) {
if (try_send_plugin_fifo("dmenu", sub_argc, sub_argv)) {
return 0;
}
}
}
if (!(sub_argc >= 2 && sub_argv[1] &&
(strcmp(sub_argv[1], "--preload") == 0 || is_dmenu_builtin_arg(sub_argv[1])))) {
int exit_code = 1;
if (try_dmenu_socket_client(sub_argc, sub_argv, &exit_code)) {
return exit_code;
}
}
} else if (try_send_plugin_fifo(plugin_name, sub_argc, sub_argv)) {
return 0;
}
+3
View File
@@ -971,6 +971,9 @@ inline void closeOtherPlugins(const char* selfPluginName) {
sendPluginCommand(p.name, "CLOSE");
}
}
if (::access("/tmp/dwm_plugin_dmenu.active", F_OK) == 0) {
sendPluginCommand("dmenu", "CLOSE");
}
}
inline std::string getModemLogDirPath() {
+2630 -1216
View File
File diff suppressed because it is too large Load Diff
+18 -2
View File
@@ -1649,7 +1649,7 @@ host_spawn_plugin(const char *plugin_name, const char *arg)
if (arg && strcmp(arg, "--preload") == 0) {
if (is_plugin_daemon_alive(plugin_name))
return;
int stagger_ms = 600 + (preload_stagger_idx++ * 220);
int stagger_ms = (strcmp(plugin_name, "dmenu") == 0) ? 150 : (600 + (preload_stagger_idx++ * 220));
if (fork() == 0) {
if (dpy)
close(ConnectionNumber(dpy));
@@ -1670,6 +1670,8 @@ host_spawn_plugin(const char *plugin_name, const char *arg)
int len;
if (strcmp(plugin_name, "xdrawer") == 0)
len = snprintf(msg, sizeof(msg), "TOGGLE\n");
else if (strcmp(plugin_name, "dmenu") == 0 && arg && strcmp(arg, "close") == 0)
len = snprintf(msg, sizeof(msg), "CLOSE\n");
else if (arg && arg[0])
len = snprintf(msg, sizeof(msg), "OPEN %s\n", arg);
else
@@ -1843,6 +1845,8 @@ trigger_softkey_chord(long long now)
kill(-last_menu_pgid, SIGKILL);
last_menu_pgid = 0;
}
if (is_plugin_loaded("dmenu"))
host_spawn_plugin("dmenu", "close");
softkey_pending = 0;
softkey_first_ms = 0;
softkey_deadline_ms = 0;
@@ -1868,6 +1872,10 @@ flush_pending_softkey(void)
XUngrabKeyboard(dpy, CurrentTime);
XFlush(dpy);
if (pending == SOFTKEY_LEFT) {
if (is_plugin_loaded("dmenu")) {
host_spawn_plugin("dmenu", "sys");
return;
}
const Arg syscmd = { .v = (const char*[]){ "sxmo_appmenu.sh", "sys", NULL } };
last_menu_pgid = spawn_pgid(&syscmd);
} else if (pending == SOFTKEY_RIGHT) {
@@ -1875,6 +1883,10 @@ flush_pending_softkey(void)
dispatch_plugin_idle_key(XF86XK_Back, 166, 0)) {
return;
}
if (is_plugin_loaded("dmenu")) {
host_spawn_plugin("dmenu", "ctx");
return;
}
const Arg ctxcmd = { .v = (const char*[]){ "sxmo_appmenu.sh", NULL } };
last_menu_pgid = spawn_pgid(&ctxcmd);
}
@@ -1953,9 +1965,13 @@ keypress(XEvent *e)
if (!selmon->sel && CLEANMASK(ev->state) == 0) {
if (keysym == XK_Return) {
const Arg entercmd = { .v = (const char*[]){ "sxmo_appmenu.sh", NULL } };
XUngrabKeyboard(dpy, CurrentTime);
XFlush(dpy);
if (is_plugin_loaded("dmenu")) {
host_spawn_plugin("dmenu", "sys");
return;
}
const Arg entercmd = { .v = (const char*[]){ "sxmo_appmenu.sh", NULL } };
spawn(&entercmd);
return;
} else if (keysym == XK_Left) {
+7 -1
View File
@@ -744,7 +744,13 @@ static int xdrawer_run_main(int argc, char** argv) {
writeIntFile(pidPath, static_cast<int>(::getpid()));
controller.refreshAll();
render();
runAsyncCmd("pkill -x dmenu >/dev/null 2>&1");
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) {
(void)::write(dfd, "CLOSE\n", 6);
::close(dfd);
}
}
};
auto hideWindow = [&](bool drainSoftkeys) {