SJphone ruft bei eingehenden Anrufen die Ausführbare Datei phoneevent.sh auf, welches hier liegt: Linux: ~/.sjphone, Mac OS: ~/Library/Preferences/SJphone (vgl. http://forum.sjphone.org/viewtopic.php?t=277.
Damit lässt sie ziemlich viel anstellen
- das einfache Abspielen eines Klingeltons ist da nur eine einfache Übung.
Ich habe gestern (mal eben) ein Shellskript + diverse Hilfsscripte gehackt
Folgendes wird erwartet:
Bitte zu entschuldigen wenn es nicht immer superschlank sein sollte, ist eben ein schneller Hack. Vielleicht kanns ja jemand gebrauchen, würde mich freuen
Die Skripte müssen eventuell leicht angepasst werden (z.B. das Minitelefonbuch, oder die Variable ${BIN}, wenn die Hilfsskripte nicht unter ${HOME}/bin liegen)
Hauptscript, wird von SJphone aufgerufen, Speicherort ~/Library/Preferences/SJphone (s.o.)
#!/bin/bash
# Date 29 June 2008, initial version
# Date 10 July 2008, v0.11, corrected growlnotify call to display correct icon
# added two more growl calls
SPEECH_VOL=80
BIN=${HOME}/bin
# mini phonebook since ${SJSESSION_RESPONDENT} seems
# to hold the number only
case "${SJSESSION_RESPONDENT}" in
12345)
SJSESSION_RESPONDENT=girlfriend
;;
23456)
SJSESSION_RESPONDENT=my\ parents
;;
34567)
SJSESSION_RESPONDENT=mine\ handy
;;
45678)
SJSESSION_RESPONDENT=brothers\ handy
;;
56789)
SJSESSION_RESPONDENT=girlfriends\ parents
;;
*)
;;
esac
# Send growl message
/Applications/growlnotify --appIcon /Applications/SJPhone.app Incoming Call -d sjphone -n SJphone -m "from ${SJSESSION_RESPONDENT}"
# mute / pause iTunes if playing, by default, assume not playing
ITUNES_PLAYING=1
if [ `ps ax | grep \[/\]"iTunes.app/Contents/MacOS/iTunes" |wc -l |sed 's/ //g'` -ge 1 ] ; then
if [ `osascript -e 'tell application "iTunes" to get player state'` = playing ] ; then
ITUNES_PLAYING=0
ITUNES_VOL=`osascript -e "tell application \"iTunes\" to get sound volume"`
#osascript -e 'tell application "iTunes" to set mute to true'
${BIN}/fadeout-iTunes.applescript
osascript -e 'tell application "iTunes" to pause'
fi
fi
# save old output volume so we can restore it
OUT_VOL=`osascript -e "get output volume of (get volume settings)"`
if [ $SPEECH_VOL -gt $OUT_VOL ] ; then
osascript -e "set volume output volume $SPEECH_VOL"
fi
say Incoming call from ${SJSESSION_RESPONDENT}
# now we check when the user accepts the call by checking the status of
# the accept menu entry: it remains enabled while the call is ringing
INCALL=0
while [ ${INCALL} -eq 0 ]
do
sleep 1
if [ `ps ax | grep \[/\]"SJphone" |wc -l |sed 's/ //g'` -eq 0 ] ; then
# SJphone does not run anymore
INCALL=1
else
if [ "`${BIN}/SJPhoneAcceptEnabled.applescript`" = "false" ] ; then
INCALL=1
fi
fi
done
osascript -e "set volume output volume $OUT_VOL"
# Send growl message
/Applications/growlnotify --appIcon /Applications/SJPhone.app Call -d sjphone -n SJphone -m "accepted (or caller hungup)"
# now we check if user is still in the call by checking the status of
# the hangup menu entry: it remains enabled while the call is active
INCALL=0
while [ ${INCALL} -eq 0 ]
do
sleep 1
if [ `ps ax | grep \[/\]"SJphone" |wc -l |sed 's/ //g'` -eq 0 ] ; then
# SJphone does not run anymore
INCALL=1
else
if [ "`${BIN}/SJPhoneHangupEnabled.applescript`" = "false" ] ; then
INCALL=1
fi
fi
done
# Send growl message
/Applications/growlnotify --appIcon /Applications/SJPhone.app Call -d sjphone -n SJphone -m "finished"
if [ ${ITUNES_PLAYING} -eq 0 ] ; then
osascript -e 'tell application "iTunes" to play'
#osascript -e 'tell application "iTunes" to set mute to false'
# unfortunately fadein does not read ${ITUNES_VOL}
${BIN}/fadein-iTunes.applescript ${ITUNES_VOL}
fi
Hilfsskript (defaultmässig in ${HOME}/bin erwartet!), fade-in der iTunes Lautstärke, leider funktioniert die Übernahme des Lautstärkeparameters von der Kommandozeile (noch) nicht. Hauptsächlich übernommen von http://dougscripts.com/itunes/itinfo/icalscripts.php
#!/usr/bin/osascript -- fadein-iTunes.applescript, Roggy, Date 29 June 2008 -- based on script on http://dougscripts.com/itunes/itinfo/icalscripts.php -- FADE IN -- LOUDER property maxvolume : 100 -- set maxvolume to item 1 of argv --on run argv -- set maxvolume to item 1 of argv --end run property tick : 10 -- raise volume level by this many each loop property thismany : 0.05 -- seconds to wait before making next increment to volume tell application "iTunes set snd to maxvolume -- was: sound volume set sound volume to 0 -- play playlist "Recently Played" -- your playlist here repeat if (get sound volume) is greater than or equal to (snd - tick) then set sound volume to snd exit repeat end if set sound volume to (sound volume + tick) delay thismany end repeat end tell
Hilfsskript (defaultmässig in ${HOME}/bin erwartet!), fade-out der iTunes Lautstärke. Hauptsächlich übernommen von http://dougscripts.com/itunes/itinfo/icalscripts.php
#!/usr/bin/osascript -- fadeout-iTunes.applescript, Roggy, Date 29 June 2008 -- based on script on http://dougscripts.com/itunes/itinfo/icalscripts.php -- FADE OUT -- MUTING in the end property tick : 10 -- change volume level by this many each loop property thismany : 0.05 -- seconds to wait before making next change to volume tell application "iTunes" repeat set snd to sound volume if snd is less than or equal to tick then set sound volume to 0 exit repeat end if set sound volume to (snd - tick) delay thismany end repeat -- pause -- stop end tell
Hilfsskript (defaultmässig in ${HOME}/bin erwartet!), prüft ob SJphone noch darauf wartet, dass der Benutzer den call annimmt darüber ob der Menüeintrag „Accept“ enabled (noch nicht angenommen) oder disabled (Call angenommen oder kein eingehender Anruf (mehr)) ist.
#!/usr/bin/osascript -- SJPhoneAcceptEnabled.applescript, Roggy, Date 29 June 2008 tell application "System Events" tell process "SJphone" tell menu bar 1 tell menu bar item "Call" tell menu 1 tell menu item "Accept" set statusenabled to get value of attribute 4 return statusenabled end tell end tell end tell end tell end tell end tell
Hilfsskript (defaultmässig in ${HOME}/bin erwartet!), prüft ob SJphone noch „im call“ ist darüber ob der Menüeintrag „Hangup“ enabled (im Call) oder disabled (nicht im Call) ist.
#!/usr/bin/osascript -- SJPhoneHangupEnabled.applescript, Roggy, Date 29 June 2008 tell application "System Events" tell process "SJphone" tell menu bar 1 tell menu bar item "Call" tell menu 1 tell menu item "Hangup" set statusenabled to get value of attribute 4 return statusenabled end tell end tell end tell end tell end tell end tell
SJphone, ringtone, Klingelton, phoneevent.sh, fade, iTunes, call, notification, Mac