summaryrefslogtreecommitdiffstats
path: root/abs/core/LinHES-system/LinHES-session
blob: ea22344c6d64cb1b03b4a48c7aa86ffb6a6477b1 (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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
#!/bin/bash
. /etc/profile
. /etc/systemconfig

if [ -e /etc/X11/WINDOWMANAGER ]
then
    . /etc/X11/WINDOWMANAGER
fi

xhost +local:
xhost +127.0.0.1
xset -dpms s off

export MALLOC_CHECK_=0



# # Run any scripting that applies to special hardware.  These brand-specific commands that run
# # after Tweaker will, of course, override generic or hardware-specific settings.
# SpecialHardwareCommands() {
#     special_hardware_file=/myth/.special_hardware_type
#     special_hardware=`cat $special_hardware_file`
#
#     case $special_hardware in
#         dragon*)
#             sudo -E twk_audio.pl --implement digital
#             sudo -E twk_dragon.pl --implement all
#             ;;
#         ausdragon*)
#             ;;
#         *)
#             # there are no brand-specific commands for configuring whatever
#             # special hardware the user chose
#             ;;
#     esac
# }


#
# . /etc/osd_cat.cfg || {
#         color=yellow
#         outline=2
#         outlinecolour=black
#         shadow=0
#         shadowcolour=black
#         font="-adobe-helvetica-bold-*-*-*-34-*-*-*-*-*-*-*"
# }
#
function delay_osd(){
    if [ x$STARTUP_STYLE = xmythvantage ]
    then
        cmd="ps -ef | grep -v grep | grep -q  xmsg.py"
    else
        cmd="ps -ef | grep -v grep | grep -q osd_cat"
    fi

    eval $cmd

    rc=$?
    while [ $rc = 0 ]
    do
        eval $cmd
        rc=$?
    done


    }
#
# function msg_osd(){
#     echo -e "$1"  | osd_cat --pos=middle --align=center --offset=200 --delay=5 --color=$color --outline=$outline --outlinecolour=$outlinecolour --shadow=$shadow --shadowcolour=$shadowcolour --font=$font
# }
#
# function msg_pyosd(){
#     /usr/LH/bin/xmsg.py -m "$1"
# }

function msg(){
#     if [ x$STARTUP_STYLE = xmythvantage ]
#     then
#         msg_pyosd "$1"
#     else
#         msg_osd "$1"
#     fi
    /usr/LH/bin/lh_message.sh "$1"
}


function unclutter(){
    if [ -e /etc/unclutter.cfg ]
    then
        . /etc/unclutter.cfg
    else
        idle=1
        jitter=200
    fi

    /usr/X11R6/bin/unclutter -root -idle $idle -jitter $jitter -noevents  &
}

function keylaunch(){
    if [ -f /usr/bin/keylaunch ]
    then
#       MHOME=`cat /etc/passwd | grep "mythtv" | cut -d":" -f6`
       if [ ! -e $HOME/.keylaunchrc ]
       then
          echo "setting symlink for keylaunch"
          ln -s /etc/keylaunchrc $HOME/.keylaunchrc
       fi
       /usr/bin/keylaunch &
    fi

}


function load_nvidia_settings(){
    lsmod |cut -f1 -d" " |grep -q nvidia
    if [ $? = 0 ]
    then
        /usr/bin/nvidia-settings --load-config-only
    fi
}

function run_tilda(){


    if [ -f /usr/bin/tilda ]
    then
        if [ ! -e  ~/.tilda/config_0 ]
        then
            mkdir -p ~/.tilda/
        fi

        width=`/usr/bin/xwininfo -root|grep Width | awk '{ print $2}'`
        height=`/usr/bin/xwininfo -root|grep Height | awk '{ print $2}'`
        center=$[width/2]
        sixtypercent=`echo "scale=0; ( $width*.6) / 1" |bc`
        quarter_height=`echo "scale=0; ($height*.35) /1" |bc`


	if [ $sixtypercent -lt 700 ]
	then
             sixtypercent=700
        fi

	if [ $quarter_height -lt 350 ]
	then
             quarter_height=350
        fi
        startloc=`echo "scale=0 ; (${center}-(${sixtypercent})/2) / 1" |bc`


        sed -e "s/^max_width.*$/max_width = $sixtypercent/" \
            -e "s/^max_height.*$/max_height = $quarter_height/" \
            -e "s/^x_pos.*$/x_pos = $startloc/g" /etc/tilda_config > ~/.tilda/config_0

        /usr/bin/tilda -h &

    fi
}


function mouse_move(){
    #move mouse to corner
    xdotool mousemove 0 0
}


function start_screensaver(){

    if [ x"$Screensavertype" = "xgscreensaver" ]
    then
        gnome-screensaver &
    elif  [ x"$Screensavertype" = "xxscreensaver" ]
    then
        xscreensaver  -no-splash &
    fi
}

function show_help_tip(){

    if [ x$ShowTips = "x1" ]
    then
        msg "Alt+h for help" &
    fi
}

function notify_scan(){
    delay_osd
    if [ -e /tmp/scan_report ]
    then
        msg "\nNew storage found. \nRun add_storage.py for details"
    fi

   }


function update_apple_trailers(){
    #update apple trailers
    if [[ x$RunFrontend = x1 && -f ~/.configure ]]
    then
        /usr/bin/php -q /usr/bin/myth_trailers_grabber > /home/mythtv/appletrailer.xml && /usr/bin/fix_aple_url.sh 2>/dev/null &
    fi
}


function first_configure(){
    if [ x$STARTUP_STYLE = xmythvantage ]
    then
        first_configure_mv
    else
        first_configure_default
    fi
}


function first_configure_default(){
    if [ !  $SystemType = "Frontend_only" ]
    then
        if [  -f ~/.configure ]
        then
            # Run Tweaker, which applies generic and hardware-specific settings
            if [ ! -f ~/.no_meth ]
            then
                #remove tweaker cause it's broken and duplicates entries
                #sudo -E tweaker.pl
                #/bin/rm /tmp/fps # ??? clean up a temp file that will eventually be obsolete anyway
                # Run any brand-specific commands, if necessary.
                SpecialHardwareCommands
            else
                rm -f ~/.no_meth
            fi

        sudo sv stop mythbackend
        /usr/LH/bin/dtheme.sh
        xterm -fn *18* -e sudo taskset -c 0 /usr/bin/mythtv-setup
        sudo sv start mythbackend
        sudo chown -R mythtv.mythtv /home/mythtv
        nice -n 19 mythfilldatabase --quiet &
        msg "Guide data is being loaded. \n Until this completes\n some shows will appear as unknown \n in the program guide."
        rm ~/.configure
        fi
    fi
}


function first_configure_mv(){
    if [ !  $SystemType = "Frontend_only" ]
    then
        if [  -f ~/.configure ]
        then
            msg "This is the first time starting MythTV.\nThe MythTV backend process will be stopped for setup."
            #for now skip these
            #autocard.py -g &
            #MythVantage -b
            #0 yes
            #1 yes/autodetech
            #2  no
            STATUS=$?
            if [ ! $STATUS = 2 ]
            then
                    /usr/MythVantage/bin/backend_control.sh stop BE 127.0.0.1
                     msg "MythTV setup is starting.\nPlease follow the steps for adding tuners and guide data."
                    /usr/bin/taskset -c 0 /usr/bin/mythtv-setup
                    /usr/MythVantage/bin/backend_control.sh start BE 127.0.0.1
            fi
         nice -n 19 mythfilldatabase --quiet &
         msg "Guide data is being loaded. \nUntil this completes \nsome shows will appear as "unknown" \nin the program guide."
         rm -f ~/.configure
        fi
    fi

}

function start_myth() {
    if [ x"$UseMythWelcome" = "x1" ]
    then
        STARTCMD="/usr/bin/mythwelcome"
    else
        if pacman -Q mythtv | grep -q 0.24
        then
            STARTCMD="/usr/bin/mythfrontend -d -l /var/log/mythtv/mythfrontend.log"
        else
            STARTCMD="/usr/bin/mythfrontend -d --syslog local6"
        fi
    fi

    echo "====================================================================="
    echo "Starting $STARTCMD"
    firstboot.sh &

    #continue on with starting mythtv

    if [ x$STARTUP_STYLE = xmythvantage ]
    then
        start_myth_mv
    else
        run_myth
    fi

    }


function run_myth(){
    if [ -f /tmp/nomfe ]
        then
            exit 0
        else
            if [ -f /tmp/debug ]
            then
                echo "using gbd/debug"
                gdb /usr/bin/mythfrontend -x $MV_ROOT/mfegdbcommands.txt
                mv gdb.txt gdb.txt.mythfrontend
                sleep 5
            else
                killall -9 irexec
                /usr/bin/irexec -d

                if [ x$STARTUP_STYLE = xmythvantage ]
                then
                    $STARTCMD 2>&1
                else
                    $STARTCMD 2>&1 &
                fi

            fi
        fi
}


function start_myth_mv(){
    while [ x = x ]
    do
        run_myth
        echo "_______________________________________________________"
    done
}


function set_background()
{
    echo "Setting the background"

    }


if [ x$WM = "x" ]
then
#	fluxbox > /var/log/fluxbox.log 2>&1
    WM=fluxbox
fi

#if using mythvantage style, start the WM right away
# this is done so that starting mythtv can loop.
$WM &
pid=$!
mouse_move
keylaunch
set_background
unclutter
load_nvidia_settings
run_tilda
start_screensaver
show_help_tip
notify_scan &
update_apple_trailers
first_configure
start_myth

# wait for the  windowmanger
#This will make the session wait on the WM to exit.
if [ x$STARTUP_STYLE != xmythvantage ]
then
    wait $pid
fi