1 /* Copyright (C) 2011 Edward Der-Hua Liu, Hsin-Chu, Taiwan
2 *
3 * This library is free software; you can redistribute it and/or
4 * modify it under the terms of the GNU Lesser General Public
5 * License as published by the Free Software Foundation version 2.1
6 * of the License.
7 *
8 * This library is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 * Lesser General Public License for more details.
12 *
13 * You should have received a copy of the GNU Lesser General Public
14 * License along with this library; if not, write to the Free Software
15 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
16 */
17
18 /**
19 @file hime-exec-script.c
20 @brief Create default settings in $HOME
21
22 mkdir -p $HOME/.config/hime/config
23 cp {essential files} to $HOME/.config/hime
24
25 */
26
27 #include <stdio.h>
28 #include <stdlib.h>
29
30 #include <pwd.h>
31
32 #include "hime.h"
33
exec_script(char * name)34 static void exec_script (char *name) {
35 char scr[512];
36 snprintf (scr, sizeof (scr), HIME_SCRIPT_DIR "/%s", name);
37 dbg ("do %s\n", scr);
38 system (scr);
39 }
40
exec_setup_scripts()41 void exec_setup_scripts () {
42 /* Workaround to prevent hime-setup segfault, when hime/config/ is not exist.
43 */
44 struct passwd *pw = getpwuid (getuid ());
45 char hime_conf_dir[512];
46 g_snprintf (hime_conf_dir, sizeof (hime_conf_dir), "mkdir -p %s/.config/hime/config", pw->pw_dir);
47 dbg ("do %s\n", hime_conf_dir);
48 system (hime_conf_dir);
49 exec_script ("hime-user-setup " HIME_TABLE_DIR " " HIME_BIN_DIR);
50 }
51