View Single Post
Posts: 76 | Thanked: 19 times | Joined on Apr 2007
#303
Based on JohnX's a2dp script, I've made the following to toggle, enable or disable hostmode.

Copy the script below into /usr/bin/hostmode
Make the script executable with chmod +x /usr/bin/hostmode
Add the following line to /etc/sudoers:
user ALL = NOPASSWD: /usr/bin/hostmode
Add the command: sudo /usr/bin/hostmode toggle to osso-statusbar-cpu's command settings and enjoy!

Code:
#!/bin/sh

if $(grep -q b_idle /sys/devices/platform/musb_hdrc/mode)
   then
    #echo "guest mode enabled"
   hostmode=0
else
    #echo "host mode"
   hostmode=1
fi

case "$1" in
        "enable" | "host" | "hostmode" )
                echo host > /sys/devices/platform/musb_hdrc/mode
                run-standalone.sh dbus-send --print-reply  \
                --type=method_call --dest=org.freedesktop.Notifications  \
                /org/freedesktop/Notifications org.freedesktop.Notifications.SystemNoteDialog  \
                string:'USB HOST MODE - ENABLED' uint32:0 string:'OK' 2> /dev/null 1> /dev/null
                ;;
        "disable" | "guest" | "otg" | "peripheral" )
                echo otg > /sys/devices/platform/musb_hdrc/mode
                run-standalone.sh dbus-send --print-reply  \
                --type=method_call --dest=org.freedesktop.Notifications  \
                /org/freedesktop/Notifications org.freedesktop.Notifications.SystemNoteDialog  \
                string:'USB HOST MODE - DISABLED' uint32:0 string:'OK' 2> /dev/null 1> /dev/null
                ;;
        "toggle" )
                if [ $hostmode -eq 1 ] ; then
                        #"Calling $0 to disable"
                        $0 disable
                else
                        #"Calling $0 to enable"
                        $0 enable
                fi
                ;;
        * )
                echo "$0 usage: enable | disable | toggle | --help"
                ;;
esac

Last edited by mplawner; 2008-01-24 at 06:27. Reason: Missed "sudo" - Thanks Darethehair
 

The Following User Says Thank You to mplawner For This Useful Post: