all repos — fluxbox @ b58d23091d3878fd8b4fbfdd7acca4383381fdf8

custom fork of the fluxbox windowmanager

util/bsetbg (raw)

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
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
#!/bin/sh

# Copyright (c) 2000 LordZork Industries (lordzork@lordzork.com)
#
# Permission is hereby granted, free of charge, to any person obtaining
# a copy of this software and associated documentation files (the
# "Software"), to deal in the Software without restriction, including
# without limitation the rights to use, copy, modify, merge, publish,
# distribute, sublicense, and/or sell copies of the Software, and to
# permit persons to whom the Software is furnished to do so, subject to
# the following conditions:
#
# The above copyright notice and this permission notice shall be
# included in all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
# IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
# CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
# TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
# SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

# $Id: bsetbg,v 1.5 2003/04/28 14:44:04 fluxgen Exp $

#
# Portability notes:
# To guarantee this script works on all platforms that support fluxbox
# please keep the following restrictions in mind:
#
# don't use [ -e file ] use [ -r file ]
# don't use $(), use ``
# don't use ~, use ${HOME}
# don't use id -u, use whoami
# getopts won't work on all platforms, but the config-file can
# compensate for that.
#


error_msg() {
    case $INFO in
        yes|y|1)
            info_msg
            ;;
    esac

    case $1 in
        1)
            cat << EOF >&2

$NAME: configuration error: $OPTION="$VALUE"
$NAME: please edit $CONFIG and provide the correct variable.
EOF
            ;;
        2)
            cat << EOF >&2

$NAME: error: couldn't execute '$APP'! tried to run fallback option $ARGUMENT
$NAME: but quit because of the following error in $CONFIG:
$NAME: $OPTION=$VALUE
$NAME: please edit $CONFIG and provide the correct variable!
EOF
            ;;
        3)
            cat << EOF >&2

$NAME: error: couldn't find any suitable image applications in the system path!
EOF
            error_msg url
            ;;
        4)
            cat << EOF >&2

$NAME: error: invalid option, or non-existent image ($ARGUMENT).
EOF
            ;;
            5)
            cat << EOF >&2

$NAME: error: the image you specified ($IMAGE) could not be found."
EOF
            ;;
            6)
            cat << EOF >&2

$NAME: error: please specify a valid image.
EOF
            ;;
            7)
            cat << EOF >&2

$NAME: error: bsetroot couldn't be found! check your fluxbox installation.
EOF
            ;;
            8)
            cat << EOF >&2

$NAME: error: wrong number of arguments!
$NAME: make sure you enclosed the options for '$APP' in double quotes.
EOF
            ;;
            nobgapp)
            cat << EOF >&2

$NAME: error: tried to run '$VALUE' for $ARGUMENT argument,
$NAME: but couldnt find '$APP' in the path! please fix the following
$NAME: line in $CONFIG to point to an existing application:
$NAME: $OPTION=\$VALUE\
EOF
            ;;
            nogrep)
            cat << EOF >&2

$NAME: error: couldn't find grep!
This script needs grep to be in your path in order to function.
You can get GNU grep from ftp://ftp.gnu.org/bin/gnu/grep/
EOF
            ;;
            url)
            cat << EOF >&2

It is suggested that you use qiv, xli (xsetbg), or xv.
You can obtain them at the following locations:

    qiv: http://www.klografx.de/software/qiv.shtml
    xli: http://pantransit.reptiles.org/prog/#xli
    xv: http://www.trilon.com/xv/downloads.html

The above URLs are current as of 05/23/2000.
EOF
            ;;
    esac
    exit 1
}


help_msg() {
cat << EOF
$NAME $VERSION: $MORE
options:

  (none)                             image is set using default values

  -full, -f                          image is set fullscreen
  -tile, -t                          image is set tiled
  -center, -c                        image is set centered

  -last, -l                          last used image is set

  -app, -a <application>             image is set using <application> with
     <'application options'>            single-quote-enclosed options and
     -center, -c|-tile, -t|-full, -f    default fallback option

  -display <string>                  display to connect to (bsetroot only)

  -mod <x> <y>                       sets bsetroot modula pattern
     -foreground, -fg <color>           modula foreground color
     -background, -bg <color>           modula background color

  -gradient <texture>                sets bsetroot gradient texture
     -from <color>                      gradient start color
     -to   <color>                      gradient end color

  -solid <color>                     sets bsetroot solid color

  -version, -v                       outputs $NAME's version number
  -info, -i                          outputs configuration info
  -help, -h                          this message

usage: <options...> <image>
EOF
    exit 0
}


info_msg() {
    case $ERROR in
	[1-3])
	    SUMMARY="error: some variables are blank"
	    ;;
	4)
	    SUMMARY="no values have been specified"
	    ;;
 	0)
	    SUMMARY="looks good"
            ;;
    esac

    case $APP_ERROR in
        [1-4])
	    SUMMARY="error: some applications couldn't be found!"
            ;;
    esac

    case `which bsetroot 2>&1` in
	*/*bsetroot)
	    BSETROOT=`which bsetroot`
	    ;;
	*)
	    BSETROOT="(error: not found)"
	    case $ERROR in
		1-4)
		    SUMMARY="$SUMMARY, and bsetroot does not seem to be present."
		    ;;
		*)
		    SUMMARY="$SUMMARY, but bsetroot does not seem to be present."
                    ;;
	    esac
            ;;
    esac
cat << EOF
$NAME $VERSION configuration:

  bsetroot:                          $BSETROOT

  reading configuration from:        $CONFIG

  configuration values:

EOF
    case $FULL_BGAPP_MSG in
	*'not found')
	    echo "      fullscreen (ERROR):            $FULL_BGAPP_MSG"
	    ;;
	*)
	    echo "      fullscreen (FULL):             $FULL_MSG"
            ;;
    esac

    echo

    case $TILE_BGAPP_MSG in
	*'not found')
	    echo "      tiled (ERROR):                 $TILE_BGAPP_MSG"
	    ;;
	*)
	    echo "      tiled (TILE):                  $TILE_MSG"
            ;;
    esac

    echo

    case $CENTER_BGAPP_MSG in
	*'not found')
	    echo "      centered (ERROR):              $CENTER_BGAPP_MSG"
	    ;;
	*)
	    echo "      centered (CENTER):             $CENTER_MSG"
            ;;
    esac

    echo

    case $DEFAULT_BGAPP_MSG in
	*'not found')
	    echo "      default (ERROR):               $DEFAULT_BGAPP_MSG"
	    ;;
	*)
	    echo "      default (DEFAULT):             $DEFAULT_MSG"
            ;;
    esac
    echo
    echo "  summary: $SUMMARY"
    exit 0
}


find_app() {
    APP_PATH=`which $1 2>&1`
    case $APP_PATH in
	*/*$1)
	    echo "$NAME: checking for $1... $APP_PATH"
            cat << EOF >> $TMPFILE
### $app
# FULL="$full"
# TILE="$tile"
# CENTER="$center"
# DEFAULT="$default"

EOF
	    FULL=$full
	    TILE=$tile
	    CENTER=$center
	    DEFAULT=$default
	    APP=$app
	    ;;
	*)
	    echo "$NAME: checking for $1... not found."
            ;;
    esac
}

search_xsri() {
    full='xsri --scale-width=100 --scale-width=100'
    tile='xsri --tile'
    center='xsri --center-x --center-y'
    default=$center
    find_app xsri
}

search_display() {
    full='display -geometry 800x600 -window root'
    tile='display -window root'
    center='display -backdrop -window root'
    default=$center
    find_app display
}

search_Esetroot() {
    full='Esetroot -scale'
    tile='Esetroot'
    center='Esetroot -c'
    default=$center
    find_app Esetroot
}

search_wmsetbg() {
    full='wmsetbg -s -S'
    tile='wmsetbg -t'
    center='wmsetbg -e'
    default=$center
    find_app wmsetbg
}

search_xli() {
    case `which xsetbg 2>&1` in
	*/*xsetbg)
	    full='xsetbg -fillscreen'
	    tile='xsetbg'
	    center='xsetbg -center'
	    default=$center
	    app='xsetbg (xli)'
	    find_app xsetbg
	    ;;
	*)
	    case `which xli 2>&1` in
                */*xli)
		    full='xli -fillscreen -onroot -quiet'
		    tile='xli -onroot -quiet'
		    center='xli -center -onroot quiet'
		    default=$center
		    app=xli
		    find_app xli
                    ;;
	    esac
            ;;
    esac
}

search_qiv() {
    full='qiv --root_s'
    tile='qiv --root_t'
    center='qiv --root'
    default=$center
    find_app qiv
}

search_xv() {
    full='xv -max -smooth -root -quit'
    tile='xv -root -quit'
    center='xv -rmode 5 -root -quit'
    default=$center
    find_app xv
}


rm_tmpfiles() {
    [ -f $TMPFILE ] && rm -f $TMPFILE
}


create_config() {
    trap rm_tmpfiles INT QUIT STOP TERM
    case `whoami` in root)
	    if [ ! "$ARGUMENT" = "-r" ]; then
                cat << EOF >&2

$NAME: Running X as root is a security hazard, and is NOT a good idea!
$NAME: If you insist upon having a ~/.fluxbox/bsetbg for root, run bsetbg with
$NAME: the '-r' flag to force its creation. You have been warned!
$NAME: And you will be warned again and again and again. Don't you get it yet?
$NAME: DON'T DO IT!!!
EOF
	        exit 1
	    fi
            ;;
    esac

    case $ARGUMENT in
	-r)
	    echo "$NAME: creating configuration for root (BAD IDEA)..."
	    ;;
	*)
	    echo "$NAME: $CONFIG not found, creating..."
            ;;
    esac

    rm_tmpfiles

    for app in $IMAGE_APPS; do
	search_$app
    done

    if [ -z "$FULL" -o -z "$TILE" -o -z "$CENTER" ]; then
	rm -f $TMPFILE
	unset INFO
        error_msg 3
    fi

    if [ ! -d ${HOME}/.fluxbox ]; then
    	mkdir ${HOME}/.fluxbox
    fi

    cat << EOF > ${CONFIG}

# $CONFIG
#
# Automagically generated with loving care by $NAME $VERSION on `date`
#
# Uncomment the set below that corresponds to your favorite root-image
# application, or mix and match to suit your pleasure.
#
# xli misbehaves under larger screen resolutions when using the -fullscreen
# option. use -fullscreen if your resolution is higher than 1024x768.
#


### $APP
FULL="$FULL"
TILE="$TILE"
CENTER="$CENTER"
DEFAULT="$DEFAULT"

EOF

    grep -v ${APP} ${TMPFILE} >> ${CONFIG}

    rm -f $TMPFILE

    if [ -f $CONFIG ]; then
	echo "$NAME: default configuration was created in $CONFIG."
    else
	echo "ERROR: $CONFIG not found!"
        exit 1
    fi
}

check_config_apps() {
    BGAPP=$1
    APP_PATH=`which $BGAPP 2>&1`
    case ${APP_PATH} in
	*/*$BGAPP)
	    BGAPP_MSG="$APP_PATH"
	    ;;
	*)
	    BGAPP_MSG="$BGAPP: not found"
	    APP_ERROR=`expr $APP_ERROR + 1`
            ;;
    esac
}


check_config_vars() {
    ERROR=0
    APP_ERROR=0

    case $FB_ARG in
	$FULL)
	    if [ -z "$FULL" ]; then
		FULL_MSG="(no value)"
		ERROR=`expr $ERROR + 1`
	    else
		check_config_apps $FULL
		FULL_BGAPP_MSG=$BGAPP_MSG
		FULL_BGAPP=$BGAPP
		FULL_MSG="$FULL"
	    fi
	    ;;
	$TILE)
	    if [ -z "$TILE" ]; then
		TILE_MSG="(no value)"
		ERROR=`expr $ERROR + 1`
	    else
		check_config_apps $TILE
		TILE_BGAPP_MSG=$BGAPP_MSG
		TILE_BGAPP=$BGAPP
		TILE_MSG="$TILE"
	    fi
	    ;;
	$CENTER)
	    if [ -z "$CENTER" ]; then
		CENTER_MSG="(no value)"
		ERROR=`expr $ERROR + 1`
	    else
		check_config_apps $CENTER
		CENTER_BGAPP_MSG=$BGAPP_MSG
		CENTER_BGAPP=$BGAPP
		CENTER_MSG="$CENTER"
	    fi
	    ;;
	*)
	    if [ -z "$DEFAULT" ]; then
		DEFAULT_MSG="(no value)"
		ERROR=`expr $ERROR + 1`
	    else
		check_config_apps $DEFAULT
		DEFAULT_BGAPP_MSG=$BGAPP_MSG
		DEFAULT_BGAPP=$BGAPP
		DEFAULT_MSG="$DEFAULT"
	    fi
	    ;;
    esac
}


final_error_check() {
    case $ARGUMENT in
	*full|-f|c)
	    OPTION=FULL
	    VALUE=$FULL_MSG
	    FB_ARG=$FULL
	    case $FULL_BGAPP_MSG in
                *'not found')
		    APP=$FULL_BGAPP
		    error_msg nobgapp
                    ;;
	    esac
	    ;;
	*tile|-t|t)
	    OPTION=TILE
	    VALUE=$TILE_MSG
	    FB_ARG=$TILE
	    case $TILE_BGAPP_MSG in
                *'not found')
		    APP=$TILE_BGAPP
		    error_msg nobgapp
                    ;;
	    esac
	    ;;
	*center|-c|c)
	    OPTION=CENTER
	    VALUE=$CENTER_MSG
	    FB_ARG=$CENTER
	    case $CENTER_BGAPP_MSG in
                *'not found')
		    APP=$CENTER_BGAPP
		    error_msg nobgapp
                    ;;
	    esac
	    ;;
        *last|-l|l)
            OPTION=DEFAULT
            VALUE=$DEFAULT_MSG
            FB_ARG=$DEFAULT
            ARGUMENT=default
            case $DEFAULT_BGAPP_MSG in
                *'not found')
                    APP=$DEFAULT_BGAPP
                    error_msg nobgapp
                    ;;
            esac
            ;;
	*)
	    OPTION=DEFAULT
	    VALUE=$DEFAULT_MSG
	    FB_ARG=$DEFAULT
	    ARGUMENT=default
	    case $DEFAULT_BGAPP_MSG in
                *'not found')
		    APP=$DEFAULT_BGAPP
		    error_msg nobgapp
                    ;;
	    esac

	    if [ ! "$IMAGE_EXISTS" = yes ]; then
	        error_msg 4; fi
            ;;
    esac

    case $VALUE in
        '(no value)')
            if [ -n "$APP" ]; then
	        error_msg 2
	    else
	        error_msg 1
	    fi
            ;;
    esac
}


check_config() {
    if [ ! -f $CONFIG ]; then
	create_config
    fi

    . $CONFIG
    check_old_config
    final_error_check
    check_config_vars
}


check_image() {
    case "$IMAGE" in
	*~/*)
	    IMAGE="$HOME/`basename $IMAGE`"
            ;;
    esac

    case $NOARG in
	yes|y|1)
	    NUM=4
	    ;;
	*)
	    if [ -n "$IMAGE" ]; then
		NUM=5
	    else
		NUM=6
	    fi
	    case $IMAGE in
                $ARGUMENT|'.'|'./')
	            error_msg 6
                    ;;
	    esac
    esac

    if [ ! -r "$IMAGE" ]; then
	error_msg $NUM
    else
	IMAGE_EXISTS=yes
    fi
}


exec_app() {
    case `which $APP 2>&1` in
	*/*$APP)
	    check_image
	    final_error_check
	    exec $APP $ARGS "$IMAGE"
	    ;;
	*)
	    check_image
	    check_config
	    exec $FB_ARG "$IMAGE"
            ;;
    esac
}


check_bsetroot_args() {
    case $1 in
	-mod)
	    ARGS="$1 $2 $3 $4 $5 $6 $7"
	    ;;
        -gradient)
	    ARGS="$1 $2 $3 $4 $5 $6"
	    ;;
        -solid)
	    ARGS="$1 $2"
            ;;
    esac
}


exec_bsetroot() {
    case `which bsetroot 2>&1` in
        */*bsetroot)
	    exec bsetroot $ARGS
	    ;;
        *)
	    error_msg 7
            ;;
    esac
}


check_old_config() {
    if [ -f $CONFIG ]; then
	if [ -n "$BGAPP"      -o -n "$CENTER_ARGS" -o \
             -n "$TILED_ARGS" -o -n "$OTHER_ARGS"  -o \
             -n "$DEFAULT_ARGS" ]; then
            cat << EOF >&2
This version of $NAME ($VERSION) no longer uses the old configuration format."
Please update $CONFIG with the new syntax:"

CENTER="value"
FULL="value"
TILE="value"
DEFAULT="value"

Look at the sample.config file for details.
EOF
            exit 1
	fi
    fi
}


debug() {
cat << EOF
DEBUG:--------------------------
config:    $CONFIG
full:      $FULL
tile:      $TILE
center:    $CENTER
default:   $DEFAULT
error:     $ERROR
app error: $APP_ERROR
argument:  $ARGUMENT
________________________________
EOF
}

IMAGE_APPS="display Esetroot wmsetbg xv xli qiv xsri"
CONFIG="$HOME/.fluxbox/bsetbg"
LASTIMAGEFILE="$HOME/.fluxbox/bsetbg.lastimage"
NAME=`basename $0`
VERSION=1.13
MORE='(C) 2000 by lordzork industries (http://lordzork.com/)'
PATH=$PATH:/usr/bin:/usr/local/bin:/usr/X11R6/bin:/usr/X11/bin
TMPFILE=$CONFIG.tmp
ARGUMENT=$1

which grep  > /dev/null 2> /dev/null || error_msg nogrep

case $1 in
    *-full|-f|f)
        check_config
        IMAGE=$2
        check_image
        echo -e "full\n$IMAGE" > $LASTIMAGEFILE
        exec $FULL "$IMAGE"
        ;;
    *-tile|*tiled|-t|t)
        check_config
        IMAGE=$2
        check_image
        echo -e "tile\n$IMAGE" > $LASTIMAGEFILE
        exec $TILE "$IMAGE"
        ;;
    *-center|-c|c)
        check_config
        IMAGE=$2
        check_image
        echo -e "center\n$IMAGE" > $LASTIMAGEFILE
        exec $CENTER "$IMAGE"
        ;;
    *-last|-l|l)
        check_config
        LASTACTION="`head -n 1 $LASTIMAGEFILE 2> /dev/null`"
        IMAGE="`tail -n 1 $LASTIMAGEFILE 2> /dev/null`" && check_image
        ACTION=$DEFAULT
        case "$LASTACTION" in
            full)   ACTION=$FULL ;;
            tile)   ACTION=$TILE ;;
            center) ACTION=$CENTER ;;
            *)  echo "Error: $LASTIMAGEFILE is kaputt" >&2
                exit 1
                ;;
        esac
        exec $ACTION "$IMAGE"
        ;;
    *-app|-a|a)
        APP=$2
        ARGS="$3"
        case $# in
            4)
                ARGUMENT=$3
                IMAGE=$4
                exec_app
                ;;
            5)
                COMMAND=`shift && echo $*`
                ARGUMENT=$4
                IMAGE=$5
                exec_app
                ;;
            *)
                error_msg 8
                ;;
        esac
        ;;
    -mod|-gradient|-solid)
        check_bsetroot_args $*
        exec_bsetroot
        ;;
    -display)
        shift 1 && check_bsetroot_args $*
        ARGS="-display $ARGS"
        exec_bsetroot
        ;;
    *-info|-i|i)
        INFO=yes
        check_config
        info_msg
        ;;
    *-version|-v|v)
        cat << EOF

$NAME version $VERSION
$MORE
EOF
        ;;
    *-help|-h|h)
        help_msg
        ;;
    -r)
        case `whoami` in
            root)
                if [ -f $CONFIG ]; then
                    echo 'Error: Config already exists' >&2
                    exit 1
                else
                    create_config
                fi
                ;;
            *)
                echo 'Error: -r is for creating a config for root and your are not root' >&2
                exit 1
        esac
        ;;
    *)
        if [ -n "$1" ]; then
            NOARG=yes
            IMAGE=$1
            check_image
            check_config && final_error_check
            echo -e "default\n$IMAGE" > $LASTIMAGEFILE
            exec $DEFAULT "$1"
        else
            if [ ! -f $CONFIG ]; then
                create_config
            fi
            help_msg
        fi
        ;;
esac