#! /bin/sh # # /etc/init.d/sony # # description: init script for SonyXOSD ### BEGIN INIT INFO # Provides: sony # Required-Start: # Required-Stop: # Default-Start: 3 5 # Default-Stop: # Description: sony FN-key support ### END INIT INFO . /etc/rc.status rc_reset SONYSCREEN=/bin/sonyscreen SONYXOSD=/bin/sonyxosd SONYXOSDTEST=/home/bin/testing/sonyxosd # The next variable is the installation location of spicctl, # which I renamed as sonyctl CMD=/bin/sonyctl DEBUG=0 case "$1" in status) LEVEL= if [ -r /dev/shm/.brightness ]; then (( LEVEL = ( $( cat /dev/shm/.brightness ) * 100 ) / 255 )) elif [ -r /tmp/.brightness ]; then (( LEVEL = ( $( cat /tmp/.brightness ) * 100 ) / 255 )) fi [ -n "$LEVEL" ] && echo "Screen at ${LEVEL}% brightness" ;; stop) if [ -x $CMD ]; then echo -n "Disabling Sony LCD brightness daemon" $CMD -b 255 fi [ -w /dev/shm/.brightness ] && echo "256" > /dev/shm/.brightness [ -w /tmp/.brightness ] && echo "256" > /dev/shm/.brightness rc_status -v rc_reset echo -n "Disabling SonyXOSD function key handler" if [ -r /var/run/sonyxosd.pid ]; then if [ "$( ps -e | grep "$( cat /var/run/sonyxosd.pid )" )" != "" ]; then kill "$( cat /var/run/sonyxosd.pid )" else rm -f /var/run/sonyxosd.pid fi fi if [ "$( ps -e | grep sonyxosd )" != "" ]; then pkill sonyxosd fi rc_status -v ;; start) echo -n "Starting Sony LCD brightness daemon" if [ -x $SONYSCREEN ]; then $SONYSCREEN --reset else echo "Cannot find $SONYSCREEN" fi rc_status -v rc_reset echo -n "Starting SonyXOSD function key handler" if [ -x $SONYXOSD ]; then if (( 0 == DEBUG )); then $SONYXOSD elif [ -x $SONYXOSDTEST ]; then echo "DEBUG flag set - using test release" $SONYXOSDTEST else echo "DEBUG flag set - cannot find test release" false fi else echo "Cannot find /bin/sonyxosd" fi rc_status -v ;; esac rc_exit