Ciao, premetto che non sono un programmatore, ho provato a modificare gli script che ho trovato nel link sopra citato ed in questo modo funzionano, unico requisito è che bisogna inserire l'auricolare quando il dialer è aperto e abbiamo in arrivo una chiamata o la stiamo facendo.
Ecco il primo script:
/usr/bin/jdd
#!/usr/bin/python
# -*- coding: utf-8 -*-
# jack.py - An application to read jack
#
# Version 0.1
#
# Authors: Francois TOURDE <fr-om@...>
#
# Copyright (c) 2008 François TOURDE
#
# jack.py is free software; you can redistribute it and/or modify it
# under the terms of the GNU General Public License as published by the
# Free Software Foundation; either version 3 of the License, or (at your
# option) any later version.
#
# jack.py is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# General Public License for more details.
#
# TODO
#
# Change List
# Change command to activate gsmheadset alsa profile
#
# 2008-09-03: First release
import os
import sys
# Hexdump of /dev/input/event0
# When jack inserted
# 9131 48be a594 0001 0005 0002 0001 0000
# 9131 48be a5f9 0001 0000 0000 0000 0000
# When jack removed
# 9131 48be a594 0001 0005 0002 0000 0000
# 9131 48be a5f9 0001 0000 0000 0000 0000
# Where files are stored
p="/usr/share/openmoko/scenarios/"
ps="saved/"
# Open the jack sensor
f = open("/dev/input/event0", "r")
while 1:
block = f.read(16)
if block[8] == "\x05":
if block[10] == "\x02":
if block[12] == "\x01":
# Moving to headset mechanism:
# point stereoout to headset
# point gmshandset to gsmheadset
#os.system("ln -sf %s%s%s %s%s" % (p, ps, "headset.state", p, "stereoout.state"))
#os.system("ln -sf %s%s%s %s%s" % (p, ps, "gsmheadset.state", p, "gmshandset.state"))
#os.system("alsactl -f %sstereoout.state restore" % p)
os.system("alsactl -f /usr/share/openmoko/scenarios/gsmheadset.state restore")
if block[12] == "\x00":
# Moving to handset mechanism
# point stereoout to stereoout
# point gsmhandset to gsmhandset
#os.system("ln -sf %s%s%s %s%s" % (p, ps, "stereoout.state", p, "stereoout.state"))
#os.system("ln -sf %s%s%s %s%s" % (p, ps, "gsmhandset.state", p, "gmshandset.state"))
#os.system("alsactl -f %sstereoout.state restore" % p)
os.system("alsactl -f /usr/share/openmoko/scenarios/gsmhandset.state restore")
# Close the jack
f.close()
Le modifiche che ho fatto sono alle righe che iniziano per
os.systemEcco il secondo:
/etc/init.d/jdd
#!/bin/sh
#
# Start or stop the Jack Detector Daemon.
#
# Written by Francois TOURDE <fr-om@...>
#
[ -f /etc/default/jdd ] && . /etc/default/jdd
case "$1" in
start)
echo -n "Starting jdd daemon: "
start-stop-daemon -S -x /usr/bin/jdd &
if [ $? = 0 ]; then
echo "jdd."
else
echo "(failed.)"
fi
;;
stop)
echo -n "Stopping jdd daemon: "
#start-stop-daemon -K -x /usr/bin/jdd &
for pid in `ps -C jdd|grep jdd |awk '{print $1}'`
do
ps -p $pid|grep -q jdd && kill $pid
done
echo "jdd."
;;
restart|force-reload)
$0 stop
$0 start
exit
;;
*)
echo "Usage: /etc/init.d/jdd {start|stop|restart|force-reload}"
exit 1
;;
esac
exit 0
Ho fatto una modifica nella sezione dello stop perchè non funzionava, ci ho aggiunto un ciclo for che killa i processi jdd se presenti, questo perchè il comando
ps -C jdd mi tira fuori 3 pid invece di uno e quindi voglio essere sicuro di killare il pid corretto.
Ultima cosa bisogna attivarlo al boot del moko:
update-rc.d jdd start 5 .Spero possa tornare utile anche a voi.
Ciao