I want to write lirc plugin for totem (linux video application) and one of option of this lirc plugin is to toggle between “totem” and another video application (“vlc” or “mplayer”)
Part of code which execute lirc command:
if (strcasecmp (cmd, "video") == 0)
{
gchar **argv;
exit_totem();
g_shell_parse_argv ("vlc", NULL, &argv, NULL);
g_spawn_async (NULL, argv, NULL, G_SPAWN_SEARCH_PATH, NULL, NULL, NULL, NULL);
g_strfreev (argv);
}
For this command I want to assign only one value “video” (example lircrc file configuration):
begin
prog = totem
button = MEDIA
config = video
end
Problem:
How to make lirc plugin to execute “vlc” or “mplayer” if one of this is installed.
Behavior:
Press button MEDIA on remote, if vlc is installed plugin to execute vlc otherwise if mplayer is installed plugin to execute mplayer and if none of them are not installed, plugin to do nothing.
In pseudo code that does not know to solve it:
if (strcasecmp (cmd, "video") == 0)
{
if (vlc installed)
------------------
gchar **argv;
exit_totem();
g_shell_parse_argv ("vlc", NULL, &argv, NULL);
g_spawn_async (NULL, argv, NULL, G_SPAWN_SEARCH_PATH, NULL, NULL, NULL, NULL);
g_strfreev (argv);
else (mplayer installed)
------------------------
gchar **argv;
exit_totem();
g_shell_parse_argv ("mplayer", NULL, &argv, NULL);
g_spawn_async (NULL, argv, NULL, G_SPAWN_SEARCH_PATH, NULL, NULL, NULL, NULL);
g_strfreev (argv);
}
Thanks and regards,
GEO
Wouldn’t you just call something like:
For a more detailed example using IO Channels for reading output instead of just
g_str_has_suffixsee Spawning processes using glib.