2 * util.c - The core of splash_util
4 * Copyright (C) 2004-2007 Michal Januszewski <spock@gentoo.org>
6 * This file is subject to the terms and conditions of the GNU General Public
7 * License v2. See the file COPYING in the main directory of this archive for
15 #include <sys/types.h>
21 #include <sys/ioctl.h>
29 static struct option options
[] = {
30 { "cmd", required_argument
, NULL
, 0x102 },
31 { "mode", required_argument
, NULL
, 0x100 },
32 #ifdef CONFIG_DEPRECATED
33 { "theme", required_argument
, NULL
, 0x103 },
34 { "progress",required_argument
, NULL
, 0x105 },
35 { "type", required_argument
, NULL
, 0x10d },
37 { "mesg", required_argument
, NULL
, 0x109 },
40 { "help", no_argument
, NULL
, 'h'},
41 { "verbose", no_argument
, NULL
, 'v'},
42 { "quiet", no_argument
, NULL
, 'q'},
45 enum { none
, getres
, paint
, setmode
, getmode
, repaint
} arg_task
;
52 static struct cmd cmds
[] = {
53 #ifdef CONFIG_DEPRECATED
55 { "repaint", repaint
},
57 { "setmode", setmode
},
58 { "getmode", getmode
},
65 "splash_util/splashutils-" PACKAGE_VERSION
"\n"
66 "Usage: splash_util [options] -c <cmd>\n\n"
68 #ifdef CONFIG_DEPRECATED
69 " paint paint the background picture\n"
70 " repaint paint the whole background picture (full refresh)\n"
72 " setmode set global splash mode\n"
73 " getmode get global splash mode\n"
74 " getres get the resolution which the silent splash will use\n\n"
76 " -c, --cmd=CMD execute command CMD\n"
77 " -v, --verbose display verbose error messages\n"
78 " -q, --quiet don't display any messages\n"
79 " -h, --help show this help message\n"
80 " -t, --theme=THEME use theme THEME\n"
81 " -m, --mode=(v|s) set silent (s) or verbose (v) mode\n"
82 #ifdef CONFIG_DEPRECATED
83 " -p, --progress=NUM set progress to NUM/65535 * 100%%\n"
85 " --mesg=TEXT use TEXT as the main splash message\n"
87 " --type=TYPE TYPE can be: bootup, reboot, shutdown\n"
92 int util_main(int argc
, char **argv
)
96 stheme_t
*theme
= NULL
;
98 fbsplash_lib_init(fbspl_bootup
);
99 fbsplashr_init(false);
104 config
.reqmode
= FBSPL_MODE_SILENT
;
106 while ((c
= getopt_long(argc
, argv
, "c:t:m:p:hvq", options
, NULL
)) != EOF
) {
115 if (optarg
[0] == 'v')
116 config
.reqmode
= FBSPL_MODE_VERBOSE
;
121 fbsplash_acc_theme_set(optarg
);
126 for (i
= 0; i
< sizeof(cmds
) / sizeof(struct cmd
); i
++) {
127 if (!strcmp(optarg
, cmds
[i
].name
)) {
128 arg_task
= cmds
[i
].value
;
136 config
.progress
= atoi(optarg
);
142 free(config
.message
);
143 config
.message
= strdup(optarg
);
147 if (!strcmp(optarg
, "reboot"))
148 config
.type
= fbspl_reboot
;
149 else if (!strcmp(optarg
, "shutdown"))
150 config
.type
= fbspl_shutdown
;
152 config
.type
= fbspl_bootup
;
155 /* Verbosity level adjustment. */
157 config
.verbosity
= FBSPL_VERB_QUIET
;
161 config
.verbosity
= FBSPL_VERB_HIGH
;
166 if (arg_task
== none
) {
172 /* Only load the theme if it will actually be used. */
173 #ifdef CONFIG_DEPRECATED
177 theme
= fbsplashr_theme_load();
184 if (arg_task
!= setmode
&& arg_vc
== -1)
191 int xres
= fbd
.var
.xres
;
192 int yres
= fbd
.var
.yres
;
193 fbsplash_get_res(config
.theme
, &xres
, &yres
);
194 printf("%dx%d\n", xres
, yres
);
199 if (config
.reqmode
& FBSPL_MODE_SILENT
) {
200 fbsplashr_tty_silent_init(true);
201 fbsplash_set_silent();
203 fbsplashr_tty_silent_cleanup();
204 fbsplash_set_verbose(0);
209 printf("%s\n", fbsplash_is_silent() ? "silent" : "verbose");
212 #ifdef CONFIG_DEPRECATED
213 /* Deprecated. The daemon mode should be used instead. */
215 fbsplashr_render_screen(theme
, false, false, FBSPL_EFF_NONE
);
219 fbsplashr_render_screen(theme
, true, false, FBSPL_EFF_NONE
);
221 #endif /* CONFIG_DEPRECATED */
227 fbsplashr_theme_free(theme
);
229 fbsplash_lib_cleanup();
233 #ifndef UNIFIED_BUILD
234 int main(int argc
, char **argv
)
236 return util_main(argc
, argv
);