]> git.pld-linux.org Git - packages/bootsplash.git/blame - bootsplash-bootanim.script
- use internal shell getopts instead of external getopt binary
[packages/bootsplash.git] / bootsplash-bootanim.script
CommitLineData
5db976e5
AM
1#!/bin/bash
2#
3# bootanim - boot animation wrapper script for fbmngplay
4#
5# This program parses /etc/bootsplash/[THEME]/config/bootsplash-XxY.cfg
6# to determine the correct animation position.
7#
8# This program is free software; you may redistribute it under the terms
9# of the GNU General Public License. This program has absolutely no warranty.
10#
11# (C) 2002,2003 SuSE Linux AG. Written by Stefan Reinauer <stepan@suse.de>
12#
13# See http://www.bootsplash.org/ for more information.
14#
15
16usage()
17{
18 echo "usage: $0 [start|stop|kill|next] -m [-r XxY] [-d dir] mng1 [mng2..]"
19 cat << EOF
20
21 Available commands:
22 start starts given animation
23 stop fades out all running animations
24 kill immediately stops all animations
25 next continue to next animation.
26
27 Options for use with start command:
28 -r XxY screen resolution to use if unable to autodetect.
29 -d dir directory containing the animation files
30 -m play multiple animations
31 mng1|mng2 animation filename(s). Specify -m if multiple.
32
33EOF
34
35}
36
37if [ "$UID" -ne "0" ]; then
38 echo "$0 must be started as user root!!!"
39 echo "Exiting..."
40 exit 1
41fi
42
43THEME="No theme selected"
d8464cf5 44[ -f /etc/sysconfig/bootsplash ] && . /etc/sysconfig/bootsplash
5db976e5
AM
45
46if [ ! -d /etc/bootsplash/themes/$THEME ]
47then
48 echo "$0: could not find theme $THEME in /etc/bootsplash/themes."
49 exit 0
50fi
51
0315d846 52MODE=$(/bin/fbresolution 2>/dev/null)
5db976e5
AM
53DIRECTORY=/etc/bootsplash/themes/$THEME/animations
54OPTIONS="-b -c 1"
55FILES=""
56
57case "$1" in
58start)
59 # echo "$0 start"
60 # We fall through here.
61 ;;
62stop)
63 # echo "$0 stop"
d8464cf5 64 /bin/killall -q -2 fbmngplay
5db976e5
AM
65 exit 0
66 ;;
67kill)
68 # echo "$0 kill"
d8464cf5 69 /bin/killall -q fbmngplay
5db976e5
AM
70 exit 0
71 ;;
72next)
73 # echo "$0 next"
d8464cf5 74 /bin/killall -q -USR1 fbmngplay
5db976e5
AM
75 exit 0
76 ;;
77*)
78 usage;
79 echo " Error: illegal parameter.";
80 exit 1
81 ;;
82esac
83
84shift
85
86# We end up in bootanim start
d8464cf5
AM
87set -x
88while getopts mr:d: name "$@"; do
5db976e5 89 # echo "loop: $*"
d8464cf5
AM
90 case "$name" in
91 d) # directory
5db976e5 92 shift
d8464cf5 93 if [ ! -d "$OPTARG" ]; then
5db976e5
AM
94 echo "Not a valid directory."
95 exit 1
96 fi
d8464cf5 97 DIRECTORY=$OPTARG
5db976e5
AM
98 shift
99 ;;
d8464cf5 100 r) # resolution
5db976e5 101 shift
d8464cf5 102 MODE=$OPTARG;
5db976e5
AM
103 shift
104 ;;
d8464cf5 105 m) # multiple files
5db976e5
AM
106 shift
107 OPTIONS="$OPTIONS -s"
108 ;;
5db976e5 109 *) # Weird
d8464cf5 110 shift
5db976e5
AM
111 echo "Internal Error."
112 exit 1
113 ;;
114 esac
115done
116
117function box() { true; } # ignore box descriptions in the config file
118
119# Sourcing config file
120if [ -f /etc/bootsplash/themes/$THEME/config/bootsplash-$MODE.cfg ]; then
121 . /etc/bootsplash/themes/$THEME/config/bootsplash-$MODE.cfg
122else
123 echo "$0: No config file found for theme $THEME ($MODE)."
124 exit 1
125fi
126
127# echo "Dir: $DIRECTORY"
128# echo "Files: $*"
129# echo "Mode: $MODE"
130# echo "Pos: $ax,$ay"
131# echo "options: $OPTIONS"
132
836926fe 133CMDLINE="/bin/fbmngplay -x $ax -y $ay $OPTIONS"
5db976e5
AM
134for i in $*; do
135 CMDLINE="$CMDLINE $DIRECTORY/$i"
136done
137
138eval "$CMDLINE &"
This page took 0.23445 seconds and 4 git commands to generate.