diff --git a/overlay/rootfs/etc/NetworkManager/conf.d/10-power.conf b/overlay/rootfs/etc/NetworkManager/conf.d/10-power.conf new file mode 100644 index 0000000..b653e4e --- /dev/null +++ b/overlay/rootfs/etc/NetworkManager/conf.d/10-power.conf @@ -0,0 +1,5 @@ +[logging] +level=ERR + +[connection] +wifi.powersave=3 diff --git a/overlay/rootfs/etc/conf.d/modemmanager b/overlay/rootfs/etc/conf.d/modemmanager index f742ccc..d5207e8 100644 --- a/overlay/rootfs/etc/conf.d/modemmanager +++ b/overlay/rootfs/etc/conf.d/modemmanager @@ -1,4 +1,4 @@ # /etc/conf.d/modemmanager: config file for modemmanager -# Enable quick suspend/resume hooks and debug mode (allows mmcli --command AT queries) -modemmanager_opts="--test-quick-suspend-resume --debug" +# Enable quick suspend/resume hooks with minimal logging to save power +modemmanager_opts="--test-quick-suspend-resume --log-level=ERR" diff --git a/overlay/rootfs/etc/local.d/10-power-save.start b/overlay/rootfs/etc/local.d/10-power-save.start new file mode 100755 index 0000000..3b8481c --- /dev/null +++ b/overlay/rootfs/etc/local.d/10-power-save.start @@ -0,0 +1,14 @@ +#!/bin/sh +# Bananarchy kernel and runtime power management optimizations + +# Disable fbcon cursor blinking (eliminates 5 Hz fb_flashcursor + drm_fb_helper_damage_work wakeups) +if [ -w /sys/class/graphics/fbcon/cursor_blink ]; then + echo 0 > /sys/class/graphics/fbcon/cursor_blink 2>/dev/null || true +fi + +# Reduce periodic VM stat shepherd and dirty writeback timer wakeups +{ echo 10 > /proc/sys/vm/stat_interval; } 2>/dev/null || true +{ echo 1500 > /proc/sys/vm/dirty_writeback_centisecs; } 2>/dev/null || true +{ echo 3000 > /proc/sys/vm/dirty_expire_centisecs; } 2>/dev/null || true +{ echo "1 4 1 4" > /proc/sys/kernel/printk; } 2>/dev/null || true + diff --git a/overlay/rootfs/home/user/.config/sxmo/conky.conf b/overlay/rootfs/home/user/.config/sxmo/conky.conf index 37a7734..0323a23 100644 --- a/overlay/rootfs/home/user/.config/sxmo/conky.conf +++ b/overlay/rootfs/home/user/.config/sxmo/conky.conf @@ -17,7 +17,7 @@ conky.config = { draw_shades = true, font = 'Fira Code:size=14:style=Regular', use_xft = true, - update_interval = 15, + update_interval = 30, } conky.text = [[${alignc}${font Fira Code:size=32:style=Regular}${time %H:%M}${font} diff --git a/overlay/rootfs/usr/bin/sxmo_modemmonitor.sh b/overlay/rootfs/usr/bin/sxmo_modemmonitor.sh index 6b94915..2d41ae9 100755 --- a/overlay/rootfs/usr/bin/sxmo_modemmonitor.sh +++ b/overlay/rootfs/usr/bin/sxmo_modemmonitor.sh @@ -67,78 +67,61 @@ mainloop() { while : ; do uim_st="$(doas -n /usr/libexec/msm-modem-uim-selection status 2>/dev/null || /usr/libexec/msm-modem-uim-selection status 2>/dev/null || true)" if printf "%s\n" "$uim_st" | grep -q "^DUAL_SIM_ACTIVE=1$"; then - # Run the daemon as root whenever doas permits it. Only fall back to - # an unprivileged instance when doas is unavailable, not when the root - # daemon merely exited or was restarted (an unprivileged instance - # cannot keep the user's call log and call state files writable). if doas -n /usr/libexec/msm-modem-uim-selection status >/dev/null 2>&1; then doas -n /usr/libexec/msm-modem-uim-selection dsds-daemon 2>/dev/null || true else /usr/libexec/msm-modem-uim-selection dsds-daemon 2>/dev/null || true fi + sleep 5 + else + sleep 30 fi - sleep 5 done ) & - # Monitor for incoming calls - dbus-monitor --system "interface='org.freedesktop.ModemManager1.Modem.Voice',type='signal',member='CallAdded'" | - while read -r line; do - echo "$line" | grep -qE "^signal" && sxmo_modem.sh checkforincomingcalls - done & - - # Monitor for incoming texts - dbus-monitor --system "interface='org.freedesktop.ModemManager1.Modem.Messaging',type='signal',member='Added'" | - while read -r line; do - echo "$line" | grep -qE "^signal" && sxmo_modem.sh checkfornewtexts - done & - - # Monitor for finished calls - dbus-monitor --system "interface='org.freedesktop.DBus.Properties',member='PropertiesChanged',arg0='org.freedesktop.ModemManager1.Call'" | - while read -r line; do - echo "$line" | grep -qE "^signal" && sxmo_modem.sh checkforfinishedcalls - done & - - # Monitor for modem state change - dbus-monitor --system "interface='org.freedesktop.ModemManager1.Modem',type='signal',member='StateChanged'" | - while read -r line; do - if echo "$line" | grep -qE "^signal.*StateChanged"; then - read -r oldstate - read -r newstate - read -r reason - sxmo_hook_modem.sh "$(statenumtoname "$oldstate")" \ - "$(statenumtoname "$newstate")" \ - "$(echo "$reason" | sed 's/uint32 //')" - sxmo_hook_statusbar.sh modem - fi - done & - - # Monitor for 3GPP USSD - dbus-monitor --system "interface='org.freedesktop.DBus.Properties',member='PropertiesChanged',arg0='org.freedesktop.ModemManager1.Modem.Modem3gpp.Ussd'" | + # Monitor ModemManager signals using a single dbus-monitor connection + dbus-monitor --system \ + "interface='org.freedesktop.ModemManager1.Modem.Voice',type='signal',member='CallAdded'" \ + "interface='org.freedesktop.ModemManager1.Modem.Messaging',type='signal',member='Added'" \ + "interface='org.freedesktop.DBus.Properties',member='PropertiesChanged',arg0='org.freedesktop.ModemManager1.Sms'" \ + "interface='org.freedesktop.DBus.Properties',member='PropertiesChanged',arg0='org.freedesktop.ModemManager1.Call'" \ + "interface='org.freedesktop.ModemManager1.Modem',type='signal',member='StateChanged'" \ + "interface='org.freedesktop.DBus.Properties',member='PropertiesChanged',arg0='org.freedesktop.ModemManager1.Modem.Modem3gpp.Ussd'" | while read -r line; do case "$line" in - *"/org/freedesktop/ModemManager1/Modem"*) - MODEM=$(echo "$line" | awk -F'[;=]' '{print $6}') - CHANGED=0 + signal*"interface=org.freedesktop.ModemManager1.Modem.Voice"*"member=CallAdded"*) + sxmo_modem.sh checkforincomingcalls & ;; - *"string \"NetworkNotification"*) - TYPE="NetworkNotification" - CHANGED=1 + signal*"interface=org.freedesktop.ModemManager1.Modem.Messaging"*"member=Added"*) + sxmo_modem.sh checkfornewtexts & ;; - *"string \"NetworkRequest"*) - TYPE="NetworkRequest" - CHANGED=1 + signal*"path=/org/freedesktop/ModemManager1/SMS/"*"member=PropertiesChanged"*) + sxmo_modem.sh checkfornewtexts & ;; - *) - CHANGED=0 + signal*"path=/org/freedesktop/ModemManager1/Call/"*"member=PropertiesChanged"*) + sxmo_modem.sh checkforfinishedcalls & + ;; + signal*"interface=org.freedesktop.ModemManager1.Modem;"*"member=StateChanged"*) + read -r oldstate || true + read -r newstate || true + read -r reason || true + ( + sxmo_hook_modem.sh "$(statenumtoname "$oldstate")" \ + "$(statenumtoname "$newstate")" \ + "$(echo "$reason" | sed 's/uint32 //')" + sxmo_hook_statusbar.sh modem + ) & + ;; + signal*"path=/org/freedesktop/ModemManager1/Modem/"*"member=PropertiesChanged"*) + MODEM="$(echo "$line" | awk -F'[;=]' '{print $6}')" + ;; + *"string \"NetworkNotification\""*) + [ -n "${MODEM:-}" ] && sxmo_ussd.sh "$MODEM" "NetworkNotification" "" & + ;; + *"string \"NetworkRequest\""*) + [ -n "${MODEM:-}" ] && sxmo_ussd.sh "$MODEM" "NetworkRequest" "" & ;; esac - - if [ "$CHANGED" = "1" ]; then - # Handle unsolicited USSD in background without spawning a terminal window - sxmo_ussd.sh "$MODEM" "$TYPE" "" & - fi - done & if [ -f "${SXMO_MMS_BASE_DIR:-"$HOME"/.mms/modemmanager}/mms" ]; then diff --git a/overlay/rootfs/usr/bin/sxmo_wm.sh b/overlay/rootfs/usr/bin/sxmo_wm.sh index f05b96d..cd33183 100755 --- a/overlay/rootfs/usr/bin/sxmo_wm.sh +++ b/overlay/rootfs/usr/bin/sxmo_wm.sh @@ -11,566 +11,566 @@ export DISPLAY="${DISPLAY:-:0}" export SXMO_WM="${SXMO_WM:-dwm}" _dwm_prep() { - if [ -z "$DISPLAY" ]; then - export DISPLAY=:0 - fi - if [ -e /tmp/dwm_plugin_dmenu.active ] && [ -p /tmp/dwm_plugin_dmenu.fifo ]; then - printf "CLOSE\n" > /tmp/dwm_plugin_dmenu.fifo 2>/dev/null || true - sleep 0.04 - fi + if [ -z "$DISPLAY" ]; then + export DISPLAY=:0 + fi + if [ -e /tmp/dwm_plugin_dmenu.active ] && [ -p /tmp/dwm_plugin_dmenu.fifo ]; then + printf "CLOSE\n" > /tmp/dwm_plugin_dmenu.fifo 2>/dev/null || true + sleep 0.04 + fi } swi3msg() { - case "$SXMO_WM" in - sway) swaymsg "$@" ;; - i3) i3-msg "$@" ;; - esac + case "$SXMO_WM" in + sway) swaymsg "$@" ;; + i3) i3-msg "$@" ;; + esac } # Output Power Management {{{ xorgdisplay() { - case "$1" in - off) - if [ -r /sys/class/backlight/backlight/brightness ]; then - _cur_bl=0 - read -r _cur_bl < /sys/class/backlight/backlight/brightness 2>/dev/null || true - if [ "${_cur_bl:-0}" -ge 1 ] 2>/dev/null; then - printf '%s\n' "$_cur_bl" > /tmp/sxmo_saved_brightness 2>/dev/null || true - mkdir -p "${XDG_CONFIG_HOME:-$HOME/.config}/sxmo" 2>/dev/null || true - printf '%s\n' "$_cur_bl" > "${XDG_CONFIG_HOME:-$HOME/.config}/sxmo/brightness" 2>/dev/null || true - fi - fi - if [ -w /sys/class/leds/white:kbd_backlight/brightness ]; then - printf '0\n' > /sys/class/leds/white:kbd_backlight/brightness 2>/dev/null || true - fi - if [ -w /sys/class/backlight/backlight/brightness ]; then - printf '0\n' > /sys/class/backlight/backlight/brightness 2>/dev/null || true - fi - xset s off s noblank >/dev/null 2>&1 || true - ;; - on) - xset s off s noblank >/dev/null 2>&1 || true - if [ -w /sys/class/backlight/backlight/bl_power ]; then - printf '0\n' > /sys/class/backlight/backlight/bl_power 2>/dev/null || true - fi - if [ -w /sys/class/backlight/backlight/brightness ]; then - _restore_bl="" - if [ -r /tmp/sxmo_saved_brightness ]; then - read -r _restore_bl < /tmp/sxmo_saved_brightness 2>/dev/null || true - fi - if [ -z "$_restore_bl" ] || [ "${_restore_bl:-0}" -lt 1 ] 2>/dev/null; then - if [ -r "${XDG_CONFIG_HOME:-$HOME/.config}/sxmo/brightness" ]; then - read -r _restore_bl < "${XDG_CONFIG_HOME:-$HOME/.config}/sxmo/brightness" 2>/dev/null || true - fi - fi - if [ -z "$_restore_bl" ] || [ "${_restore_bl:-0}" -lt 1 ] 2>/dev/null; then - _restore_bl=14 - read -r _restore_bl < /sys/class/backlight/backlight/max_brightness 2>/dev/null || true - fi - printf '%s\n' "${_restore_bl:-14}" > /tmp/sxmo_saved_brightness 2>/dev/null || true - printf '%s\n' "${_restore_bl:-14}" > /sys/class/backlight/backlight/brightness 2>/dev/null || true - fi - if [ -w /sys/class/leds/white:kbd_backlight/brightness ]; then - _restore_kbd="255" - if [ -r /tmp/sxmo_saved_kbd_brightness ]; then - read -r _restore_kbd < /tmp/sxmo_saved_kbd_brightness 2>/dev/null || true - elif [ -r "${XDG_CONFIG_HOME:-$HOME/.config}/sxmo/kbd_brightness" ]; then - read -r _restore_kbd < "${XDG_CONFIG_HOME:-$HOME/.config}/sxmo/kbd_brightness" 2>/dev/null || true - fi - printf '%s\n' "${_restore_kbd:-255}" > /sys/class/leds/white:kbd_backlight/brightness 2>/dev/null || true - fi - ;; - "") - _cur_bl=14 - if [ -r /sys/class/backlight/backlight/brightness ]; then - read -r _cur_bl < /sys/class/backlight/backlight/brightness 2>/dev/null || _cur_bl=14 - fi - if [ "${_cur_bl:-0}" -le 0 ] 2>/dev/null; then - printf "off\n" - else - printf "on\n" - fi - ;; - *) - printf 'sxmo_wm.sh display: unknown command "%s"\n' "$1" >&2 - printf 'Usage: sxmo_wm.sh display [on|off]\n' >&2 - ;; - esac + case "$1" in + off) + if [ -r /sys/class/backlight/backlight/brightness ]; then + _cur_bl=0 + read -r _cur_bl < /sys/class/backlight/backlight/brightness 2>/dev/null || true + if [ "${_cur_bl:-0}" -ge 1 ] 2>/dev/null; then + printf '%s\n' "$_cur_bl" > /tmp/sxmo_saved_brightness 2>/dev/null || true + mkdir -p "${XDG_CONFIG_HOME:-$HOME/.config}/sxmo" 2>/dev/null || true + printf '%s\n' "$_cur_bl" > "${XDG_CONFIG_HOME:-$HOME/.config}/sxmo/brightness" 2>/dev/null || true + fi + fi + if [ -w /sys/class/leds/white:kbd_backlight/brightness ]; then + printf '0\n' > /sys/class/leds/white:kbd_backlight/brightness 2>/dev/null || true + fi + if [ -w /sys/class/backlight/backlight/brightness ]; then + printf '0\n' > /sys/class/backlight/backlight/brightness 2>/dev/null || true + fi + xset s off s noblank >/dev/null 2>&1 || true + ;; + on) + xset s off s noblank >/dev/null 2>&1 || true + if [ -w /sys/class/backlight/backlight/bl_power ]; then + printf '0\n' > /sys/class/backlight/backlight/bl_power 2>/dev/null || true + fi + if [ -w /sys/class/backlight/backlight/brightness ]; then + _restore_bl="" + if [ -r /tmp/sxmo_saved_brightness ]; then + read -r _restore_bl < /tmp/sxmo_saved_brightness 2>/dev/null || true + fi + if [ -z "$_restore_bl" ] || [ "${_restore_bl:-0}" -lt 1 ] 2>/dev/null; then + if [ -r "${XDG_CONFIG_HOME:-$HOME/.config}/sxmo/brightness" ]; then + read -r _restore_bl < "${XDG_CONFIG_HOME:-$HOME/.config}/sxmo/brightness" 2>/dev/null || true + fi + fi + if [ -z "$_restore_bl" ] || [ "${_restore_bl:-0}" -lt 1 ] 2>/dev/null; then + _restore_bl=14 + read -r _restore_bl < /sys/class/backlight/backlight/max_brightness 2>/dev/null || true + fi + printf '%s\n' "${_restore_bl:-14}" > /tmp/sxmo_saved_brightness 2>/dev/null || true + printf '%s\n' "${_restore_bl:-14}" > /sys/class/backlight/backlight/brightness 2>/dev/null || true + fi + if [ -w /sys/class/leds/white:kbd_backlight/brightness ]; then + _restore_kbd="255" + if [ -r /tmp/sxmo_saved_kbd_brightness ]; then + read -r _restore_kbd < /tmp/sxmo_saved_kbd_brightness 2>/dev/null || true + elif [ -r "${XDG_CONFIG_HOME:-$HOME/.config}/sxmo/kbd_brightness" ]; then + read -r _restore_kbd < "${XDG_CONFIG_HOME:-$HOME/.config}/sxmo/kbd_brightness" 2>/dev/null || true + fi + printf '%s\n' "${_restore_kbd:-255}" > /sys/class/leds/white:kbd_backlight/brightness 2>/dev/null || true + fi + ;; + "") + _cur_bl=14 + if [ -r /sys/class/backlight/backlight/brightness ]; then + read -r _cur_bl < /sys/class/backlight/backlight/brightness 2>/dev/null || _cur_bl=14 + fi + if [ "${_cur_bl:-0}" -le 0 ] 2>/dev/null; then + printf "off\n" + else + printf "on\n" + fi + ;; + *) + printf 'sxmo_wm.sh display: unknown command "%s"\n' "$1" >&2 + printf 'Usage: sxmo_wm.sh display [on|off]\n' >&2 + ;; + esac } wldisplay() { - case "$1" in - on) wlopm --on "*" ;; - off) wlopm --off "*";; - "") - if wlopm | grep -q "on"; then - printf "on\n" - else - printf "off\n" - fi - ;; - *) - printf 'sxmo_wm.sh display: unknown command "%s"\n' "$1" >&2 - printf 'Usage: sxmo_wm.sh display [on|off]\n' >&2 - ;; - esac + case "$1" in + on) wlopm --on "*" ;; + off) wlopm --off "*";; + "") + if wlopm | grep -q "on"; then + printf "on\n" + else + printf "off\n" + fi + ;; + *) + printf 'sxmo_wm.sh display: unknown command "%s"\n' "$1" >&2 + printf 'Usage: sxmo_wm.sh display [on|off]\n' >&2 + ;; + esac } wm_generic_dpms() { - sxmo_log "WARNING: $0: the dpms subcommand is deprecated, use display instead" + sxmo_log "WARNING: $0: the dpms subcommand is deprecated, use display instead" - # The dpms command was origionally implemented with on/off being the - # opposite of what they should have been. Swap them for backwards - # compatability. - case "$1" in - on) - shift - set -- "off" "$@" - ;; - off) - shift - set -- "on" "$@" - ;; - esac + # The dpms command was origionally implemented with on/off being the + # opposite of what they should have been. Swap them for backwards + # compatability. + case "$1" in + on) + shift + set -- "off" "$@" + ;; + off) + shift + set -- "on" "$@" + ;; + esac - dispatch display "$@" + dispatch display "$@" } # }}} # inputevent {{{ xorginputevent() { - if [ "$1" = "touchscreen" ]; then - TOUCH_POINTER_ID="$SXMO_TOUCHSCREEN_ID" - elif [ "$1" = "stylus" ]; then - TOUCH_POINTER_ID="$SXMO_STYLUS_ID" - fi + if [ "$1" = "touchscreen" ]; then + TOUCH_POINTER_ID="$SXMO_TOUCHSCREEN_ID" + elif [ "$1" = "stylus" ]; then + TOUCH_POINTER_ID="$SXMO_STYLUS_ID" + fi - if [ -z "$TOUCH_POINTER_ID" ]; then - echo "not found" - return 0 - fi + if [ -z "$TOUCH_POINTER_ID" ]; then + echo "not found" + return 0 + fi - STATE=off - if xinput list-props "$TOUCH_POINTER_ID" | \ - grep "Device Enabled" | \ - grep -q "1$"; then - STATE=on - fi + STATE=off + if xinput list-props "$TOUCH_POINTER_ID" | \ + grep "Device Enabled" | \ + grep -q "1$"; then + STATE=on + fi - if [ -z "$2" ]; then - printf %s "$STATE" - elif [ "$2" = on ] && [ "$STATE" != on ]; then - xinput enable "$TOUCH_POINTER_ID" - elif [ "$2" = off ] && [ "$STATE" != off ] ; then - xinput disable "$TOUCH_POINTER_ID" - fi + if [ -z "$2" ]; then + printf %s "$STATE" + elif [ "$2" = on ] && [ "$STATE" != on ]; then + xinput enable "$TOUCH_POINTER_ID" + elif [ "$2" = off ] && [ "$STATE" != off ] ; then + xinput disable "$TOUCH_POINTER_ID" + fi } swayinputevent() { - if [ "$1" = "touchscreen" ]; then - TOUCH_POINTER_ID="touch" - elif [ "$1" = "stylus" ]; then - TOUCH_POINTER_ID="tablet_tool" - fi + if [ "$1" = "touchscreen" ]; then + TOUCH_POINTER_ID="touch" + elif [ "$1" = "stylus" ]; then + TOUCH_POINTER_ID="tablet_tool" + fi - # If we dont have any matching input - if ! swaymsg -t get_inputs \ - | jq -r ".[] | select(.type == \"$TOUCH_POINTER_ID\" )" \ - | grep -q .; then + # If we dont have any matching input + if ! swaymsg -t get_inputs \ + | jq -r ".[] | select(.type == \"$TOUCH_POINTER_ID\" )" \ + | grep -q .; then - if [ -z "$2" ]; then - printf "not found" - exit 0 - else - exit 0 - fi - fi + if [ -z "$2" ]; then + printf "not found" + exit 0 + else + exit 0 + fi + fi - STATE=on - if swaymsg -t get_inputs \ - | jq -r ".[] | select(.type == \"$TOUCH_POINTER_ID\" ) | .libinput.send_events" \ - | grep -q "disabled"; then - STATE=off - fi + STATE=on + if swaymsg -t get_inputs \ + | jq -r ".[] | select(.type == \"$TOUCH_POINTER_ID\" ) | .libinput.send_events" \ + | grep -q "disabled"; then + STATE=off + fi - if [ -z "$2" ]; then - printf %s "$STATE" - elif [ "$2" = on ] && [ "$STATE" != on ]; then - swaymsg "input type:$TOUCH_POINTER_ID events enabled" > /dev/null - elif [ "$2" = off ] && [ "$STATE" != off ] ; then - swaymsg "input type:$TOUCH_POINTER_ID events disabled" > /dev/null - fi + if [ -z "$2" ]; then + printf %s "$STATE" + elif [ "$2" = on ] && [ "$STATE" != on ]; then + swaymsg "input type:$TOUCH_POINTER_ID events enabled" > /dev/null + elif [ "$2" = off ] && [ "$STATE" != off ] ; then + swaymsg "input type:$TOUCH_POINTER_ID events disabled" > /dev/null + fi } # }}} # focusedwindow {{{ _xorgfocusedwindow() { - xprop -id "$(xdotool getactivewindow 2>/dev/null)" 2>/dev/null | awk ' - /^WM_CLASS/ { - sub(/^WM_CLASS[^=]*= ?"[^"]*", "/, "") - sub(/"$/, "") - class = $0 - } - /^WM_NAME/ { - sub(/^WM_NAME[^=]*= ?"/, "") - sub(/"$/, "") - title = $0 - } - END { printf "%s\n%s\n", tolower(class), tolower(title) } - ' + xprop -id "$(xdotool getactivewindow 2>/dev/null)" 2>/dev/null | awk ' + /^WM_CLASS/ { + sub(/^WM_CLASS[^=]*= ?"[^"]*", "/, "") + sub(/"$/, "") + class = $0 + } + /^WM_NAME/ { + sub(/^WM_NAME[^=]*= ?"/, "") + sub(/"$/, "") + title = $0 + } + END { printf "%s\n%s\n", tolower(class), tolower(title) } + ' } _swi3_focusedwindow() { - swi3msg -t get_tree | jq -r ' - recurse(.nodes[]) | - select(.focused == true) | - { - app_id: ((if .app_id != null then - .app_id - else - .window_properties.class - end) // "" | tostring | gsub("\n"; "\\n") | ascii_downcase), - name: ((.name // "") | tostring | gsub("\n"; "\\n") | ascii_downcase), - } | - select(.app_id != "" or .name != "") | - "\(.app_id)\n\(.name)" - ' + swi3msg -t get_tree | jq -r ' + recurse(.nodes[]) | + select(.focused == true) | + { + app_id: ((if .app_id != null then + .app_id + else + .window_properties.class + end) // "" | tostring | gsub("\n"; "\\n") | ascii_downcase), + name: ((.name // "") | tostring | gsub("\n"; "\\n") | ascii_downcase), + } | + select(.app_id != "" or .name != "") | + "\(.app_id)\n\(.name)" + ' } _raw_focusedwindow() { - case "$SXMO_WM" in - dwm) _xorgfocusedwindow ;; - sway|i3) _swi3_focusedwindow ;; - river) lswt -j | jq -r ' - .toplevels | - map(select(.activated))[0] | - (."app-id" | ascii_downcase), (.title | ascii_downcase) - ' - esac + case "$SXMO_WM" in + dwm) _xorgfocusedwindow ;; + sway|i3) _swi3_focusedwindow ;; + river) lswt -j | jq -r ' + .toplevels | + map(select(.activated))[0] | + (."app-id" | ascii_downcase), (.title | ascii_downcase) + ' + esac } wm_generic_focusedwindow() { - if [ "$1" = "-r" ]; then - _raw_focusedwindow - else - # This script originally output this format, which is a bit - # harder to parse. Keep it for backwards compatibility in case - # anyone was using it. - _raw_focusedwindow | { - read -r app - read -r title - printf "app: %s\ntitle: %s\n" "$app" "$title" - } - fi + if [ "$1" = "-r" ]; then + _raw_focusedwindow + else + # This script originally output this format, which is a bit + # harder to parse. Keep it for backwards compatibility in case + # anyone was using it. + _raw_focusedwindow | { + read -r app + read -r title + printf "app: %s\ntitle: %s\n" "$app" "$title" + } + fi } # }}} # paste {{{ wlpaste() { - wl-paste + wl-paste } xorgpaste() { - xclip -o + xclip -o } # }}} # exec {{{ wm_generic__swi3exec_inner() { - cmd="$(cat "$1")" - rm "$1" - eval "$cmd" + cmd="$(cat "$1")" + rm "$1" + eval "$cmd" } swi3exec() { - set -e + set -e - cmdfile="$(mktemp)" - jq -r --null-input '$ARGS.positional | @sh' --args -- "$@" > "$cmdfile" + cmdfile="$(mktemp)" + jq -r --null-input '$ARGS.positional | @sh' --args -- "$@" > "$cmdfile" - swi3msg exec "sxmo_wm.sh _swi3exec_inner '$cmdfile'" > /dev/null + swi3msg exec "sxmo_wm.sh _swi3exec_inner '$cmdfile'" > /dev/null } riverexec() { - riverctl spawn "$@" + riverctl spawn "$@" } xorgexec() { - if [ -z "$DISPLAY" ]; then - export DISPLAY=:0 - fi - "$@" & + if [ -z "$DISPLAY" ]; then + export DISPLAY=:0 + fi + "$@" & } # }}} # execwait {{{ wm_generic__execwait_inner() { - notify_file="$1/done" - shift + notify_file="$1/done" + shift - # This opens the pipe for writing, when this process exits it will be - # closed, which will send eof to the monitoring process. - exec 3>"$notify_file" + # This opens the pipe for writing, when this process exits it will be + # closed, which will send eof to the monitoring process. + exec 3>"$notify_file" - "$@" + "$@" } _execwait() { - set -e - runner="$1" - shift + set -e + runner="$1" + shift - notify_dir="$(mktemp -d)" - mkfifo "$notify_dir/done" + notify_dir="$(mktemp -d)" + mkfifo "$notify_dir/done" - "$runner" sxmo_wm.sh _execwait_inner "$notify_dir" "$@" + "$runner" sxmo_wm.sh _execwait_inner "$notify_dir" "$@" - exec 3<"$notify_dir/done" + exec 3<"$notify_dir/done" - # The exec line won't finish until the inner file has been opened for - # writing, so it's safe to remove the temp dir here. - rm -r "$notify_dir" + # The exec line won't finish until the inner file has been opened for + # writing, so it's safe to remove the temp dir here. + rm -r "$notify_dir" - # Wait for the notification file to be closed - read -r _ <&3 || true + # Wait for the notification file to be closed + read -r _ <&3 || true } swi3execwait() { - _execwait swi3exec "$@" + _execwait swi3exec "$@" } riverexecwait() { - _execwait riverexec "$@" + _execwait riverexec "$@" } xorgexecwait() { - if [ -z "$DISPLAY" ]; then - export DISPLAY=:0 - fi - exec "$@" + if [ -z "$DISPLAY" ]; then + export DISPLAY=:0 + fi + exec "$@" } # }}} # toggle layout {{{ swi3togglelayout() { - swi3msg "layout toggle splitv splith tabbed" > /dev/null + swi3msg "layout toggle splitv splith tabbed" > /dev/null } dwmtogglelayout() { - _dwm_prep - xdotool key --clearmodifiers Super+space + _dwm_prep + xdotool key --clearmodifiers Super+space } rivertogglelayout() { - riverctl toggle-fullscreen + riverctl toggle-fullscreen } # }}} # switch focus {{{ i3switchfocus() { - sxmo_wmmenu.sh i3windowswitcher + sxmo_wmmenu.sh i3windowswitcher } swayswitchfocus() { - sxmo_wmmenu.sh swaywindowswitcher + sxmo_wmmenu.sh swaywindowswitcher } dwmswitchfocus() { - _dwm_prep - xdotool key --clearmodifiers Super+x + _dwm_prep + xdotool key --clearmodifiers Super+x } # }}} # workspace switching {{{ _swi3getcurrentworkspace() { - swi3msg -t get_workspaces | jq -r '.[] | select(.focused).name' + swi3msg -t get_workspaces | jq -r '.[] | select(.focused).name' } _swi3getnextworkspace() { - value="$(($(_swi3getcurrentworkspace)+1))" - if [ "$value" -eq "$((${SXMO_WORKSPACE_WRAPPING:-4}+1))" ]; then - printf 1 - else - printf %s "$value" - fi + value="$(($(_swi3getcurrentworkspace)+1))" + if [ "$value" -eq "$((${SXMO_WORKSPACE_WRAPPING:-4}+1))" ]; then + printf 1 + else + printf %s "$value" + fi } _swi3getpreviousworkspace() { - value="$(($(_swi3getcurrentworkspace)-1))" - if [ "$value" -lt 1 ]; then - if [ "${SXMO_WORKSPACE_WRAPPING:-4}" -ne 0 ]; then - printf %s "${SXMO_WORKSPACE_WRAPPING:-4}" - else - return 1 # cant have previous workspace - fi - else - printf %s "$value" - fi + value="$(($(_swi3getcurrentworkspace)-1))" + if [ "$value" -lt 1 ]; then + if [ "${SXMO_WORKSPACE_WRAPPING:-4}" -ne 0 ]; then + printf %s "${SXMO_WORKSPACE_WRAPPING:-4}" + else + return 1 # cant have previous workspace + fi + else + printf %s "$value" + fi } swi3nextworkspace() { - swi3msg "workspace $(_swi3getnextworkspace)" > /dev/null + swi3msg "workspace $(_swi3getnextworkspace)" > /dev/null } rivernextworkspace() { - river-shifttags + river-shifttags } dwmnextworkspace() { - _dwm_prep - xdotool key --clearmodifiers Super+Shift+r + _dwm_prep + xdotool key --clearmodifiers Super+Shift+r } swi3previousworkspace() { - swi3msg "workspace $(_swi3getpreviousworkspace )" > /dev/null + swi3msg "workspace $(_swi3getpreviousworkspace )" > /dev/null } dwmpreviousworkspace() { - _dwm_prep - xdotool key --clearmodifiers Super+Shift+e + _dwm_prep + xdotool key --clearmodifiers Super+Shift+e } riverpreviousworkspace() { - river-shifttags --shift -1 + river-shifttags --shift -1 } swi3movenextworkspace() { - swi3msg "move container to workspace $(_swi3getnextworkspace)" > /dev/null + swi3msg "move container to workspace $(_swi3getnextworkspace)" > /dev/null } dwmmovenextworkspace() { - _dwm_prep - xdotool key --clearmodifiers Super+r + _dwm_prep + xdotool key --clearmodifiers Super+r } swi3movepreviousworkspace() { - swi3msg "move container to workspace $(_swi3getpreviousworkspace )" > /dev/null + swi3msg "move container to workspace $(_swi3getpreviousworkspace )" > /dev/null } dwmmovepreviousworkspace() { - _dwm_prep - xdotool key --clearmodifiers Super+e + _dwm_prep + xdotool key --clearmodifiers Super+e } swi3workspace() { - swi3msg "workspace $1" > /dev/null + swi3msg "workspace $1" > /dev/null } riverworkspace() { - tags=$((1 << ($1 - 1))) - riverctl set-focused-tags "$tags" + tags=$((1 << ($1 - 1))) + riverctl set-focused-tags "$tags" } dwmworkspace() { - _dwm_prep - xdotool key --clearmodifiers "Super+$1" + _dwm_prep + xdotool key --clearmodifiers "Super+$1" } swi3moveworkspace() { - swi3msg "move container to workspace $1" > /dev/null + swi3msg "move container to workspace $1" > /dev/null } rivermoveworkspace() { - tags=$((1 << ($1 - 1))) - riverctl set-view-tags "$tags" + tags=$((1 << ($1 - 1))) + riverctl set-view-tags "$tags" } dwmmoveworkspace() { - _dwm_prep - xdotool key --clearmodifiers "Super+shift+$1" + _dwm_prep + xdotool key --clearmodifiers "Super+shift+$1" } # }}} # toggle bar {{{ swi3togglebar() { - swi3msg "bar mode toggle" > /dev/null + swi3msg "bar mode toggle" > /dev/null } dwmtogglebar() { - if [ -z "$DISPLAY" ]; then - export DISPLAY=:0 - fi - xdotool key --clearmodifiers "Super+b" + if [ -z "$DISPLAY" ]; then + export DISPLAY=:0 + fi + xdotool key --clearmodifiers "Super+b" } rivertogglebar() { - if superctl status sxmo_riverbar | grep -q started; then - superctl stop sxmo_riverbar - else - superctl start sxmo_riverbar - fi + if superctl status sxmo_riverbar | grep -q started; then + superctl stop sxmo_riverbar + else + superctl start sxmo_riverbar + fi } # }}} # configmenuentry {{{ wm_generic_configmenuentry() { - # shellcheck source=configs/default_hooks/sxmo_hook_icons.sh - . sxmo_hook_icons.sh - case "$SXMO_WM" in - dwm) - printf "%s\n" "$icon_cfg Edit configuration ^ 0 ^ sxmo_terminal.sh $EDITOR $XDG_CONFIG_HOME/sxmo/xinit" - ;; - i3) - printf "%s\n" "$icon_cfg Edit configuration ^ 0 ^ sxmo_terminal.sh $EDITOR $XDG_CONFIG_HOME/sxmo/i3" - ;; - river) - printf "%s\n" "$icon_cfg Edit configuration ^ 0 ^ sxmo_terminal.sh $EDITOR $XDG_CONFIG_HOME/sxmo/river" - ;; - sway) - printf "%s\n" "$icon_cfg Edit configuration ^ 0 ^ sxmo_terminal.sh $EDITOR $XDG_CONFIG_HOME/sxmo/sway" - ;; - esac + # shellcheck source=configs/default_hooks/sxmo_hook_icons.sh + . sxmo_hook_icons.sh + case "$SXMO_WM" in + dwm) + printf "%s\n" "$icon_cfg Edit configuration ^ 0 ^ sxmo_terminal.sh $EDITOR $XDG_CONFIG_HOME/sxmo/xinit" + ;; + i3) + printf "%s\n" "$icon_cfg Edit configuration ^ 0 ^ sxmo_terminal.sh $EDITOR $XDG_CONFIG_HOME/sxmo/i3" + ;; + river) + printf "%s\n" "$icon_cfg Edit configuration ^ 0 ^ sxmo_terminal.sh $EDITOR $XDG_CONFIG_HOME/sxmo/river" + ;; + sway) + printf "%s\n" "$icon_cfg Edit configuration ^ 0 ^ sxmo_terminal.sh $EDITOR $XDG_CONFIG_HOME/sxmo/sway" + ;; + esac } # }}} dispatch() { - if [ "$#" -lt 1 ]; then - echo "Usage: sxmo_wm.sh " >&2 - return 1 - fi + if [ "$#" -lt 1 ]; then + echo "Usage: sxmo_wm.sh " >&2 + return 1 + fi - action="$1" - shift + action="$1" + shift - # invoke action covering single wm - if type "$SXMO_WM$action" >/dev/null 2>&1; then - "$SXMO_WM$action" "$@" - return - fi + # invoke action covering single wm + if type "$SXMO_WM$action" >/dev/null 2>&1; then + "$SXMO_WM$action" "$@" + return + fi - # invoke action covering multiple wms - if [ "$SXMO_WM" = "sway" ] || [ "$SXMO_WM" = "i3" ]; then - if type "swi3$action" >/dev/null 2>&1; then - "swi3$action" "$@" - return - fi - fi + # invoke action covering multiple wms + if [ "$SXMO_WM" = "sway" ] || [ "$SXMO_WM" = "i3" ]; then + if type "swi3$action" >/dev/null 2>&1; then + "swi3$action" "$@" + return + fi + fi - # invoke action covering all of xorg/wayland - case "$SXMO_WM" in - dwm|i3) - if type "xorg$action" >/dev/null 2>&1; then - "xorg$action" "$@" - return - fi - ;; - sway|river) - # We don't yet support everything - if type "wl$action" >/dev/null 2>&1; then - "wl$action" "$@" - return - fi - ;; - esac + # invoke action covering all of xorg/wayland + case "$SXMO_WM" in + dwm|i3) + if type "xorg$action" >/dev/null 2>&1; then + "xorg$action" "$@" + return + fi + ;; + sway|river) + # We don't yet support everything + if type "wl$action" >/dev/null 2>&1; then + "wl$action" "$@" + return + fi + ;; + esac - # invoke action covering all wms - if type "wm_generic_$action" >/dev/null 2>&1; then - "wm_generic_$action" "$@" - return - else - printf "%s not implemented for %s\n" "$action" "$SXMO_WM" >&2 - return 1 - fi + # invoke action covering all wms + if type "wm_generic_$action" >/dev/null 2>&1; then + "wm_generic_$action" "$@" + return + else + printf "%s not implemented for %s\n" "$action" "$SXMO_WM" >&2 + return 1 + fi } dispatch "$@" 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 a6a82ae..1f84a2f 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 @@ -18,543 +18,556 @@ # right and "variable" icons (that come and go) on the left. restart_conky() { - lockdir="/tmp/sxmo_conky_restart.lock" - if ! mkdir "$lockdir" 2>/dev/null; then - return 0 - fi - superctl stop sxmo_conky >/dev/null 2>&1 || true - pkill -x conky >/dev/null 2>&1 || true - sleep 0.05 - pkill -9 -x conky >/dev/null 2>&1 || true - DISPLAY="${DISPLAY:-:0}" CONKY_DPY="${DISPLAY:-:0}" \ - conky -c "${XDG_CONFIG_HOME:-/home/user/.config}/sxmo/conky.conf" -d >/dev/null 2>&1 /dev/null || true + lockdir="/tmp/sxmo_conky_restart.lock" + if ! mkdir "$lockdir" 2>/dev/null; then + return 0 + fi + superctl stop sxmo_conky >/dev/null 2>&1 || true + pkill -x conky >/dev/null 2>&1 || true + sleep 0.05 + pkill -9 -x conky >/dev/null 2>&1 || true + DISPLAY="${DISPLAY:-:0}" CONKY_DPY="${DISPLAY:-:0}" \ + conky -c "${XDG_CONFIG_HOME:-/home/user/.config}/sxmo/conky.conf" -d >/dev/null 2>&1 /dev/null || true } set_time() { - sxmobar -a time 99 " $(date "+${SXMO_STATUS_DATE_FORMAT:-%H:%M}")" - force_conky="${1:-0}" - state_file="/tmp/sxmo_conky_time_state" - cur_btime="$(awk '/^btime / {print $2}' /proc/stat 2>/dev/null || echo 0)" - cur_tz="$(readlink /etc/localtime 2>/dev/null || cat /etc/timezone 2>/dev/null || echo "")|$(date '+%Z%z')" - do_restart="$force_conky" - if ! pidof -s conky >/dev/null 2>&1; then - do_restart=1 - elif [ -r "$state_file" ]; then - old_btime="" - old_tz="" - { - IFS= read -r old_btime || true - IFS= read -r old_tz || true - } < "$state_file" - if [ "$cur_tz" != "$old_tz" ]; then - do_restart=1 - else - case "$cur_btime:$old_btime" in - *[!0-9:]*) do_restart=1 ;; - *) - diff=$((cur_btime - old_btime)) - [ "$diff" -lt 0 ] && diff=$((-diff)) - [ "$diff" -ge 2 ] && do_restart=1 - ;; - esac - fi - fi - printf "%s\n%s\n" "$cur_btime" "$cur_tz" > "$state_file" 2>/dev/null || true - if [ "$do_restart" = "1" ]; then - restart_conky - fi + sxmobar -a time 99 " $(date "+${SXMO_STATUS_DATE_FORMAT:-%H:%M}")" + force_conky="${1:-0}" + state_file="/tmp/sxmo_conky_time_state" + cur_btime="$(awk '/^btime / {print $2}' /proc/stat 2>/dev/null || echo 0)" + cur_tz="$(readlink /etc/localtime 2>/dev/null || cat /etc/timezone 2>/dev/null || echo "")|$(date '+%Z%z')" + do_restart="$force_conky" + if ! pidof -s conky >/dev/null 2>&1; then + do_restart=1 + elif [ -r "$state_file" ]; then + old_btime="" + old_tz="" + { + IFS= read -r old_btime || true + IFS= read -r old_tz || true + } < "$state_file" + if [ "$cur_tz" != "$old_tz" ]; then + do_restart=1 + else + case "$cur_btime:$old_btime" in + *[!0-9:]*) do_restart=1 ;; + *) + diff=$((cur_btime - old_btime)) + [ "$diff" -lt 0 ] && diff=$((-diff)) + [ "$diff" -ge 2 ] && do_restart=1 + ;; + esac + fi + fi + printf "%s\n%s\n" "$cur_btime" "$cur_tz" > "$state_file" 2>/dev/null || true + if [ "$do_restart" = "1" ]; then + restart_conky + fi } set_state() { - if [ ! -f "$SXMO_STATE" ]; then - return - fi + if [ ! -f "$SXMO_STATE" ]; then + return + fi - if sxmo_jobs.sh running proximity_lock -q; then - sxmobar -a -e bold -f orange state 90 "$icon_state_proximity" # circle with dot - return - fi + if sxmo_jobs.sh running proximity_lock -q; then + sxmobar -a -e bold -f orange state 90 "$icon_state_proximity" # circle with dot + return + fi - cur_state="" - read -r cur_state < "$SXMO_STATE" 2>/dev/null || true - case "$cur_state" in - screenoff) - sxmobar -a -e bold -f red state 90 "$icon_state_screenoff" # filled circle - ;; - lock) - sxmobar -a -e bold -f red state 90 "$icon_state_lock" # open circle with slash - ;; - unlock) - sxmobar -d state - ;; - esac + cur_state="" + read -r cur_state < "$SXMO_STATE" 2>/dev/null || true + case "$cur_state" in + screenoff) + sxmobar -a -e bold -f red state 90 "$icon_state_screenoff" # filled circle + ;; + lock) + sxmobar -a -e bold -f red state 90 "$icon_state_lock" # open circle with slash + ;; + unlock) + sxmobar -d state + ;; + esac } # from right to left: indicate signal, technologies, mm state set_modem() { - MMCLI="$(mmcli -m any -J 2>/dev/null)" + MMCLI="$(mmcli -m any -J 2>/dev/null)" - bgcolor=default - fgcolor=default - style=normal + bgcolor=default + fgcolor=default + style=normal - if [ -z "$MMCLI" ]; then - MODEMSTATE="nomodem" - else - MODEMSTATE="$(printf %s "$MMCLI" | jq -r .modem.generic.state)" - fi + if [ -z "$MMCLI" ]; then + MODEMSTATE="nomodem" + else + MODEMSTATE="$(printf %s "$MMCLI" | jq -r .modem.generic.state)" + fi - if [ "$MODEMSTATE" = "failed" ] || [ "$MODEMSTATE" = "nomodem" ]; then - uim_st="$(doas -n /usr/libexec/msm-modem-uim-selection status 2>/dev/null || /usr/libexec/msm-modem-uim-selection status 2>/dev/null || true)" - if printf "%s\n" "$uim_st" | grep -qE "SLOT[12]_PIN1_STATE=(enabled-not-verified|blocked)|SLOT[12]_APP_STATE=(pin1|puk1)"; then - MODEMSTATE="locked" - fi - fi + if [ "$MODEMSTATE" = "failed" ] || [ "$MODEMSTATE" = "nomodem" ]; then + uim_st="$(doas -n /usr/libexec/msm-modem-uim-selection status 2>/dev/null || /usr/libexec/msm-modem-uim-selection status 2>/dev/null || true)" + if printf "%s\n" "$uim_st" | grep -qE "SLOT[12]_PIN1_STATE=(enabled-not-verified|blocked)|SLOT[12]_APP_STATE=(pin1|puk1)"; then + MODEMSTATE="locked" + fi + fi - case "$MODEMSTATE" in - nomodem) - fgcolor=red - MODEMSTATECMP="$icon_modem_nomodem" - ;; - locked) - fgcolor=red - MODEMSTATECMP="$icon_modem_locked" - ;; - initializing) - fgcolor=red - MODEMSTATECMP="$icon_modem_initializing" - ;; - disabled) # low power state - fgcolor=red - MODEMSTATECMP="$icon_modem_disabled" - ;; - disabling) - fgcolor=red - MODEMSTATECMP="$icon_modem_disabling" - ;; - enabling) # modem enabled but neither registered (cell) nor connected (data) - fgcolor=red - MODEMSTATECMP="$icon_modem_enabling" - ;; - enabled) - fgcolor=red - MODEMSTATECMP="$icon_modem_enabled" - ;; - searching) # i.e. registering - fgcolor=red - MODEMSTATECMP="$icon_modem_searching" - ;; - registered) # i.e. phone but no data - fgcolor=orange - MODEMSTATECMP="$icon_modem_registered" - ;; - connecting) - fgcolor=orange - MODEMSTATECMP="$icon_modem_connecting" - ;; - disconnecting) # i.e., going back to registered state - fgcolor=orange - MODEMSTATECMP="$icon_modem_disconnecting" - ;; - connected) - MODEMSTATECMP="$icon_modem_connected" - ;; - *) - # FAILED, UNKNOWN - # see https://www.freedesktop.org/software/ModemManager/doc/latest/ModemManager/ModemManager-Flags-and-Enumerations.html#MMModemState - fgcolor=red - MODEMSTATECMP="$icon_modem_failed" # cell with ! - sxmo_log "WARNING: MODEMSTATE: $MODEMSTATE" - ;; - esac + case "$MODEMSTATE" in + nomodem) + fgcolor=red + MODEMSTATECMP="$icon_modem_nomodem" + ;; + locked) + fgcolor=red + MODEMSTATECMP="$icon_modem_locked" + ;; + initializing) + fgcolor=red + MODEMSTATECMP="$icon_modem_initializing" + ;; + disabled) # low power state + fgcolor=red + MODEMSTATECMP="$icon_modem_disabled" + ;; + disabling) + fgcolor=red + MODEMSTATECMP="$icon_modem_disabling" + ;; + enabling) # modem enabled but neither registered (cell) nor connected (data) + fgcolor=red + MODEMSTATECMP="$icon_modem_enabling" + ;; + enabled) + fgcolor=red + MODEMSTATECMP="$icon_modem_enabled" + ;; + searching) # i.e. registering + fgcolor=red + MODEMSTATECMP="$icon_modem_searching" + ;; + registered) # i.e. phone but no data + fgcolor=orange + MODEMSTATECMP="$icon_modem_registered" + ;; + connecting) + fgcolor=orange + MODEMSTATECMP="$icon_modem_connecting" + ;; + disconnecting) # i.e., going back to registered state + fgcolor=orange + MODEMSTATECMP="$icon_modem_disconnecting" + ;; + connected) + MODEMSTATECMP="$icon_modem_connected" + ;; + *) + # FAILED, UNKNOWN + # see https://www.freedesktop.org/software/ModemManager/doc/latest/ModemManager/ModemManager-Flags-and-Enumerations.html#MMModemState + fgcolor=red + MODEMSTATECMP="$icon_modem_failed" # cell with ! + sxmo_log "WARNING: MODEMSTATE: $MODEMSTATE" + ;; + esac - sxmobar -a -f "$fgcolor" -b "$bgcolor" -t "$style" \ - modem-state 10 "$MODEMSTATECMP" + sxmobar -a -f "$fgcolor" -b "$bgcolor" -t "$style" \ + modem-state 10 "$MODEMSTATECMP" - if [ "$MODEMSTATE" = nomodem ] || [ "$MODEMSTATE" = locked ] || [ "$MODEMSTATE" = failed ] || [ "$MODEMSTATE" = unknown ]; then - sxmobar -d modem-tech - sxmobar -d modem-signal - return - fi + if [ "$MODEMSTATE" = nomodem ] || [ "$MODEMSTATE" = locked ] || [ "$MODEMSTATE" = failed ] || [ "$MODEMSTATE" = unknown ]; then + sxmobar -d modem-tech + sxmobar -d modem-signal + return + fi - MODEMTECHCMP="$icon_modem_notech" - bgcolor=default - fgcolor=default - style=normal + MODEMTECHCMP="$icon_modem_notech" + bgcolor=default + fgcolor=default + style=normal - # see https://www.freedesktop.org/software/ModemManager/api/latest/ModemManager-Flags-and-Enumerations.html#MMModemAccessTechnology - USEDTECHS="$(printf %s "$MMCLI" | jq -r '.modem.generic."access-technologies"[]? // empty' 2>/dev/null)" - case "$USEDTECHS" in - *5gnr*) - MODEMTECHCMP="$icon_modem_fiveg" - ;; - *lte*) # lte, lte_nb_iot, lte_cat_m - MODEMTECHCMP="$icon_modem_fourg" - ;; - *umts*|*hsupa*|*hsdpa*|*1xrtt*|*evdo*) - MODEMTECHCMP="$icon_modem_threeg" - ;; - *hspa_plus*) - MODEMTECHCMP="$icon_modem_hspa_plus" # 3g - ;; - *hspa*) - MODEMTECHCMP="$icon_modem_hspa" # 3g - ;; - *edge*) - MODEMTECHCMP="E" # 2G+ - ;; - *pots*) - MODEMTECHCMP="P" # 0G - ;; - *gsm*) # gsm, gsm_compact - MODEMTECHCMP="$icon_modem_twog" - ;; - *gprs*) - MODEMTECHCMP="G" # 2G - ;; - *) - sxmo_log "WARNING: USEDTECHS: $USEDTECHS" - fgcolor=red - ;; - esac + # see https://www.freedesktop.org/software/ModemManager/api/latest/ModemManager-Flags-and-Enumerations.html#MMModemAccessTechnology + USEDTECHS="$(printf %s "$MMCLI" | jq -r '.modem.generic."access-technologies"[]? // empty' 2>/dev/null)" + case "$USEDTECHS" in + *5gnr*) + MODEMTECHCMP="$icon_modem_fiveg" + ;; + *lte*) # lte, lte_nb_iot, lte_cat_m + MODEMTECHCMP="$icon_modem_fourg" + ;; + *umts*|*hsupa*|*hsdpa*|*1xrtt*|*evdo*) + MODEMTECHCMP="$icon_modem_threeg" + ;; + *hspa_plus*) + MODEMTECHCMP="$icon_modem_hspa_plus" # 3g + ;; + *hspa*) + MODEMTECHCMP="$icon_modem_hspa" # 3g + ;; + *edge*) + MODEMTECHCMP="E" # 2G+ + ;; + *pots*) + MODEMTECHCMP="P" # 0G + ;; + *gsm*) # gsm, gsm_compact + MODEMTECHCMP="$icon_modem_twog" + ;; + *gprs*) + MODEMTECHCMP="G" # 2G + ;; + *) + sxmo_log "WARNING: USEDTECHS: $USEDTECHS" + fgcolor=red + ;; + esac - if [ "$MODEMSTATE" != failed ] && [ "$MODEMSTATE" != unknown ]; then - sxmobar -a -f "$fgcolor" -b "$bgcolor" -t "$style" \ - modem-tech 11 "$MODEMTECHCMP" - fi + if [ "$MODEMSTATE" != failed ] && [ "$MODEMSTATE" != unknown ]; then + sxmobar -a -f "$fgcolor" -b "$bgcolor" -t "$style" \ + modem-tech 11 "$MODEMTECHCMP" + fi - MODEMSIGNALCMP="$icon_modem_signal_0" - bgcolor=default - fgcolor=default - style=normal + MODEMSIGNALCMP="$icon_modem_signal_0" + bgcolor=default + fgcolor=default + style=normal - case "$MODEMSTATE" in - registered|connected|connecting|disconnecting) - MODEMSIGNAL="$(printf %s "$MMCLI" | jq -r '.modem.generic."signal-quality".value // 0' 2>/dev/null)" - case "$MODEMSIGNAL" in - ''|*[!0-9]*) MODEMSIGNAL=0 ;; - esac - if [ "$MODEMSIGNAL" -lt 33 ]; then - MODEMSIGNALCMP="$icon_modem_signal_1" - elif [ "$MODEMSIGNAL" -lt 66 ]; then - MODEMSIGNALCMP="$icon_modem_signal_2" - else - MODEMSIGNALCMP="$icon_modem_signal_3" - fi - ;; - esac + case "$MODEMSTATE" in + registered|connected|connecting|disconnecting) + MODEMSIGNAL="$(printf %s "$MMCLI" | jq -r '.modem.generic."signal-quality".value // 0' 2>/dev/null)" + case "$MODEMSIGNAL" in + ''|*[!0-9]*) MODEMSIGNAL=0 ;; + esac + if [ "$MODEMSIGNAL" -lt 33 ]; then + MODEMSIGNALCMP="$icon_modem_signal_1" + elif [ "$MODEMSIGNAL" -lt 66 ]; then + MODEMSIGNALCMP="$icon_modem_signal_2" + else + MODEMSIGNALCMP="$icon_modem_signal_3" + fi + ;; + esac - if [ "$MODEMSTATE" != failed ] && [ "$MODEMSTATE" != unknown ]; then - sxmobar -a -f "$fgcolor" -b "$bgcolor" -t "$style" \ - modem-signal 12 "$MODEMSIGNALCMP" - fi + if [ "$MODEMSTATE" != failed ] && [ "$MODEMSTATE" != unknown ]; then + sxmobar -a -f "$fgcolor" -b "$bgcolor" -t "$style" \ + modem-signal 12 "$MODEMSIGNALCMP" + fi } # $1 = type (wifi, tun) # $2 = interface name (wlan0, tun0) set_wifi() { - if /usr/sbin/rfkill list wifi 2>/dev/null | grep -q "yes"; then - sxmobar -d wifi-status - return - fi + if /usr/sbin/rfkill list wifi 2>/dev/null | grep -q "yes"; then + sxmobar -d wifi-status + return + fi - CONN="$(nmcli -t con show --active)" + CONN="$(nmcli -t con show --active)" - if ! printf %b "$CONN" | cut -d':' -f3 | grep -q wireless; then - sxmobar -a -f red wifi-status 30 "$icon_wifi_disconnected" - return - fi + if ! printf %b "$CONN" | cut -d':' -f3 | grep -q wireless; then + sxmobar -a -f red wifi-status 30 "$icon_wifi_disconnected" + return + fi - # we simply assume Hotspot as first bit of name - # for hotspot as this is what we create. - if printf %b "$CONN" | grep -q ^Hotspot; then - sxmobar -a wifi-status 30 "$icon_wfh" - return - fi + # we simply assume Hotspot as first bit of name + # for hotspot as this is what we create. + if printf %b "$CONN" | grep -q ^Hotspot; then + sxmobar -a wifi-status 30 "$icon_wfh" + return + fi - # if they have a vpn nmcli c shown --active should also list: - # tun0 ef5fcce9-fdae-4ffe-a540-b16fc7b42852 tun tun0 - if printf %b "$CONN" | cut -d':' -f3 | grep -q -E "^tun$|^wireguard$"; then - wifivpn=1 - else - wifivpn=0 - fi + # if they have a vpn nmcli c shown --active should also list: + # tun0 ef5fcce9-fdae-4ffe-a540-b16fc7b42852 tun tun0 + if printf %b "$CONN" | cut -d':' -f3 | grep -q -E "^tun$|^wireguard$"; then + wifivpn=1 + else + wifivpn=0 + fi - wifi_signal="$(nmcli -f IN-USE,SIGNAL,SSID device wifi list --rescan no 2>/dev/null | awk '/^\*/{if (NR!=1) {print $2}}')" - if [ -z "$wifi_signal" ]; then - icon_wif="$icon_wifi_signal_exclam" - elif [ "$wifi_signal" -lt 20 ]; then - if [ "$wifivpn" -eq 1 ]; then - icon_wif="$icon_wifi_key_signal_0" - else - icon_wif="$icon_wifi_signal_0" - fi - elif [ "$wifi_signal" -lt 40 ]; then - if [ "$wifivpn" -eq 1 ]; then - icon_wif="$icon_wifi_key_signal_1" - else - icon_wif="$icon_wifi_signal_1" - fi - elif [ "$wifi_signal" -lt 60 ]; then - if [ "$wifivpn" -eq 1 ]; then - icon_wif="$icon_wifi_key_signal_2" - else - icon_wif="$icon_wifi_signal_2" - fi - elif [ "$wifi_signal" -lt 80 ]; then - if [ "$wifivpn" -eq 1 ]; then - icon_wif="$icon_wifi_key_signal_3" - else - icon_wif="$icon_wifi_signal_3" - fi - else - if [ "$wifivpn" -eq 1 ]; then - icon_wif="$icon_wifi_key_signal_4" - else - icon_wif="$icon_wifi_signal_4" - fi - fi + wifi_signal="$(nmcli -f IN-USE,SIGNAL,SSID device wifi list --rescan no 2>/dev/null | awk '/^\*/{if (NR!=1) {print $2}}')" + if [ -z "$wifi_signal" ]; then + icon_wif="$icon_wifi_signal_exclam" + elif [ "$wifi_signal" -lt 20 ]; then + if [ "$wifivpn" -eq 1 ]; then + icon_wif="$icon_wifi_key_signal_0" + else + icon_wif="$icon_wifi_signal_0" + fi + elif [ "$wifi_signal" -lt 40 ]; then + if [ "$wifivpn" -eq 1 ]; then + icon_wif="$icon_wifi_key_signal_1" + else + icon_wif="$icon_wifi_signal_1" + fi + elif [ "$wifi_signal" -lt 60 ]; then + if [ "$wifivpn" -eq 1 ]; then + icon_wif="$icon_wifi_key_signal_2" + else + icon_wif="$icon_wifi_signal_2" + fi + elif [ "$wifi_signal" -lt 80 ]; then + if [ "$wifivpn" -eq 1 ]; then + icon_wif="$icon_wifi_key_signal_3" + else + icon_wif="$icon_wifi_signal_3" + fi + else + if [ "$wifivpn" -eq 1 ]; then + icon_wif="$icon_wifi_key_signal_4" + else + icon_wif="$icon_wifi_signal_4" + fi + fi - sxmobar -a wifi-status 30 "$icon_wif" + sxmobar -a wifi-status 30 "$icon_wif" } # $1 = type (wifi, tun) # $2 = interface name (wlan0, tun0) set_ethernet() { - conname="$(nmcli -t device show "$2" | grep ^GENERAL.CONNECTION | cut -d: -f2-)" - if [ "$conname" = "--" ]; then - # not used device - sxmobar -d ethernet-status-"$2" 30 - return - fi + conname="$(nmcli -t device show "$2" | grep ^GENERAL.CONNECTION | cut -d: -f2-)" + if [ "$conname" = "--" ]; then + # not used device + sxmobar -d ethernet-status-"$2" 30 + return + fi - if nmcli -t connection show "$conname" | grep ^ipv4.method | grep -q :shared; then - sxmobar -a ethernet-status-"$2" 30 "$icon_lnk" - else - sxmobar -d ethernet-status-"$2" 30 - fi + if nmcli -t connection show "$conname" | grep ^ipv4.method | grep -q :shared; then + sxmobar -a ethernet-status-"$2" 30 "$icon_lnk" + else + sxmobar -d ethernet-status-"$2" 30 + fi } # $1: type (reported by nmcli, e.g., wifi, tun) # $2: interface name (reported by nmcli, e.g., wlan0, tun0) set_network() { - case "$1" in - wifi|tun) set_wifi "$@" ;; - ethernet) set_ethernet "$@" ;; - esac + case "$1" in + wifi|tun) set_wifi "$@" ;; + ethernet) set_ethernet "$@" ;; + esac } set_battery() { - name="$1" - state="$2" - percentage="$3" + name="$1" + state="$2" + percentage="$3" - fgcolor=default - bgcolor=default - style=normal - BATCMP= + fgcolor=default + bgcolor=default + style=normal + BATCMP= - case "$state" in - fully-charged) - BATCMP="$icon_bat_c_full" - ;; - charging) - if [ "$percentage" -lt 10 ]; then - BATCMP="$icon_bat_c_0" - elif [ "$percentage" -lt 20 ]; then - BATCMP="$icon_bat_c_10" - elif [ "$percentage" -lt 30 ]; then - BATCMP="$icon_bat_c_20" - elif [ "$percentage" -lt 40 ]; then - BATCMP="$icon_bat_c_30" - elif [ "$percentage" -lt 50 ]; then - BATCMP="$icon_bat_c_40" - elif [ "$percentage" -lt 60 ]; then - BATCMP="$icon_bat_c_50" - elif [ "$percentage" -lt 70 ]; then - BATCMP="$icon_bat_c_60" - elif [ "$percentage" -lt 80 ]; then - BATCMP="$icon_bat_c_70" - elif [ "$percentage" -lt 90 ]; then - BATCMP="$icon_bat_c_80" - elif [ "$percentage" -lt 95 ]; then - BATCMP="$icon_bat_c_90" - else - # Treat 'Full' status as same as 'fully-charged' - fgcolor=green - BATCMP="$icon_bat_c_full" - fi - ;; - discharging) - if [ "$percentage" -lt 10 ]; then - fgcolor=red - BATCMP="$icon_bat_warning" - elif [ "$percentage" -lt 20 ]; then - fgcolor=red - BATCMP="$icon_bat_10" - elif [ "$percentage" -lt 30 ]; then - fgcolor=orange - BATCMP="$icon_bat_20" - elif [ "$percentage" -lt 40 ]; then - fgcolor=orange - BATCMP="$icon_bat_30" - elif [ "$percentage" -lt 50 ]; then - fgcolor=orange - BATCMP="$icon_bat_40" - elif [ "$percentage" -lt 60 ]; then - BATCMP="$icon_bat_50" - elif [ "$percentage" -lt 70 ]; then - BATCMP="$icon_bat_60" - elif [ "$percentage" -lt 80 ]; then - BATCMP="$icon_bat_70" - elif [ "$percentage" -lt 90 ]; then - BATCMP="$icon_bat_80" - elif [ "$percentage" -lt 95 ]; then - BATCMP="$icon_bat_90" - else - # Treat 'Full' status as same as 'fully-charged' - BATCMP="$icon_bat_full" - fi - ;; - esac + case "$state" in + fully-charged) + BATCMP="$icon_bat_c_full" + ;; + charging) + if [ "$percentage" -lt 10 ]; then + BATCMP="$icon_bat_c_0" + elif [ "$percentage" -lt 20 ]; then + BATCMP="$icon_bat_c_10" + elif [ "$percentage" -lt 30 ]; then + BATCMP="$icon_bat_c_20" + elif [ "$percentage" -lt 40 ]; then + BATCMP="$icon_bat_c_30" + elif [ "$percentage" -lt 50 ]; then + BATCMP="$icon_bat_c_40" + elif [ "$percentage" -lt 60 ]; then + BATCMP="$icon_bat_c_50" + elif [ "$percentage" -lt 70 ]; then + BATCMP="$icon_bat_c_60" + elif [ "$percentage" -lt 80 ]; then + BATCMP="$icon_bat_c_70" + elif [ "$percentage" -lt 90 ]; then + BATCMP="$icon_bat_c_80" + elif [ "$percentage" -lt 95 ]; then + BATCMP="$icon_bat_c_90" + else + # Treat 'Full' status as same as 'fully-charged' + fgcolor=green + BATCMP="$icon_bat_c_full" + fi + ;; + discharging) + if [ "$percentage" -lt 10 ]; then + fgcolor=red + BATCMP="$icon_bat_warning" + elif [ "$percentage" -lt 20 ]; then + fgcolor=red + BATCMP="$icon_bat_10" + elif [ "$percentage" -lt 30 ]; then + fgcolor=orange + BATCMP="$icon_bat_20" + elif [ "$percentage" -lt 40 ]; then + fgcolor=orange + BATCMP="$icon_bat_30" + elif [ "$percentage" -lt 50 ]; then + fgcolor=orange + BATCMP="$icon_bat_40" + elif [ "$percentage" -lt 60 ]; then + BATCMP="$icon_bat_50" + elif [ "$percentage" -lt 70 ]; then + BATCMP="$icon_bat_60" + elif [ "$percentage" -lt 80 ]; then + BATCMP="$icon_bat_70" + elif [ "$percentage" -lt 90 ]; then + BATCMP="$icon_bat_80" + elif [ "$percentage" -lt 95 ]; then + BATCMP="$icon_bat_90" + else + # Treat 'Full' status as same as 'fully-charged' + BATCMP="$icon_bat_full" + fi + ;; + esac - sxmobar -a -t "$style" -b "$bgcolor" -f "$fgcolor" \ - "battery-icon-$name" 40 "$BATCMP" + sxmobar -a -t "$style" -b "$bgcolor" -f "$fgcolor" \ + "battery-icon-$name" 40 "$BATCMP" - if [ -z "$SXMO_BAR_SHOW_BAT_PER" ]; then - sxmobar -d "battery-status-$name" - else - sxmobar -a "battery-status-$name" 41 "$percentage%" - fi + if [ -z "$SXMO_BAR_SHOW_BAT_PER" ]; then + sxmobar -d "battery-status-$name" + else + sxmobar -a "battery-status-$name" 41 "$percentage%" + fi } set_notifications() { - [ -z "$SXMO_DISABLE_LEDS" ] && return - NNOTIFICATIONS="$(find "$SXMO_NOTIFDIR" -type f | wc -l)" - if [ "$NNOTIFICATIONS" = 0 ]; then - sxmobar -d notifs - else - sxmobar -a -f red notifs 5 "!: $NNOTIFICATIONS" - fi + [ -z "$SXMO_DISABLE_LEDS" ] && return + NNOTIFICATIONS="$(find "$SXMO_NOTIFDIR" -type f | wc -l)" + if [ "$NNOTIFICATIONS" = 0 ]; then + sxmobar -d notifs + else + sxmobar -a -f red notifs 5 "!: $NNOTIFICATIONS" + fi } set_volume() { - VOLCMP="" + VOLCMP="" - if sxmo_audio.sh mic ismuted; then - VOLCMP="$icon_mmc" - else - case "$(sxmo_audio.sh device getinput 2>/dev/null)" in - *Headset*) - VOLCMP="$icon_hst" - ;; - esac - fi + if sxmo_audio.sh mic ismuted; then + VOLCMP="$icon_mmc" + else + case "$(sxmo_audio.sh device getinput 2>/dev/null)" in + *Headset*) + VOLCMP="$icon_hst" + ;; + esac + fi - if sxmo_audio.sh vol ismuted; 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 - if [ "$VOL" -gt 66 ]; then - VOLCMP="${VOLCMP:+$VOLCMP }$icon_spk" - elif [ "$VOL" -gt 33 ]; then - VOLCMP="${VOLCMP:+$VOLCMP }$icon_spm" - elif [ "$VOL" -ge 0 ]; then - VOLCMP="${VOLCMP:+$VOLCMP }$icon_spl" - fi - fi - sxmobar -a volume 50 "$VOLCMP" + if sxmo_audio.sh vol ismuted; 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 + if [ "$VOL" -gt 66 ]; then + VOLCMP="${VOLCMP:+$VOLCMP }$icon_spk" + elif [ "$VOL" -gt 33 ]; then + VOLCMP="${VOLCMP:+$VOLCMP }$icon_spm" + elif [ "$VOL" -ge 0 ]; then + VOLCMP="${VOLCMP:+$VOLCMP }$icon_spl" + fi + fi + sxmobar -a volume 50 "$VOLCMP" } set_notch() { - if [ -n "$SXMO_NOTCH" ] && ! pidof peanutbutter > /dev/null; then - sxmobar -a notch "${SXMO_NOTCH_PRIO:-29}" "$SXMO_NOTCH" - else - sxmobar -d notch - fi + if [ -n "$SXMO_NOTCH" ] && ! pidof peanutbutter > /dev/null; then + sxmobar -a notch "${SXMO_NOTCH_PRIO:-29}" "$SXMO_NOTCH" + else + sxmobar -d notch + fi } set_inputmethod() { - im_file="${XDG_RUNTIME_DIR:-/run/user/10000}/sxmo_t9_mode" - if [ -r "$im_file" ]; then - read -r im_mode < "$im_file" 2>/dev/null || im_mode="[abc]" - else - im_mode="[abc]" - fi - [ -n "$im_mode" ] || im_mode="[abc]" - sxmobar -a input-method 5 "$im_mode" + im_file="${XDG_RUNTIME_DIR:-/run/user/10000}/sxmo_t9_mode" + if [ -r "$im_file" ]; then + read -r im_mode < "$im_file" 2>/dev/null || im_mode="[abc]" + else + im_mode="[abc]" + fi + [ -n "$im_mode" ] || im_mode="[abc]" + sxmobar -a input-method 5 "$im_mode" } sxmo_debug "$@" case "$1" in - network) - shift - set_network "$@" - ;; - battery) - shift - set_battery "$@" - ;; - time) - set_time 1 - ;; - modem|volume|state|notifications|notch|inputmethod) - set_"$1" - ;; - state_change) - set_state - set_time - set_inputmethod - sxmo_hook_battery.sh 2>/dev/null || true - ;; - periodics) # 55 s loop - set_time - set_inputmethod - if [ -z "$SXMO_NO_MODEM" ]; then - set_modem - fi - set_notch - set_state - set_network wifi wlan0 - sxmo_hook_battery.sh 2>/dev/null || true - ;; - all) - sxmobar -r - set_inputmethod - set_time - if [ -z "$SXMO_NO_MODEM" ]; then - set_modem - fi - if [ -z "$SXMO_NO_AUDIO" ]; then - set_volume - fi - set_state - set_notifications - set_notch - set_network wifi wlan0 - sxmo_hook_battery.sh 2>/dev/null || true - ;; - *) - exit # swallow it ! - ;; + network) + shift + set_network "$@" + ;; + battery) + shift + set_battery "$@" + ;; + time) + set_time 1 + ;; + modem|volume|state|notifications|notch|inputmethod) + set_"$1" + ;; + state_change) + set_state + cur_st="" + [ -r "$SXMO_STATE" ] && { read -r cur_st < "$SXMO_STATE" 2>/dev/null || true; } + if [ "$cur_st" != "screenoff" ]; then + set_time + set_inputmethod + if [ -z "$SXMO_NO_MODEM" ]; then + set_modem + fi + set_network wifi wlan0 + sxmo_hook_battery.sh 2>/dev/null || true + fi + ;; + periodics) # 60 s loop + cur_st="" + [ -r "$SXMO_STATE" ] && { read -r cur_st < "$SXMO_STATE" 2>/dev/null || true; } + if [ "$cur_st" = "screenoff" ]; then + exit 0 + fi + set_time + set_inputmethod + if [ -z "$SXMO_NO_MODEM" ]; then + set_modem + fi + set_notch + set_state + set_network wifi wlan0 + sxmo_hook_battery.sh 2>/dev/null || true + ;; + all) + sxmobar -r + set_inputmethod + set_time + if [ -z "$SXMO_NO_MODEM" ]; then + set_modem + fi + if [ -z "$SXMO_NO_AUDIO" ]; then + set_volume + fi + set_state + set_notifications + set_notch + set_network wifi wlan0 + sxmo_hook_battery.sh 2>/dev/null || true + ;; + *) + exit # swallow it ! + ;; esac if [ "${SXMO_WM:-dwm}" = "dwm" ] && command -v xsetroot >/dev/null 2>&1; then - DISPLAY="${DISPLAY:-:0}" xsetroot -name "$(sxmo_status.sh)" 2>/dev/null || true + DISPLAY="${DISPLAY:-:0}" xsetroot -name "$(sxmo_status.sh)" 2>/dev/null || true fi