Implement 2720 Flip cover display behaviour
This commit is contained in:
1 parent
a50c01b416
commit
ec55fb1457
20 files changed
+630
-49
No files matched your search
@@ -27,6 +27,14 @@ case "$EVENT" in
|
||||
screenoff)
|
||||
/usr/bin/bananarchy-coverctl REFRESH >/dev/null 2>&1 || true
|
||||
;;
|
||||
network)
|
||||
/usr/bin/bananarchy-cover-status.sh >/dev/null 2>&1 || true
|
||||
;;
|
||||
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
|
||||
;;
|
||||
wake|refresh|theme)
|
||||
/usr/bin/bananarchy-coverctl RELOAD_THEME >/dev/null 2>&1 || true
|
||||
;;
|
||||
|
||||
Binary file not shown.
+56
@@ -0,0 +1,56 @@
|
||||
#!/bin/sh
|
||||
# Publish compact main-network indicators to the 2720 Flip cover display.
|
||||
# Event-driven: called from the NetworkManager dispatcher and Sxmo hooks, so
|
||||
# the idle cover daemon never has to poll mmcli/nmcli itself.
|
||||
set -u
|
||||
|
||||
COVERCTL="${BANANARCHY_COVERCTL:-/usr/bin/bananarchy-coverctl}"
|
||||
MMCLI="${BANANARCHY_MMCLI:-/usr/bin/mmcli}"
|
||||
GPS_MODEM="${BANANARCHY_GPS_MODEM:-/usr/bin/bananarchy-gps-modem.sh}"
|
||||
|
||||
modem=""
|
||||
if [ -x "$GPS_MODEM" ]; then
|
||||
modem="$("$GPS_MODEM" path 2>/dev/null | head -n1)"
|
||||
fi
|
||||
case "$modem" in ''|*[!0-9a-zA-Z/_-]*) modem=any ;; esac
|
||||
|
||||
tech=""
|
||||
signal=""
|
||||
if command -v jq >/dev/null 2>&1; then
|
||||
info="$("$MMCLI" -m "$modem" -J 2>/dev/null || true)"
|
||||
if [ -n "$info" ]; then
|
||||
rawtech="$(printf '%s' "$info" | jq -r \
|
||||
'.modem.generic."access-technologies"[0]? // empty' 2>/dev/null || true)"
|
||||
case "$rawtech" in
|
||||
*5gnr*) tech="5G" ;;
|
||||
*lte*) tech="4G" ;;
|
||||
*hspa*|*umts*|*hsupa*|*hsdpa*) tech="3G" ;;
|
||||
*edge*) tech="E" ;;
|
||||
*gsm*|*gprs*) tech="2G" ;;
|
||||
esac
|
||||
signal="$(printf '%s' "$info" | jq -r \
|
||||
'.modem.generic."signal-quality".value // empty' 2>/dev/null || true)"
|
||||
fi
|
||||
fi
|
||||
|
||||
line=""
|
||||
[ -n "$tech" ] && line="$tech"
|
||||
case "$signal" in ''|*[!0-9]*) ;; *) line="$line SIG$signal" ;; esac
|
||||
|
||||
if command -v nmcli >/dev/null 2>&1; then
|
||||
case "$(nmcli -t -f TYPE,STATE device 2>/dev/null || true)" in
|
||||
*wifi:connected*) line="$line WIFI" ;;
|
||||
esac
|
||||
fi
|
||||
line="$(printf '%s' "$line" | tr -s ' ' | sed 's/^ *//' | cut -c1-40)"
|
||||
[ -n "$line" ] && "$COVERCTL" NETWORK "$line" >/dev/null 2>&1 || true
|
||||
|
||||
for d in /sys/class/power_supply/*; do
|
||||
[ -r "$d/type" ] && [ -r "$d/capacity" ] || continue
|
||||
read -r pstype < "$d/type" 2>/dev/null || continue
|
||||
[ "$pstype" = "Battery" ] || continue
|
||||
read -r pct < "$d/capacity" 2>/dev/null || continue
|
||||
case "$pct" in ''|*[!0-9]*) ;; *) "$COVERCTL" BATTERY "$pct" >/dev/null 2>&1 || true ;; esac
|
||||
break
|
||||
done
|
||||
exit 0
|
||||
@@ -48,4 +48,7 @@ case "$ACTION" in
|
||||
;;
|
||||
*) exit 0 ;;
|
||||
esac
|
||||
# Feed the flip's external panel with the same main network indicators the
|
||||
# status bar shows. No-op on non-flip targets and when the cover daemon is off.
|
||||
/usr/bin/bananarchy-cover-event.sh network >/dev/null 2>&1 || true
|
||||
exit 0
|
||||
Binary file not shown.
Reference in new issue
Block a user