summaryrefslogtreecommitdiff
path: root/packages/zaurusd/files/zaurus-hinge.in
blob: 0fcad38f984613e7b3af0e91fe46202e06629696 (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
#!/bin/sh
#
# Quick handler for chkhinge26 and X. 
#

killproc() {            # kill the named process(es)
        pid=`/bin/ps -e x |
             /bin/grep $1 |
             /bin/grep -v grep |
             /bin/sed -e 's/^  *//' -e 's/ .*//'`
        [ "$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

panel_user="`ps aux|grep matchbox-panel|grep -v grep | awk '{print $1}'`"

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