aboutsummaryrefslogtreecommitdiffstats
path: root/recipes-bsp/zaurusd/zaurusd/zaurus-hinge.in
blob: 660e6ccb8fdca9a51f7934bc08b3cb53a5b4fbea (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
#!/bin/sh
#
# Quick handler for chkhinge26 and X. 
#

killproc() {            # kill the named process(es)
        pid=`/bin/pidof $1`
        [ "$pid" != "" ] && kill $pid
}

ZD_BINDIR="@bindir@"
export DISPLAY=:0

if [ -z "$1" ]; then
   echo "Usage: hinge-handler <state> ( 3 = closed, 0 = landscape, 2 = portrait )"
   exit 1
fi

if [ ps aux > /dev/null 2>&1 ] ; then
	panel_user="`ps aux|grep matchbox-panel|grep -v grep | awk '{print $1}'`"
else
	panel_user="`ps|grep matchbox-panel|grep -v grep | awk '{print $2}'`"
fi

STATE=$1

# touch ~/.norot can disable rotation.
if test -f /home/$panel_user/.norot ; then
  if [ $STATE = "3" ]; then
	. /etc/zaurusd/hinge-close.d/00-backlight-off
  else
	. /etc/zaurusd/hinge-landscape.d/00-backlight-on
  fi
  exit
fi

if [ $STATE = "3" ]; then

  for script in `ls -1 /etc/zaurusd/hinge-close.d`
  do
  	. /etc/zaurusd/hinge-close.d/$script
  done

  exit 0
fi

if [ $STATE = "0" ]; then
  #echo "landscape"

  for script in `ls -1 /etc/zaurusd/hinge-landscape.d`
  do
  	. /etc/zaurusd/hinge-landscape.d/$script
  done

  exit 0
fi

if [ $STATE = "2" ]; then
  #echo "portrait"

  for script in `ls -1 /etc/zaurusd/hinge-portrait.d`
  do
  	. /etc/zaurusd/hinge-portrait.d/$script
  done

  exit 0
fi