~shivers


#526 Add ring profiles for incoming calls and texts 4 months ago

Comment by ~shivers on ~mil/sxmo-tickets

Thanks for the great suggestions for improvements and the link to the git send-email guide. I have made the corrections to the files and when I figure out git send-email I will send it to the sxmo-devel mailing list.

#526 Add ring profiles for incoming calls and texts 4 months ago

Ticket created by ~shivers on ~mil/sxmo-tickets

This is a proposed set of patches that will add a menu item to the audio menu to choose between profiles for incoming calls and texts(mute, vibrate, ring, ring&vibrate). It also includes a config file so the user can set their ringtone and text sound without editing the scripts.

--- a/usr/share/sxmo/default_hooks/sxmo_hook_ring.sh
+++ b/usr/share/sxmo/default_hooks/sxmo_hook_ring.sh
@@ -24,12 +24,30 @@
 fi

 # Start the mpv ring until another hook kill it or the max (10) is reached
-mpv --quiet --no-video --loop=10 /usr/share/sxmo/ring.ogg &
-MPVID=$!
-echo "$MPVID" > "$XDG_RUNTIME_DIR/sxmo.ring.pid"
+source "$HOME/.sxmocfg"

-# Vibrate while mpv is running
-while kill -0 $MPVID; do
+case `cat /home/user/.ringmode` in
+       0) #Mute
+          ;;
+       1) #Vibrate
+          for i in `seq 5`; do
                sxmo_vibrate 1500
                sleep 0.5
-done
+           done
+          ;;
+       2) #Ring
+          timeout "$RINGTIME" mpv --quiet --no-video --loop="$RINGNUMBER" $RINGTONE &
+           MPVID=$!
+           echo "$MPVID" > "$XDG_RUNTIME_DIR/sxmo.ring.pid"
+          ;;
+       *) #Default ring and vibrate
+          timeout "$RINGTIME" mpv --quiet --no-video --loop="$RINGNUMBER" $RINGTONE &
+          MPVID=$!
+          echo "$MPVID" > "$XDG_RUNTIME_DIR/sxmo.ring.pid"
+           # Vibrate while mpv is running
+          while kill -0 $MPVID; do
+                         sxmo_vibrate 1500
+                         sleep 0.5
+          done
+          ;;
+esac
--- a/usr/share/sxmo/default_hooks/sxmo_hook_sms.sh
+++ b/usr/share/sxmo/default_hooks/sxmo_hook_sms.sh
@@ -14,4 +14,19 @@
 # Finally, mms may include this parameter:
 # $4 = Group Contact Name or Number (if number not in contacts)

-mpv --quiet --no-video /usr/share/sxmo/notify.ogg
+source "$HOME/.sxmocfg"
+
+case `cat /home/user/.ringmode` in
+       0) #Mute
+          ;;
+       1) #Vibrate
+          sxmo_vibrate 500
+          ;;
+       2) #Ring
+          mpv --quiet --no-video "$TEXTSOUND"
+          ;;
+       *) #Default: ring&vibrate
+          mpv --quiet --no-video "$TEXTSOUND" &
+          sxmo_vibrate 500
+          ;;
+esac
--- -
+++ /home/user/.sxmocfg
@@ -0,0 +1,10 @@
+#Set RINGTONE to audio file to play for incoming call
+RINGTONE="/usr/share/sxmo/ring.ogg"
+#Set TEXTSOUND to audio file to play when receive text message
+TEXTSOUND="/usr/share/sxmo/notify.ogg"
+
+#Set RINGTIME to number of seconds the phone will ring
+RINGTIME=20
+#Set RINGNUMBER to number of times phone will ring or repeat ringtone
+#(Whichever RINGTIME or RINGNUMBER runs less will be how long phone rings)
+RINGNUMER=10
--- a/usr/bin/sxmo_audio.sh
+++ b/usr/bin/sxmo_audio.sh
@@ -92,6 +92,17 @@
        else
                printf "Mic: On -> Off ^ sxmo_modemaudio.sh mute_mic\n"
        fi
+       printf "%s " "$icon_ear"
+       case `cat /home/user/.ringmode` in
+               0) printf "Mute -> Vibrate ^ echo 1 > /home/user/.ringmode\n"
+                  ;;
+               1) printf "Vibrate -> Ring ^ echo 2 > /home/user/.ringmode\n"
+                  ;;
+               2) printf "Ring -> Ring&Vibrate ^ echo "" > /home/user/.ringmode\n"
+                  ;;
+               *) printf "Ring&Vibrate -> Mute ^ echo 0 > /home/user/.ringmode\n"
+                  ;;
+       esac
 }

 pulsemenuchoices() {