From 31695be0e739f0653576d8fd937b885abf32768a Mon Sep 17 00:00:00 2001 From: Patrick McDermott Date: Tue, 07 Nov 2017 21:31:00 -0500 Subject: mq_profile_launch(): New function --- 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 */ -- cgit v0.9.1