diff --git a/CHANGELOG.md b/CHANGELOG.md index 300de82..4e75aec 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -23,7 +23,7 @@ Release versions follow the `
` format (where `2026` is `a`, - Upgraded **SIP (`sip.so` / `xsip`)** with direct accountless P2P/federated SIP URI calling (`user@host[:port]` or `sip:user@host[:port]`), alphanumeric username/password multi-tap entry, 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 and active `[SIP/]` / `[SIP/:]` call badges in `xcallscreen`, wideband and narrowband multi-codec RTP/SRTP audio (`G.711 PCMU`/`PCMA` 8 kHz via PJSIP `pjmedia`, `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 via PJSIP `pjmedia-codec/g722`, `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 seamless early-media (`183 Session Progress` -> `200 OK`) `arecord`/`aplay` stream continuity. - Upgraded **IRC (`irc.so` / `xirc`)** with `1:Chat` default tab ordering, `433` nick-in-use fallback, `470` channel forwarding tracking, `/close` and `/clear` commands, targeted buffer closing (`Menu -> Close Buffer` or `BackSpace` in `Buffers`), and notification hook integration in `BG Mode`. - **Bluetooth audio (`A2DP`, `HSP/HFP`), HID peripherals (keyboards, mice, gamepads), discoverability & alias settings, and active connection badges (`xnetworks`, `bananarchy-bt-obex`, `sxmo_audio.sh`, `sxmo_soundmonitor.sh`, `dwm`, `libneoui.so`)**: - - Configured BlueZ (`/etc/bluetooth/main.conf`, `/etc/bluetooth/input.conf`), WirePlumber (`50-bluetooth.conf` with `bluetooth.autoswitch-to-headset-profile = false`, `bluetooth.use-persistent-storage = false`, and `bluez5.enable-msbc = false`), and the `6.12.1-msm8916` QDSP6/ASoC/SMD kernel stack (`0005-msm8909-qdsp6-bt-sco-support.patch` adding `INTERNAL_BT_SCO_RX` `0x3000` / `INTERNAL_BT_SCO_TX` `0x3001` `dai@136`/`dai@137` AFE ports, `AFE_PARAM_ID_INTERNAL_BT_FM_CONFIG`, dynamic mid-call `q6voice` CVP port switching with idempotent `q6voice_path_stop` / `q6voice_path_start` null-session guards, codec-less DPCM backend links in `snd-soc-qcom-common.ko.zst` / `snd-soc-apq8016-sbc.ko.zst`, and `HCI_SCODATA_PKT` handling in `btqcomsmd.ko.zst`) with full **A2DP** (`a2dp_sink`, `a2dp_source` with `sbc_xq`, `aac`, `ldac`, `aptx`, `aptx_hd`), **HSP/HFP** (`hsp_hs`, `hsp_ag`, `hfp_hf`, `hfp_ag` 8 kHz CVSD over hardware LPASS `INT_BT_SCO_RX`/`INT_BT_SCO_TX` with automatic PipeWire SCO socket keepalive), and **HID / BLE HOGP** (`uhid`, `hidp`, `uinput`, `rfcomm`, `bnep`, `xpad`) profile support, and added `Bluetooth` as a selectable and hotplug-monitored audio output/input route in `sxmo_audio.sh`, `sxmo_soundmonitor.sh`, `sxmo_modemaudio.sh`, `sxmo_hook_ring.sh`, `xcallscreen` (`[3] Audio Out`), `xdrawer`, `xmusic`, `xringtones`, `xfiles`, `webarchy`, `gambatte`, `remedy`, and `dmenu` Audio menu (with automatic `pactl move-sink-input` stream migration, non-blocking post-ACL AVDTP sink readiness polling, and `SPK DAC Switch` muting when routing to Bluetooth or Headphones). + - Configured BlueZ (`/etc/bluetooth/main.conf`, `/etc/bluetooth/input.conf`), WirePlumber (`50-bluetooth.conf` across `/etc/wireplumber`, `/usr/share/wireplumber`, and `~/.config/wireplumber` with `bluetooth.autoswitch-to-headset-profile = false`, `bluetooth.use-persistent-storage = false`, `bluez5.enable-msbc = false`, and disabled `hardware.video-capture` / `monitor.bluez-midi` / `support.logind` / `support.reserve-device` / `support.portal-permissionstore` probing, plus `pipewire-0` socket readiness gating in `sxmo_hook_start.sh` and automatic `Restart=always` in `wireplumber.service` / `pipewire-pulse.service` / `pipewire.service`), and the `6.12.1-msm8916` QDSP6/ASoC/SMD kernel stack (`0005-msm8909-qdsp6-bt-sco-support.patch` adding `INTERNAL_BT_SCO_RX` `0x3000` / `INTERNAL_BT_SCO_TX` `0x3001` `dai@136`/`dai@137` AFE ports, `AFE_PARAM_ID_INTERNAL_BT_FM_CONFIG`, dynamic mid-call `q6voice` CVP port switching with idempotent `q6voice_path_stop` / `q6voice_path_start` null-session guards, codec-less DPCM backend links in `snd-soc-qcom-common.ko.zst` / `snd-soc-apq8016-sbc.ko.zst`, and `HCI_SCODATA_PKT` handling in `btqcomsmd.ko.zst`) with full **A2DP** (`a2dp_sink`, `a2dp_source` with `sbc_xq`, `aac`, `ldac`, `aptx`, `aptx_hd`), **HSP/HFP** (`hsp_hs`, `hsp_ag`, `hfp_hf`, `hfp_ag` 8 kHz CVSD over hardware LPASS `INT_BT_SCO_RX`/`INT_BT_SCO_TX` with automatic PipeWire SCO socket keepalive), and **HID / BLE HOGP** (`uhid`, `hidp`, `uinput`, `rfcomm`, `bnep`, `xpad`) profile support, and added `Bluetooth` as a selectable and hotplug-monitored audio output/input route in `sxmo_audio.sh`, `sxmo_soundmonitor.sh`, `sxmo_modemaudio.sh`, `sxmo_hook_ring.sh`, `xcallscreen` (`[3] Audio Out`), `xdrawer`, `xmusic`, `xringtones`, `xfiles`, `webarchy`, `gambatte`, `remedy`, and `dmenu` Audio menu (with automatic `pactl move-sink-input` stream migration, non-blocking post-ACL AVDTP sink readiness polling, lock-coalesced `apply_vol_out` volume stepping and pure-shell `sxmo_hook_statusbar.sh` volume updates, and `SPK DAC Switch` muting when routing to Bluetooth or Headphones). - Added **Discoverable** (`ON (Visible)` / `OFF (Hidden)`, persisted in `~/.config/sxmo/bt_discoverable`) and **Bluetooth Device Name** (`Name: [Edit]` with a multi-tap modal editor persisted in `~/.config/sxmo/bt_name` and applied via `bluetoothctl system-alias` independently of the system hostname) rows to the `3:Bluetooth` tab of `xnetworks`, alongside active connection count headers (`Bluetooth: ON (N Active)`), pinned active device cards with live profile and battery badges (`[ACTIVE: A2DP]`, `[ACTIVE: HSP/HFP]`, `[ACTIVE: HID Gamepad]`, `[ACTIVE: HID Keyboard]`, `[ACTIVE: HID Mouse]`), and a **Switch Audio (A2DP / HSP-HFP)** action. - Added a persistent BlueZ `NoInputNoOutput` default pairing/authorization agent (`/org/bananarchy/bt_agent`) and D-Bus `connect`/`pair` handler inside `/usr/bin/bananarchy-bt-obex` (skipping redundant pre-connect inquiry scans for known BlueZ devices and automatically recovering from stale `[LinkKey]` `br-connection-key-missing` errors) for seamless BLE HOGP (`00001812`), Classic HID (`00001124`), and A2DP/HFP bonding and reconnection, an automatic `/dev/uinput` gamepad-to-keypad bridge (`Bananarchy BT Gamepad Bridge`, excluding QWERTY keyboards) so Bluetooth/USB gamepads (`D-Pad` / `Left Stick` -> `Up`/`Down`/`Left`/`Right`, `South/A` -> `Enter`, `East/B` -> `8`, `West/X` -> `5`, `North/Y` -> `6`, `Start` -> `2`, `Select` -> `3`, `L1`/`R1` -> `Left`/`Right softkey`, `L2`/`R2` -> `*`/`0`, `Mode` -> `Escape`) control all NeoUI apps and games (`snake`, `tetris`, `scoundrel`, `gambatte`, `remedy`) out of the box, automatic `[KBD]` external keyboard detection (`isExternalKeyboardActive()`) in `fcitx5-t9`, `libneoui.so`, and DWM plugins so connecting a Bluetooth/USB QWERTY keyboard automatically bypasses T9 multi-tap and preedit popups for all keys (`0-9`, `*`, `#`, `Shift+0-9`, and letters), and automatic `XFixes` cursor display in `dwm` (`dwm_has_external_mouse()`) whenever a Bluetooth/USB mouse is connected. - **Universal Power button (`dmenu power`) access, lockscreen X11 grab preemption, ReMEdy `Call (green)` pause menu, JSR expansion, and 64 MB mark-and-sweep GC**: diff --git a/overlay/rootfs/etc/skel/.config/sxmo/hooks/sxmo_hook_start.sh b/overlay/rootfs/etc/skel/.config/sxmo/hooks/sxmo_hook_start.sh index 43f1a62..3af800c 100755 --- a/overlay/rootfs/etc/skel/.config/sxmo/hooks/sxmo_hook_start.sh +++ b/overlay/rootfs/etc/skel/.config/sxmo/hooks/sxmo_hook_start.sh @@ -37,8 +37,15 @@ if [ -z "$SXMO_NO_AUDIO" ]; then if [ "$(command -v pulseaudio)" ]; then superctl start pulseaudio elif [ "$(command -v pipewire)" ]; then - # pipewire-pulse will start pipewire - pidof -s pipewire >/dev/null 2>&1 || superctl start pipewire-pulse + if ! pidof -s pipewire >/dev/null 2>&1; then + superctl start pipewire + pw_wait=0 + while [ ! -S "${XDG_RUNTIME_DIR:-/run/user/10000}/pipewire-0" ] && [ "$pw_wait" -lt 30 ]; do + sleep 0.1 + pw_wait=$((pw_wait + 1)) + done + fi + superctl start pipewire-pulse pidof -s wireplumber >/dev/null 2>&1 || superctl start wireplumber fi fi diff --git a/overlay/rootfs/etc/skel/.config/wireplumber/wireplumber.conf.d/50-bluetooth.conf b/overlay/rootfs/etc/skel/.config/wireplumber/wireplumber.conf.d/50-bluetooth.conf index 0f40c24..3d5c3db 100644 --- a/overlay/rootfs/etc/skel/.config/wireplumber/wireplumber.conf.d/50-bluetooth.conf +++ b/overlay/rootfs/etc/skel/.config/wireplumber/wireplumber.conf.d/50-bluetooth.conf @@ -1,8 +1,27 @@ +wireplumber.profiles = { + main = { + hardware.video-capture = disabled + monitor.bluez-midi = disabled + support.logind = disabled + monitor.bluez.seat-monitoring = disabled + support.reserve-device = disabled + monitor.alsa.reserve-device = disabled + support.portal-permissionstore = disabled + script.client.access-portal = disabled + } +} + +wireplumber.settings = { + bluetooth.autoswitch-to-headset-profile = false + bluetooth.use-persistent-storage = false + device.routes.default-sink-volume = 0.512 +} + monitor.bluez.properties = { bluez5.roles = [ a2dp_sink a2dp_source bap_sink bap_source hsp_hs hsp_ag hfp_hf hfp_ag ] bluez5.codecs = [ sbc sbc_xq aac ldac aptx aptx_hd aptx_ll aptx_ll_duplex faststream faststream_duplex opus_05 opus_05_51 opus_05_71 opus_05_dup opus_05_pro lc3 ] bluez5.enable-sbc-xq = true - bluez5.enable-msbc = true + bluez5.enable-msbc = false bluez5.enable-hw-volume = true bluez5.hfphsp-backend = "native" bluez5.hfphsp-backend-native-modem = "any" diff --git a/overlay/rootfs/etc/wireplumber/wireplumber.conf.d/50-bluetooth.conf b/overlay/rootfs/etc/wireplumber/wireplumber.conf.d/50-bluetooth.conf index 3854531..3d5c3db 100644 --- a/overlay/rootfs/etc/wireplumber/wireplumber.conf.d/50-bluetooth.conf +++ b/overlay/rootfs/etc/wireplumber/wireplumber.conf.d/50-bluetooth.conf @@ -1,6 +1,20 @@ +wireplumber.profiles = { + main = { + hardware.video-capture = disabled + monitor.bluez-midi = disabled + support.logind = disabled + monitor.bluez.seat-monitoring = disabled + support.reserve-device = disabled + monitor.alsa.reserve-device = disabled + support.portal-permissionstore = disabled + script.client.access-portal = disabled + } +} + wireplumber.settings = { bluetooth.autoswitch-to-headset-profile = false bluetooth.use-persistent-storage = false + device.routes.default-sink-volume = 0.512 } monitor.bluez.properties = { diff --git a/overlay/rootfs/home/user/.config/sxmo/hooks/sxmo_hook_start.sh b/overlay/rootfs/home/user/.config/sxmo/hooks/sxmo_hook_start.sh index 43f1a62..3af800c 100755 --- a/overlay/rootfs/home/user/.config/sxmo/hooks/sxmo_hook_start.sh +++ b/overlay/rootfs/home/user/.config/sxmo/hooks/sxmo_hook_start.sh @@ -37,8 +37,15 @@ if [ -z "$SXMO_NO_AUDIO" ]; then if [ "$(command -v pulseaudio)" ]; then superctl start pulseaudio elif [ "$(command -v pipewire)" ]; then - # pipewire-pulse will start pipewire - pidof -s pipewire >/dev/null 2>&1 || superctl start pipewire-pulse + if ! pidof -s pipewire >/dev/null 2>&1; then + superctl start pipewire + pw_wait=0 + while [ ! -S "${XDG_RUNTIME_DIR:-/run/user/10000}/pipewire-0" ] && [ "$pw_wait" -lt 30 ]; do + sleep 0.1 + pw_wait=$((pw_wait + 1)) + done + fi + superctl start pipewire-pulse pidof -s wireplumber >/dev/null 2>&1 || superctl start wireplumber fi fi diff --git a/overlay/rootfs/home/user/.config/wireplumber/wireplumber.conf.d/50-bluetooth.conf b/overlay/rootfs/home/user/.config/wireplumber/wireplumber.conf.d/50-bluetooth.conf index 0f40c24..3d5c3db 100644 --- a/overlay/rootfs/home/user/.config/wireplumber/wireplumber.conf.d/50-bluetooth.conf +++ b/overlay/rootfs/home/user/.config/wireplumber/wireplumber.conf.d/50-bluetooth.conf @@ -1,8 +1,27 @@ +wireplumber.profiles = { + main = { + hardware.video-capture = disabled + monitor.bluez-midi = disabled + support.logind = disabled + monitor.bluez.seat-monitoring = disabled + support.reserve-device = disabled + monitor.alsa.reserve-device = disabled + support.portal-permissionstore = disabled + script.client.access-portal = disabled + } +} + +wireplumber.settings = { + bluetooth.autoswitch-to-headset-profile = false + bluetooth.use-persistent-storage = false + device.routes.default-sink-volume = 0.512 +} + monitor.bluez.properties = { bluez5.roles = [ a2dp_sink a2dp_source bap_sink bap_source hsp_hs hsp_ag hfp_hf hfp_ag ] bluez5.codecs = [ sbc sbc_xq aac ldac aptx aptx_hd aptx_ll aptx_ll_duplex faststream faststream_duplex opus_05 opus_05_51 opus_05_71 opus_05_dup opus_05_pro lc3 ] bluez5.enable-sbc-xq = true - bluez5.enable-msbc = true + bluez5.enable-msbc = false bluez5.enable-hw-volume = true bluez5.hfphsp-backend = "native" bluez5.hfphsp-backend-native-modem = "any" diff --git a/overlay/rootfs/usr/bin/sxmo_audio.sh b/overlay/rootfs/usr/bin/sxmo_audio.sh index 90abfa6..a751110 100755 --- a/overlay/rootfs/usr/bin/sxmo_audio.sh +++ b/overlay/rootfs/usr/bin/sxmo_audio.sh @@ -12,12 +12,12 @@ if [ -z "${XDG_RUNTIME_DIR:-}" ] || [ ! -d "${XDG_RUNTIME_DIR}" ]; then fi fi -# shellcheck source=configs/default_hooks/sxmo_hook_icons.sh -. sxmo_hook_icons.sh -. sxmo_common.sh +sxmo_log() { + logger -t sxmo_audio "$*" 2>/dev/null || true +} CFG_DIR="${XDG_CONFIG_HOME:-$HOME/.config}/sxmo" -mkdir -p "$CFG_DIR" 2>/dev/null || true +[ -d "$CFG_DIR" ] || mkdir -p "$CFG_DIR" 2>/dev/null || true ALSA_CARD="alsa_card.platform-7702000.sound" @@ -295,8 +295,30 @@ devicegetinput() { printf "%s\n" "$in_dev" } +fast_out_dev() { + if [ -r /tmp/sxmo_audio_out_device ]; then + read -r _fdev < /tmp/sxmo_audio_out_device 2>/dev/null || _fdev="" + if [ -n "$_fdev" ]; then + normalize_out_dev "$_fdev" + return 0 + fi + fi + deviceget +} + +fast_in_dev() { + if [ -r /tmp/sxmo_audio_in_device ]; then + read -r _fidev < /tmp/sxmo_audio_in_device 2>/dev/null || _fidev="" + if [ -n "$_fidev" ]; then + normalize_in_dev "$_fidev" + return 0 + fi + fi + devicegetinput +} + read_dev_vol() { - dev="$(normalize_out_dev "${1:-$(deviceget)}")" + dev="$(normalize_out_dev "${1:-$(fast_out_dev)}")" vf="$(vol_file_for_dev "$dev")" defv="$(default_vol_for_dev "$dev")" val="$defv" @@ -319,7 +341,7 @@ volismuted() { read -r m < /tmp/sxmo_out_muted 2>/dev/null || m=0 [ "$m" = "1" ] && return 0 fi - cur="$(read_dev_vol "$(deviceget)")" + cur="$(read_dev_vol "$(fast_out_dev)")" [ "$cur" -le 0 ] } @@ -333,7 +355,7 @@ micismuted() { } apply_alsa_out() { - dev="$(normalize_out_dev "${1:-$(deviceget)}")" + dev="$(normalize_out_dev "${1:-$(fast_out_dev)}")" pct="$(clamp_pct "${2:-$(read_dev_vol "$dev")}" 85)" muted=0 if [ -r /tmp/sxmo_out_muted ]; then @@ -349,107 +371,215 @@ apply_alsa_out() { if command -v amixer >/dev/null 2>&1; then case "$dev" in Earpiece) - amixer -c 0 -q sset 'SPK DAC' off 2>/dev/null || amixer -c 0 cset "name='SPK DAC Switch'" 0 >/dev/null 2>&1 || true - amixer -c 0 cset "name='RX3 MIX1 INP1'" 'ZERO' >/dev/null 2>&1 || true - amixer -c 0 cset "name='RX3 Digital Volume'" 0 >/dev/null 2>&1 || true - amixer -c 0 cset "name='HPHL'" 'ZERO' >/dev/null 2>&1 || true - amixer -c 0 cset "name='HPHR'" 'ZERO' >/dev/null 2>&1 || true - amixer -c 0 cset "name='RX2 MIX1 INP1'" 'ZERO' >/dev/null 2>&1 || true - amixer -c 0 cset "name='RX2 Digital Volume'" 0 >/dev/null 2>&1 || true - amixer -c 0 cset "name='INT_BT_SCO_RX Audio Mixer MultiMedia1'" 0 >/dev/null 2>&1 || true - amixer -c 0 cset "name='PRI_MI2S_RX Audio Mixer MultiMedia1'" 1 >/dev/null 2>&1 || true - amixer -c 0 cset "name='RDAC2 MUX'" 'RX1' >/dev/null 2>&1 || true if [ "$eff_pct" -gt 0 ]; then - amixer -c 0 cset "name='RX1 MIX1 INP1'" 'RX1' >/dev/null 2>&1 || true - amixer -c 0 cset "name='EAR_S'" 'Switch' >/dev/null 2>&1 || true - amixer -c 0 cset "name='RX1 Digital Volume'" "$hw" >/dev/null 2>&1 || true + ear_sw="Switch" + ear_hw="$hw" else - amixer -c 0 cset "name='EAR_S'" 'ZERO' >/dev/null 2>&1 || true - amixer -c 0 cset "name='RX1 Digital Volume'" 0 >/dev/null 2>&1 || true + ear_sw="ZERO" + ear_hw="0" fi + amixer -c 0 -s >/dev/null 2>&1 </dev/null || amixer -c 0 cset "name='SPK DAC Switch'" 0 >/dev/null 2>&1 || true - amixer -c 0 cset "name='RX3 MIX1 INP1'" 'ZERO' >/dev/null 2>&1 || true - amixer -c 0 cset "name='RX3 Digital Volume'" 0 >/dev/null 2>&1 || true - amixer -c 0 cset "name='EAR_S'" 'ZERO' >/dev/null 2>&1 || true - amixer -c 0 cset "name='INT_BT_SCO_RX Audio Mixer MultiMedia1'" 0 >/dev/null 2>&1 || true - amixer -c 0 cset "name='PRI_MI2S_RX Audio Mixer MultiMedia1'" 1 >/dev/null 2>&1 || true - amixer -c 0 cset "name='RDAC2 MUX'" 'RX2' >/dev/null 2>&1 || true if [ "$eff_pct" -gt 0 ]; then - amixer -c 0 cset "name='RX1 MIX1 INP1'" 'RX1' >/dev/null 2>&1 || true - amixer -c 0 cset "name='RX2 MIX1 INP1'" 'RX2' >/dev/null 2>&1 || true - amixer -c 0 cset "name='HPHL'" 'Switch' >/dev/null 2>&1 || true - amixer -c 0 cset "name='HPHR'" 'Switch' >/dev/null 2>&1 || true - amixer -c 0 cset "name='RX1 Digital Volume'" "$hw" >/dev/null 2>&1 || true - amixer -c 0 cset "name='RX2 Digital Volume'" "$hw" >/dev/null 2>&1 || true + hp_sw="Switch" + hp_hw="$hw" else - amixer -c 0 cset "name='HPHL'" 'ZERO' >/dev/null 2>&1 || true - amixer -c 0 cset "name='HPHR'" 'ZERO' >/dev/null 2>&1 || true - amixer -c 0 cset "name='RX1 Digital Volume'" 0 >/dev/null 2>&1 || true - amixer -c 0 cset "name='RX2 Digital Volume'" 0 >/dev/null 2>&1 || true + hp_sw="ZERO" + hp_hw="0" fi + amixer -c 0 -s >/dev/null 2>&1 </dev/null || amixer -c 0 cset "name='SPK DAC Switch'" 0 >/dev/null 2>&1 || true - amixer -c 0 cset "name='EAR_S'" 'ZERO' >/dev/null 2>&1 || true - amixer -c 0 cset "name='HPHL'" 'ZERO' >/dev/null 2>&1 || true - amixer -c 0 cset "name='HPHR'" 'ZERO' >/dev/null 2>&1 || true - amixer -c 0 cset "name='RX1 MIX1 INP1'" 'ZERO' >/dev/null 2>&1 || true - amixer -c 0 cset "name='RX2 MIX1 INP1'" 'ZERO' >/dev/null 2>&1 || true - amixer -c 0 cset "name='RX3 MIX1 INP1'" 'ZERO' >/dev/null 2>&1 || true - amixer -c 0 cset "name='RX1 Digital Volume'" 0 >/dev/null 2>&1 || true - amixer -c 0 cset "name='RX2 Digital Volume'" 0 >/dev/null 2>&1 || true - amixer -c 0 cset "name='RX3 Digital Volume'" 0 >/dev/null 2>&1 || true if is_bt_hfp && [ ! -r /tmp/sxmo_in_call ]; then - amixer -c 0 cset "name='PRI_MI2S_RX Audio Mixer MultiMedia1'" 0 >/dev/null 2>&1 || true - amixer -c 0 cset "name='INT_BT_SCO_RX Audio Mixer MultiMedia1'" 1 >/dev/null 2>&1 || true + pri_mm=0 + sco_mm=1 else - amixer -c 0 cset "name='INT_BT_SCO_RX Audio Mixer MultiMedia1'" 0 >/dev/null 2>&1 || true - amixer -c 0 cset "name='PRI_MI2S_RX Audio Mixer MultiMedia1'" 1 >/dev/null 2>&1 || true + pri_mm=1 + sco_mm=0 fi + amixer -c 0 -s >/dev/null 2>&1 </dev/null 2>&1 || true - amixer -c 0 cset "name='HPHL'" 'ZERO' >/dev/null 2>&1 || true - amixer -c 0 cset "name='HPHR'" 'ZERO' >/dev/null 2>&1 || true - amixer -c 0 cset "name='RX1 MIX1 INP1'" 'ZERO' >/dev/null 2>&1 || true - amixer -c 0 cset "name='RX2 MIX1 INP1'" 'ZERO' >/dev/null 2>&1 || true - amixer -c 0 cset "name='RX1 Digital Volume'" 0 >/dev/null 2>&1 || true - amixer -c 0 cset "name='RX2 Digital Volume'" 0 >/dev/null 2>&1 || true - amixer -c 0 cset "name='INT_BT_SCO_RX Audio Mixer MultiMedia1'" 0 >/dev/null 2>&1 || true - amixer -c 0 cset "name='PRI_MI2S_RX Audio Mixer MultiMedia1'" 1 >/dev/null 2>&1 || true - amixer -c 0 cset "name='RX3 MIX1 INP1'" 'RX1' >/dev/null 2>&1 || true if [ "$eff_pct" -gt 0 ]; then - amixer -c 0 cset "name='SPK DAC Switch'" 1 >/dev/null 2>&1 || true - amixer -c 0 cset "name='RX3 Digital Volume'" "$hw" >/dev/null 2>&1 || true + spk_sw=1 + spk_hw="$hw" else - amixer -c 0 cset "name='SPK DAC Switch'" 0 >/dev/null 2>&1 || true - amixer -c 0 cset "name='RX3 Digital Volume'" 0 >/dev/null 2>&1 || true + spk_sw=0 + spk_hw=0 fi + amixer -c 0 -s >/dev/null 2>&1 </dev/null 2>&1 || true + printf "0\n" > /tmp/sxmo_pw_sink_muted 2>/dev/null || true + pactl set-sink-mute @DEFAULT_SINK@ 0 >/dev/null 2>&1 || true if [ "$dev" = "Bluetooth" ]; then - bt_sink="$(find_bt_sink)" - if [ -n "$bt_sink" ]; then - pactl set-sink-mute "$bt_sink" 0 >/dev/null 2>&1 || true - pactl set-sink-volume "$bt_sink" "${eff_pct}%" >/dev/null 2>&1 || true - fi - wpctl set-volume @DEFAULT_AUDIO_SINK@ "${eff_pct}%" >/dev/null 2>&1 || true + pactl set-sink-volume @DEFAULT_SINK@ "${eff_pct}%" >/dev/null 2>&1 || true else - wpctl set-volume @DEFAULT_AUDIO_SINK@ 100% >/dev/null 2>&1 || true + pactl set-sink-volume @DEFAULT_SINK@ 100% >/dev/null 2>&1 || true fi else - wpctl set-mute @DEFAULT_AUDIO_SINK@ 1 >/dev/null 2>&1 || true + printf "1\n" > /tmp/sxmo_pw_sink_muted 2>/dev/null || true + pactl set-sink-mute @DEFAULT_SINK@ 1 >/dev/null 2>&1 || true + fi +} + +apply_vol_out() { + dev="$(normalize_out_dev "${1:-$(fast_out_dev)}")" + pct="$(clamp_pct "${2:-$(read_dev_vol "$dev")}" 85)" + muted=0 + if [ -r /tmp/sxmo_out_muted ]; then + read -r muted < /tmp/sxmo_out_muted 2>/dev/null || muted=0 + fi + if [ "$muted" = "1" ] || [ "$pct" -le 0 ]; then + eff_pct=0 + else + eff_pct="$pct" + fi + + pw_muted="" + [ -r /tmp/sxmo_pw_sink_muted ] && read -r pw_muted < /tmp/sxmo_pw_sink_muted 2>/dev/null || pw_muted="" + + if [ "$dev" = "Bluetooth" ]; then + if [ "$eff_pct" -gt 0 ]; then + if [ "$pw_muted" != "0" ]; then + printf "0\n" > /tmp/sxmo_pw_sink_muted 2>/dev/null || true + pactl set-sink-mute @DEFAULT_SINK@ 0 >/dev/null 2>&1 || true + fi + pactl set-sink-volume @DEFAULT_SINK@ "${eff_pct}%" >/dev/null 2>&1 || true + else + if [ "$pw_muted" != "1" ]; then + printf "1\n" > /tmp/sxmo_pw_sink_muted 2>/dev/null || true + fi + pactl set-sink-mute @DEFAULT_SINK@ 1 >/dev/null 2>&1 || true + fi + return 0 + fi + + hw="$(pct_to_hw_out "$dev" "$eff_pct")" + case "$dev" in + Earpiece) + if [ "$eff_pct" -gt 0 ]; then + amixer -c 0 -s >/dev/null 2>&1 </dev/null 2>&1 </dev/null 2>&1 </dev/null 2>&1 </dev/null 2>&1 </dev/null 2>&1 < /tmp/sxmo_pw_sink_muted 2>/dev/null || true + pactl set-sink-mute @DEFAULT_SINK@ 0 >/dev/null 2>&1 || true + pactl set-sink-volume @DEFAULT_SINK@ 100% >/dev/null 2>&1 || true + fi + else + if [ "$pw_muted" != "1" ]; then + printf "1\n" > /tmp/sxmo_pw_sink_muted 2>/dev/null || true + pactl set-sink-mute @DEFAULT_SINK@ 1 >/dev/null 2>&1 || true + fi fi } apply_alsa_in() { - in_dev="$(normalize_in_dev "${1:-$(devicegetinput)}")" + in_dev="$(normalize_in_dev "${1:-$(fast_in_dev)}")" pct="$(clamp_pct "${2:-$(read_mic_vol)}" 85)" muted=0 if [ -r /tmp/sxmo_mic_muted ]; then @@ -464,55 +594,64 @@ apply_alsa_in() { adc_hw="$(pct_to_hw_adc "$eff_pct")" if command -v amixer >/dev/null 2>&1; then - amixer -c 0 cset "name='CIC1 MUX'" 'AMIC' >/dev/null 2>&1 || true if [ "$eff_pct" -gt 0 ]; then if [ "$in_dev" = "Bluetooth" ] && is_bt_hfp && [ ! -r /tmp/sxmo_in_call ]; then - amixer -c 0 cset "name='MultiMedia2 Mixer TERT_MI2S_TX'" 0 >/dev/null 2>&1 || true - amixer -c 0 cset "name='MultiMedia2 Mixer INT_BT_SCO_TX'" 1 >/dev/null 2>&1 || true + amixer -c 0 -s >/dev/null 2>&1 </dev/null 2>&1 || true + tert_mm=1 + [ -r /tmp/sxmo_in_call ] && tert_mm=0 if [ "$in_dev" = "Headset" ]; then - amixer -c 0 cset "name='DEC1 MUX'" 'ADC2' >/dev/null 2>&1 || true - amixer -c 0 cset "name='ADC2 MUX'" 'INP2' >/dev/null 2>&1 || true - amixer -c 0 cset "name='ADC2 Volume'" "$adc_hw" >/dev/null 2>&1 || true - amixer -c 0 cset "name='ADC1 Volume'" 0 >/dev/null 2>&1 || true printf "2\n" > /tmp/xdrawer_mic_mux 2>/dev/null || true + amixer -c 0 -s >/dev/null 2>&1 </dev/null 2>&1 || true - amixer -c 0 cset "name='ADC2 MUX'" 'ZERO' >/dev/null 2>&1 || true - amixer -c 0 cset "name='ADC1 Volume'" "$adc_hw" >/dev/null 2>&1 || true - amixer -c 0 cset "name='ADC2 Volume'" 0 >/dev/null 2>&1 || true printf "1\n" > /tmp/xdrawer_mic_mux 2>/dev/null || true - fi - amixer -c 0 cset "name='TX1 Digital Volume'" "$tx_hw" >/dev/null 2>&1 || true - if [ ! -r /tmp/sxmo_in_call ]; then - amixer -c 0 cset "name='MultiMedia2 Mixer TERT_MI2S_TX'" 1 >/dev/null 2>&1 || true + amixer -c 0 -s >/dev/null 2>&1 </dev/null 2>&1 || true - amixer -c 0 cset "name='ADC1 Volume'" 0 >/dev/null 2>&1 || true - amixer -c 0 cset "name='ADC2 Volume'" 0 >/dev/null 2>&1 || true - amixer -c 0 cset "name='TX1 Digital Volume'" 0 >/dev/null 2>&1 || true - amixer -c 0 cset "name='MultiMedia2 Mixer TERT_MI2S_TX'" 0 >/dev/null 2>&1 || true - amixer -c 0 cset "name='MultiMedia2 Mixer INT_BT_SCO_TX'" 0 >/dev/null 2>&1 || true + amixer -c 0 -s >/dev/null 2>&1 </dev/null 2>&1 || true + pactl set-source-mute @DEFAULT_SOURCE@ 0 >/dev/null 2>&1 || true if [ "$in_dev" = "Bluetooth" ]; then - bt_src="$(find_bt_source)" - if [ -n "$bt_src" ]; then - pactl set-source-mute "$bt_src" 0 >/dev/null 2>&1 || true - pactl set-source-volume "$bt_src" "${eff_pct}%" >/dev/null 2>&1 || true - fi - wpctl set-volume @DEFAULT_AUDIO_SOURCE@ "${eff_pct}%" >/dev/null 2>&1 || true + pactl set-source-volume @DEFAULT_SOURCE@ "${eff_pct}%" >/dev/null 2>&1 || true else - wpctl set-volume @DEFAULT_AUDIO_SOURCE@ 100% >/dev/null 2>&1 || true + pactl set-source-volume @DEFAULT_SOURCE@ 100% >/dev/null 2>&1 || true fi else - wpctl set-mute @DEFAULT_AUDIO_SOURCE@ 1 >/dev/null 2>&1 || true + pactl set-source-mute @DEFAULT_SOURCE@ 1 >/dev/null 2>&1 || true fi } @@ -648,7 +787,7 @@ notifyvol() { } volget() { - target_dev="${1:-$(deviceget)}" + target_dev="${1:-$(fast_out_dev)}" if [ -z "$1" ] && volismuted; then printf "muted\n" return 0 @@ -657,9 +796,27 @@ volget() { printf "\n" } +acquire_volset_lock() { + if mkdir /tmp/sxmo_volset.lock 2>/dev/null; then + printf "%d\n" "$$" > /tmp/sxmo_volset.lock/pid 2>/dev/null || true + return 0 + fi + lpid="" + [ -r /tmp/sxmo_volset.lock/pid ] && read -r lpid < /tmp/sxmo_volset.lock/pid 2>/dev/null || lpid="" + if [ -n "$lpid" ] && kill -0 "$lpid" 2>/dev/null; then + return 1 + fi + rm -rf /tmp/sxmo_volset.lock 2>/dev/null || true + if mkdir /tmp/sxmo_volset.lock 2>/dev/null; then + printf "%d\n" "$$" > /tmp/sxmo_volset.lock/pid 2>/dev/null || true + return 0 + fi + return 1 +} + volset() { pct="$(clamp_pct "$1" 85)" - active_dev="$(deviceget)" + active_dev="$(fast_out_dev)" target_dev="$(normalize_out_dev "${2:-$active_dev}")" vf="$(vol_file_for_dev "$target_dev")" printf "%d\n" "$pct" > "$vf" 2>/dev/null || true @@ -672,14 +829,29 @@ volset() { if [ -r /tmp/sxmo_call_vol ]; then printf "%d\n" "$pct" > /tmp/sxmo_call_vol 2>/dev/null || true fi - apply_alsa_out "$target_dev" "$pct" + if ! acquire_volset_lock; then + return 0 + fi + applied_pct="" + while : ; do + cur_pct="$(read_dev_vol "$target_dev")" + apply_vol_out "$target_dev" "$cur_pct" + applied_pct="$cur_pct" + next_pct="$(read_dev_vol "$target_dev")" + [ "$next_pct" = "$applied_pct" ] && break + done + rm -rf /tmp/sxmo_volset.lock 2>/dev/null || true + final_pct="$(read_dev_vol "$target_dev")" + if [ "$final_pct" != "$applied_pct" ]; then + apply_vol_out "$target_dev" "$final_pct" + fi sxmo_hook_statusbar.sh volume >/dev/null 2>&1 & fi } volup() { step="${1:-5}" - target_dev="$(normalize_out_dev "${2:-$(deviceget)}")" + target_dev="$(normalize_out_dev "${2:-$(fast_out_dev)}")" cur="$(read_dev_vol "$target_dev")" next="$(( cur + step ))" [ "$next" -gt 100 ] && next=100 @@ -688,7 +860,7 @@ volup() { voldown() { step="${1:-5}" - target_dev="$(normalize_out_dev "${2:-$(deviceget)}")" + target_dev="$(normalize_out_dev "${2:-$(fast_out_dev)}")" cur="$(read_dev_vol "$target_dev")" next="$(( cur - step ))" [ "$next" -lt 0 ] && next=0 @@ -696,34 +868,34 @@ voldown() { } voltogglemute() { - active_dev="$(deviceget)" + active_dev="$(fast_out_dev)" if volismuted; then printf "0\n" > /tmp/sxmo_out_muted 2>/dev/null || true cur="$(read_dev_vol "$active_dev")" [ "$cur" -le 0 ] && cur="$(default_vol_for_dev "$active_dev")" printf "%d\n" "$cur" > "$(vol_file_for_dev "$active_dev")" 2>/dev/null || true - apply_alsa_out "$active_dev" "$cur" + apply_vol_out "$active_dev" "$cur" else printf "1\n" > /tmp/sxmo_out_muted 2>/dev/null || true - apply_alsa_out "$active_dev" 0 + apply_vol_out "$active_dev" 0 fi sxmo_hook_statusbar.sh volume >/dev/null 2>&1 & } volmute() { - active_dev="$(deviceget)" + active_dev="$(fast_out_dev)" printf "1\n" > /tmp/sxmo_out_muted 2>/dev/null || true - apply_alsa_out "$active_dev" 0 + apply_vol_out "$active_dev" 0 sxmo_hook_statusbar.sh volume >/dev/null 2>&1 & } volunmute() { - active_dev="$(deviceget)" + active_dev="$(fast_out_dev)" printf "0\n" > /tmp/sxmo_out_muted 2>/dev/null || true cur="$(read_dev_vol "$active_dev")" [ "$cur" -le 0 ] && cur="$(default_vol_for_dev "$active_dev")" printf "%d\n" "$cur" > "$(vol_file_for_dev "$active_dev")" 2>/dev/null || true - apply_alsa_out "$active_dev" "$cur" + apply_vol_out "$active_dev" "$cur" sxmo_hook_statusbar.sh volume >/dev/null 2>&1 & } @@ -744,7 +916,7 @@ micvolset() { else printf "1\n" > /tmp/sxmo_mic_muted 2>/dev/null || true fi - apply_alsa_in "$(devicegetinput)" "$pct" + apply_alsa_in "$(fast_in_dev)" "$pct" sxmo_hook_statusbar.sh volume >/dev/null 2>&1 & } @@ -770,10 +942,10 @@ mictogglemute() { cur="$(read_mic_vol)" [ "$cur" -le 0 ] && cur=85 printf "%d\n" "$cur" > "$CFG_DIR/mic_vol" 2>/dev/null || true - apply_alsa_in "$(devicegetinput)" "$cur" + apply_alsa_in "$(fast_in_dev)" "$cur" else printf "1\n" > /tmp/sxmo_mic_muted 2>/dev/null || true - apply_alsa_in "$(devicegetinput)" 0 + apply_alsa_in "$(fast_in_dev)" 0 fi sxmo_hook_statusbar.sh volume >/dev/null 2>&1 & } @@ -1009,6 +1181,9 @@ cmd="$1" shift case "$cmd" in menu) + # shellcheck source=configs/default_hooks/sxmo_hook_icons.sh + . sxmo_hook_icons.sh + . sxmo_common.sh while : ; do CHOICES="$(menuchoices)" PICKED="$( diff --git a/overlay/rootfs/usr/bin/sxmo_soundmonitor.sh b/overlay/rootfs/usr/bin/sxmo_soundmonitor.sh index 4f4cb7f..51d1cbe 100755 --- a/overlay/rootfs/usr/bin/sxmo_soundmonitor.sh +++ b/overlay/rootfs/usr/bin/sxmo_soundmonitor.sh @@ -162,7 +162,9 @@ handle_change() { sxmo_hook_statusbar.sh volume >/dev/null 2>&1 || true ;; *"Event 'change' on sink"*|*"Event 'change' on source"*) - sxmo_hook_statusbar.sh volume >/dev/null 2>&1 || true + if [ ! -d /tmp/sxmo_volset.lock ]; then + sxmo_hook_statusbar.sh volume >/dev/null 2>&1 || true + fi ;; esac done diff --git a/overlay/rootfs/usr/lib/dwm/plugins/callscreen.so b/overlay/rootfs/usr/lib/dwm/plugins/callscreen.so index 991e1fa..b99d7ba 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/files.so b/overlay/rootfs/usr/lib/dwm/plugins/files.so index 68ab00b..0bccdf2 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/music.so b/overlay/rootfs/usr/lib/dwm/plugins/music.so index ac8a36a..0aabead 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/ringtones.so b/overlay/rootfs/usr/lib/dwm/plugins/ringtones.so index ed1bab7..da85a25 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/xdrawer.so b/overlay/rootfs/usr/lib/dwm/plugins/xdrawer.so index 34824fe..3b94086 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/share/superd/services/pipewire-pulse.service b/overlay/rootfs/usr/share/superd/services/pipewire-pulse.service new file mode 100644 index 0000000..196acd2 --- /dev/null +++ b/overlay/rootfs/usr/share/superd/services/pipewire-pulse.service @@ -0,0 +1,9 @@ +[Unit] +Description=low-level multimedia framework - capture and playback for both audio and video +After=pipewire + +[Service] +Type=simple +Restart=always +ExecStart=/usr/bin/pipewire -c pipewire-pulse.conf +RestartSec=1s diff --git a/overlay/rootfs/usr/share/superd/services/pipewire.service b/overlay/rootfs/usr/share/superd/services/pipewire.service new file mode 100644 index 0000000..6a6248e --- /dev/null +++ b/overlay/rootfs/usr/share/superd/services/pipewire.service @@ -0,0 +1,8 @@ +[Unit] +Description=low-level multimedia framework - capture and playback for both audio and video + +[Service] +Type=simple +Restart=always +ExecStart=/usr/bin/pipewire +RestartSec=1s diff --git a/overlay/rootfs/usr/share/superd/services/wireplumber.service b/overlay/rootfs/usr/share/superd/services/wireplumber.service new file mode 100644 index 0000000..65939fc --- /dev/null +++ b/overlay/rootfs/usr/share/superd/services/wireplumber.service @@ -0,0 +1,9 @@ +[Unit] +Description=Session / policy manager implementation for PipeWire +After=pipewire + +[Service] +Type=simple +Restart=always +ExecStart=/usr/bin/wireplumber +RestartSec=1s diff --git a/overlay/rootfs/usr/share/sxmo/default_hooks/sxmo_hook_ring.sh b/overlay/rootfs/usr/share/sxmo/default_hooks/sxmo_hook_ring.sh index a39d0ad..52b7f87 100755 --- a/overlay/rootfs/usr/share/sxmo/default_hooks/sxmo_hook_ring.sh +++ b/overlay/rootfs/usr/share/sxmo/default_hooks/sxmo_hook_ring.sh @@ -182,8 +182,8 @@ ring() { if [ "$out_dev" = "Bluetooth" ]; then amixer -c 0 cset "name='SPK DAC Switch'" 0 >/dev/null 2>&1 || true - wpctl set-mute @DEFAULT_AUDIO_SINK@ 0 >/dev/null 2>&1 || true - wpctl set-volume @DEFAULT_AUDIO_SINK@ "${SXMO_RINGVOL}%" >/dev/null 2>&1 || true + pactl set-sink-mute @DEFAULT_SINK@ 0 >/dev/null 2>&1 || true + pactl set-sink-volume @DEFAULT_SINK@ "${SXMO_RINGVOL}%" >/dev/null 2>&1 || true elif [ "$out_dev" = "Headphones" ]; then ring_hp=$(( 52 + (SXMO_RINGVOL * 32 + 50) / 100 )) amixer -c 0 -s >/dev/null 2>&1 </dev/null 2>&1 || true - wpctl set-volume @DEFAULT_AUDIO_SINK@ 100% >/dev/null 2>&1 || true + pactl set-sink-mute @DEFAULT_SINK@ 0 >/dev/null 2>&1 || true + pactl set-sink-volume @DEFAULT_SINK@ 100% >/dev/null 2>&1 || true else amixer -c 0 -s >/dev/null 2>&1 </dev/null 2>&1 || true - wpctl set-volume @DEFAULT_AUDIO_SINK@ 100% >/dev/null 2>&1 || true + pactl set-sink-mute @DEFAULT_SINK@ 0 >/dev/null 2>&1 || true + pactl set-sink-volume @DEFAULT_SINK@ 100% >/dev/null 2>&1 || true ( for d in 0.15 0.40; do @@ -223,7 +223,7 @@ cset "name='SPK DAC Switch'" 1 cset "name='RX3 MIX1 INP1'" 3 cset "name='RX3 Digital Volume'" $ring_rx3 EOF - wpctl set-volume @DEFAULT_AUDIO_SINK@ 100% >/dev/null 2>&1 || true + pactl set-sink-volume @DEFAULT_SINK@ 100% >/dev/null 2>&1 || true done ) & vhelper="$!" @@ -252,10 +252,10 @@ EOF while [ "$i" -lt "$loops" ]; do should_stop_ringing && break if [ "$out_dev" = "Bluetooth" ]; then - wpctl set-volume @DEFAULT_AUDIO_SINK@ "${SXMO_RINGVOL}%" >/dev/null 2>&1 || true + pactl set-sink-volume @DEFAULT_SINK@ "${SXMO_RINGVOL}%" >/dev/null 2>&1 || true elif [ "$out_dev" != "Headphones" ]; then amixer -c 0 cset "name='RX3 Digital Volume'" "$ring_rx3" >/dev/null 2>&1 || true - wpctl set-volume @DEFAULT_AUDIO_SINK@ 100% >/dev/null 2>&1 || true + pactl set-sink-volume @DEFAULT_SINK@ 100% >/dev/null 2>&1 || true fi pw-play --volume=1.0 "$play_file" >/dev/null 2>&1 & rchild="$!" diff --git a/overlay/rootfs/usr/share/sxmo/default_hooks/sxmo_hook_start.sh b/overlay/rootfs/usr/share/sxmo/default_hooks/sxmo_hook_start.sh index 43f1a62..3af800c 100755 --- a/overlay/rootfs/usr/share/sxmo/default_hooks/sxmo_hook_start.sh +++ b/overlay/rootfs/usr/share/sxmo/default_hooks/sxmo_hook_start.sh @@ -37,8 +37,15 @@ if [ -z "$SXMO_NO_AUDIO" ]; then if [ "$(command -v pulseaudio)" ]; then superctl start pulseaudio elif [ "$(command -v pipewire)" ]; then - # pipewire-pulse will start pipewire - pidof -s pipewire >/dev/null 2>&1 || superctl start pipewire-pulse + if ! pidof -s pipewire >/dev/null 2>&1; then + superctl start pipewire + pw_wait=0 + while [ ! -S "${XDG_RUNTIME_DIR:-/run/user/10000}/pipewire-0" ] && [ "$pw_wait" -lt 30 ]; do + sleep 0.1 + pw_wait=$((pw_wait + 1)) + done + fi + superctl start pipewire-pulse pidof -s wireplumber >/dev/null 2>&1 || superctl start wireplumber fi fi diff --git a/overlay/rootfs/usr/share/sxmo/default_hooks/sxmo_hook_statusbar.sh b/overlay/rootfs/usr/share/sxmo/default_hooks/sxmo_hook_statusbar.sh index 9cb0b15..95bbbfe 100755 --- a/overlay/rootfs/usr/share/sxmo/default_hooks/sxmo_hook_statusbar.sh +++ b/overlay/rootfs/usr/share/sxmo/default_hooks/sxmo_hook_statusbar.sh @@ -442,35 +442,60 @@ set_notifications() { set_volume() { VOLCMP="" - - if sxmo_audio.sh mic ismuted; then + _cfg_dir="${XDG_CONFIG_HOME:-$HOME/.config}/sxmo" + _mic_m=0 + [ -r /tmp/sxmo_mic_muted ] && read -r _mic_m < /tmp/sxmo_mic_muted 2>/dev/null || _mic_m=0 + if [ "$_mic_m" = "1" ]; then VOLCMP="$icon_mmc" else - case "$(sxmo_audio.sh device getinput 2>/dev/null)" in + _in_dev="" + [ -r /tmp/sxmo_audio_in_device ] && read -r _in_dev < /tmp/sxmo_audio_in_device 2>/dev/null || _in_dev="" + case "$_in_dev" in *Headset*) VOLCMP="$icon_hst" ;; esac fi - if sxmo_audio.sh vol ismuted; then + _out_m=0 + [ -r /tmp/sxmo_out_muted ] && read -r _out_m < /tmp/sxmo_out_muted 2>/dev/null || _out_m=0 + _out_dev="" + [ -r /tmp/sxmo_audio_out_device ] && read -r _out_dev < /tmp/sxmo_audio_out_device 2>/dev/null || _out_dev="" + if [ -z "$_out_dev" ] && [ -r "$_cfg_dir/audio_out_device" ]; then + read -r _out_dev < "$_cfg_dir/audio_out_device" 2>/dev/null || _out_dev="" + fi + case "$_out_dev" in + *[Bb]luetooth*|*[Bb]luez*) + _vf="$_cfg_dir/bluetooth_vol" + _defv=80 + _dev_icon="$icon_hdp" + ;; + *[Hh]eadphone*|*[Hh]eadset*) + _vf="$_cfg_dir/headphones_vol" + _defv=80 + _dev_icon="$icon_hdp" + ;; + *[Ee]arpiece*) + _vf="$_cfg_dir/earpiece_vol" + _defv=85 + _dev_icon="$icon_ear" + ;; + *) + _vf="$_cfg_dir/speaker_vol" + _defv=85 + _dev_icon="" + ;; + esac + VOL="$_defv" + [ -r "$_vf" ] && read -r VOL < "$_vf" 2>/dev/null || VOL="$_defv" + case "$VOL" in + ''|*[!0-9-]*) VOL="$_defv" ;; + esac + + if [ "$_out_m" = "1" ] || [ "$VOL" -le 0 ]; then VOLCMP="${VOLCMP:+$VOLCMP }$icon_mut" else - case "$(sxmo_audio.sh device get 2>/dev/null)" in - *Speaker*|"") - # nothing for default or pulse devices - ;; - *Headphone*) - VOLCMP="${VOLCMP:+$VOLCMP }$icon_hdp" - ;; - *Earpiece*) - VOLCMP="${VOLCMP:+$VOLCMP }$icon_ear" - ;; - esac - VOL="$(sxmo_audio.sh vol get 2>/dev/null)" - case "$VOL" in - ''|*[!0-9]*) VOL=0 ;; - esac + [ -n "$_dev_icon" ] && VOLCMP="${VOLCMP:+$VOLCMP }$_dev_icon" if [ "$VOL" -gt 66 ]; then VOLCMP="${VOLCMP:+$VOLCMP }$icon_spk" elif [ "$VOL" -gt 33 ]; then diff --git a/overlay/rootfs/usr/share/wireplumber/wireplumber.conf.d/50-bluetooth.conf b/overlay/rootfs/usr/share/wireplumber/wireplumber.conf.d/50-bluetooth.conf index 0f40c24..3d5c3db 100644 --- a/overlay/rootfs/usr/share/wireplumber/wireplumber.conf.d/50-bluetooth.conf +++ b/overlay/rootfs/usr/share/wireplumber/wireplumber.conf.d/50-bluetooth.conf @@ -1,8 +1,27 @@ +wireplumber.profiles = { + main = { + hardware.video-capture = disabled + monitor.bluez-midi = disabled + support.logind = disabled + monitor.bluez.seat-monitoring = disabled + support.reserve-device = disabled + monitor.alsa.reserve-device = disabled + support.portal-permissionstore = disabled + script.client.access-portal = disabled + } +} + +wireplumber.settings = { + bluetooth.autoswitch-to-headset-profile = false + bluetooth.use-persistent-storage = false + device.routes.default-sink-volume = 0.512 +} + monitor.bluez.properties = { bluez5.roles = [ a2dp_sink a2dp_source bap_sink bap_source hsp_hs hsp_ag hfp_hf hfp_ag ] bluez5.codecs = [ sbc sbc_xq aac ldac aptx aptx_hd aptx_ll aptx_ll_duplex faststream faststream_duplex opus_05 opus_05_51 opus_05_71 opus_05_dup opus_05_pro lc3 ] bluez5.enable-sbc-xq = true - bluez5.enable-msbc = true + bluez5.enable-msbc = false bluez5.enable-hw-volume = true bluez5.hfphsp-backend = "native" bluez5.hfphsp-backend-native-modem = "any" diff --git a/prebuilt/sxmo-x11/usr/lib/dwm/plugins/callscreen.so b/prebuilt/sxmo-x11/usr/lib/dwm/plugins/callscreen.so index 991e1fa..b99d7ba 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/files.so b/prebuilt/sxmo-x11/usr/lib/dwm/plugins/files.so index 68ab00b..0bccdf2 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/music.so b/prebuilt/sxmo-x11/usr/lib/dwm/plugins/music.so index ac8a36a..0aabead 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/ringtones.so b/prebuilt/sxmo-x11/usr/lib/dwm/plugins/ringtones.so index ed1bab7..da85a25 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/xdrawer.so b/prebuilt/sxmo-x11/usr/lib/dwm/plugins/xdrawer.so index 34824fe..3b94086 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/src/dwm-plugins/callscreen_plugin.cpp b/src/dwm-plugins/callscreen_plugin.cpp index 5d4ca9d..6a11bc4 100644 --- a/src/dwm-plugins/callscreen_plugin.cpp +++ b/src/dwm-plugins/callscreen_plugin.cpp @@ -524,8 +524,8 @@ int callscreen_run_main(int argc, char** argv) { alsa.setBoolean("VoiceMMode1 Capture Mixer TERT_MI2S_TX", !mute); alsa.setBoolean("MultiMedia2 Mixer TERT_MI2S_TX", !mute); } - runAsyncCmd(mute ? "wpctl set-mute @DEFAULT_AUDIO_SOURCE@ 1 >/dev/null 2>&1" - : "wpctl set-mute @DEFAULT_AUDIO_SOURCE@ 0 >/dev/null 2>&1"); + runAsyncCmd(mute ? "pactl set-source-mute @DEFAULT_SOURCE@ 1 >/dev/null 2>&1" + : "pactl set-source-mute @DEFAULT_SOURCE@ 0 >/dev/null 2>&1"); statusNotice = mute ? "Microphone muted" : "Microphone unmuted"; statusNoticeUntilMs = nowMs() + 2000; }; @@ -644,8 +644,8 @@ int callscreen_run_main(int argc, char** argv) { statusNotice = "Audio routed to Earpiece"; } 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; " + runAsyncCmd("pactl set-sink-mute @DEFAULT_SINK@ 0 >/dev/null 2>&1; " + "pactl set-sink-volume @DEFAULT_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 { diff --git a/src/dwm-plugins/files_plugin.cpp b/src/dwm-plugins/files_plugin.cpp index fb82a78..935f8fc 100644 --- a/src/dwm-plugins/files_plugin.cpp +++ b/src/dwm-plugins/files_plugin.cpp @@ -828,16 +828,16 @@ int runFilesApp(int argc, char** argv) { runAsyncCmd("outdev=$(cat /tmp/sxmo_audio_out_device 2>/dev/null); " "if [ \"$outdev\" = \"Bluetooth\" ]; then " " amixer -c 0 cset \"name='SPK DAC Switch'\" 0 >/dev/null 2>&1; " - " wpctl set-mute @DEFAULT_AUDIO_SINK@ 0 >/dev/null 2>&1; " - " wpctl set-volume @DEFAULT_AUDIO_SINK@ " + std::to_string(rvol) + "% >/dev/null 2>&1; " + " pactl set-sink-mute @DEFAULT_SINK@ 0 >/dev/null 2>&1; " + " pactl set-sink-volume @DEFAULT_SINK@ " + std::to_string(rvol) + "% >/dev/null 2>&1; " "elif [ \"$outdev\" = \"Headphones\" ]; then " " amixer -c 0 cset \"name='SPK DAC Switch'\" 0 >/dev/null 2>&1; " " amixer -c 0 cset \"name='EAR_S'\" 0 >/dev/null 2>&1; " " amixer -c 0 cset \"name='PRI_MI2S_RX Audio Mixer MultiMedia1'\" 1 >/dev/null 2>&1; " " amixer -c 0 cset \"name='RX1 Digital Volume'\" " + std::to_string(hp) + " >/dev/null 2>&1; " " amixer -c 0 cset \"name='RX2 Digital Volume'\" " + std::to_string(hp) + " >/dev/null 2>&1; " - " wpctl set-mute @DEFAULT_AUDIO_SINK@ 0 >/dev/null 2>&1; " - " wpctl set-volume @DEFAULT_AUDIO_SINK@ 100% >/dev/null 2>&1; " + " pactl set-sink-mute @DEFAULT_SINK@ 0 >/dev/null 2>&1; " + " pactl set-sink-volume @DEFAULT_SINK@ 100% >/dev/null 2>&1; " "else " " amixer -c 0 cset \"name='EAR_S'\" 0 >/dev/null 2>&1; " " amixer -c 0 cset \"name='RX1 MIX1 INP1'\" 0 >/dev/null 2>&1; " @@ -845,8 +845,8 @@ int runFilesApp(int argc, char** argv) { " amixer -c 0 cset \"name='SPK DAC Switch'\" 1 >/dev/null 2>&1; " " amixer -c 0 cset \"name='RX3 MIX1 INP1'\" 3 >/dev/null 2>&1; " " amixer -c 0 cset \"name='RX3 Digital Volume'\" " + std::to_string(rx3) + " >/dev/null 2>&1; " - " wpctl set-mute @DEFAULT_AUDIO_SINK@ 0 >/dev/null 2>&1; " - " wpctl set-volume @DEFAULT_AUDIO_SINK@ 100% >/dev/null 2>&1; " + " pactl set-sink-mute @DEFAULT_SINK@ 0 >/dev/null 2>&1; " + " pactl set-sink-volume @DEFAULT_SINK@ 100% >/dev/null 2>&1; " "fi"); pid_t pid = ::fork(); diff --git a/src/dwm-plugins/music_plugin.cpp b/src/dwm-plugins/music_plugin.cpp index 9c182e0..4d15d42 100644 --- a/src/dwm-plugins/music_plugin.cpp +++ b/src/dwm-plugins/music_plugin.cpp @@ -1318,6 +1318,15 @@ int runMusicApp(int argc, char** argv) { continue; } + if (sym == XF86XK_AudioRaiseVolume || sym == XF86XK_AudioLowerVolume) { + int delta = (sym == XF86XK_AudioRaiseVolume) ? 5 : -5; + volumePct = std::clamp(volumePct + delta, 0, 100); + applySystemSpeakerVol(volumePct); + setBanner("Volume: " + std::to_string(volumePct) + "%", 1200); + render(); + continue; + } + char dch = mapDialKey(sym, kc, ev.xkey.state); if (dch == '1') { activeTab = TabId::Player; @@ -1342,11 +1351,11 @@ int runMusicApp(int argc, char** argv) { } else if (sym == XK_Right || sym == XK_KP_Right) { seekRelative(5); } else if (sym == XK_Up || sym == XK_KP_Up) { - volumePct = std::clamp(readSavedSpeakerVol() + 5, 0, 100); + volumePct = std::clamp(volumePct + 5, 0, 100); applySystemSpeakerVol(volumePct); setBanner("Volume: " + std::to_string(volumePct) + "%", 1200); } else if (sym == XK_Down || sym == XK_KP_Down) { - volumePct = std::clamp(readSavedSpeakerVol() - 5, 0, 100); + volumePct = std::clamp(volumePct - 5, 0, 100); applySystemSpeakerVol(volumePct); setBanner("Volume: " + std::to_string(volumePct) + "%", 1200); } else if (dch == '4') { diff --git a/src/dwm-plugins/ringtones_plugin.cpp b/src/dwm-plugins/ringtones_plugin.cpp index 4b7d727..6134fb7 100644 --- a/src/dwm-plugins/ringtones_plugin.cpp +++ b/src/dwm-plugins/ringtones_plugin.cpp @@ -506,16 +506,16 @@ int runRingtonesApp(int argc, char** argv) { runAsyncCmd("outdev=$(cat /tmp/sxmo_audio_out_device 2>/dev/null); " "if [ \"$outdev\" = \"Bluetooth\" ]; then " " amixer -c 0 cset \"name='SPK DAC Switch'\" 0 >/dev/null 2>&1; " - " wpctl set-mute @DEFAULT_AUDIO_SINK@ 0 >/dev/null 2>&1; " - " wpctl set-volume @DEFAULT_AUDIO_SINK@ " + std::to_string(rvol) + "% >/dev/null 2>&1; " + " pactl set-sink-mute @DEFAULT_SINK@ 0 >/dev/null 2>&1; " + " pactl set-sink-volume @DEFAULT_SINK@ " + std::to_string(rvol) + "% >/dev/null 2>&1; " "elif [ \"$outdev\" = \"Headphones\" ]; then " " amixer -c 0 cset \"name='SPK DAC Switch'\" 0 >/dev/null 2>&1; " " amixer -c 0 cset \"name='EAR_S'\" 0 >/dev/null 2>&1; " " amixer -c 0 cset \"name='PRI_MI2S_RX Audio Mixer MultiMedia1'\" 1 >/dev/null 2>&1; " " amixer -c 0 cset \"name='RX1 Digital Volume'\" " + std::to_string(hp) + " >/dev/null 2>&1; " " amixer -c 0 cset \"name='RX2 Digital Volume'\" " + std::to_string(hp) + " >/dev/null 2>&1; " - " wpctl set-mute @DEFAULT_AUDIO_SINK@ 0 >/dev/null 2>&1; " - " wpctl set-volume @DEFAULT_AUDIO_SINK@ 100% >/dev/null 2>&1; " + " pactl set-sink-mute @DEFAULT_SINK@ 0 >/dev/null 2>&1; " + " pactl set-sink-volume @DEFAULT_SINK@ 100% >/dev/null 2>&1; " "else " " amixer -c 0 cset \"name='EAR_S'\" 0 >/dev/null 2>&1; " " amixer -c 0 cset \"name='RX1 MIX1 INP1'\" 0 >/dev/null 2>&1; " @@ -523,11 +523,11 @@ int runRingtonesApp(int argc, char** argv) { " amixer -c 0 cset \"name='SPK DAC Switch'\" 1 >/dev/null 2>&1; " " amixer -c 0 cset \"name='RX3 MIX1 INP1'\" 3 >/dev/null 2>&1; " " amixer -c 0 cset \"name='RX3 Digital Volume'\" " + std::to_string(rx3) + " >/dev/null 2>&1; " - " wpctl set-mute @DEFAULT_AUDIO_SINK@ 0 >/dev/null 2>&1; " - " wpctl set-volume @DEFAULT_AUDIO_SINK@ 100% >/dev/null 2>&1; " + " pactl set-sink-mute @DEFAULT_SINK@ 0 >/dev/null 2>&1; " + " pactl set-sink-volume @DEFAULT_SINK@ 100% >/dev/null 2>&1; " " (sleep 0.25; amixer -c 0 cset \"name='RX3 Digital Volume'\" " + std::to_string(rx3) + " >/dev/null 2>&1; " - " wpctl set-volume @DEFAULT_AUDIO_SINK@ 100% >/dev/null 2>&1) & " + " pactl set-sink-volume @DEFAULT_SINK@ 100% >/dev/null 2>&1) & " "fi"); pid_t pid = ::fork(); if (pid == 0) { @@ -1001,13 +1001,13 @@ int runRingtonesApp(int argc, char** argv) { int hp = (rvol <= 0) ? 0 : (52 + (rvol * 32 + 50) / 100); runAsyncCmd("outdev=$(cat /tmp/sxmo_audio_out_device 2>/dev/null); " "if [ \"$outdev\" = \"Bluetooth\" ]; then " - " wpctl set-volume @DEFAULT_AUDIO_SINK@ " + std::to_string(rvol) + "% >/dev/null 2>&1; " + " pactl set-sink-volume @DEFAULT_SINK@ " + std::to_string(rvol) + "% >/dev/null 2>&1; " "elif [ \"$outdev\" = \"Headphones\" ]; then " " amixer -c 0 cset \"name='RX1 Digital Volume'\" " + std::to_string(hp) + " >/dev/null 2>&1; " " amixer -c 0 cset \"name='RX2 Digital Volume'\" " + std::to_string(hp) + " >/dev/null 2>&1; " "else " " amixer -c 0 cset \"name='RX3 Digital Volume'\" " + std::to_string(rx3) + " >/dev/null 2>&1; " - " wpctl set-volume @DEFAULT_AUDIO_SINK@ 100% >/dev/null 2>&1; " + " pactl set-sink-volume @DEFAULT_SINK@ 100% >/dev/null 2>&1; " "fi"); } setBanner("Ring volume: " + std::to_string(settings.ringVol) + "%"); diff --git a/src/xdrawer/xdrawer.cpp b/src/xdrawer/xdrawer.cpp index 3e89db3..6d17b58 100644 --- a/src/xdrawer/xdrawer.cpp +++ b/src/xdrawer/xdrawer.cpp @@ -739,9 +739,9 @@ class PhoneController { alsa_.setInteger("ADC2 Volume", it.value ? 7 : 0); alsa_.setInteger("TX1 Digital Volume", it.value ? 84 : 0); runAsyncCmd(it.value - ? "wpctl set-mute @DEFAULT_AUDIO_SOURCE@ 0 >/dev/null 2>&1; " + ? "pactl set-source-mute @DEFAULT_SOURCE@ 0 >/dev/null 2>&1; " "sxmo_hook_statusbar.sh volume >/dev/null 2>&1" - : "wpctl set-mute @DEFAULT_AUDIO_SOURCE@ 1 >/dev/null 2>&1; " + : "pactl set-source-mute @DEFAULT_SOURCE@ 1 >/dev/null 2>&1; " "sxmo_hook_statusbar.sh volume >/dev/null 2>&1"); break; }