Fix 2720 closed-flip call wakeups/preservation, live timezone sync, and Power menu

- Default CPU_RPM_SLEEP=0, CPU_L2_SLEEP=0, and MODEM_DRX_MODE=0 across bananarchy-power-policy.conf, bananarchy-power-policy.sh, bananarchy-display-power-sync, and kernel patch 0010 so closed-flip incoming calls wake APSS promptly via smd-edge without AT port contention.
- Serialize sxmo_modem.sh incoming/finished call checks, expire stale /tmp/sxmo_hangup_requested flags, re-verify live ModemManager call state before ringing/raising callscreen, guard idle/flip-open HANGUP_CLOSE paths in locker.so, callscreen.so, bananarchy-idle-lock.sh, and bananarchy-lid, preserve calls on flip-open (UNGRAB/RAISE), and add closed-flip cover call controls (bananarchy-cover-idle, bananarchy-cover-event.sh, bananarchy-volume-keys).
- Propagate live network/manual timezone updates across statusbar, locker.so, bananarchy-cover-idle, bananarchy-dsds, callscreen.so, and bananarchy-run-aligned without reboot (scripts/test-time-timezone-sync.py), remove non-functional Logout from the Power menu, ignore post-call sxmo_calls markers, add scripts/build-dwm-plugins.sh, and update a1114 (carbonara) hashes and docs.
This commit is contained in:
Luxferre committed 2026-11-14 10:57:29 +02:00
1 parent 786480a08f
commit 8b466ef8ae
110 files changed
+2728 -285

No files matched your search

+147 -14
View File
@@ -1,31 +1,164 @@
#!/bin/sh
# Bridge Sxmo hooks to the cover display daemon. Safe no-op on non-flip
# devices and when the daemon is not running.
# Bridge Sxmo hooks and cover button call controls to bananarchy-cover-idle.
# Safe no-op on non-flip devices and when the daemon is not running.
set -u
EVENT="${1:-refresh}"
shift 2>/dev/null || true
[ "$(cat /usr/share/bananarchy/lid-profile 2>/dev/null)" = "flip" ] || exit 0
LID_PROFILE_FILE="${BANANARCHY_LID_PROFILE_FILE:-/usr/share/bananarchy/lid-profile}"
COVERCTL_BIN="${BANANARCHY_COVERCTL_BIN:-/usr/bin/bananarchy-coverctl}"
CALLSCREEN_FIFO="${BANANARCHY_CALLSCREEN_FIFO:-/tmp/dwm_plugin_callscreen.fifo}"
RING_FILE="${BANANARCHY_RINGING_FILE:-/tmp/sxmo_call_ringing}"
ACTIVE_CALL_FILE="${BANANARCHY_ACTIVE_CALL_FILE:-/tmp/sxmo_active_call}"
[ "$(cat "$LID_PROFILE_FILE" 2>/dev/null || true)" = "flip" ] || exit 0
coverctl() {
"$COVERCTL_BIN" "$@"
}
clean_field() {
printf '%s' "${1:-}" | tr '|\r\n' ' ' | sed 's/^ *//; s/ *$//'
}
is_phone_number() {
[ -n "${1:-}" ] || return 1
printf '%s\n' "$1" | grep -q '^[+0-9*#(). -]*$' && \
printf '%s\n' "$1" | grep -q '[0-9]'
}
lookup_contact_name() {
raw="$(clean_field "${1:-}")"
digits="$(printf '%s' "$raw" | tr -cd '0-9')"
[ "${#digits}" -ge 7 ] || return 0
cfile="${SXMO_CONTACTFILE:-/home/user/.config/sxmo/contacts.tsv}"
[ -r "$cfile" ] || return 0
sfx="${digits#"${digits%???????}"}"
awk -F '\t' -v d="$digits" -v s="$sfx" '
NF >= 2 {
c1 = $1
gsub(/[^0-9]/, "", c1)
name = $2
sub(/\r$/, "", name)
if (length(c1) >= 7) {
c1_sfx = substr(c1, length(c1) - 6)
if (c1 == d || c1_sfx == s) {
print name
exit
}
}
}
' "$cfile" 2>/dev/null || true
}
send_callscreen_fifo() {
cmd="${1:-}"
[ -n "$cmd" ] || return 0
if [ -p "$CALLSCREEN_FIFO" ]; then
timeout 1 sh -c 'printf "%s\n" "$1" > "$2"' _ "$cmd" "$CALLSCREEN_FIFO" >/dev/null 2>&1 || true
fi
}
stop_ring_audio() {
killall -q -TERM bananarchy-melody sxmo_vibrate pw-play mpv 2>/dev/null || true
rpids="$(pgrep -f '[s]xmo_hook_ring\.sh|[p]w-play.*ring|[m]pv.*ring' 2>/dev/null || true)"
[ -n "$rpids" ] && kill -TERM $rpids 2>/dev/null || true
}
run_user_cmd() {
ucmd="$1"
if [ -n "${BANANARCHY_COVER_TEST_USER_SH:-}" ]; then
sh -c "$ucmd" >/dev/null 2>&1 || true
elif [ "$(id -u)" -eq 0 ]; then
su -s /bin/sh user -c "export HOME=/home/user XDG_RUNTIME_DIR=/run/user/10000 XDG_CONFIG_HOME=/home/user/.config DISPLAY=:0 SXMO_STATE=/run/user/10000/sxmo.state PATH=/home/user/.config/sxmo/hooks:/usr/share/sxmo/default_hooks:/usr/local/bin:/usr/bin:/bin:/sbin:/usr/sbin; $ucmd" </dev/null >/dev/null 2>&1 || true
else
sh -c "$ucmd" </dev/null >/dev/null 2>&1 || true
fi
}
case "$EVENT" in
notification)
/usr/bin/bananarchy-coverctl NOTIFY "Notification" >/dev/null 2>&1 || true
coverctl NOTIFY "Notification" >/dev/null 2>&1 || true
;;
ring)
/usr/bin/bananarchy-coverctl CALL incoming "${1:--}" "-" >/dev/null 2>&1 || true
arg1="$(clean_field "${1:-}")"
sim="$(clean_field "${2:-}")"
case "$arg1" in
"[SIM1] "*|"[SIM1]")
[ -z "$sim" ] && sim="SIM1"
arg1="$(clean_field "${arg1#"[SIM1]"}")"
;;
"[SIM2] "*|"[SIM2]")
[ -z "$sim" ] && sim="SIM2"
arg1="$(clean_field "${arg1#"[SIM2]"}")"
;;
esac
num="-"
name="-"
if [ -n "$arg1" ] && [ "$arg1" != "-" ]; then
if is_phone_number "$arg1"; then
num="$arg1"
resolved="$(clean_field "$(lookup_contact_name "$num")")"
[ -n "$resolved" ] && name="$resolved"
else
name="$arg1"
fi
fi
[ -n "$sim" ] || sim="-"
coverctl CALL "incoming|${num}|${name}|${sim}" >/dev/null 2>&1 || true
;;
muted)
num="$(clean_field "${1:--}")"
name="$(clean_field "${2:--}")"
sim="$(clean_field "${3:--}")"
[ -n "$num" ] || num="-"
[ -n "$name" ] || name="-"
[ -n "$sim" ] || sim="-"
coverctl CALL "muted|${num}|${name}|${sim}" >/dev/null 2>&1 || true
;;
missed)
/usr/bin/bananarchy-coverctl CALL missed "${1:--}" "-" >/dev/null 2>&1 || true
who="$(clean_field "${1:--}")"
[ -n "$who" ] || who="-"
coverctl CALL "missed|${who}|-|-" >/dev/null 2>&1 || true
;;
call|active)
/usr/bin/bananarchy-coverctl CALL active "${1:--}" "-" >/dev/null 2>&1 || true
num="$(clean_field "${1:--}")"
name="$(clean_field "${2:--}")"
sim="$(clean_field "${3:--}")"
[ -n "$num" ] || num="-"
[ -n "$name" ] || name="-"
[ -n "$sim" ] || sim="-"
coverctl CALL "active|${num}|${name}|${sim}" >/dev/null 2>&1 || true
;;
hangup|ended)
/usr/bin/bananarchy-coverctl CALL none "-" "-" >/dev/null 2>&1 || true
coverctl CALL "none|-|-|-" >/dev/null 2>&1 || true
;;
mute-ring)
stop_ring_audio
for f in /run/user/10000/sxmo_calls/*.monitoredcall /run/user/10000/sxmo_calls/*.ringing-in; do
[ -e "$f" ] || continue
touch "${f%.*}.mutedring" 2>/dev/null || true
done
send_callscreen_fifo "MUTE_RING"
run_user_cmd "sxmo_jobs.sh stop ringing >/dev/null 2>&1 || true; sxmo_hook_mute_ring.sh >/dev/null 2>&1 || true"
;;
hangup-call)
rm -f "$RING_FILE" "$ACTIVE_CALL_FILE" 2>/dev/null || true
stop_ring_audio
send_callscreen_fifo "HANGUP_CLOSE"
if [ -x /usr/libexec/msm-modem-uim-selection ]; then
timeout 2 /usr/libexec/msm-modem-uim-selection call-hangup all >/dev/null 2>&1 || true
fi
if command -v mmcli >/dev/null 2>&1; then
timeout 2 mmcli -m any --voice-hangup-all >/dev/null 2>&1 || true
fi
run_user_cmd "sxmo_modemcall.sh hangup all >/dev/null 2>&1 || true; sxmo_hook_discard.sh >/dev/null 2>&1 || true"
;;
sms)
/usr/bin/bananarchy-coverctl SMS "${1:-1}" >/dev/null 2>&1 || true
coverctl SMS "${1:-1}" >/dev/null 2>&1 || true
;;
screenoff)
/usr/bin/bananarchy-coverctl REFRESH >/dev/null 2>&1 || true
coverctl REFRESH >/dev/null 2>&1 || true
;;
network)
/usr/bin/bananarchy-cover-status.sh >/dev/null 2>&1 || true
@@ -33,17 +166,17 @@ case "$EVENT" in
button)
# Trusted external side-button wake (also sent directly by
# bananarchy-volume-keys when the flip is closed).
/usr/bin/bananarchy-coverctl BUTTON >/dev/null 2>&1 || true
coverctl BUTTON >/dev/null 2>&1 || true
;;
wake)
# Every blocked main-panel wake request is forwarded here by the lid gate.
/usr/bin/bananarchy-coverctl WAKE >/dev/null 2>&1 || true
coverctl WAKE >/dev/null 2>&1 || true
;;
refresh|theme)
/usr/bin/bananarchy-coverctl RELOAD_THEME >/dev/null 2>&1 || true
coverctl RELOAD_THEME >/dev/null 2>&1 || true
;;
*)
/usr/bin/bananarchy-coverctl REFRESH >/dev/null 2>&1 || true
coverctl REFRESH >/dev/null 2>&1 || true
;;
esac
exit 0
Binary file not shown.
@@ -17,6 +17,7 @@ RL_PATH=/sys/devices/system/cpu/cpufreq/schedutil/rate_limit_us
GPU_GOV_PATH=/sys/class/devfreq/1c00000.gpu/governor
WIFI_OFFLOAD_PATH=/sys/module/wcn36xx/parameters/screen_off_offload
SPM_SCREEN_OFF_PATH=/sys/module/cpuidle_qcom_spm/parameters/screen_off
SPM_RPM_SLEEP_PATH=/sys/module/cpuidle_qcom_spm/parameters/rpm_sleep
COVER_MARKER=/run/bananarchy/cover-backlight
FORCE_MARKER=/run/bananarchy/cover-bl-force
STATE_CACHE=/run/bananarchy/cover-power-state
@@ -49,6 +50,20 @@ for _dpms in /sys/class/drm/card*-*/dpms; do
[ -r "$_dpms" ] && DPMS_PATH="$_dpms" && break
done
[ -n "${BANANARCHY_BR_PATH:-}" ] && BR_PATH="$BANANARCHY_BR_PATH"
[ -n "${BANANARCHY_BL_POWER_PATH:-}" ] && BL_POWER_PATH="$BANANARCHY_BL_POWER_PATH"
[ -n "${BANANARCHY_KBD_PATH:-}" ] && KBD_PATH="$BANANARCHY_KBD_PATH"
[ -n "${BANANARCHY_RL_PATH:-}" ] && RL_PATH="$BANANARCHY_RL_PATH"
[ -n "${BANANARCHY_GPU_GOV_PATH:-}" ] && GPU_GOV_PATH="$BANANARCHY_GPU_GOV_PATH"
[ -n "${BANANARCHY_WIFI_OFFLOAD_PATH:-}" ] && WIFI_OFFLOAD_PATH="$BANANARCHY_WIFI_OFFLOAD_PATH"
[ -n "${BANANARCHY_SPM_SCREEN_OFF_PATH:-}" ] && SPM_SCREEN_OFF_PATH="$BANANARCHY_SPM_SCREEN_OFF_PATH"
[ -n "${BANANARCHY_SPM_RPM_SLEEP_PATH:-}" ] && SPM_RPM_SLEEP_PATH="$BANANARCHY_SPM_RPM_SLEEP_PATH"
[ -n "${BANANARCHY_LID_STATE:-}" ] && LID_STATE="$BANANARCHY_LID_STATE"
[ -n "${BANANARCHY_COVER_MARKER:-}" ] && COVER_MARKER="$BANANARCHY_COVER_MARKER"
[ -n "${BANANARCHY_FORCE_MARKER:-}" ] && FORCE_MARKER="$BANANARCHY_FORCE_MARKER"
[ -n "${BANANARCHY_STATE_CACHE:-}" ] && STATE_CACHE="$BANANARCHY_STATE_CACHE"
[ -n "${BANANARCHY_DPMS_PATH:-}" ] && DPMS_PATH="$BANANARCHY_DPMS_PATH"
read_value() {
_path="$1"
_value=""
@@ -73,6 +88,16 @@ sync_schedutil_rate_limit() {
done
}
sync_spm_screen_off() {
_want="$1"
[ -w "$SPM_SCREEN_OFF_PATH" ] || return 0
if [ "$_want" = "Y" ] && [ "$(read_value "$SPM_RPM_SLEEP_PATH")" = "Y" ]; then
set_if_changed "$SPM_SCREEN_OFF_PATH" "Y"
else
set_if_changed "$SPM_SCREEN_OFF_PATH" "N"
fi
}
cleanup_force() {
rm -f "$FORCE_MARKER" 2>/dev/null || true
}
@@ -95,9 +120,9 @@ if [ "$(read_value "$LID_PROFILE")" != "flip" ]; then
[ -w "$GPU_GOV_PATH" ] && set_if_changed "$GPU_GOV_PATH" "powersave"
[ -w "$WIFI_OFFLOAD_PATH" ] && set_if_changed "$WIFI_OFFLOAD_PATH" "Y"
force_dpms "Off"
[ -w "$SPM_SCREEN_OFF_PATH" ] && set_if_changed "$SPM_SCREEN_OFF_PATH" "Y"
sync_spm_screen_off "Y"
else
[ -w "$SPM_SCREEN_OFF_PATH" ] && set_if_changed "$SPM_SCREEN_OFF_PATH" "N"
sync_spm_screen_off "N"
[ -w "$GPU_GOV_PATH" ] && set_if_changed "$GPU_GOV_PATH" "simple_ondemand"
[ -w "$WIFI_OFFLOAD_PATH" ] && set_if_changed "$WIFI_OFFLOAD_PATH" "N"
force_dpms "On"
@@ -202,11 +227,11 @@ else
[ -w "$WIFI_OFFLOAD_PATH" ] && set_if_changed "$WIFI_OFFLOAD_PATH" "N"
fi
if [ "$DESIRED_DPMS" != "Off" ]; then
[ -w "$SPM_SCREEN_OFF_PATH" ] && set_if_changed "$SPM_SCREEN_OFF_PATH" "N"
sync_spm_screen_off "N"
fi
force_dpms "$DESIRED_DPMS"
if [ "$DESIRED_DPMS" = "Off" ]; then
[ -w "$SPM_SCREEN_OFF_PATH" ] && set_if_changed "$SPM_SCREEN_OFF_PATH" "Y"
sync_spm_screen_off "Y"
fi
sync_schedutil_rate_limit "40000"
Binary file not shown.
@@ -39,6 +39,13 @@ refresh_statusbar() {
PATH=/usr/share/sxmo/default_hooks:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin \
sxmo_hook_statusbar.sh refresh
' >/dev/null 2>&1 || true
locker_fifo="${BANANARCHY_LOCKER_FIFO:-/tmp/dwm_plugin_locker.fifo}"
if [ -p "$locker_fifo" ] || [ -f "$locker_fifo" ]; then
timeout 1 sh -c 'printf "REFRESH_TIME\n" > "$1"' _ "$locker_fifo" >/dev/null 2>&1 || true
fi
coverctl="${BANANARCHY_COVERCTL:-/usr/bin/bananarchy-coverctl}"
"$coverctl" REFRESH >/dev/null 2>&1 || true
killall -q -USR1 bananarchy-run-aligned >/dev/null 2>&1 || true
}
# Stop chronyd while GPS is the only time source; start it again for NTP.
@@ -22,6 +22,9 @@ MAX_DELAY=3600
LOCK_FLAG="${BANANARCHY_LOCK_FLAG:-/tmp/bananarchy_screen_locked}"
STATE_CMD="${BANANARCHY_STATE_CMD:-/usr/bin/sxmo_state.sh}"
WM_CMD="${BANANARCHY_WM_CMD:-/usr/bin/sxmo_wm.sh}"
LID_STATE="${BANANARCHY_LID_STATE:-/run/bananarchy/lid-state}"
RING_FLAG="${BANANARCHY_RING_FLAG:-/tmp/sxmo_call_ringing}"
ACTIVE_CALL_FLAG="${BANANARCHY_ACTIVE_CALL_FLAG:-/tmp/sxmo_active_call}"
get_delay() {
v="$DEFAULT"
@@ -70,6 +73,9 @@ cancel() {
lock_panel() {
[ -f "$LOCK_FLAG" ] && return 0
[ "$(cat "$LID_STATE" 2>/dev/null || true)" = "closed" ] && return 0
[ -e "$RING_FLAG" ] && return 0
[ -e "$ACTIVE_CALL_FLAG" ] && return 0
panel_is_dark || return 0
"$STATE_CMD" set screenoff >/dev/null 2>&1 || true
}
Binary file not shown.
@@ -26,11 +26,11 @@ if [ "$(id -u)" != "0" ]; then
fi
WIFI_LISTEN_INTERVAL=5
MODEM_DRX_MODE=6
MODEM_DRX_MODE=0
DSDS_SECONDARY_MODE=active
DSDS_PARK_DELAY=300
CPU_RPM_SLEEP=1
CPU_L2_SLEEP=1
CPU_RPM_SLEEP=0
CPU_L2_SLEEP=0
WIFI_SCREEN_OFF_IPV6_MUTE=1
WIFI_STANDBY_RAT=keep
[ -r "$CONF" ] && . "$CONF"
@@ -178,6 +178,10 @@ set_spm_bool() {
apply_cpu_lpm() {
set_spm_bool "$SPM_PARAM_DIR/rpm_sleep" "$CPU_RPM_SLEEP"
set_spm_bool "$SPM_PARAM_DIR/l2_sleep" "$CPU_L2_SLEEP"
case "$CPU_RPM_SLEEP" in
1|Y|y) ;;
*) set_spm_bool "$SPM_PARAM_DIR/screen_off" 0 ;;
esac
}
mute_wifi_ipv6_ra() {
@@ -305,27 +309,29 @@ boot() {
rm -f "$TOKEN" "$RAT_TOKEN" "$PARKED" "$AIDFILE" "$SLOTFILE" "$RAT_PARKED" "$RAT_SAVED" "$IPV6_RA_SAVED" "$READYSTAMP" "$RUNDIR"/drx.wwan* 2>/dev/null || true
write_modprobe || true
apply_cpu_lpm
btok="$$-$(cat /proc/uptime 2>/dev/null | awk '{print $1}' || echo 0)"
printf '%s\n' "$btok" > "$BOOTTOKEN"
(
# Let ModemManager finish its startup AT port probe (~5 s) so we do not
# compete with mm-port-probe on wwan_core's shared RX queue, then retry
# until all enumerated AT channels accept AT$QCDRX.
sleep 5
i=0
while [ "$i" -lt 12 ]; do
cur=""
[ -r "$BOOTTOKEN" ] && { read -r cur < "$BOOTTOKEN" 2>/dev/null || cur=""; }
[ "$cur" = "$btok" ] || exit 0
if [ -c /dev/wwan0at0 ] && { [ -c /dev/wwan0at1 ] || [ "$i" -ge 2 ]; }; then
if apply_modem_drx force >/dev/null 2>&1; then
exit 0
if [ "$MODEM_DRX_MODE" != "0" ]; then
btok="$$-$(cat /proc/uptime 2>/dev/null | awk '{print $1}' || echo 0)"
printf '%s\n' "$btok" > "$BOOTTOKEN"
(
# Let ModemManager finish its startup AT port probe (~5 s) so we do not
# compete with mm-port-probe on wwan_core's shared RX queue, then retry
# until all enumerated AT channels accept AT$QCDRX.
sleep 5
i=0
while [ "$i" -lt 12 ]; do
cur=""
[ -r "$BOOTTOKEN" ] && { read -r cur < "$BOOTTOKEN" 2>/dev/null || cur=""; }
[ "$cur" = "$btok" ] || exit 0
if [ -c /dev/wwan0at0 ] && { [ -c /dev/wwan0at1 ] || [ "$i" -ge 2 ]; }; then
if apply_modem_drx force >/dev/null 2>&1; then
exit 0
fi
fi
fi
sleep 3
i=$((i + 1))
done
) >/dev/null 2>&1 &
sleep 3
i=$((i + 1))
done
) >/dev/null 2>&1 &
fi
}
debugfs_summary() {
Binary file not shown.
+63 -21
View File
@@ -36,7 +36,7 @@ BOOT_ATTEMPTS=30
SYNC_WAIT=15
# Host tests (and callers that already have privileges) can skip the doas hop.
if [ "$(id -u)" != "0" ] && [ "${BANANARCHY_TIME_SYNC_NO_ESCALATION:-0}" != "1" ]; then
if [ "${1:-}" != "refresh-ui" ] && [ "$(id -u)" != "0" ] && [ "${BANANARCHY_TIME_SYNC_NO_ESCALATION:-0}" != "1" ]; then
exec doas -n "$0" "$@"
fi
@@ -91,16 +91,54 @@ synced() {
[ -n "$ref" ] && [ "$ref" != "00000000" ]
}
burst_done() {
"$CHRONYC" -h "$SOCKET" activity 2>/dev/null | awk '
/^[0-9]+ sources doing burst/ { b = $1 }
END { exit !(b + 0 == 0) }
'
}
wait_sync_complete() {
wait_s="${BANANARCHY_SYNC_WAIT:-$SYNC_WAIT}"
sleep_s="${BANANARCHY_TIME_SYNC_SLEEP:-1}"
i=0
while [ "$i" -lt "$wait_s" ]; do
if synced && burst_done; then
return 0
fi
sleep "$sleep_s"
i=$((i + 1))
done
synced
}
refresh_statusbar() {
# chronyd can step the clock by decades (e.g. from a 1970 RTC to network
# time). Republish the status bar clock and charge icon as the X session
# user so they do not stay stale until the next 300 s periodic tick.
su user -s /bin/sh -c '
HOME=/home/user DISPLAY=:0 XDG_RUNTIME_DIR=/run/user/10000 \
SXMO_WM=dwm SXMO_STATUS_NAME=default SXMO_STATE=/run/user/10000/sxmo.state \
PATH=/usr/share/sxmo/default_hooks:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin \
sxmo_hook_statusbar.sh refresh
' >/dev/null 2>&1 || true
# time) or the user can switch timezones live. Republish desktop statusbar,
# xlocker, 2720 cover display, and realign bananarchy-run-aligned immediately.
su_cmd="${BANANARCHY_STATUS_REFRESH_CMD:-su}"
if [ "$(id -u)" = "0" ]; then
"$su_cmd" user -s /bin/sh -c '
HOME=/home/user DISPLAY=:0 XDG_RUNTIME_DIR=/run/user/10000 \
SXMO_WM=dwm SXMO_STATUS_NAME=default SXMO_STATE=/run/user/10000/sxmo.state \
PATH=/usr/share/sxmo/default_hooks:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin \
sxmo_hook_statusbar.sh refresh
' >/dev/null 2>&1 || true
else
HOME="${HOME:-/home/user}" DISPLAY="${DISPLAY:-:0}" \
XDG_RUNTIME_DIR="${XDG_RUNTIME_DIR:-/run/user/10000}" \
SXMO_WM=dwm SXMO_STATUS_NAME=default \
SXMO_STATE="${SXMO_STATE:-/run/user/10000/sxmo.state}" \
PATH="/usr/share/sxmo/default_hooks:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/usr/sbin:$PATH" \
sxmo_hook_statusbar.sh refresh >/dev/null 2>&1 || true
fi
locker_fifo="${BANANARCHY_LOCKER_FIFO:-/tmp/dwm_plugin_locker.fifo}"
if [ -p "$locker_fifo" ] || [ -f "$locker_fifo" ]; then
timeout 1 sh -c 'printf "REFRESH_TIME\n" > "$1"' _ "$locker_fifo" >/dev/null 2>&1 || true
fi
coverctl="${BANANARCHY_COVERCTL:-/usr/bin/bananarchy-coverctl}"
"$coverctl" REFRESH >/dev/null 2>&1 || true
killall -q -USR1 bananarchy-run-aligned >/dev/null 2>&1 || true
}
# refresh re-resolves pool names asynchronously. Keep retrying while DNS is
@@ -170,16 +208,11 @@ sync_now() {
echo "Network time unavailable: chronyd or DNS is not ready"
return 1
fi
i=0
while [ "$i" -lt "$SYNC_WAIT" ]; do
if synced; then
refresh_statusbar
printf 'Network time synced: %s\n' "$(date -u '+%Y-%m-%d %H:%M:%S UTC')"
return 0
fi
sleep 1
i=$((i + 1))
done
if wait_sync_complete; then
refresh_statusbar
printf 'Network time synced: %s\n' "$(date -u '+%Y-%m-%d %H:%M:%S UTC')"
return 0
fi
echo "Network time not confirmed yet; retry when the network is up"
return 1
}
@@ -190,19 +223,28 @@ case "${1:-status}" in
[ "${1:-}" = "boot" ] && "$GPS_TIME_HELPER" boot >/dev/null 2>&1 || true
exit 0
fi
trigger "$1" && refresh_statusbar
if trigger "$1"; then
wait_sync_complete || true
refresh_statusbar
fi
;;
force)
if [ "$(time_source)" = "gps" ]; then
"$GPS_TIME_HELPER" sync && refresh_statusbar
exit $?
fi
trigger force && refresh_statusbar
if trigger force; then
wait_sync_complete || true
refresh_statusbar
fi
;;
sync)
sync_now
exit $?
;;
refresh-ui)
refresh_statusbar
;;
status)
if [ ! -S "$SOCKET" ]; then
echo "chronyd command socket absent"
Binary file not shown.
+20 -6
View File
@@ -82,11 +82,26 @@ EOF
}
has_tracked_calls() {
[ -d "$XDG_RUNTIME_DIR/sxmo_calls" ] || return 1
for f in "$XDG_RUNTIME_DIR/sxmo_calls"/*; do
[ -e "$f" ] && return 0
done
return 1
[ -d "$XDG_RUNTIME_DIR/sxmo_calls" ] || return 1
for f in "$XDG_RUNTIME_DIR/sxmo_calls"/*; do
[ -e "$f" ] || continue
base="${f%.*}"
ext="${f##*.}"
case "$ext" in
pickedupcall|initiatedcall|ringing-in|dialing|ringing-out|active|held|waiting)
return 0
;;
monitoredcall)
if [ ! -e "${base}.discardedcall" ] && \
[ ! -e "${base}.hangedupcall" ] && \
[ ! -e "${base}.terminated" ] && \
[ ! -e "${base}.blockedcall" ]; then
return 0
fi
;;
esac
done
return 1
}
call_entries() {
@@ -208,7 +223,6 @@ getprogchoices() {
WINNAME="Power"
CHOICES="$icon_lck Lock^0^sxmo_state.sh set lock
$icon_lck Lock (Screen off)^0^sxmo_state.sh set screenoff
$icon_out Logout^0^confirm Logout && sxmo_power.sh logout
$icon_rld Reboot^0^confirm Reboot && sxmo_power.sh reboot
$icon_rld Reboot to loader^0^confirm Bootloader && sxmo_power.sh bootloader
$icon_pwr Poweroff^0^confirm Poweroff && sxmo_power.sh poweroff"
+41 -13
View File
@@ -17,6 +17,7 @@ fi
# We use this directory to store states, so it must exist
mkdir -p "$XDG_RUNTIME_DIR/sxmo_calls"
HANGUP_FLAG="${SXMO_HANGUP_FLAG:-/tmp/sxmo_hangup_requested}"
stderr() {
sxmo_log "$*"
@@ -37,8 +38,25 @@ cleanupnumber() {
echo "$1"
}
is_recent_hangup_requested() {
[ -f "$HANGUP_FLAG" ] || return 1
_now="$(date +%s 2>/dev/null || echo 0)"
_mt="$(stat -c %Y "$HANGUP_FLAG" 2>/dev/null || echo 0)"
case "$_now:$_mt" in
*[!0-9:]*)
rm -f "$HANGUP_FLAG" 2>/dev/null || true
return 1
;;
esac
if [ "$_now" -ge "$_mt" ] && [ "$((_now - _mt))" -le 8 ]; then
return 0
fi
rm -f "$HANGUP_FLAG" 2>/dev/null || true
return 1
}
checkforfinishedcalls() {
exec 3<> "$XDG_RUNTIME_DIR/sxmo_modem.checkforfinishedcalls.lock"
exec 3<> "$XDG_RUNTIME_DIR/sxmo_modem.voicecalls.lock"
flock -x 3
#find all finished calls
for FINISHEDCALLID in $(
@@ -67,7 +85,7 @@ checkforfinishedcalls() {
STATE=pickedup
stderr "Finished call from $FINISHEDNUMBER"
printf %b "$TIME\tcall_finished\t$FINISHEDNUMBER\n" >> "$SXMO_LOGDIR/modemlog.tsv"
elif [ -f "$XDG_RUNTIME_DIR/sxmo_calls/${FINISHEDCALLID}.hangedupcall" ] || [ -f /tmp/sxmo_hangup_requested ]; then
elif [ -f "$XDG_RUNTIME_DIR/sxmo_calls/${FINISHEDCALLID}.hangedupcall" ] || is_recent_hangup_requested; then
#this call was hung up by the user
STATE=wehangedup
stderr "Finished call from $FINISHEDNUMBER"
@@ -111,11 +129,10 @@ checkforfinishedcalls() {
if ! sxmo_modemcall.sh list_active_calls | grep -q .; then
# Cleanup
sxmo_jobs.sh stop ringing
pkill -TERM -f sxmo_hook_ring.sh 2>/dev/null || true
pkill -TERM -f "pw-play.*ring" 2>/dev/null || true
pkill -TERM -f "mpv.*ring" 2>/dev/null || true
pkill -TERM -x sxmo_vibrate 2>/dev/null || true
rm -f "$XDG_RUNTIME_DIR/sxmo_calls/"* 2>/dev/null || true
killall -q -TERM bananarchy-melody sxmo_vibrate pw-play mpv 2>/dev/null || true
rpids="$(pgrep -f '[s]xmo_hook_ring\.sh|[p]w-play.*ring|[m]pv.*ring' 2>/dev/null || true)"
[ -n "$rpids" ] && kill -TERM $rpids 2>/dev/null || true
rm -f "$XDG_RUNTIME_DIR/sxmo_calls/"* "$HANGUP_FLAG" 2>/dev/null || true
if [ "$STATE" != muted ] && [ ! -f "$XDG_CONFIG_HOME/sxmo/.novibrate" ]; then
sxmo_vibrate 600 &
fi
@@ -135,10 +152,9 @@ checkforfinishedcalls() {
# Or refresh the menu
if ! sxmo_modemcall.sh list_active_calls | grep -q "ringing-in"; then
sxmo_jobs.sh stop ringing
pkill -TERM -f sxmo_hook_ring.sh 2>/dev/null || true
pkill -TERM -f "pw-play.*ring" 2>/dev/null || true
pkill -TERM -f "mpv.*ring" 2>/dev/null || true
pkill -TERM -x sxmo_vibrate 2>/dev/null || true
killall -q -TERM bananarchy-melody sxmo_vibrate pw-play mpv 2>/dev/null || true
rpids="$(pgrep -f '[s]xmo_hook_ring\.sh|[p]w-play.*ring|[m]pv.*ring' 2>/dev/null || true)"
[ -n "$rpids" ] && kill -TERM $rpids 2>/dev/null || true
fi
sxmo_jobs.sh start incall_menu sxmo_modemcall.sh incall_menu
fi
@@ -146,6 +162,8 @@ checkforfinishedcalls() {
}
checkforincomingcalls() {
exec 3<> "$XDG_RUNTIME_DIR/sxmo_modem.voicecalls.lock"
flock -x 3
VOICECALLID="$(
mmcli -m any --voice-list-calls -a |
grep -Eo '[0-9]+ incoming \(ringing-in\)' |
@@ -153,7 +171,12 @@ checkforincomingcalls() {
)"
[ -z "$VOICECALLID" ] && return
[ -f "$XDG_RUNTIME_DIR/sxmo_calls/${VOICECALLID}.monitoredcall" ] && return # prevent multiple rings
if [ -f "$XDG_RUNTIME_DIR/sxmo_calls/${VOICECALLID}.monitoredcall" ] || \
[ -f "$XDG_RUNTIME_DIR/sxmo_calls/${VOICECALLID}.discardedcall" ] || \
[ -f "$XDG_RUNTIME_DIR/sxmo_calls/${VOICECALLID}.hangedupcall" ] || \
[ -f "$XDG_RUNTIME_DIR/sxmo_calls/${VOICECALLID}.blockedcall" ]; then
return # prevent multiple rings or re-ringing a rejected call
fi
rm "$XDG_RUNTIME_DIR/sxmo_calls/$VOICECALLID."* 2>/dev/null # we cleanup all dangling event files
touch "$XDG_RUNTIME_DIR/sxmo_calls/${VOICECALLID}.monitoredcall" #this signals that we handled the call
@@ -172,6 +195,11 @@ checkforincomingcalls() {
else
stderr "Invoking ring hook (async)"
CONTACTNAME=$(sxmo_contacts.sh --name-or-number "$INCOMINGNUMBER")
if ! mmcli -m any -o "$VOICECALLID" -K 2>/dev/null | \
grep -qE 'call\.properties\.state[[:space:]]*:[[:space:]]*(ringing-in|waiting)'; then
rm -f "$XDG_RUNTIME_DIR/sxmo_calls/${VOICECALLID}."* 2>/dev/null || true
return
fi
sxmo_jobs.sh start --group ringing sxmo_hook_ring.sh "$CONTACTNAME"
mkdir -p "$SXMO_LOGDIR"
@@ -194,7 +222,7 @@ checkforincomingcalls() {
| grep -q .; then
# Refresh the incall menu
sxmo_jobs.sh start incall_menu sxmo_modemcall.sh incall_menu
else
elif ! command -v xcallscreen >/dev/null 2>&1; then
# Or fire the incoming call menu
sxmo_jobs.sh start incall_menu sxmo_modemcall.sh incoming_call_menu "$VOICECALLID"
fi
+34 -2
View File
@@ -133,7 +133,8 @@ pickup() {
hangup() {
CALLID="${1:-all}"
touch /tmp/sxmo_hangup_requested 2>/dev/null || true
pkill -TERM -f sxmo_modemdial.sh 2>/dev/null || true
dpids="$(pgrep -f '[s]xmo_modemdial\.sh' 2>/dev/null || true)"
[ -n "$dpids" ] && kill -TERM $dpids 2>/dev/null || true
case "$CALLID" in
""|"-"|"all")
@@ -143,6 +144,12 @@ hangup() {
rm -f "$f" 2>/dev/null || true
touch "${base}.hangedupcall" 2>/dev/null || true
done
for f in "$XDG_RUNTIME_DIR"/sxmo_calls/*.monitoredcall; do
[ -e "$f" ] || continue
base="${f%.*}"
rm -f "$f" 2>/dev/null || true
touch "${base}.discardedcall" 2>/dev/null || true
done
rm -f "$XDG_RUNTIME_DIR"/sxmo_calls/sub1_* "$XDG_RUNTIME_DIR"/sxmo_calls/sub0_* /tmp/sxmo_call_ringing /tmp/sxmo_active_call 2>/dev/null || true
doas -n /usr/libexec/msm-modem-uim-selection call-hangup all >/dev/null 2>&1 || \
/usr/libexec/msm-modem-uim-selection call-hangup all >/dev/null 2>&1 || true
@@ -151,6 +158,16 @@ hangup() {
mmcli -m any -o "$cid" --hangup >/dev/null 2>&1 || true
mmcli -m any --voice-delete-call="$cid" >/dev/null 2>&1 || true
done
mm_calls="$(mmcli -m any --voice-list-calls 2>/dev/null || true)"
for f in "$XDG_RUNTIME_DIR"/sxmo_calls/*; do
[ -e "$f" ] || continue
bn="${f##*/}"
cid="${bn%%.*}"
case "$cid" in
''|*[!0-9]*) continue ;;
esac
printf '%s\n' "$mm_calls" | grep -qE "/Call/${cid}([[:space:]]|\$)" || rm -f "$f" 2>/dev/null || true
done
doas -n dbus-send --system --type=signal / org.ofono.VoiceCallManager.CallRemoved >/dev/null 2>&1 || true
sxmo_hook_hangup.sh || true
return 0
@@ -175,10 +192,12 @@ hangup() {
[ -f "$XDG_RUNTIME_DIR/sxmo_calls/${CALLID}.initiatedcall" ]; then
WAS_PICKED_UP=1
rm -f "$XDG_RUNTIME_DIR/sxmo_calls/${CALLID}.pickedupcall" \
"$XDG_RUNTIME_DIR/sxmo_calls/${CALLID}.initiatedcall"
"$XDG_RUNTIME_DIR/sxmo_calls/${CALLID}.initiatedcall" \
"$XDG_RUNTIME_DIR/sxmo_calls/${CALLID}.monitoredcall"
touch "$XDG_RUNTIME_DIR/sxmo_calls/${CALLID}.hangedupcall" || true
else
# this call was never picked up and hung up immediately, so it is a discarded call
rm -f "$XDG_RUNTIME_DIR/sxmo_calls/${CALLID}.monitoredcall"
touch "$XDG_RUNTIME_DIR/sxmo_calls/${CALLID}.discardedcall" || true
fi
rm -f /tmp/sxmo_call_ringing /tmp/sxmo_active_call 2>/dev/null || true
@@ -205,6 +224,10 @@ hangup() {
sxmo_hook_discard.sh || true
fi
if ! mmcli -m any --voice-list-calls 2>/dev/null | grep -qE "/Call/${CALLID}([[:space:]]|\$)"; then
rm -f "$XDG_RUNTIME_DIR/sxmo_calls/${CALLID}."* 2>/dev/null || true
fi
if [ "$HANGUP_FAILED" = "1" ]; then
sxmo_notify_user.sh --urgency=critical "We failed to hangup the call"
return 1
@@ -272,6 +295,15 @@ mute() {
}
incoming_call_menu() {
case "$1" in
sub1_*|sub0_*)
[ -e "$XDG_RUNTIME_DIR/sxmo_calls/${1}.ringing-in" ] || return 0
;;
*)
mmcli -m any -o "$1" -K 2>/dev/null | \
grep -qE 'call\.properties\.state[[:space:]]*:[[:space:]]*(ringing-in|waiting)' || return 0
;;
esac
NUMBER="$(vid_to_number "$1")"
NUMBER="$(sxmo_modem.sh cleanupnumber "$NUMBER")"
if command -v xcallscreen >/dev/null 2>&1; then
+1 -1
View File
@@ -113,7 +113,7 @@ case "$1" in
"i3") i3-msg exit ;;
"sway") swaymsg exit ;;
"river") riverctl exit ;;
"dwm") pkill -x dwm || pkill dwm ;;
"dwm") killall -q dwm ;;
esac
;;
togglewm) sxmo_togglewm.sh ;;
@@ -10,7 +10,11 @@ change_alpine() {
echo "Changing timezone to $1"
doas -n setup-timezone -z "$1" 2>/dev/null || doas setup-timezone -z "$1"
sxmo_hook_statusbar.sh time
if [ -x /usr/bin/bananarchy-time-sync.sh ]; then
/usr/bin/bananarchy-time-sync.sh refresh-ui >/dev/null 2>&1 || true
else
sxmo_hook_statusbar.sh time
fi
echo "Timezone changed ok"
}