diff --git a/CHANGELOG.md b/CHANGELOG.md index 62412f3..7c8466f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -13,7 +13,7 @@ Release versions follow the `
` format (where `2026` is `a`, ### New features and improvements - **Native NeoUI communication and internet suite (`xsip`, `xemail`, `xirc`, `xtox`, `xkopher`, `webarchy`)**: - - **SIP VoIP client (`sip.so` / `xsip`)**: implemented an RFC 3261 SIP softphone (`Dialer`, `Accounts`, `History` tabs) supporting both account-registered calling (with alphanumeric username/password multi-tap entry, Digest MD5 authentication, and background standby `REGISTER` keepalive) and direct accountless P2P/federated SIP URI calling (`user@host[:port]` or `sip:user@host[:port]`) with RFC 3263 DNS `SRV` (`_sip._udp.`) proxy discovery, RFC 3261 Timer A `INVITE` retransmission with multi-`A` proxy failover, `Record-Route`/`Contact` dialog routing, RFC 6189 **ZRTP** media-path key agreement (`DH3k` 3072-bit / `DH2k` 2048-bit Diffie-Hellman, `H0..H3` SHA-256 hash chain, Castagnoli CRC-32C framing, `a=zrtp-hash` SDP signaling, and 4-character Base32 `SAS` verification code) with RFC 3711 **SRTP** (`AES-128-CM` + `HMAC-SHA1-80`/`32`) encrypted voice media, incoming `INVITE` standby wakeup and call handling integrated with `xcallscreen` (`[SIP/]` / `[SIP/:]`), wideband and narrowband multi-codec RTP/SRTP audio (`Opus` 16 kHz / 48 kHz RTP clock with in-band FEC, `ITU-T G.722` 16 kHz wideband SB-ADPCM, `G.711 PCMU`/`PCMA` 8 kHz, `GSM 06.10` Full Rate 8 kHz, `ITU-T G.726-32` 8 kHz ADPCM, `IMA ADPCM DVI4` 8/16 kHz, and `L16` uncompressed 16-bit PCM 8/16 kHz) with per-account and direct-mode codec preference selection, and RFC 2833 / RFC 4733 DTMF tones. + - **SIP VoIP client (`sip.so` / `xsip`)**: implemented an RFC 3261 SIP softphone (`Dialer`, `Accounts`, `History` tabs) supporting both account-registered calling (with alphanumeric username/password multi-tap entry, Digest MD5 authentication, and background standby `REGISTER` keepalive) and direct accountless P2P/federated SIP URI calling (`user@host[:port]` or `sip:user@host[:port]`) with RFC 3263 DNS `SRV` (`_sip._udp.`) proxy discovery, RFC 3261 Timer A `INVITE` retransmission with multi-`A` proxy failover, `Record-Route`/`Contact` dialog routing, RFC 6189 **ZRTP** media-path key agreement (`DH3k` 3072-bit / `DH2k` 2048-bit Diffie-Hellman, `H0..H3` SHA-256 hash chain, Castagnoli CRC-32C framing, `a=zrtp-hash` SDP signaling, and 4-character Base32 `SAS` verification code) with RFC 3711 **SRTP** (`AES-128-CM` + `HMAC-SHA1-80`/`32`) encrypted voice media, incoming `INVITE` standby wakeup and call handling integrated with `xcallscreen` (`[SIP/]` / `[SIP/:]`), wideband and narrowband multi-codec RTP/SRTP audio (`G.711 PCMU`/`PCMA` 8 kHz prioritized by default in `AUTO` mode, `GSM 06.10` Full Rate 8 kHz, `Opus` 16 kHz / 48 kHz RTP clock with in-band FEC, `ITU-T G.722` 16 kHz wideband SB-ADPCM, `ITU-T G.726-32` 8 kHz ADPCM, `IMA ADPCM DVI4` 8/16 kHz, and `L16` uncompressed 16-bit PCM 8/16 kHz) with per-account and direct-mode codec preference selection, seamless early-media (`183 Session Progress` -> `200 OK`) `arecord`/`aplay` stream continuity, and RFC 2833 / RFC 4733 DTMF tones. - **Email client (`email.so` / `xemail` / `xmail`)**: implemented a multi-account `IMAP4rev1`, `POP3`, and `SMTP` client (`Inbox`, `Compose`, `Accounts` tabs) supporting implicit TLS (`993`/`995`/`465`), `STARTTLS` (`143`/`110`/`587`), and plain TCP, SASL `PLAIN`/`LOGIN` authentication, RFC 2047 encoded-word header decoding, Base64/Quoted-Printable MIME body decoding, HTML tag stripping, offline inbox cache (`~/.local/share/sxmo/email/`), full-screen reader, and message composer/reply. - **IRCv3 client (`irc.so` / `xirc`)**: implemented a multi-server IRC client (`Chat`, `Buffers`, `Servers` tabs) with OpenSSL TLS, IRCv3 capability negotiation (`CAP LS 302`: `sasl`, `server-time`, `message-tags`, `multi-prefix`, `away-notify`, `account-notify`, `chghost`, `cap-notify`), `SASL PLAIN` authentication, `433` nick-in-use fallback and `470` channel forwarding tracking, slash commands (`/join`, `/part`, `/close`, `/msg`, `/nick`, `/me`, `/clear`, `/raw`, `/quit`), targeted buffer closing (`Menu -> Close Buffer` or `BackSpace` in `Buffers`), and a resident background mode (`BG Mode`) that keeps sockets connected when the window is closed and triggers notification hooks on nick highlights or private messages. - **Tox / Trifa P2P messenger and audio call client (`tox.so` / `xtox`)**: built an encrypted P2P messenger and voice call client (`Friends`, `Chat`, `My Tox ID` tabs) on `c-toxcore` (`libtoxcore.so.2`), featuring persistent profile storage (`~/.local/share/sxmo/tox/profile.tox`), non-blocking IPv4 DHT + TCP relay bootstrap, friend request handling, persistent chat logs, and standby incoming `ToxAV` 48 kHz Opus voice calls integrated with `xcallscreen` (`[TOX]`). @@ -59,6 +59,8 @@ Release versions follow the `
` format (where `2026` is `a`, - Added VM writeback (`dirty_writeback_centisecs=6000`), `printk` throttling, `sched_autogroup_enabled=0`, `nmi_watchdog=0`, `schedutil` governor rate-limit tuning (`rate_limit_us=2000`, fixing the 6.44s default caused by `qcom-cpufreq` `UINT_MAX` transition latency so cores downclock to `200 MHz` within `2 ms`), Wi-Fi powersave (`iw dev wlan0 set power_save on`), USB/platform runtime PM (`power/control = auto`), and automatic unbinding of the `7864900.sdhci` microSD host controller when no card is inserted (along with `bias-pull-up` on `sdc2-cd-off-state` and unified Adreno 304 GPU / IOMMU device-tree nodes across all 5 device `.dts`/`.dtb` files). - Replaced the 120ms busy-wait loop in `gps.so` (`OsmTileCache::workerLoop`) with `std::condition_variable`, cached Dual-SIM status in `/tmp/sxmo_dsds_active` to avoid repeated `qmicli` wakes on single-SIM setups, increased the DSDS idle `select()` timeout to `300s`, and set display framebuffer `bl_power = 4` (`FB_BLANK_POWERDOWN`) whenever the screen is blanked. - Increased `conky` desktop clock refresh interval to `15.0s` and froze `conky` (`SIGSTOP`/`SIGCONT`) whenever the screen is off or locked, replaced polling in `sxmo_modemmonitor.sh` with event-driven `dbus-monitor`, skipped redundant `sxmo_hook_statusbar.sh` updates while `screenoff` or locked, and drained queued X11 `UnmapNotify` events in `neoui_hide()` so all resident DWM plugins sleep at `0%` CPU when hidden. +- **Universal Power button (`dmenu power`) access and ReMEdy `Call (green)` pause menu**: + - Updated `dwm`, `dmenu`, `xdrawer`, `libneoui.so`, `sxmo_multikey.sh`, all standalone Xlib DWM plugins, and standalone games (`scoundrel`, `gambatte`, `remedy`) so pressing **End / Power (red)** (`XF86PowerOff`, keycode `124`) from any active window or menu immediately opens (or toggles) the system **Power menu (`dmenu power`)** while mapped **Call (green)** (`XF86Phone` / `XF86PickupPhone`) and `500 ms` **Right softkey** hold in `remedy` open the **ReMEdy Pause Menu**. --- diff --git a/MANUAL.md b/MANUAL.md index 274e8fd..b1a820a 100644 --- a/MANUAL.md +++ b/MANUAL.md @@ -233,7 +233,7 @@ All twenty-four phone applications are compiled as shared-object plugins (`/usr/ - **`1:Dialer`**: enter a SIP URI (`user@host[:port]` or `sip:user@host[:port]`) or account extension (`1001`) using multi-tap alphanumeric input (`*` or `#` cycles `[abc]` / `[ABC]` / `[123]` / `[Sym]` / `[Abc]`) or select a recent peer with `Up`/`Down`, and press **Call (green)** or **Center `OK`** to place an outgoing SIP call. Outbound calls work both with a registered SIP account and directly without any configured account (`Direct URI` mode, selectable via `Menu -> Switch Account` when accounts are also present). - **`2:Accounts`**: add or edit SIP accounts (`~/.config/sxmo/sip_accounts.tsv`: Label, alphanumeric Username, Password, Domain, Port, UDP/TCP/TLS transport, ZRTP toggle, Preferred Codec, Enabled). Enabled accounts maintain RFC 3261 `REGISTER` keepalives with Digest MD5 authentication in the background even when `xsip` is closed. - **`3:History`**: browse incoming, outgoing, and missed SIP calls (`~/.local/share/sxmo/sip_history.tsv`) and press **Call (green)** or **Center `OK`** to redial. - - **Audio codecs (`AUTO`, `OPUS`, `G722`, `PCMU`, `PCMA`, `GSM`, `G726-32`, `DVI4`, `L16`)**: supports full SDP `m=audio` / `a=rtpmap` / `a=fmtp` negotiation across 10 wideband (`16 kHz`) and narrowband (`8 kHz`) RTP/SRTP audio profiles: **Opus** (`opus/48000/2`, RFC 7587, 16 kHz wideband VoIP with in-band FEC), **ITU-T G.722** (`G722/8000`, 16 kHz wideband 64 kbps SB-ADPCM), **ITU-T G.711** `PCMU` (`PT 0`) and `PCMA` (`PT 8`, 8 kHz 64 kbps), **GSM 06.10 Full Rate** (`GSM/8000`, `PT 3`, 8 kHz 13 kbps RPE-LTP), **ITU-T G.726-32** (`G726-32/8000`, 8 kHz 32 kbps ADPCM), **IMA ADPCM** (`DVI4/8000` `PT 5` and `DVI4/16000` `PT 6`), and **uncompressed 16-bit PCM** (`L16/8000` and `L16/16000`), plus **RFC 2833 / RFC 4733 `telephone-event/8000`** DTMF. Preferred codec priority is configurable per account (`Codec` field in the Account Editor) or for direct accountless calls (`Menu -> Cycle Direct Codec`). + - **Audio codecs (`AUTO`, `PCMU`, `PCMA`, `GSM`, `OPUS`, `G722`, `G726-32`, `DVI4`, `L16`)**: supports full SDP `m=audio` / `a=rtpmap` / `a=fmtp` negotiation across 10 narrowband (`8 kHz`) and wideband (`16 kHz`) RTP/SRTP audio profiles, prioritizing **ITU-T G.711** `PCMU` (`PT 0`) and `PCMA` (`PT 8`, 8 kHz 64 kbps) first in `AUTO` mode, followed by **GSM 06.10 Full Rate** (`GSM/8000`, `PT 3`, 8 kHz 13 kbps RPE-LTP), **Opus** (`opus/48000/2`, RFC 7587, 16 kHz wideband VoIP with in-band FEC), **ITU-T G.722** (`G722/8000`, 16 kHz wideband 64 kbps SB-ADPCM), **ITU-T G.726-32** (`G726-32/8000`, 8 kHz 32 kbps ADPCM), **IMA ADPCM** (`DVI4/8000` `PT 5` and `DVI4/16000` `PT 6`), and **uncompressed 16-bit PCM** (`L16/8000` and `L16/16000`), plus **RFC 2833 / RFC 4733 `telephone-event/8000`** DTMF. Preferred codec priority is configurable per account (`Codec` field in the Account Editor) or for direct accountless calls (`Menu -> Cycle Direct Codec`). - **ZRTP / SRTP encryption and CallScreen (`xcallscreen`) integration**: supports RFC 6189 **ZRTP** (`DH3k` 3072-bit / `DH2k` 2048-bit Diffie-Hellman key agreement with `a=zrtp-hash` SDP signaling and persistent 96-bit `ZID`) and RFC 3711 **SRTP** (`AES-128-CM` + `HMAC-SHA1-80`/`32`) encrypted voice media (`ON` by default per account and for direct accountless calls via `Menu -> Toggle Direct ZRTP`). Incoming `INVITE` requests wake the phone, trigger the ringtone/vibrator, and open `xcallscreen` with a `[SIP/]` badge; once ZRTP completes its handshake, the active codec and 4-character Short Authentication String (`SAS`) are displayed in both `xsip` (` | ZRTP SAS:`) and `xcallscreen` (`[SIP/:]`). 17. **Email client (`email.so` / `xemail` / `xmail`)**: @@ -321,7 +321,7 @@ Three native X11 games (`/usr/bin/snake`, `/usr/bin/tetris`, and `/usr/bin/scoun - **Launch**: open **ReMEdy (J2ME)** from **System menu -> Applications** or **System menu -> Games**, open any `.jar` or `.jad` file from **Files (`xfiles`)**, or run `remedy [app.jar|app.jad]`. When launched without a file argument, opens the NeoUI-themed **ReMEdy J2ME** browser scanning `/usr/share/games/j2me`, `~/Games`, `~/J2ME`, `~/Downloads`, and user directories, displaying the selected MIDlet's `MIDlet-Name`, `MIDlet-Vendor`, `MIDlet-Version`, main class, and RMS save status. - **Full-screen `240x320` resolution and NeoUI-themed LCDUI**: runs in a full-screen `240x320` window (`X=0, Y=0, W=240, H=320`) and declares native `240x320` dimensions (`getWidth() == 240`, `getHeight() == 320`) to J2ME applications. Full-screen `Canvas` and `GameCanvas` games get the entire `240x320` display, while high-level LCDUI screens (`Form`, `List`, `TextBox`, `Alert`, `ChoiceGroup`, `Gauge`, `TextField`, `StringItem`, and `Command` bars/menus) render with `libneoui.so` (`PluginTheme`) and adapt automatically to the active `.Xresources` / `~/.xthemes/*.xth` system theme. - **Hardware-accelerated 3D (JSR-184 M3G), networking, RMS, and audio**: accelerates JSR-184 (`javax.microedition.m3g.*`) 3D scenes on the Adreno 304 (`FD304`) GPU via EGL + OpenGL ES 2.0 (with depth-buffered software fallback), supports HTTP/HTTPS and raw TCP/UDP socket connections (`javax.microedition.io.Connector`, `HttpConnection`, `SocketConnection`, `FileConnection` JSR-75), Nokia UI API (`com.nokia.mid.ui.*`), persistent `RecordStore` (RMS) storage (`~/.local/share/sxmo/remedy/rms/`), and MMAPI (`javax.microedition.media.Manager`) tone and WAV/MIDI audio over ALSA (`hw:0,0`). Audio follows the system speaker volume and mute state (the xdrawer **Speaker** slider) live, at the same loudness as other apps. - - **Keypad controls and pause menu**: maps D-Pad (`Up`/`Down`/`Left`/`Right`), `Center OK` (`FIRE`), `0`–`9`, `*`, `#`, **Left softkey** (`-6`), and **Right softkey** (`-7`) directly to MIDP 2.0 / Nokia key codes, with customizable D-Pad (`D-Pad + 2/4/6/8`, `D-Pad Only`, `2/4/6/8 Only`) and softkey modes persisted in `~/.config/sxmo/remedy.cfg`. Press **End / Power (red)** (`Escape`) during execution to open the **ReMEdy Pause Menu** (Resume, Send Left/Right Softkey Command, Screen Scaling, 3D Renderer toggle, Audio (`Left`/`Right` change the system speaker volume, `OK` toggles ReMEdy sound), Keypad Controls remapping, Reset RMS Save Data, Load Another MIDlet, or Quit). Preinstalled MIDlets in `/usr/share/games/j2me/` and `~/Games/` include `g2048.jar`, `ReMEdy3DArena.jar` (JSR-184 3D benchmark), `AstroBlaster240.jar` (`GameCanvas` space shooter), and `NetToolJ2ME.jar` (LCDUI + HTTP/TCP socket test suite). + - **Keypad controls and pause menu**: maps D-Pad (`Up`/`Down`/`Left`/`Right`), `Center OK` (`FIRE`), `0`–`9`, `*`, `#`, **Left softkey** (`-6`), and **Right softkey** (`-7`) directly to MIDP 2.0 / Nokia key codes, with customizable key bindings persisted in `~/.config/sxmo/remedy.conf`. Press **Call (green)** (or hold **Right softkey** for `500 ms`) during execution to open the **ReMEdy Pause Menu** (Resume, MIDlet Commands, 3D Engine toggle, Softkey Bar mode, FPS Cap/Overlay, Audio (`Left`/`Right` change the system speaker volume, `OK` toggles ReMEdy sound), Keypad Controls remapping, Restart MIDlet, Clear MIDlet RMS Data, Load JAR/JAD, or Quit). Preinstalled MIDlets in `/usr/share/games/j2me/` and `~/Games/` include `g2048.jar`, `ReMEdy3DArena.jar` (JSR-184 3D benchmark), `AstroBlaster240.jar` (`GameCanvas` space shooter), and `NetToolJ2ME.jar` (LCDUI + HTTP/TCP socket test suite). ### 3.2 Multi-mode `fcitx5-t9` keypad reference diff --git a/overlay/rootfs/usr/bin/dwm b/overlay/rootfs/usr/bin/dwm index 4021380..e24113e 100755 Binary files a/overlay/rootfs/usr/bin/dwm and b/overlay/rootfs/usr/bin/dwm differ diff --git a/overlay/rootfs/usr/bin/gambatte b/overlay/rootfs/usr/bin/gambatte index 6a23fc9..8849393 100755 Binary files a/overlay/rootfs/usr/bin/gambatte and b/overlay/rootfs/usr/bin/gambatte differ diff --git a/overlay/rootfs/usr/bin/remedy b/overlay/rootfs/usr/bin/remedy index a4a41de..8f859fc 100755 Binary files a/overlay/rootfs/usr/bin/remedy and b/overlay/rootfs/usr/bin/remedy differ diff --git a/overlay/rootfs/usr/bin/scoundrel b/overlay/rootfs/usr/bin/scoundrel index bb1e664..ee6fdac 100755 Binary files a/overlay/rootfs/usr/bin/scoundrel and b/overlay/rootfs/usr/bin/scoundrel differ diff --git a/overlay/rootfs/usr/bin/sxmo_multikey.sh b/overlay/rootfs/usr/bin/sxmo_multikey.sh index 8e2a0db..3f778f5 100755 --- a/overlay/rootfs/usr/bin/sxmo_multikey.sh +++ b/overlay/rootfs/usr/bin/sxmo_multikey.sh @@ -40,8 +40,13 @@ fi printf '%s\n' "$counter" > "$count_file" +if [ "$counter" -ge "$#" ]; then + rm -f "$count_file" + exit +fi shift "$counter" if [ "$#" -eq 0 ]; then + rm -f "$count_file" exit fi diff --git a/overlay/rootfs/usr/lib/dwm/plugins/calllog.so b/overlay/rootfs/usr/lib/dwm/plugins/calllog.so index 47686bf..e75cef8 100755 Binary files a/overlay/rootfs/usr/lib/dwm/plugins/calllog.so and b/overlay/rootfs/usr/lib/dwm/plugins/calllog.so differ diff --git a/overlay/rootfs/usr/lib/dwm/plugins/callscreen.so b/overlay/rootfs/usr/lib/dwm/plugins/callscreen.so index 2704784..7d44a87 100755 Binary files a/overlay/rootfs/usr/lib/dwm/plugins/callscreen.so and b/overlay/rootfs/usr/lib/dwm/plugins/callscreen.so differ diff --git a/overlay/rootfs/usr/lib/dwm/plugins/camera.so b/overlay/rootfs/usr/lib/dwm/plugins/camera.so index 0844944..0cfc4fa 100755 Binary files a/overlay/rootfs/usr/lib/dwm/plugins/camera.so and b/overlay/rootfs/usr/lib/dwm/plugins/camera.so differ diff --git a/overlay/rootfs/usr/lib/dwm/plugins/contacts.so b/overlay/rootfs/usr/lib/dwm/plugins/contacts.so index d297d8b..d24582b 100755 Binary files a/overlay/rootfs/usr/lib/dwm/plugins/contacts.so and b/overlay/rootfs/usr/lib/dwm/plugins/contacts.so differ diff --git a/overlay/rootfs/usr/lib/dwm/plugins/dialer.so b/overlay/rootfs/usr/lib/dwm/plugins/dialer.so index b45219c..5bbd81b 100755 Binary files a/overlay/rootfs/usr/lib/dwm/plugins/dialer.so and b/overlay/rootfs/usr/lib/dwm/plugins/dialer.so differ diff --git a/overlay/rootfs/usr/lib/dwm/plugins/dmenu.so b/overlay/rootfs/usr/lib/dwm/plugins/dmenu.so index 4039ad2..2a664c8 100755 Binary files a/overlay/rootfs/usr/lib/dwm/plugins/dmenu.so and b/overlay/rootfs/usr/lib/dwm/plugins/dmenu.so differ diff --git a/overlay/rootfs/usr/lib/dwm/plugins/engmenu.so b/overlay/rootfs/usr/lib/dwm/plugins/engmenu.so index bb0fef5..3d9c648 100755 Binary files a/overlay/rootfs/usr/lib/dwm/plugins/engmenu.so and b/overlay/rootfs/usr/lib/dwm/plugins/engmenu.so differ diff --git a/overlay/rootfs/usr/lib/dwm/plugins/files.so b/overlay/rootfs/usr/lib/dwm/plugins/files.so index 63441ef..b4b9e7b 100755 Binary files a/overlay/rootfs/usr/lib/dwm/plugins/files.so and b/overlay/rootfs/usr/lib/dwm/plugins/files.so differ diff --git a/overlay/rootfs/usr/lib/dwm/plugins/modem.so b/overlay/rootfs/usr/lib/dwm/plugins/modem.so index 2779f8b..f395be1 100755 Binary files a/overlay/rootfs/usr/lib/dwm/plugins/modem.so and b/overlay/rootfs/usr/lib/dwm/plugins/modem.so differ diff --git a/overlay/rootfs/usr/lib/dwm/plugins/music.so b/overlay/rootfs/usr/lib/dwm/plugins/music.so index 517a38a..7b07b54 100755 Binary files a/overlay/rootfs/usr/lib/dwm/plugins/music.so and b/overlay/rootfs/usr/lib/dwm/plugins/music.so differ diff --git a/overlay/rootfs/usr/lib/dwm/plugins/networks.so b/overlay/rootfs/usr/lib/dwm/plugins/networks.so index 583dc18..33f2562 100755 Binary files a/overlay/rootfs/usr/lib/dwm/plugins/networks.so and b/overlay/rootfs/usr/lib/dwm/plugins/networks.so differ diff --git a/overlay/rootfs/usr/lib/dwm/plugins/passcode.so b/overlay/rootfs/usr/lib/dwm/plugins/passcode.so index c6e7f79..409e962 100755 Binary files a/overlay/rootfs/usr/lib/dwm/plugins/passcode.so and b/overlay/rootfs/usr/lib/dwm/plugins/passcode.so differ diff --git a/overlay/rootfs/usr/lib/dwm/plugins/ringtones.so b/overlay/rootfs/usr/lib/dwm/plugins/ringtones.so index 7d12772..cb5e18c 100755 Binary files a/overlay/rootfs/usr/lib/dwm/plugins/ringtones.so and b/overlay/rootfs/usr/lib/dwm/plugins/ringtones.so differ diff --git a/overlay/rootfs/usr/lib/dwm/plugins/sip.so b/overlay/rootfs/usr/lib/dwm/plugins/sip.so index f81dc70..9cf9073 100755 Binary files a/overlay/rootfs/usr/lib/dwm/plugins/sip.so and b/overlay/rootfs/usr/lib/dwm/plugins/sip.so differ diff --git a/overlay/rootfs/usr/lib/dwm/plugins/sms.so b/overlay/rootfs/usr/lib/dwm/plugins/sms.so index 9003288..826778c 100755 Binary files a/overlay/rootfs/usr/lib/dwm/plugins/sms.so and b/overlay/rootfs/usr/lib/dwm/plugins/sms.so differ diff --git a/overlay/rootfs/usr/lib/dwm/plugins/themes.so b/overlay/rootfs/usr/lib/dwm/plugins/themes.so index a74e417..4a49ec4 100755 Binary files a/overlay/rootfs/usr/lib/dwm/plugins/themes.so and b/overlay/rootfs/usr/lib/dwm/plugins/themes.so differ diff --git a/overlay/rootfs/usr/lib/dwm/plugins/wallpapers.so b/overlay/rootfs/usr/lib/dwm/plugins/wallpapers.so index 4316e2c..54c000b 100755 Binary files a/overlay/rootfs/usr/lib/dwm/plugins/wallpapers.so and b/overlay/rootfs/usr/lib/dwm/plugins/wallpapers.so differ diff --git a/overlay/rootfs/usr/lib/dwm/plugins/webarchy.so b/overlay/rootfs/usr/lib/dwm/plugins/webarchy.so index 041b613..90e6694 100755 Binary files a/overlay/rootfs/usr/lib/dwm/plugins/webarchy.so and b/overlay/rootfs/usr/lib/dwm/plugins/webarchy.so differ diff --git a/overlay/rootfs/usr/lib/dwm/plugins/xdrawer.so b/overlay/rootfs/usr/lib/dwm/plugins/xdrawer.so index c013eef..307e044 100755 Binary files a/overlay/rootfs/usr/lib/dwm/plugins/xdrawer.so and b/overlay/rootfs/usr/lib/dwm/plugins/xdrawer.so differ diff --git a/overlay/rootfs/usr/lib/libneoui.so b/overlay/rootfs/usr/lib/libneoui.so index efdbf19..6d6f447 100755 Binary files a/overlay/rootfs/usr/lib/libneoui.so and b/overlay/rootfs/usr/lib/libneoui.so differ diff --git a/prebuilt/games/usr/bin/gambatte b/prebuilt/games/usr/bin/gambatte index 6a23fc9..8849393 100755 Binary files a/prebuilt/games/usr/bin/gambatte and b/prebuilt/games/usr/bin/gambatte differ diff --git a/prebuilt/games/usr/bin/remedy b/prebuilt/games/usr/bin/remedy index a4a41de..8f859fc 100755 Binary files a/prebuilt/games/usr/bin/remedy and b/prebuilt/games/usr/bin/remedy differ diff --git a/prebuilt/games/usr/bin/scoundrel b/prebuilt/games/usr/bin/scoundrel index bb1e664..ee6fdac 100755 Binary files a/prebuilt/games/usr/bin/scoundrel and b/prebuilt/games/usr/bin/scoundrel differ diff --git a/prebuilt/sxmo-x11/usr/bin/dwm b/prebuilt/sxmo-x11/usr/bin/dwm index 4021380..e24113e 100755 Binary files a/prebuilt/sxmo-x11/usr/bin/dwm and b/prebuilt/sxmo-x11/usr/bin/dwm differ diff --git a/prebuilt/sxmo-x11/usr/lib/dwm/plugins/calllog.so b/prebuilt/sxmo-x11/usr/lib/dwm/plugins/calllog.so index 47686bf..e75cef8 100755 Binary files a/prebuilt/sxmo-x11/usr/lib/dwm/plugins/calllog.so and b/prebuilt/sxmo-x11/usr/lib/dwm/plugins/calllog.so differ diff --git a/prebuilt/sxmo-x11/usr/lib/dwm/plugins/callscreen.so b/prebuilt/sxmo-x11/usr/lib/dwm/plugins/callscreen.so index 2704784..7d44a87 100755 Binary files a/prebuilt/sxmo-x11/usr/lib/dwm/plugins/callscreen.so and b/prebuilt/sxmo-x11/usr/lib/dwm/plugins/callscreen.so differ diff --git a/prebuilt/sxmo-x11/usr/lib/dwm/plugins/camera.so b/prebuilt/sxmo-x11/usr/lib/dwm/plugins/camera.so index 0844944..0cfc4fa 100755 Binary files a/prebuilt/sxmo-x11/usr/lib/dwm/plugins/camera.so and b/prebuilt/sxmo-x11/usr/lib/dwm/plugins/camera.so differ diff --git a/prebuilt/sxmo-x11/usr/lib/dwm/plugins/contacts.so b/prebuilt/sxmo-x11/usr/lib/dwm/plugins/contacts.so index d297d8b..d24582b 100755 Binary files a/prebuilt/sxmo-x11/usr/lib/dwm/plugins/contacts.so and b/prebuilt/sxmo-x11/usr/lib/dwm/plugins/contacts.so differ diff --git a/prebuilt/sxmo-x11/usr/lib/dwm/plugins/dialer.so b/prebuilt/sxmo-x11/usr/lib/dwm/plugins/dialer.so index b45219c..5bbd81b 100755 Binary files a/prebuilt/sxmo-x11/usr/lib/dwm/plugins/dialer.so and b/prebuilt/sxmo-x11/usr/lib/dwm/plugins/dialer.so differ diff --git a/prebuilt/sxmo-x11/usr/lib/dwm/plugins/dmenu.so b/prebuilt/sxmo-x11/usr/lib/dwm/plugins/dmenu.so index 4039ad2..2a664c8 100755 Binary files a/prebuilt/sxmo-x11/usr/lib/dwm/plugins/dmenu.so and b/prebuilt/sxmo-x11/usr/lib/dwm/plugins/dmenu.so differ diff --git a/prebuilt/sxmo-x11/usr/lib/dwm/plugins/engmenu.so b/prebuilt/sxmo-x11/usr/lib/dwm/plugins/engmenu.so index bb0fef5..3d9c648 100755 Binary files a/prebuilt/sxmo-x11/usr/lib/dwm/plugins/engmenu.so and b/prebuilt/sxmo-x11/usr/lib/dwm/plugins/engmenu.so differ diff --git a/prebuilt/sxmo-x11/usr/lib/dwm/plugins/files.so b/prebuilt/sxmo-x11/usr/lib/dwm/plugins/files.so index 63441ef..b4b9e7b 100755 Binary files a/prebuilt/sxmo-x11/usr/lib/dwm/plugins/files.so and b/prebuilt/sxmo-x11/usr/lib/dwm/plugins/files.so differ diff --git a/prebuilt/sxmo-x11/usr/lib/dwm/plugins/modem.so b/prebuilt/sxmo-x11/usr/lib/dwm/plugins/modem.so index 2779f8b..f395be1 100755 Binary files a/prebuilt/sxmo-x11/usr/lib/dwm/plugins/modem.so and b/prebuilt/sxmo-x11/usr/lib/dwm/plugins/modem.so differ diff --git a/prebuilt/sxmo-x11/usr/lib/dwm/plugins/music.so b/prebuilt/sxmo-x11/usr/lib/dwm/plugins/music.so index 517a38a..7b07b54 100755 Binary files a/prebuilt/sxmo-x11/usr/lib/dwm/plugins/music.so and b/prebuilt/sxmo-x11/usr/lib/dwm/plugins/music.so differ diff --git a/prebuilt/sxmo-x11/usr/lib/dwm/plugins/networks.so b/prebuilt/sxmo-x11/usr/lib/dwm/plugins/networks.so index 583dc18..33f2562 100755 Binary files a/prebuilt/sxmo-x11/usr/lib/dwm/plugins/networks.so and b/prebuilt/sxmo-x11/usr/lib/dwm/plugins/networks.so differ diff --git a/prebuilt/sxmo-x11/usr/lib/dwm/plugins/passcode.so b/prebuilt/sxmo-x11/usr/lib/dwm/plugins/passcode.so index c6e7f79..409e962 100755 Binary files a/prebuilt/sxmo-x11/usr/lib/dwm/plugins/passcode.so and b/prebuilt/sxmo-x11/usr/lib/dwm/plugins/passcode.so differ diff --git a/prebuilt/sxmo-x11/usr/lib/dwm/plugins/ringtones.so b/prebuilt/sxmo-x11/usr/lib/dwm/plugins/ringtones.so index 7d12772..cb5e18c 100755 Binary files a/prebuilt/sxmo-x11/usr/lib/dwm/plugins/ringtones.so and b/prebuilt/sxmo-x11/usr/lib/dwm/plugins/ringtones.so differ diff --git a/prebuilt/sxmo-x11/usr/lib/dwm/plugins/sip.so b/prebuilt/sxmo-x11/usr/lib/dwm/plugins/sip.so index f81dc70..9cf9073 100755 Binary files a/prebuilt/sxmo-x11/usr/lib/dwm/plugins/sip.so and b/prebuilt/sxmo-x11/usr/lib/dwm/plugins/sip.so differ diff --git a/prebuilt/sxmo-x11/usr/lib/dwm/plugins/sms.so b/prebuilt/sxmo-x11/usr/lib/dwm/plugins/sms.so index 9003288..826778c 100755 Binary files a/prebuilt/sxmo-x11/usr/lib/dwm/plugins/sms.so and b/prebuilt/sxmo-x11/usr/lib/dwm/plugins/sms.so differ diff --git a/prebuilt/sxmo-x11/usr/lib/dwm/plugins/themes.so b/prebuilt/sxmo-x11/usr/lib/dwm/plugins/themes.so index a74e417..4a49ec4 100755 Binary files a/prebuilt/sxmo-x11/usr/lib/dwm/plugins/themes.so and b/prebuilt/sxmo-x11/usr/lib/dwm/plugins/themes.so differ diff --git a/prebuilt/sxmo-x11/usr/lib/dwm/plugins/wallpapers.so b/prebuilt/sxmo-x11/usr/lib/dwm/plugins/wallpapers.so index 4316e2c..54c000b 100755 Binary files a/prebuilt/sxmo-x11/usr/lib/dwm/plugins/wallpapers.so and b/prebuilt/sxmo-x11/usr/lib/dwm/plugins/wallpapers.so differ diff --git a/prebuilt/sxmo-x11/usr/lib/dwm/plugins/webarchy.so b/prebuilt/sxmo-x11/usr/lib/dwm/plugins/webarchy.so index 041b613..90e6694 100755 Binary files a/prebuilt/sxmo-x11/usr/lib/dwm/plugins/webarchy.so and b/prebuilt/sxmo-x11/usr/lib/dwm/plugins/webarchy.so differ diff --git a/prebuilt/sxmo-x11/usr/lib/dwm/plugins/xdrawer.so b/prebuilt/sxmo-x11/usr/lib/dwm/plugins/xdrawer.so index c013eef..307e044 100755 Binary files a/prebuilt/sxmo-x11/usr/lib/dwm/plugins/xdrawer.so and b/prebuilt/sxmo-x11/usr/lib/dwm/plugins/xdrawer.so differ diff --git a/prebuilt/sxmo-x11/usr/lib/libneoui.so b/prebuilt/sxmo-x11/usr/lib/libneoui.so index efdbf19..6d6f447 100755 Binary files a/prebuilt/sxmo-x11/usr/lib/libneoui.so and b/prebuilt/sxmo-x11/usr/lib/libneoui.so differ diff --git a/src/dwm-plugins/calllog_plugin.cpp b/src/dwm-plugins/calllog_plugin.cpp index 756268b..2801b9a 100644 --- a/src/dwm-plugins/calllog_plugin.cpp +++ b/src/dwm-plugins/calllog_plugin.cpp @@ -818,6 +818,12 @@ int calllog_run_main(int argc, char** argv) { continue; } + if (isPowerKey(sym, ev.xkey.keycode)) { + hideWindow(false); + openPowerMenuFromPlugin(dpy); + continue; + } + if (mode == ViewMode::AddBlock) { char dialCh = mapDialKey(sym, ev.xkey.keycode, ev.xkey.state); if (dialCh == '#') { diff --git a/src/dwm-plugins/callscreen_plugin.cpp b/src/dwm-plugins/callscreen_plugin.cpp index 03b7b31..fe7cdb8 100644 --- a/src/dwm-plugins/callscreen_plugin.cpp +++ b/src/dwm-plugins/callscreen_plugin.cpp @@ -506,7 +506,8 @@ int callscreen_run_main(int argc, char** argv) { }; auto isVoipCallId = [&](const std::string& cid) -> bool { - return cid.rfind("sip:", 0) == 0 || cid.rfind("tox:", 0) == 0; + return cid.rfind("sip:", 0) == 0 || cid.rfind("tox:", 0) == 0 || + activeSimSlot == 3 || activeSimSlot == 4; }; auto setSpeakerRoute = [&](bool toSpeaker) { @@ -572,8 +573,15 @@ int callscreen_run_main(int argc, char** argv) { setOutDevFile("Earpiece"); statusNotice = "Audio routed to Earpiece"; } - runAsyncCmd("PATH=\"$HOME/.config/sxmo/hooks:/usr/share/sxmo/default_hooks:$PATH\" " - "sxmo_hook_statusbar.sh volume >/dev/null 2>&1"); + if (voip) { + runAsyncCmd("wpctl set-mute @DEFAULT_AUDIO_SINK@ 0 >/dev/null 2>&1; " + "wpctl set-volume @DEFAULT_AUDIO_SINK@ 100% >/dev/null 2>&1; " + "PATH=\"$HOME/.config/sxmo/hooks:/usr/share/sxmo/default_hooks:$PATH\" " + "sxmo_hook_statusbar.sh volume >/dev/null 2>&1"); + } else { + runAsyncCmd("PATH=\"$HOME/.config/sxmo/hooks:/usr/share/sxmo/default_hooks:$PATH\" " + "sxmo_hook_statusbar.sh volume >/dev/null 2>&1"); + } statusNoticeUntilMs = nowMs() + 2000; }; @@ -1305,14 +1313,28 @@ int callscreen_run_main(int argc, char** argv) { alsa.setBoolean("PRI_MI2S_RX Voice Mixer VoiceMMode1", false); alsa.setBoolean("VoiceMMode1 Capture Mixer TERT_MI2S_TX", false); alsa.setEnum("EAR_S", 0); + alsa.setEnum("RX1 MIX1 INP1", 0); + alsa.setInteger("RX1 Digital Volume", 0); alsa.setEnum("RX3 MIX1 INP1", 3); alsa.setBoolean("SPK DAC Switch", true); + int spkPct = readIntFile(getHomeDirPath() + "/.config/sxmo/speaker_vol", 85); + alsa.setInteger("RX3 Digital Volume", pctToHwVol(spkPct, true, false)); + { + bool jackPlugged = (readIntFile("/tmp/sxmo_jack_plugged", 0) == 1); + std::ofstream out("/tmp/sxmo_audio_out_device", std::ios::trunc); + if (out.is_open()) out << (jackPlugged ? "Headphones" : "Speaker") << "\n"; + } runAsyncCmd("sxmo_jobs.sh stop ringing >/dev/null 2>&1; " "pkill -TERM -f sxmo_hook_ring.sh >/dev/null 2>&1; " "pkill -TERM -f 'pw-play.*ring' >/dev/null 2>&1; " "pkill -TERM -f 'mpv.*ring' >/dev/null 2>&1; " "pkill -TERM -x sxmo_vibrate >/dev/null 2>&1; " - "sxmo_modemaudio.sh disable_call_audio_mode >/dev/null 2>&1"); + "sxmo_modemaudio.sh disable_call_audio_mode >/dev/null 2>&1; " + "if [ \"$(cat /tmp/sxmo_jack_plugged 2>/dev/null)\" = \"1\" ]; then " + " sxmo_audio.sh out set Headphones >/dev/null 2>&1; " + "else " + " sxmo_audio.sh out set Speaker >/dev/null 2>&1; " + "fi"); render(); }; @@ -1320,9 +1342,9 @@ int callscreen_run_main(int argc, char** argv) { std::string cid = resolveActiveModemCallId(); bool wasIncoming = (callState == CallState::Incoming); stopRingingJobs(); - if (cid.rfind("sip:", 0) == 0) { + if (cid.rfind("sip:", 0) == 0 || activeSimSlot == 3) { sendPluginCommand("sip", "CALL_HANGUP " + cid); - } else if (cid.rfind("tox:", 0) == 0) { + } else if (cid.rfind("tox:", 0) == 0 || activeSimSlot == 4) { sendPluginCommand("tox", "CALL_HANGUP " + cid); } else if (!cid.empty() && cid != "-" && cid != "sim" && cid != "test") { runAsyncArgv("sxmo_modemcall.sh", "hangup", cid.c_str()); diff --git a/src/dwm-plugins/camera_plugin.cpp b/src/dwm-plugins/camera_plugin.cpp index 7e6fa3c..eac8d45 100644 --- a/src/dwm-plugins/camera_plugin.cpp +++ b/src/dwm-plugins/camera_plugin.cpp @@ -800,7 +800,13 @@ int runCameraApp(int argc, char** argv) { continue; } - if (sym == XK_Escape || kc == 124 || sym == XF86XK_PowerOff) { + if (isPowerKey(sym, kc)) { + hideWindow(); + openPowerMenuFromPlugin(dpy); + continue; + } + + if (sym == XK_Escape) { hideWindow(); continue; } diff --git a/src/dwm-plugins/contacts_plugin.cpp b/src/dwm-plugins/contacts_plugin.cpp index f2aa6cb..bd5645e 100644 --- a/src/dwm-plugins/contacts_plugin.cpp +++ b/src/dwm-plugins/contacts_plugin.cpp @@ -1234,6 +1234,12 @@ int runContactsApp(int argc, char** argv) { continue; } + if (isPowerKey(sym, ev.xkey.keycode)) { + hideWindow(false); + openPowerMenuFromPlugin(dpy); + continue; + } + if (sym == XK_Escape) { if (mode == ViewMode::List) { writeSoftkeySuppress(nowMs() + 300); diff --git a/src/dwm-plugins/dialer_plugin.cpp b/src/dwm-plugins/dialer_plugin.cpp index d2d9704..cdcb17e 100644 --- a/src/dwm-plugins/dialer_plugin.cpp +++ b/src/dwm-plugins/dialer_plugin.cpp @@ -747,6 +747,12 @@ int dialer_run_main(int argc, char** argv) { continue; } + if (isPowerKey(sym, ev.xkey.keycode)) { + hideWindow(false); + openPowerMenuFromPlugin(dpy); + continue; + } + char dialCh = mapDialKey(sym, ev.xkey.keycode, ev.xkey.state); if (modal == DialerModal::SelectSim) { diff --git a/src/dwm-plugins/engmenu_plugin.cpp b/src/dwm-plugins/engmenu_plugin.cpp index af3520d..ae891d6 100644 --- a/src/dwm-plugins/engmenu_plugin.cpp +++ b/src/dwm-plugins/engmenu_plugin.cpp @@ -311,8 +311,14 @@ int engmenu_run_main(int argc, char** argv) { continue; } + if (isPowerKey(sym, kc)) { + closeWindow(); + openPowerMenuFromPlugin(dpy); + continue; + } + if (isRightSoftkey(sym, kc) || sym == XK_Escape || - sym == XK_BackSpace || kc == 124 || sym == XF86XK_HangupPhone || + sym == XK_BackSpace || sym == XF86XK_HangupPhone || sym == XK_Cancel) { writeSoftkeySuppress(nowMs() + 300); closeWindow(); diff --git a/src/dwm-plugins/files_plugin.cpp b/src/dwm-plugins/files_plugin.cpp index 00ec33f..2f8360b 100644 --- a/src/dwm-plugins/files_plugin.cpp +++ b/src/dwm-plugins/files_plugin.cpp @@ -2506,7 +2506,13 @@ int runFilesApp(int argc, char** argv) { continue; } - if (sym == XK_Escape || kc == 124 || sym == XF86XK_PowerOff) { + if (isPowerKey(sym, kc)) { + hideWindow(); + openPowerMenuFromPlugin(dpy); + continue; + } + + if (sym == XK_Escape) { hideWindow(); continue; } diff --git a/src/dwm-plugins/modem_plugin.cpp b/src/dwm-plugins/modem_plugin.cpp index f2dc020..6df3c68 100644 --- a/src/dwm-plugins/modem_plugin.cpp +++ b/src/dwm-plugins/modem_plugin.cpp @@ -1895,6 +1895,12 @@ int runModemApp(int argc, char** argv) { continue; } + if (isPowerKey(sym, kc)) { + hideWindow(); + openPowerMenuFromPlugin(dpy); + continue; + } + if (sym == XF86XK_HangupPhone || sym == XK_Cancel) { hideWindow(); continue; diff --git a/src/dwm-plugins/music_plugin.cpp b/src/dwm-plugins/music_plugin.cpp index fe80a59..5c3d104 100644 --- a/src/dwm-plugins/music_plugin.cpp +++ b/src/dwm-plugins/music_plugin.cpp @@ -1298,8 +1298,13 @@ int runMusicApp(int argc, char** argv) { continue; } - if (sym == XF86XK_HangupPhone || sym == XK_Cancel || kc == 124 || - sym == XF86XK_PowerOff) { + if (isPowerKey(sym, kc)) { + hideWindow(); + openPowerMenuFromPlugin(dpy); + continue; + } + + if (sym == XF86XK_HangupPhone || sym == XK_Cancel) { hideWindow(); continue; } diff --git a/src/dwm-plugins/networks_plugin.cpp b/src/dwm-plugins/networks_plugin.cpp index 71058ec..eaa3c95 100644 --- a/src/dwm-plugins/networks_plugin.cpp +++ b/src/dwm-plugins/networks_plugin.cpp @@ -1365,6 +1365,12 @@ int runNetworksApp(int argc, char** argv) { continue; } + if (isPowerKey(sym, kc)) { + hideWindow(); + openPowerMenuFromPlugin(dpy); + continue; + } + if (sym == XF86XK_HangupPhone || sym == XK_Cancel) { hideWindow(); continue; diff --git a/src/dwm-plugins/passcode_plugin.cpp b/src/dwm-plugins/passcode_plugin.cpp index 178dd57..6d3e4d9 100644 --- a/src/dwm-plugins/passcode_plugin.cpp +++ b/src/dwm-plugins/passcode_plugin.cpp @@ -628,7 +628,13 @@ int passcode_run_main(int argc, char** argv) { continue; } - if (sym == XK_Escape || kc == 124 || sym == XF86XK_HangupPhone || + if (isPowerKey(sym, kc)) { + closeWindow(); + openPowerMenuFromPlugin(dpy); + continue; + } + + if (sym == XK_Escape || sym == XF86XK_HangupPhone || sym == XK_Cancel) { writeSoftkeySuppress(nowMs() + 300); closeWindow(); diff --git a/src/dwm-plugins/phone_data.h b/src/dwm-plugins/phone_data.h index 48cc220..f8b212f 100644 --- a/src/dwm-plugins/phone_data.h +++ b/src/dwm-plugins/phone_data.h @@ -1949,6 +1949,29 @@ inline void grabPluginKeyboard(Display* dpy, Window win) { XSetInputFocus(dpy, win, RevertToPointerRoot, CurrentTime); } +inline bool isPowerKey(KeySym sym, unsigned int kc) { + return sym == XF86XK_PowerOff || kc == 124; +} + +inline void openPowerMenuFromPlugin(Display* dpy) { + if (dpy) { + XUngrabKeyboard(dpy, CurrentTime); + XFlush(dpy); + } + if (isCallActiveOrRingingFast()) { + if (!sendPluginCommand("callscreen", "HANGUP")) { + runAsyncArgv("xcallscreen", "hangup"); + } + return; + } + if (::access("/tmp/bananarchy_screen_locked", F_OK) == 0) { + return; + } + if (!sendPluginCommand("dmenu", "OPEN power")) { + runAsyncArgv("dmenu", "power"); + } +} + inline void broadcastThemeReload(const char* selfPluginName = nullptr) { static const char* kPlugins[] = { "dmenu", diff --git a/src/dwm-plugins/ringtones_plugin.cpp b/src/dwm-plugins/ringtones_plugin.cpp index 1fcbeb8..14fd3a4 100644 --- a/src/dwm-plugins/ringtones_plugin.cpp +++ b/src/dwm-plugins/ringtones_plugin.cpp @@ -1073,6 +1073,12 @@ int runRingtonesApp(int argc, char** argv) { continue; } + if (isPowerKey(sym, kc)) { + hideWindow(); + openPowerMenuFromPlugin(dpy); + continue; + } + if (sym == XF86XK_HangupPhone || sym == XK_Cancel) { hideWindow(); continue; diff --git a/src/dwm-plugins/sip_plugin.cpp b/src/dwm-plugins/sip_plugin.cpp index 0dac044..8fba9af 100644 --- a/src/dwm-plugins/sip_plugin.cpp +++ b/src/dwm-plugins/sip_plugin.cpp @@ -137,7 +137,7 @@ std::string normalizePreferredCodec(const std::string& raw) { std::string cyclePreferredCodec(const std::string& cur) { static const char* kList[] = { - "AUTO", "OPUS", "G722", "PCMU", "PCMA", "GSM", "G726-32", "DVI4", "L16" + "AUTO", "PCMU", "PCMA", "GSM", "OPUS", "G722", "G726-32", "DVI4", "L16" }; std::string norm = normalizePreferredCodec(cur); for (size_t i = 0; i < sizeof(kList) / sizeof(kList[0]); ++i) { @@ -152,14 +152,15 @@ std::string cyclePreferredCodec(const std::string& cur) { uint8_t linearToUlaw(int16_t pcmVal) { constexpr int kBias = 0x84; constexpr int kClip = 32635; - int mask = (pcmVal < 0) ? 0x7f : 0xff; - if (pcmVal < 0) pcmVal = static_cast(-pcmVal); - if (pcmVal > kClip) pcmVal = kClip; - pcmVal = static_cast(pcmVal + kBias); + int pcm = pcmVal; + int mask = (pcm < 0) ? 0x7f : 0xff; + if (pcm < 0) pcm = -pcm; + if (pcm > kClip) pcm = kClip; + pcm += kBias; int seg = 0; - for (int thr = 0xFF; seg < 7 && pcmVal > thr; ++seg, thr = (thr << 1) | 1) { + for (int thr = 0xFF; seg < 7 && pcm > thr; ++seg, thr = (thr << 1) | 1) { } - uint8_t uval = static_cast((seg << 4) | ((pcmVal >> (seg + 3)) & 0x0f)); + uint8_t uval = static_cast((seg << 4) | ((pcm >> (seg + 3)) & 0x0f)); return static_cast(uval ^ mask); } @@ -170,18 +171,20 @@ int16_t ulawToLinear(uint8_t uval) { } uint8_t linearToAlaw(int16_t pcmVal) { + int pcm = pcmVal; int mask = 0x55; - if (pcmVal >= 0) { + if (pcm >= 0) { mask |= 0x80; } else { - pcmVal = static_cast(-pcmVal - 1); + pcm = -pcm - 1; } + if (pcm > 32767) pcm = 32767; int seg = 0; - for (int thr = 0xFF; seg < 7 && pcmVal > thr; ++seg, thr = (thr << 1) | 1) { + for (int thr = 0xFF; seg < 7 && pcm > thr; ++seg, thr = (thr << 1) | 1) { } uint8_t aval = (seg == 0) - ? static_cast((pcmVal >> 4) & 0x0f) - : static_cast((seg << 4) | ((pcmVal >> (seg + 3)) & 0x0f)); + ? static_cast((pcm >> 4) & 0x0f) + : static_cast((seg << 4) | ((pcm >> (seg + 3)) & 0x0f)); return static_cast(aval ^ mask); } @@ -424,7 +427,6 @@ class G722State { int il = (el < 0) ? kMisn[mila] : kMisp[mila]; int ril = il >> 2; int dlt = (band_[0].det * kQ6m4[ril]) >> 15; - if (il < 32) dlt = -dlt; updateBand(0, dlt, ril, true); // Higher sub-band (2-bit quantizer) @@ -451,8 +453,7 @@ class G722State { int ril = il >> 2; int dlt = (band_[0].det * kQ6b[il]) >> 15; int rlow = std::clamp(band_[0].s + dlt, -16384, 16383); - updateBand(0, (band_[0].det * ((il < 32) ? -kQ6m4[ril] : kQ6m4[ril])) >> 15, - ril, true); + updateBand(0, (band_[0].det * kQ6m4[ril]) >> 15, ril, true); // Higher sub-band reconstruction (2-bit) int dhy = (band_[1].det * kQm2[ih]) >> 15; @@ -573,18 +574,18 @@ class G722State { 41, 40, 39, 38, 37, 36, 35, 34, 33, 32 }; static constexpr int kQ6m4[16] = { - 0, 20456, 12896, 8968, 6288, 4240, 2584, 1200, - 20456, 12896, 8968, 6288, 4240, 2584, 1200, 296 + 0, -20456, -12896, -8968, -6288, -4240, -2584, -1200, + 20456, 12896, 8968, 6288, 4240, 2584, 1200, 0 }; static constexpr int kQ6b[64] = { - -152, -28000, -21984, -18256, -15800, -13864, -12240, -10840, - -9608, -8512, -7528, -6624, -5792, -5032, -4328, -3664, - -3056, -2480, -1936, -1424, -936, -464, -152, -152, - -26400, -20912, -17600, -15288, -13448, -11880, -10520, -9320, - 28000, 21984, 18256, 15800, 13864, 12240, 10840, 9608, - 8512, 7528, 6624, 5792, 5032, 4328, 3664, 3056, - 2480, 1936, 1424, 936, 464, 152, 26400, 20912, - 17600, 15288, 13448, 11880, 10520, 9320, -8232, 8232 + -136, -136, -136, -136, -24808, -21904, -19008, -16704, + -14984, -13512, -12280, -11192, -10232, -9360, -8576, -7856, + -7192, -6576, -6000, -5456, -4944, -4464, -4008, -3576, + -3168, -2776, -2400, -2032, -1688, -1360, -1040, -728, + 24808, 21904, 19008, 16704, 14984, 13512, 12280, 11192, + 10232, 9360, 8576, 7856, 7192, 6576, 6000, 5456, + 4944, 4464, 4008, 3576, 3168, 2776, 2400, 2032, + 1688, 1360, 1040, 728, 432, 136, -432, -136 }; static constexpr int kQm2[4] = { -7408, -1616, 7408, 1616 }; static constexpr int kWl[16] = { @@ -1403,16 +1404,16 @@ bool codecMatchesPreference(SipCodecId id, const std::string& pref) { std::vector orderedCodecsForPreference(const std::string& pref) { static const SipCodecId kDefaultOrder[] = { - SipCodecId::Opus, - SipCodecId::G722, SipCodecId::Pcmu, SipCodecId::Pcma, SipCodecId::Gsm, + SipCodecId::Opus, + SipCodecId::G722, SipCodecId::G726_32, - SipCodecId::Dvi4_16k, SipCodecId::Dvi4_8k, - SipCodecId::L16_16k, - SipCodecId::L16_8k + SipCodecId::Dvi4_16k, + SipCodecId::L16_8k, + SipCodecId::L16_16k }; std::vector out; for (SipCodecId c : kDefaultOrder) { @@ -1434,7 +1435,9 @@ std::string codecRtpmapLine(int pt, SipCodecId id) { switch (id) { case SipCodecId::Opus: oss << "opus/48000/2\r\n" - << "a=fmtp:" << pt << " minptime=10;useinbandfec=1;maxaveragebitrate=24000\r\n"; + << "a=fmtp:" << pt + << " minptime=10;useinbandfec=1;maxaveragebitrate=24000;" + "maxplaybackrate=16000;sprop-maxcapturerate=16000;stereo=0;sprop-stereo=0\r\n"; break; case SipCodecId::G722: oss << "G722/8000\r\n"; @@ -1579,7 +1582,20 @@ void parseSdpMedia(const std::string& msg, const std::string& preferredCodec, } } - // 2. Otherwise pick the first mutually supported codec in peer's m=audio line + // 2. In AUTO mode, prefer our ordered priority list (G.711 PCMU/PCMA first) + // among all codecs offered by the peer. + for (SipCodecId prefId : orderedCodecsForPreference("AUTO")) { + for (int pt : offeredPts) { + auto it = outPtMap.find(pt); + if (it != outPtMap.end() && it->second == prefId) { + outCodec = it->second; + outPayloadType = pt; + return; + } + } + } + + // 3. Otherwise pick the first mutually supported codec in peer's m=audio line for (int pt : offeredPts) { auto it = outPtMap.find(pt); if (it != outPtMap.end()) { @@ -1619,8 +1635,17 @@ class RtpAudioSession { SipCodecId codec, int payloadType, int dtmfPt, const std::map& ptMap, bool enableZrtp, bool peerHasZrtpSdp = false) { + if (remoteIp.empty() || remotePort <= 0) { + stop(); + return false; + } + if (running_.load() && sock_ >= 0 && remoteIp == activeRemoteIp_ && + remotePort == activeRemotePort_ && codec == codec_ && + payloadType == payloadType_) { + dtmfPt_ = (dtmfPt > 0 && dtmfPt <= 127) ? dtmfPt : 101; + return true; + } stop(); - if (remoteIp.empty() || remotePort <= 0) return false; int sock = ::socket(AF_INET, SOCK_DGRAM | SOCK_NONBLOCK | SOCK_CLOEXEC, 0); if (sock < 0) return false; @@ -1667,6 +1692,8 @@ class RtpAudioSession { sock_ = sock; remAddr_ = remAddr; + activeRemoteIp_ = remoteIp; + activeRemotePort_ = remotePort; codec_ = codec; payloadType_ = payloadType; dtmfPt_ = (dtmfPt > 0 && dtmfPt <= 127) ? dtmfPt : 101; @@ -1679,6 +1706,10 @@ class RtpAudioSession { void stop() { running_.store(false); + pid_t cp = capPid_.load(); + if (cp > 1) ::kill(cp, SIGTERM); + pid_t pp = playPid_.load(); + if (pp > 1) ::kill(pp, SIGTERM); if (worker_.joinable()) { worker_.join(); } @@ -1686,6 +1717,8 @@ class RtpAudioSession { ::close(sock_); sock_ = -1; } + activeRemoteIp_.clear(); + activeRemotePort_ = 0; std::lock_guard lk(zrtpMtx_); localHelloMsg_.clear(); srtpActive_.store(false); @@ -2319,18 +2352,69 @@ class RtpAudioSession { "amixer -c 0 cset \"name='MultiMedia2 Mixer TERT_MI2S_TX'\" 1 >/dev/null 2>&1"); int audioRate = codecAudioSampleRate(codec_); size_t frameSamples = static_cast(audioRate / 50); // 160 @ 8k, 320 @ 16k - std::string capCmd = "arecord -q -D plughw:0,1 --buffer-time=80000 --period-time=20000 " - "-f S16_LE -r " + std::to_string(audioRate) + - " -c 1 -t raw 2>/dev/null"; - std::string playCmd = "aplay -q --buffer-time=80000 --period-time=20000 " - "-f S16_LE -r " + std::to_string(audioRate) + - " -c 1 -t raw 2>/dev/null"; - FILE* capFp = ::popen(capCmd.c_str(), "r"); - FILE* playFp = ::popen(playCmd.c_str(), "w"); - int capFd = capFp ? ::fileno(capFp) : -1; - if (capFd >= 0) { - int fl = ::fcntl(capFd, F_GETFL, 0); - ::fcntl(capFd, F_SETFL, fl | O_NONBLOCK); + size_t frameBytes = frameSamples * sizeof(int16_t); + std::string rateStr = std::to_string(audioRate); + + int capPipe[2] = {-1, -1}; + int capFd = -1; + pid_t capPid = -1; + if (::pipe(capPipe) == 0) { + capPid = ::fork(); + if (capPid == 0) { + ::close(capPipe[0]); + ::dup2(capPipe[1], STDOUT_FILENO); + ::close(capPipe[1]); + int nullFd = ::open("/dev/null", O_RDWR); + if (nullFd >= 0) { + ::dup2(nullFd, STDIN_FILENO); + ::dup2(nullFd, STDERR_FILENO); + if (nullFd > 2) ::close(nullFd); + } + ::execlp("arecord", "arecord", "-q", "--buffer-time=160000", + "--period-time=20000", "-f", "S16_LE", "-r", rateStr.c_str(), + "-c", "1", "-t", "raw", static_cast(nullptr)); + ::_exit(1); + } else if (capPid > 0) { + ::close(capPipe[1]); + capFd = capPipe[0]; + int fl = ::fcntl(capFd, F_GETFL, 0); + ::fcntl(capFd, F_SETFL, fl | O_NONBLOCK); + capPid_.store(capPid); + } else { + ::close(capPipe[0]); + ::close(capPipe[1]); + } + } + + int playPipe[2] = {-1, -1}; + int playFd = -1; + pid_t playPid = -1; + if (::pipe(playPipe) == 0) { + playPid = ::fork(); + if (playPid == 0) { + ::close(playPipe[1]); + ::dup2(playPipe[0], STDIN_FILENO); + ::close(playPipe[0]); + int nullFd = ::open("/dev/null", O_RDWR); + if (nullFd >= 0) { + ::dup2(nullFd, STDOUT_FILENO); + ::dup2(nullFd, STDERR_FILENO); + if (nullFd > 2) ::close(nullFd); + } + ::execlp("aplay", "aplay", "-q", "--buffer-time=200000", + "--period-time=20000", "-f", "S16_LE", "-r", rateStr.c_str(), + "-c", "1", "-t", "raw", static_cast(nullptr)); + ::_exit(1); + } else if (playPid > 0) { + ::close(playPipe[0]); + playFd = playPipe[1]; + int fl = ::fcntl(playFd, F_GETFL, 0); + ::fcntl(playFd, F_SETFL, fl | O_NONBLOCK); + playPid_.store(playPid); + } else { + ::close(playPipe[0]); + ::close(playPipe[1]); + } } int opusErr = OPUS_OK; @@ -2356,8 +2440,19 @@ class RtpAudioSession { uint32_t ts = static_cast(nowMs() * 8); uint32_t ssrc = 0x51504241u ^ static_cast(::getpid()); int64_t nextTxMs = nowMs() + 20; + bool playPrimed = false; + uint8_t capRing[2560]; + size_t capAvail = 0; while (running_.load()) { + // Drain available microphone capture bytes into capRing without blocking + if (capFd >= 0 && capAvail < sizeof(capRing)) { + ssize_t r = ::read(capFd, capRing + capAvail, sizeof(capRing) - capAvail); + if (r > 0) { + capAvail += static_cast(r); + } + } + // 1. Receive incoming RTP / SRTP / ZRTP packets uint8_t rxPkt[1500]; while (true) { @@ -2388,9 +2483,9 @@ class RtpAudioSession { const uint8_t* payload = rxPkt + hdrLen; size_t payLen = pktLen - hdrLen; - if (!playFp || payLen == 0) continue; + if (playFd < 0 || payLen == 0) continue; - int16_t pcmDecoded[960]; + int16_t pcmDecoded[1920]; size_t decodedSamples = 0; switch (rxCodec) { @@ -2398,28 +2493,28 @@ class RtpAudioSession { if (opusDec) { int r = opus_decode(opusDec, payload, static_cast(payLen), - pcmDecoded, 960, 0); + pcmDecoded, 1920, 0); if (r > 0) decodedSamples = static_cast(r); } break; case SipCodecId::G722: - decodedSamples = g722Dec.decodeFrame(payload, payLen, pcmDecoded, 960); + decodedSamples = g722Dec.decodeFrame(payload, payLen, pcmDecoded, 1920); break; case SipCodecId::Pcmu: - decodedSamples = std::min(payLen, 960); + decodedSamples = std::min(payLen, 1920); for (size_t i = 0; i < decodedSamples; ++i) { pcmDecoded[i] = ulawToLinear(payload[i]); } break; case SipCodecId::Pcma: - decodedSamples = std::min(payLen, 960); + decodedSamples = std::min(payLen, 1920); for (size_t i = 0; i < decodedSamples; ++i) { pcmDecoded[i] = alawToLinear(payload[i]); } break; case SipCodecId::Gsm: if (gsmDec) { - for (size_t off = 0; off + 33 <= payLen && decodedSamples + 160 <= 960; off += 33) { + for (size_t off = 0; off + 33 <= payLen && decodedSamples + 160 <= 1920; off += 33) { gsm_byte frame[33]; std::memcpy(frame, payload + off, 33); if (gsm_decode(gsmDec, frame, pcmDecoded + decodedSamples) == 0) { @@ -2429,15 +2524,15 @@ class RtpAudioSession { } break; case SipCodecId::G726_32: - decodedSamples = g726Dec.decodeFrame(payload, payLen, pcmDecoded, 960); + decodedSamples = g726Dec.decodeFrame(payload, payLen, pcmDecoded, 1920); break; case SipCodecId::Dvi4_8k: case SipCodecId::Dvi4_16k: - decodedSamples = dvi4Dec.decodeFrame(payload, payLen, pcmDecoded, 960); + decodedSamples = dvi4Dec.decodeFrame(payload, payLen, pcmDecoded, 1920); break; case SipCodecId::L16_8k: case SipCodecId::L16_16k: - for (size_t i = 0; i + 1 < payLen && decodedSamples < 960; i += 2) { + for (size_t i = 0; i + 1 < payLen && decodedSamples < 1920; i += 2) { uint16_t be = (static_cast(payload[i]) << 8) | payload[i + 1]; pcmDecoded[decodedSamples++] = static_cast(be); } @@ -2445,9 +2540,14 @@ class RtpAudioSession { } if (decodedSamples > 0) { + if (!playPrimed) { + playPrimed = true; + int16_t silence[960] = {0}; + (void)::write(playFd, silence, frameSamples * 3 * sizeof(int16_t)); + } int rxRate = codecAudioSampleRate(rxCodec); if (rxRate == audioRate) { - std::fwrite(pcmDecoded, sizeof(int16_t), decodedSamples, playFp); + (void)::write(playFd, pcmDecoded, decodedSamples * sizeof(int16_t)); } else if (rxRate == 8000 && audioRate == 16000) { int16_t pcmUp[1920]; size_t upCount = 0; @@ -2457,17 +2557,16 @@ class RtpAudioSession { pcmUp[upCount++] = s0; pcmUp[upCount++] = static_cast((static_cast(s0) + s1) / 2); } - std::fwrite(pcmUp, sizeof(int16_t), upCount, playFp); + (void)::write(playFd, pcmUp, upCount * sizeof(int16_t)); } else if (rxRate == 16000 && audioRate == 8000) { - int16_t pcmDown[480]; + int16_t pcmDown[960]; size_t downCount = 0; - for (size_t i = 0; i + 1 < decodedSamples && downCount < 480; i += 2) { + for (size_t i = 0; i + 1 < decodedSamples && downCount < 960; i += 2) { pcmDown[downCount++] = static_cast( (static_cast(pcmDecoded[i]) + pcmDecoded[i + 1]) / 2); } - std::fwrite(pcmDown, sizeof(int16_t), downCount, playFp); + (void)::write(playFd, pcmDown, downCount * sizeof(int16_t)); } - std::fflush(playFp); } } @@ -2476,7 +2575,10 @@ class RtpAudioSession { periodicZrtpTick(ssrc, now); if (now >= nextTxMs) { - nextTxMs = now + 20; + nextTxMs += 20; + if (now - nextTxMs > 60) { + nextTxMs = now + 20; + } char dtmfCh = '\0'; { std::lock_guard lk(dtmfMtx_); @@ -2513,9 +2615,12 @@ class RtpAudioSession { ts += codecRtpTimestampStep20ms(codec_) * 3; } else { int16_t pcmIn[320] = {0}; - if (capFd >= 0) { - ssize_t r = ::read(capFd, pcmIn, frameSamples * sizeof(int16_t)); - (void)r; + if (capAvail >= frameBytes) { + std::memcpy(pcmIn, capRing, frameBytes); + capAvail -= frameBytes; + if (capAvail > 0) { + std::memmove(capRing, capRing + frameBytes, capAvail); + } } uint8_t pkt[12 + 768 + 16]; uint16_t curSeq = seq++; @@ -2596,17 +2701,31 @@ class RtpAudioSession { if (opusDec) opus_decoder_destroy(opusDec); if (gsmEnc) gsm_destroy(gsmEnc); if (gsmDec) gsm_destroy(gsmDec); - if (capFp) ::pclose(capFp); - if (playFp) ::pclose(playFp); + if (capFd >= 0) ::close(capFd); + if (playFd >= 0) ::close(playFd); + capPid_.store(-1); + playPid_.store(-1); + if (capPid > 1) { + ::kill(capPid, SIGKILL); + ::waitpid(capPid, nullptr, 0); + } + if (playPid > 1) { + ::kill(playPid, SIGKILL); + ::waitpid(playPid, nullptr, 0); + } } int sock_ = -1; struct sockaddr_in remAddr_ {}; + std::string activeRemoteIp_; + int activeRemotePort_ = 0; SipCodecId codec_ = SipCodecId::Pcmu; int payloadType_ = 0; int dtmfPt_ = 101; std::map rxPtMap_; std::atomic running_{false}; + std::atomic capPid_{-1}; + std::atomic playPid_{-1}; std::thread worker_; std::mutex dtmfMtx_; std::string dtmfQueue_; @@ -3635,6 +3754,9 @@ int sip_run_main(int argc, char** argv) { } else if (cmd.rfind("CALL_HANGUP", 0) == 0) { hangupActiveSipCall(false); if (visible) render(); + } else if (cmd == "HANGUP" || cmd.rfind("HANGUP ", 0) == 0) { + hangupActiveSipCall(true); + if (visible) render(); } else if (cmd.rfind("CALL_MUTE_RING", 0) == 0) { ::unlink("/tmp/sxmo_call_ringing"); runAsyncCmd("sxmo_jobs.sh stop ringing >/dev/null 2>&1; " diff --git a/src/dwm-plugins/sms_plugin.cpp b/src/dwm-plugins/sms_plugin.cpp index 8da3e5f..a6f32a2 100644 --- a/src/dwm-plugins/sms_plugin.cpp +++ b/src/dwm-plugins/sms_plugin.cpp @@ -1411,7 +1411,13 @@ int runSmsApp(int argc, char** argv) { continue; } - if (sym == XK_Escape || kc == 124 || sym == XF86XK_PowerOff) { + if (isPowerKey(sym, kc)) { + hideWindow(); + openPowerMenuFromPlugin(dpy); + continue; + } + + if (sym == XK_Escape) { hideWindow(); continue; } diff --git a/src/dwm-plugins/themes_plugin.cpp b/src/dwm-plugins/themes_plugin.cpp index 9133acb..ba0b841 100644 --- a/src/dwm-plugins/themes_plugin.cpp +++ b/src/dwm-plugins/themes_plugin.cpp @@ -1138,7 +1138,13 @@ int runThemesApp(int argc, char** argv) { continue; } - if (sym == XK_Escape || kc == 124 || sym == XF86XK_PowerOff) { + if (isPowerKey(sym, kc)) { + hideWindow(); + openPowerMenuFromPlugin(dpy); + continue; + } + + if (sym == XK_Escape) { hideWindow(); continue; } diff --git a/src/dwm-plugins/wallpapers_plugin.cpp b/src/dwm-plugins/wallpapers_plugin.cpp index c66c877..44d9ada 100644 --- a/src/dwm-plugins/wallpapers_plugin.cpp +++ b/src/dwm-plugins/wallpapers_plugin.cpp @@ -589,6 +589,12 @@ int runWallpapersApp(int argc, char** argv) { continue; } + if (isPowerKey(sym, kc)) { + hideWindow(); + openPowerMenuFromPlugin(dpy); + continue; + } + if (sym == XF86XK_HangupPhone || sym == XK_Cancel) { hideWindow(); continue; diff --git a/src/dwm-plugins/webarchy_plugin.cpp b/src/dwm-plugins/webarchy_plugin.cpp index 790b27a..e30014f 100644 --- a/src/dwm-plugins/webarchy_plugin.cpp +++ b/src/dwm-plugins/webarchy_plugin.cpp @@ -785,14 +785,19 @@ gboolean onWebProcessTerminated(WebKitWebView* webView, } void ensureAlsaMultimediaRouting() { - static bool routed = false; - if (routed) return; - routed = true; - runAsyncCmd("amixer -q -c 0 cset name='PRI_MI2S_RX Audio Mixer MultiMedia1' 1 >/dev/null 2>&1; " - "amixer -q -c 0 cset name='RX1 MIX1 INP1' 'RX1' >/dev/null 2>&1; " - "amixer -q -c 0 cset name='RX2 MIX1 INP1' 'RX2' >/dev/null 2>&1; " - "amixer -q -c 0 cset name='RDAC2 MUX' 'RX2' >/dev/null 2>&1; " - "amixer -q -c 0 cset name='SPK DAC Switch' 1 >/dev/null 2>&1"); + if (isCallActiveOrRingingFast()) return; + runAsyncCmd( + "outdev=$(cat /tmp/sxmo_audio_out_device 2>/dev/null); " + "if [ \"$outdev\" = \"Earpiece\" ] || [ -z \"$outdev\" ]; then " + " if [ \"$(cat /tmp/sxmo_jack_plugged 2>/dev/null)\" = \"1\" ]; then " + " sxmo_audio.sh out set Headphones >/dev/null 2>&1; " + " else " + " sxmo_audio.sh out set Speaker >/dev/null 2>&1; " + " fi; " + "fi; " + "amixer -q -c 0 cset \"name='PRI_MI2S_RX Audio Mixer MultiMedia1'\" 1 >/dev/null 2>&1; " + "amixer -q -c 0 cset \"name='RX3 MIX1 INP1'\" 'RX1' >/dev/null 2>&1; " + "amixer -q -c 0 cset \"name='SPK DAC Switch'\" 1 >/dev/null 2>&1"); } bool initBrowserEngine(BrowserRuntimeState& st, const std::string& userAgent) { @@ -801,6 +806,7 @@ bool initBrowserEngine(BrowserRuntimeState& st, const std::string& userAgent) { // Hardware acceleration & Cortex-A7 / 512 MB RAM environment tuning ::setenv("GDK_BACKEND", "x11", 1); ::setenv("GTK_THEME", "Adwaita:dark", 1); + ::setenv("WEBKIT_DISABLE_SANDBOX_THIS_IS_DANGEROUS", "1", 1); ::setenv("WEBKIT_DISABLE_COMPOSITING_MODE", "0", 0); ::setenv("WEBKIT_DISABLE_DMABUF_RENDERER", "0", 0); ::setenv("WEBKIT_SKIA_ENABLE_CPU_RENDERING", "0", 0); @@ -863,6 +869,7 @@ bool initBrowserEngine(BrowserRuntimeState& st, const std::string& userAgent) { WebKitWebContext* webCtx = webkit_web_context_new_with_website_data_manager(dataMgr); g_object_unref(dataMgr); + webkit_web_context_set_sandbox_enabled(webCtx, FALSE); webkit_web_context_set_cache_model(webCtx, WEBKIT_CACHE_MODEL_DOCUMENT_BROWSER); WebKitCookieManager* cookieMgr = webkit_web_context_get_cookie_manager(webCtx); @@ -1093,8 +1100,6 @@ int webarchy_run_main(int argc, char** argv) { } else if (visible) { // Shift subwindow outside 240px parent clip while modal is open so media continues playing XMoveResizeWindow(neo.dpy, br.webkitXid, 240, 35, 240, 217); - } else { - XUnmapWindow(neo.dpy, br.webkitXid); } XFlush(neo.dpy); }; @@ -1309,8 +1314,10 @@ int webarchy_run_main(int argc, char** argv) { if (isPhonePasscodeLocked()) return; writeIntFile(activePidPath, static_cast(::getpid())); closeOtherPlugins("webarchy"); + ensureAlsaMultimediaRouting(); visible = true; neoui_show(); + grabPluginKeyboard(neo.dpy, neo.win); if (!br.initialized) { br.statusMsg = "Starting WPE/WebKit engine..."; render(); @@ -1320,6 +1327,9 @@ int webarchy_run_main(int argc, char** argv) { br.statusMsg = "Failed to initialize WebKit display"; } } + if (br.initialized && br.webView) { + webkit_web_view_set_is_muted(br.webView, FALSE); + } syncWebkitVisibility(); grabPluginKeyboard(neo.dpy, neo.win); render(); @@ -1335,6 +1345,10 @@ int webarchy_run_main(int argc, char** argv) { controlsModalOpen = false; infoModalOpen = false; chordPrefix.clear(); + if (br.initialized && br.webView) { + evalJs(br, "try{document.querySelectorAll('audio,video').forEach(function(m){m.pause();});}catch(e){}"); + webkit_web_view_set_is_muted(br.webView, TRUE); + } syncWebkitVisibility(); neoui_hide(); ::unlink(activePidPath.c_str()); @@ -1353,16 +1367,19 @@ int webarchy_run_main(int argc, char** argv) { neo.reloadTheme(); if (visible) render(); } else if (cmd == "OPEN" || cmd.rfind("OPEN ", 0) == 0) { + std::string newUrl; if (cmd.size() > 5) { std::string arg = trimStr(cmd.substr(5)); if (!arg.empty()) { - br.currentUrl = normalizeInputUrlOrSearch(arg); - if (br.initialized && br.webView) { - webkit_web_view_load_uri(br.webView, br.currentUrl.c_str()); - } + newUrl = normalizeInputUrlOrSearch(arg); + br.currentUrl = newUrl; } } + bool wasInitialized = br.initialized; openWindow(); + if (wasInitialized && !newUrl.empty() && br.initialized && br.webView) { + webkit_web_view_load_uri(br.webView, newUrl.c_str()); + } } } diff --git a/src/games/gambatte_phone.cpp b/src/games/gambatte_phone.cpp index 25467fb..6ef1cc8 100644 --- a/src/games/gambatte_phone.cpp +++ b/src/games/gambatte_phone.cpp @@ -2138,6 +2138,20 @@ int main(int argc, char** argv) { unsigned int kc = ev.xkey.keycode; KeySym sym = XLookupKeysym(&ev.xkey, 0); + if (isPress && (sym == XF86XK_PowerOff || kc == 124)) { + unfocusWindow(false); + int64_t tNow = nowMs(); + writeSoftkeySuppress(tNow + 500); + overlayCooldownUntilMs = tNow + 500; + int ffd = ::open("/tmp/dwm_plugin_dmenu.fifo", + O_WRONLY | O_NONBLOCK | O_CLOEXEC); + if (ffd >= 0) { + (void)::write(ffd, "OPEN power\n", 11); + ::close(ffd); + } + continue; + } + if (isPress && (sym == XF86XK_AudioLowerVolume || sym == XF86XK_AudioRaiseVolume)) { audioOut.adjustSpeakerVol( diff --git a/src/games/remedy/remedy_main.cpp b/src/games/remedy/remedy_main.cpp index 45756af..9b3b117 100644 --- a/src/games/remedy/remedy_main.cpp +++ b/src/games/remedy/remedy_main.cpp @@ -143,7 +143,7 @@ static std::string keysymLabel(KeySym ks) { case XK_Super_L: case XK_F1: return "LSoft"; case XK_F2: return "RSoft"; - case XK_Escape: return "End/Esc"; + case XK_Escape: return "Call/Esc"; case XK_asterisk: return "* (Star)"; case XK_numbersign: return "# (Hash)"; default: { @@ -1211,15 +1211,37 @@ class RemedyEmulator { } bool handleKeyPress(KeySym ks, unsigned int keycode = 0) { - // Normalize Nokia 8110 4G hardware softkeys & End key + // Normalize Nokia 8110 4G hardware softkeys, Call key, & End/Power key if (keycode == 135 || ks == XK_Menu || ks == XF86XK_KbdLcdMenu1 || ks == _EVDEVK(0x246)) { ks = XK_F1; } else if (keycode == 166 || ks == XF86XK_Back || ks == XF86XK_KbdLcdMenu2 || ks == _EVDEVK(0x247)) { ks = XK_F2; - } else if (keycode == 124 || ks == XF86XK_PowerOff) { + } else if (keycode == 169 || ks == XF86XK_Phone || + ks == XF86XK_PickupPhone || ks == _EVDEVK(0x0e7)) { ks = XK_Escape; + } else if (keycode == 124 || ks == XF86XK_PowerOff) { + cldcRuntime.sound.setPaused(true); + ungrabKeyboard(); + int ffd = ::open("/tmp/dwm_plugin_dmenu.fifo", + O_WRONLY | O_NONBLOCK | O_CLOEXEC); + if (ffd >= 0) { + (void)::write(ffd, "OPEN power\n", 11); + ::close(ffd); + } else { + std::system("dmenu power >/dev/null 2>&1"); + } + usleep(120000); + for (int wait = 0; wait < 600; ++wait) { + if (::access("/tmp/dwm_plugin_dmenu.active", F_OK) != 0) break; + usleep(50000); + } + XRaiseWindow(neoWin.dpy, neoWin.win); + XSetInputFocus(neoWin.dpy, neoWin.win, RevertToParent, CurrentTime); + grabKeyboard(); + appCtx.repaintPending = true; + return true; } if (ks == XF86XK_AudioLowerVolume || ks == XF86XK_AudioRaiseVolume) { @@ -1329,8 +1351,9 @@ class RemedyEmulator { return true; } if (mode == EmuUiMode::PAUSED) { - if (softIdx == 2) { + if (softIdx == 1 || softIdx == 2) { mode = hasLoadedMidlet ? EmuUiMode::RUNNING : EmuUiMode::BROWSER; + if (mode == EmuUiMode::BROWSER) renderBrowserMenu(); appCtx.repaintPending = true; } return true; @@ -1397,6 +1420,7 @@ class RemedyEmulator { } if (ks == XK_Escape) { mode = hasLoadedMidlet ? EmuUiMode::RUNNING : EmuUiMode::BROWSER; + if (mode == EmuUiMode::BROWSER) renderBrowserMenu(); appCtx.repaintPending = true; return true; } @@ -1493,7 +1517,10 @@ class RemedyEmulator { } } } else if (ks == XK_Escape) { - return false; + pauseSel = 0; + pauseScroll = 0; + mode = EmuUiMode::PAUSED; + renderPauseMenu(); } return true; } diff --git a/src/games/scoundrel.cpp b/src/games/scoundrel.cpp index 64fc2cd..c171881 100644 --- a/src/games/scoundrel.cpp +++ b/src/games/scoundrel.cpp @@ -993,6 +993,16 @@ int main() { continue; } if (evType == NEO_EV_CLOSE_REQ) { + if (neoui_event_keysym() == XF86XK_PowerOff || + neoui_event_keycode() == 124) { + ::usleep(80000); + while (::access("/tmp/dwm_plugin_dmenu.active", F_OK) == 0) { + ::usleep(50000); + } + neoui_raise_and_grab(); + render(); + continue; + } gRunning = 0; break; } diff --git a/src/neoui/neoui.cpp b/src/neoui/neoui.cpp index ed2797e..b0ec029 100644 --- a/src/neoui/neoui.cpp +++ b/src/neoui/neoui.cpp @@ -155,6 +155,30 @@ bool sendPluginFifoMsg(const char* name, const std::string& cmdLine) { return w == static_cast(msg.size()); } +bool isCallActiveOrRingingInNeoui() { + if (::access("/tmp/sxmo_call_ringing", F_OK) == 0 || + ::access("/tmp/sxmo_active_call", F_OK) == 0) { + return true; + } + const char* rdir = std::getenv("XDG_RUNTIME_DIR"); + std::string base = (rdir && rdir[0]) ? rdir : "/run/user/10000"; + if (::access((base + "/sxmo_jobs/ringing").c_str(), F_OK) == 0) { + return true; + } + DIR* d = ::opendir((base + "/sxmo_calls").c_str()); + if (d) { + struct dirent* ent; + while ((ent = ::readdir(d)) != nullptr) { + if (ent->d_name[0] != '.' && ent->d_name[0] != '\0') { + ::closedir(d); + return true; + } + } + ::closedir(d); + } + return false; +} + int mapHardwareKey(KeySym sym, unsigned int keycode, unsigned int state) { if (keycode == 135 || sym == XK_Super_L || sym == XK_Menu || static_cast(sym) == _EVDEVK(0x8b)) { @@ -2709,6 +2733,19 @@ int neoui_poll_event(int timeout_ms) { } if (ev.type == KeyPress) { + if (sym == XF86XK_PowerOff || kc == 124) { + if (bananarchy::isCallActiveOrRingingInNeoui()) { + bananarchy::sendPluginFifoMsg("callscreen", "HANGUP"); + continue; + } + if (::access("/tmp/bananarchy_screen_locked", F_OK) != 0) { + neoui_ungrab(); + XFlush(dpy); + bananarchy::sendPluginFifoMsg("dmenu", "OPEN power"); + ctx->lastEventType = NEO_EV_CLOSE_REQ; + return NEO_EV_CLOSE_REQ; + } + } if (ctx->chordXdrawer && (nkey == NEO_KEY_SOFT_LEFT || nkey == NEO_KEY_SOFT_RIGHT)) { int curBit = (nkey == NEO_KEY_SOFT_LEFT) ? 1 : 2; diff --git a/src/sxmo-dmenu/dmenu.c b/src/sxmo-dmenu/dmenu.c index 87d9cce..47de640 100644 --- a/src/sxmo-dmenu/dmenu.c +++ b/src/sxmo-dmenu/dmenu.c @@ -779,6 +779,8 @@ query_trigger_keys_down(void) mask |= 4; if (km[104 / 8] & (1 << (104 % 8))) mask |= 8; + if (km[124 / 8] & (1 << (124 % 8))) + mask |= 16; return mask; } @@ -1572,6 +1574,8 @@ keypress(XKeyEvent *ev) len = Xutf8LookupString(xic, ev, buf, sizeof buf, &ksym, &status); else { len = XLookupString(ev, buf, sizeof buf, &ksym, NULL); + if (ksym == NoSymbol && ev->keycode == 124) + ksym = XF86XK_PowerOff; status = (len > 0 && ksym != NoSymbol) ? XLookupBoth : (len > 0) ? XLookupChars : (ksym != NoSymbol) ? XLookupKeySym : XLookupNone; @@ -1688,7 +1692,16 @@ insert: sel = matchend; break; case XK_Escape: + cancel_session(); + return; case XF86XK_PowerOff: + if (daemon_mode && + (menu_mode != MODE_BUILTIN || strcmp(current_builtin_menu, "power") != 0)) { + if (active_client_fd >= 0) + finish_client_session(1, NULL); + open_builtin_menu("power", 0); + return; + } cancel_session(); return; case XF86XK_Back: @@ -3569,6 +3582,7 @@ process_x11_events(void) int is_enter = (ks == XK_Return || ks == XK_KP_Enter || ks == XF86XK_Phone || ks == XF86XK_PickupPhone || ev.xkey.keycode == 36 || ev.xkey.keycode == 104); + int is_power = (ks == XF86XK_PowerOff || ev.xkey.keycode == 124); if (is_left || is_right) { long long now = dmenu_now_ms(); int which = (is_left ? 1 : 0) | (is_right ? 2 : 0); @@ -3595,7 +3609,7 @@ process_x11_events(void) soft_deadline = now + 30; continue; } - if (is_enter) { + if (is_enter || is_power) { if (ev.type == KeyRelease) { initial_released = 1; continue; diff --git a/src/sxmo-dwm/dwm.c b/src/sxmo-dwm/dwm.c index 88c7977..4f8b0a3 100644 --- a/src/sxmo-dwm/dwm.c +++ b/src/sxmo-dwm/dwm.c @@ -2261,6 +2261,19 @@ keypress(XEvent *e) return; } + if (!is_phone_locked() && CLEANMASK(ev->state) == 0 && + (keysym == XF86XK_PowerOff || ev->keycode == 124)) { + XUngrabKeyboard(dpy, CurrentTime); + XFlush(dpy); + if (is_plugin_loaded("dmenu")) { + host_spawn_plugin("dmenu", "power"); + return; + } + const Arg pwrcmd = { .v = (const char*[]){ "sxmo_appmenu.sh", "power", NULL } }; + spawn(&pwrcmd); + return; + } + if (!selmon->sel && !is_phone_locked()) { if (dispatch_plugin_idle_key(keysym, ev->keycode, CLEANMASK(ev->state))) return; diff --git a/src/xdrawer/xdrawer.cpp b/src/xdrawer/xdrawer.cpp index c1a1223..73217e7 100644 --- a/src/xdrawer/xdrawer.cpp +++ b/src/xdrawer/xdrawer.cpp @@ -1212,6 +1212,19 @@ static int xdrawer_run_main(int argc, char** argv) { continue; } + if (sym == XF86XK_PowerOff || ev.xkey.keycode == 124) { + hideWindow(false); + int ffd = ::open("/tmp/dwm_plugin_dmenu.fifo", + O_WRONLY | O_NONBLOCK | O_CLOEXEC); + if (ffd >= 0) { + (void)::write(ffd, "OPEN power\n", 11); + ::close(ffd); + } else { + runAsyncCmd("dmenu power >/dev/null 2>&1"); + } + break; + } + switch (sym) { case XK_Escape: case XK_BackSpace: