diff options
author | Patrick McDermott <pj@pehjota.net> | 2017-11-07 21:31:00 (EST) |
---|---|---|
committer | Patrick McDermott <pj@pehjota.net> | 2017-11-07 21:31:00 (EST) |
commit | 31695be0e739f0653576d8fd937b885abf32768a (patch) | |
tree | b379f052f453e71bb9539f60fe852f840d394991 /src/config | |
parent | 8bacc543d96508d048694aff7ce1422a35f2700f (diff) | |
download | marquee-31695be0e739f0653576d8fd937b885abf32768a.zip marquee-31695be0e739f0653576d8fd937b885abf32768a.tar.gz marquee-31695be0e739f0653576d8fd937b885abf32768a.tar.bz2 |
mq_profile_launch(): New function
Diffstat (limited to 'src/config')
-rw-r--r-- | src/config/profiles.c | 32 | ||||
-rw-r--r-- | src/config/profiles.h | 3 |
2 files changed, 35 insertions, 0 deletions
diff --git a/src/config/profiles.c b/src/config/profiles.c index a94cb47..9fbba95 100644 --- a/src/config/profiles.c +++ b/src/config/profiles.c @@ -254,3 +254,35 @@ mq_profiles_save(MqProfiles *profiles) return g_key_file_save_to_file(profiles->key_file, profiles->file_name, NULL); } + +gboolean +mq_profile_launch(gchar *profile) +{ + static gchar *program_path = NULL; + gchar *argv[4]; + gboolean success; + GPid child_pid; + + if (!program_path) { +#if defined(RUN_IN_PLACE) && RUN_IN_PLACE + program_path = g_build_filename(ABS_TOP_BUILDDIR, PROGRAM_NAME, + NULL); +#else + program_path = g_build_filename(BINDIR, PROGRAM_NAME, NULL); +#endif + } + + argv[0] = g_strdup(program_path); + argv[1] = g_strdup("-P"); + argv[2] = profile; + argv[3] = NULL; + + success = g_spawn_async(NULL, argv, NULL, G_SPAWN_DEFAULT, NULL, NULL, + &child_pid, NULL); + g_spawn_close_pid(child_pid); + + g_free(argv[0]); + g_free(argv[1]); + + return success; +} diff --git a/src/config/profiles.h b/src/config/profiles.h index 3a9ab91..c75f3b3 100644 --- a/src/config/profiles.h +++ b/src/config/profiles.h @@ -72,6 +72,9 @@ mq_profiles_remove(MqProfiles *profiles, const gchar *profile); gboolean mq_profiles_save(MqProfiles *profiles); +gboolean +mq_profile_launch(gchar *profile); + G_END_DECLS #endif /* MQ_PROFILES_H */ |