adding poc implementation for autostarting x11 applications
[openwrt/svn-archive/archive.git] / Xorg / xorg / xserver / xorg-server / files / x.init
1 #!/bin/sh /etc/rc.common
2 # Copyright (C) 2006 OpenWrt.org
3 START=99
4
5 ARGS=""
6
7 screen() {
8 local cfg="$1"
9 config_get resolution $cfg resolution
10 config_get dpi $cfg dpi
11 [ -n "$resolution" ] && ARGS="$ARGS -screen $resolution"
12 [ -n "$dpi" ] && ARGS="$ARGS -dpi $dpi"
13 }
14
15 graphic() {
16 local cfg="$1"
17 config_get device $cfg device
18 [ -n "$device" ] && ARGS="$ARGS -fb $device"
19 }
20
21 input() {
22 local cfg="$1"
23 config_get device $cfg device
24 config_get driver $cfg driver
25 #[ -n "$device" ] || return 0
26 [ -n "$driver" ] || return 0
27 ARGS="$ARGS -$cfg $driver,,device=$device"
28 }
29
30 desktop() {
31 local cfg="$1"
32 config_get autostart $cfg autostart
33 [ -n "$autostart" ] && eval $autostart &
34 config_get fdo_compliance $cfg fdo_compliance
35 [ -n "`echo \"$fdo_compliance\" 2> /dev/null | grep autostart`" ] && exit # in case the environment provides its own functionality to do the autostart stuff exit here
36 }
37
38 start() {
39 export DISPLAY=":0"
40 config_load x11
41 config_foreach screen screen
42 config_foreach graphic graphic
43 config_foreach input input
44 Xorg $ARGS &
45 sleep 1 # give the xserver some time get initialized
46 config_foreach desktop desktop
47 test -d /etc/xdg/autostart || exit
48 sleep 1 # give the first x11 application some time to get present - afterwars we'll start the x11 autostart applications
49 for elem in `ls /etc/xdg/autostart/`; do
50 if grep "^Hidden=true" "/etc/xdg/autostart/$elem" > /dev/null; then
51 continue
52 fi
53 exec=`grep "^Exec=" "/etc/xdg/autostart/$elem"`
54 eval ${exec#*=} &
55 done
56 }