updated on Thu Jan 26 16:09:46 UTC 2012
[aur-mirror.git] / fbsplash-extras / fbsplash-chvt
blobca51eedf06e409fb66f2694bca3f7ac0f1b868da
1 #!/bin/bash
3 # fbsplash-chvt #
5 # Helper for Changing Virtual Consoles #
6 # #
7 # Get X to change back to the splash VT on exit #
8 # or chvt from silent splash VT to console to avoid blackscreen #
9 # #
10 # Can determine changing direction from configuration and runlevel #
11 # when used with SysV-Init. #
12 # #
13 # Author: Kurt J. Bosch <kjb-temp-2009 at alpenjodel.de> #
14 # #
15 # Distributed under the terms of the GNU General Public License (GPL) #
17 # Make sure /proc/cmdline is parsed
18 unset "${!SPLASH_@}"
20 . /sbin/splash-functions.sh
22 # Add miscsplashutils fgconsole path
23 [[ $spl_bindir ]] && PATH+=":$spl_bindir"
25 # Defaults, Configuration
26 SPLASH_XCHVT_WAIT=5 # seconds (undocumented setting)
27 SPLASH_XLEVELS=( 5 )
28 . /etc/conf.d/splash-extras
30 case $SPLASH_MODE_REQ
31 in silent ) splash_vt=$SPLASH_TTY
32 ;; verbose ) splash_vt=1
33 ;; * ) exit 0
34 esac
36 chvt_wait=0
37 case $1 in -w | --wait )
38 chvt_wait=$SPLASH_XCHVT_WAIT
39 shift
40 esac
42 if [[ $1 ]]; then
44 elif [[ -z $RUNLEVEL ]]; then
45 echo "$0: Error: RUNLEVEL not set in environment. Unable to determine action." >&2
46 exit 1
47 elif [[ " "${SPLASH_XLEVELS[*]}" " = *" "$RUNLEVEL" "* ]]; then
48 set -- splash
49 else
50 set -- 1
53 fgc=$( fgconsole ) || exit 1
55 if [[ $1 = "splash" ]]; then
56 [[ $fgc = "$splash_vt" ]] && exit 0
57 echo "Changing to Splash VT (for starting X)"
58 chvt "$splash_vt"
59 elif [[ $1 =~ ^[0-9]+$ ]]; then
60 [[ $fgc = 1 ]] && exit 0
61 if [[ $fgc = "$splash_vt" ]]; then
63 elif (( chvt_wait > 0 )); then
64 echo -n "Waiting for Splash VT to be activated (by terminated X)"
65 t=$(( chvt_wait * 10 ))
66 until [[ $( fgconsole ) = "$splash_vt" ]]; do
67 (( -- t >= 0 )) && sleep .1 && continue
68 echo " - Timeout!"
69 exit 1
70 done
71 echo
72 # If not on splash VT (after waiting until X changes), do nothing
73 else
74 exit 0
76 echo "Changing from Splash VT to VT#: $1"
77 chvt "$1"
78 else
79 echo "Usage: ${0##*/} splash" >&2
80 echo " ${0##*/} [-w|--wait] [<vt-number>]" >&2
81 exit 1
84 # EOF #