dwm-plugins: fix vibration test, AT debug channel, and Close softkey leak

This commit is contained in:
Luxferre
2026-10-24 21:11:57 +03:00
parent f394d2b135
commit 5646f03ebe
21 changed files with 160 additions and 54 deletions
@@ -1,3 +1,4 @@
SUBSYSTEM=="input", KERNEL=="event*", ATTRS{name}=="keypad", ENV{ID_INPUT_KEYBOARD}="1"
SUBSYSTEM=="input", KERNEL=="event*", ATTRS{name}=="gpio-keys", ENV{ID_INPUT_KEYBOARD}="1"
SUBSYSTEM=="input", KERNEL=="event*", ATTRS{name}=="pm8941_resin", ENV{ID_INPUT_KEYBOARD}="1"
SUBSYSTEM=="input", KERNEL=="event*", ATTRS{name}=="pm8xxx*vib*", SYMLINK+="input/by-path/platform-vibrator-event"
+4
View File
@@ -0,0 +1,4 @@
# /etc/conf.d/modemmanager: config file for modemmanager
# Enable quick suspend/resume hooks and debug mode (allows mmcli --command AT queries)
modemmanager_opts="--test-quick-suspend-resume --debug"
@@ -1,3 +1,4 @@
SUBSYSTEM=="input", KERNEL=="event*", ATTRS{name}=="keypad", ENV{ID_INPUT_KEYBOARD}="1"
SUBSYSTEM=="input", KERNEL=="event*", ATTRS{name}=="gpio-keys", ENV{ID_INPUT_KEYBOARD}="1"
SUBSYSTEM=="input", KERNEL=="event*", ATTRS{name}=="pm8941_resin", ENV{ID_INPUT_KEYBOARD}="1"
SUBSYSTEM=="input", KERNEL=="event*", ATTRS{name}=="pm8xxx*vib*", SYMLINK+="input/by-path/platform-vibrator-event"
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -504,57 +504,50 @@ case "$cmd" in
echo "ERROR: Empty AT command"
exit 1
fi
run_at_dev() {
dev="$1"
[ -c "$dev" ] || return 1
out="$(timeout 2 awk -v dev="$dev" -v cmd="$at_cmd" '
BEGIN {
sys = "stty -F " dev " raw -echo 115200 min 0 time 2 2>/dev/null"
system(sys)
printf "%s\r\n", cmd > dev
close(dev)
}
' 2>/dev/null || true)"
return 0
}
resp=""
for candidate in "$port" wwan0at1 wwan0at0; do
for candidate in "$port" /dev/wwan0at1 /dev/wwan0at0; do
case "$candidate" in
wwan0at0|wwan0at1)
dev="/dev/$candidate"
if [ -c "$dev" ]; then
resp="$(timeout 2 sh -c '
dev="$1"
cmd="$2"
stty -F "$dev" raw -echo 115200 min 0 time 2 2>/dev/null || true
exec 3<>"$dev"
dd bs=256 count=4 status=none <&3 >/dev/null 2>&1 || true
printf "%s\r\n" "$cmd" >&3
lines=""
i=0
while [ "$i" -lt 8 ]; do
chunk="$(dd bs=512 count=1 status=none <&3 2>/dev/null | tr -d "\r" || true)"
if [ -n "$chunk" ]; then
lines="${lines}${chunk}"
case "$lines" in
*OK*|*ERROR*)
break
;;
esac
fi
i=$((i + 1))
done
exec 3>&-
printf "%s\n" "$lines"
' _ "$dev" "$at_cmd" 2>/dev/null | sed '/^[[:space:]]*$/d' || true)"
if [ -n "$resp" ]; then
printf "%s\n" "$resp"
exit 0
fi
fi
;;
/dev/wwan0at0|/dev/wwan0at1)
dev="$candidate"
;;
*)
dev=""
;;
esac
[ "$port" != "auto" ] && [ "$candidate" = "$port" ] && break
if [ -n "$dev" ] && [ -c "$dev" ]; then
resp="$(timeout 2 sh -c '
dev="$1"
cmd="$2"
tmpf="/tmp/at_resp_$$.txt"
rm -f "$tmpf"
cat "$dev" > "$tmpf" 2>/dev/null &
rpid=$!
sleep 0.04
printf "%s\r\n" "$cmd" > "$dev" 2>/dev/null || true
i=0
while [ "$i" -lt 12 ]; do
if grep -qE "(^|[[:space:]])(OK|ERROR|\+CME ERROR|\+CMS ERROR)([[:space:]]|$)" "$tmpf" 2>/dev/null; then
break
fi
sleep 0.08
i=$((i + 1))
done
kill "$rpid" 2>/dev/null || true
wait "$rpid" 2>/dev/null || true
tr -d "\r" < "$tmpf" 2>/dev/null || true
rm -f "$tmpf"
' _ "$dev" "$at_cmd" 2>/dev/null | sed '/^[[:space:]]*$/d' || true)"
if [ -n "$resp" ]; then
printf "%s\n" "$resp"
exit 0
fi
fi
if [ "$port" != "auto" ] && [ "$candidate" = "$port" ]; then
break
fi
done
mm_out="$(mmcli -m any --command="$at_cmd" 2>&1 || true)"
if [ -n "$mm_out" ]; then
@@ -0,0 +1,5 @@
[D-BUS Service]
Name=org.freedesktop.ModemManager1
Exec=/usr/sbin/ModemManager --debug
User=root
SystemdService=dbus-org.freedesktop.ModemManager1.service
@@ -11,11 +11,27 @@
# shellcheck source=scripts/core/sxmo_common.sh
. sxmo_common.sh
if [ -z "${SXMO_VIBRATE_DEV:-}" ] && [ ! -e /dev/input/by-path/platform-vibrator-event ]; then
for vdev in /dev/input/by-path/*vibrator*-event; do
if [ -e "$vdev" ]; then
export SXMO_VIBRATE_DEV="$vdev"
break
fi
done
fi
if [ -f "$XDG_CONFIG_HOME/sxmo/ringsettings" ]; then
# shellcheck disable=SC1091
. "$XDG_CONFIG_HOME/sxmo/ringsettings"
fi
# pm8xxx-vib shifts FF_RUMBLE strong_magnitude right by 8 bits (valid 256..65535)
case "${SXMO_VIBRATE_STRENGTH:-}" in
1) SXMO_VIBRATE_STRENGTH=20000 ;;
2|"") SXMO_VIBRATE_STRENGTH=40000 ;;
3) SXMO_VIBRATE_STRENGTH=65535 ;;
esac
if [ -f "$XDG_CONFIG_HOME/sxmo/ringtone" ]; then
custom_ring="$(head -n 1 "$XDG_CONFIG_HOME/sxmo/ringtone" 2>/dev/null)"
if [ -n "$custom_ring" ] && [ -f "$custom_ring" ]; then
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
+13
View File
@@ -1110,6 +1110,19 @@ int runModemApp(int argc, char** argv) {
auto hideWindow = [&]() {
if (!visible) return;
int xfdLocal = ConnectionNumber(dpy);
int64_t drainDeadline = nowMs() + 180;
while (nowMs() < drainDeadline && querySoftkeysDown(dpy) != 0) {
while (XPending(dpy) > 0) {
XEvent ev;
XNextEvent(dpy, &ev);
}
struct pollfd pfd {};
pfd.fd = xfdLocal;
pfd.events = POLLIN;
::poll(&pfd, 1, 10);
}
writeSoftkeySuppress(nowMs() + 450);
XUngrabKeyboard(dpy, CurrentTime);
XUnmapWindow(dpy, win);
XFlush(dpy);
+13
View File
@@ -952,6 +952,19 @@ int runNetworksApp(int argc, char** argv) {
auto hideWindow = [&]() {
if (!visible) return;
int xfdLocal = ConnectionNumber(dpy);
int64_t drainDeadline = nowMs() + 180;
while (nowMs() < drainDeadline && querySoftkeysDown(dpy) != 0) {
while (XPending(dpy) > 0) {
XEvent ev;
XNextEvent(dpy, &ev);
}
struct pollfd pfd {};
pfd.fd = xfdLocal;
pfd.events = POLLIN;
::poll(&pfd, 1, 10);
}
writeSoftkeySuppress(nowMs() + 450);
XUngrabKeyboard(dpy, CurrentTime);
XUnmapWindow(dpy, win);
XFlush(dpy);
+38 -6
View File
@@ -585,18 +585,44 @@ int runRingtonesApp(int argc, char** argv) {
}
}
writeIntFile(activePidPath, static_cast<int>(::getpid()));
visible = true;
if (!visible) {
visible = true;
XMapRaised(dpy, win);
XSync(dpy, False);
} else {
XRaiseWindow(dpy, win);
}
for (int i = 0; i < 20; ++i) {
if (XGrabKeyboard(dpy, win, True, GrabModeAsync, GrabModeAsync,
CurrentTime) == GrabSuccess) {
break;
}
usleep(2000);
}
XSetInputFocus(dpy, win, RevertToPointerRoot, CurrentTime);
startupIgnoreUntilMs = nowMs() + 180;
initialSoftkeysReleased = (querySoftkeysDown(dpy) == 0);
softkeyPending = 0;
XMapRaised(dpy, win);
XSetInputFocus(dpy, win, RevertToPointerRoot, CurrentTime);
render();
};
auto hideWindow = [&]() {
stopPreview();
if (!visible) return;
int xfdLocal = ConnectionNumber(dpy);
int64_t drainDeadline = nowMs() + 180;
while (nowMs() < drainDeadline && querySoftkeysDown(dpy) != 0) {
while (XPending(dpy) > 0) {
XEvent ev;
XNextEvent(dpy, &ev);
}
struct pollfd pfd {};
pfd.fd = xfdLocal;
pfd.events = POLLIN;
::poll(&pfd, 1, 10);
}
writeSoftkeySuppress(nowMs() + 450);
XUngrabKeyboard(dpy, CurrentTime);
visible = false;
softkeyPending = 0;
XUnmapWindow(dpy, win);
@@ -636,9 +662,15 @@ int runRingtonesApp(int argc, char** argv) {
((settings.vibrateStrength - 1 + 3 + delta) % 3) + 1;
saveRingSettings(settings);
} else if (settingsRow == 4) {
runAsyncCmd("sxmo_vibrate 600 " +
std::to_string(settings.vibrateStrength) +
" >/dev/null 2>&1");
int mag = (settings.vibrateStrength == 1)
? 20000
: (settings.vibrateStrength == 3 ? 65535 : 40000);
runAsyncCmd(
"for d in /dev/input/by-path/platform-vibrator-event "
"/dev/input/by-path/*vibrator*-event; do "
"[ -e \"$d\" ] && export SXMO_VIBRATE_DEV=\"$d\" && break; done; "
"sxmo_vibrate 600 " +
std::to_string(mag) + " >/dev/null 2>&1");
setBanner("Testing vibration...");
}
};
+29 -3
View File
@@ -490,17 +490,43 @@ int runWallpapersApp(int argc, char** argv) {
}
updatePreviewCache();
writeIntFile(activePidPath, static_cast<int>(::getpid()));
visible = true;
if (!visible) {
visible = true;
XMapRaised(dpy, win);
XSync(dpy, False);
} else {
XRaiseWindow(dpy, win);
}
for (int i = 0; i < 20; ++i) {
if (XGrabKeyboard(dpy, win, True, GrabModeAsync, GrabModeAsync,
CurrentTime) == GrabSuccess) {
break;
}
usleep(2000);
}
XSetInputFocus(dpy, win, RevertToPointerRoot, CurrentTime);
startupIgnoreUntilMs = nowMs() + 180;
initialSoftkeysReleased = (querySoftkeysDown(dpy) == 0);
softkeyPending = 0;
XMapRaised(dpy, win);
XSetInputFocus(dpy, win, RevertToPointerRoot, CurrentTime);
render();
};
auto hideWindow = [&]() {
if (!visible) return;
int xfdLocal = ConnectionNumber(dpy);
int64_t drainDeadline = nowMs() + 180;
while (nowMs() < drainDeadline && querySoftkeysDown(dpy) != 0) {
while (XPending(dpy) > 0) {
XEvent ev;
XNextEvent(dpy, &ev);
}
struct pollfd pfd {};
pfd.fd = xfdLocal;
pfd.events = POLLIN;
::poll(&pfd, 1, 10);
}
writeSoftkeySuppress(nowMs() + 450);
XUngrabKeyboard(dpy, CurrentTime);
visible = false;
fullscreenPreview = false;
softkeyPending = 0;
+2
View File
@@ -1873,6 +1873,8 @@ flush_pending_softkey(void)
softkey_deadline_ms = 0;
XUngrabKeyboard(dpy, CurrentTime);
XFlush(dpy);
if (dwm_now_ms() < read_softkey_suppress())
return;
if (pending == SOFTKEY_LEFT) {
if (is_plugin_loaded("dmenu")) {
host_spawn_plugin("dmenu", "sys");