ChangeLog entry for previous commits.
[fvwm-themes.git] / bin / fvwm-themes-start.in
blob947ea8cf9bef9606ccc6c44036681d0fa5a84c20
1 #!/bin/sh
3 # This script runs fvwm with fvwm-themes config. It should be run under X.
4 # Put a call to this script as the last line of your .Xclients or .xinitrc.
6 prefix=@prefix@
7 : ${ROOT_PREFIX=$DESTDIR}
8 : ${ROOT_PREFIX=@ROOT_PREFIX@}
10 : ${FVWM_USERDIR=@FVWM_DEFAULT_USERDIR@}
11 rcName=themes-rc
12 rcFile=$FVWM_USERDIR/$rcName
13 rcName2=themes-rc-2
14 rcFile2=$FVWM_USERDIR/$rcName2
15 themesName=themes
16 themesDir=$FVWM_USERDIR/$themesName
17 currentThemeName=current
18 currentThemeDir=$themesDir/$currentThemeName
19 startDir=`pwd`
20 isNewSession=0
22 # Arguments
23 fvwmArgs=""
24 whoseArgs="my"
25 start=yes
26 ### to be autoconfigured
27 fvwmExe="fvwm"
28 session="main"
30 while [ "x$1" != "x" ]; do
31 case "$1" in
32 --)
33 whoseArgs="fvwm" ;;
35 if [ "$whoseArgs" = "fvwm" ]; then
36 fvwmArgs="$fvwmArgs $1"
37 else
38 case "$1" in
39 --no-start|-no-start|-n)
40 start=no ;;
41 --fvwm|-fvwm|--fvwm-exe|-fvwm-exe|-e)
42 shift
43 fvwmExe="$1" ;;
44 --session|-session|-s)
45 # fvwm-2.2.x adds -s on 'Restart fvwm-themes-start'
46 if [ $# -gt 1 ]; then
47 shift
48 if [ "$1" = "--" ]; then
49 whoseArgs="fvwm"
50 else
51 session="$1"
53 fi ;;
54 esac
55 fi ;;
56 esac
57 shift
58 done
60 realCurrentThemeName="current-$session"
61 realCurrentThemeDir="$themesDir/$realCurrentThemeName"
62 destRcFile2="$themesName/$realCurrentThemeName/$rcName2"
64 [ -d $FVWM_USERDIR ] || mkdir $FVWM_USERDIR
65 # create the symbolic links
66 # POSIX says that we can have symlink to a not existing file.
67 # However some 2.3.x Linux kernels and may be 2.4.x do not support this???
68 [ -d $themesDir ] || mkdir $themesDir
69 [ -d $themesDir/personal ] || mkdir $themesDir/personal
70 cd $themesDir || echo "Fatal error, can't chdir $themesDir"
71 if [ ! -d $realCurrentThemeName ]; then
72 mkdir $realCurrentThemeName
73 isNewSession=1
75 rm -rf $currentThemeName
76 ln -s $realCurrentThemeName $currentThemeName
77 cd $FVWM_USERDIR
78 if [ ! -f $destRcFile2 ]; then
79 touch $destRcFile2
80 isNewSession=1
82 rm -f $rcName2
83 ln -s $destRcFile2 $rcName2
85 HEADERS_LINE=""
86 test -f $rcFile && HEADERS_LINE="`head -1 $rcFile 2>/dev/null`"
88 # check whether this is the first run
89 test "`echo $HEADERS_LINE | cut -d' ' -f3`" = "@VERSION@"
90 isNewVersion="$?"
91 if [ "$isNewVersion" = 1 -o "$isNewSession" = 1 ]; then
92 if [ "$isNewVersion" = 1 ]; then
93 echo '[FVWM-Themes]: Welcome to FVWM Themes @VERSION@!'
94 xmessage -g 400x100+0+0 -xrm "*form*background:rgb:c0/c0/a0" -xrm "*form*okay*background:rgb:90/90/7a" -xrm "*textSink*font:lucidasans-18" -xrm "*form*scrollVertical:false" -xrm "*form*message*background:rgb:f0/f0/c0" 'Welcome to FVWM Themes @VERSION@!' 2>/dev/null &
95 else
96 echo "[FVWM-Themes]: Initial $session FVWM Themes session"
98 @bindir@/fvwm-themes-config --reset
99 @bindir@/fvwm-themes-config --load @personal 2>/dev/null
100 else
101 # different build id may mean that themes or prefix were changed,
102 # be safe and refresh in this case
103 if [ "`echo $HEADERS_LINE | cut -d' ' -f4-`" != "@FT_BUILD_ID@" ]; then
104 echo "[FVWM-Themes]: A new @VERSION@ build detected; refreshing configuration"
105 @bindir@/fvwm-themes-config --fresh
109 # check that @FVWM_BINDIR@ is in $PATH and first for fvwm-config
110 if [ "`which fvwm-config 2>/dev/null`" != "@FVWM_BINDIR@/fvwm-config" ]; then
111 echo "[FVWM-Themes]: There is no correct fvwm-config in your PATH; prepended"
112 PATH="@FVWM_BINDIR@:$PATH"
113 export PATH
116 # check that @bindir@ is in $PATH and first for fvwm-themes-config
117 if [ "`which fvwm-themes-config 2>/dev/null`" != "@bindir@/fvwm-themes-config" ]; then
118 echo "[FVWM-Themes]: There is no correct fvwm-themes-config in your PATH; prepended"
119 PATH="@bindir@:$PATH"
120 export PATH
123 cd $startDir
124 echo "[FVWM-Themes]: Starting FVWM under the $session fvwm-themes session"
125 if [ "$start" = "yes" ]; then
126 exec $fvwmExe -f "$rcName" $fvwmArgs