Spawn

Spawn — spawn a command with startup notification

Stability Level

Stable, unless otherwise indicated

Functions

Includes

#include <libxfce4ui/libxfce4ui.h>

Description

Functions to spawn a command with startup notification support.

Functions

xfce_spawn_on_screen_with_child_watch ()

gboolean
xfce_spawn_on_screen_with_child_watch (GdkScreen *screen,
                                       const gchar *working_directory,
                                       gchar **argv,
                                       gchar **envp,
                                       GSpawnFlags flags,
                                       gboolean startup_notify,
                                       guint32 startup_timestamp,
                                       const gchar *startup_icon_name,
                                       GClosure *child_watch_closure,
                                       GError **error);

Like xfce_spawn_on_screen(), but allows to attach a closure to watch the child's exit status. This because only one g_child_watch_add() is allowed on Unix (per PID) and this is already internally needed for a proper startup notification implementation.

Example 2. Spawning with a child watch

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
static void
child_watch_callback (GObject *object,
                      gint     status)
{
  g_message ("Child exit status is %d", status);
}

static void
spawn_something (void)
{
  GClosure *child_watch;

  child_watch = g_cclosure_new_swap (G_CALLBACK (child_watch_callback),
                                     object, NULL);
  xfce_spawn_on_screen_with_child_watch (...,
                                         child_watch,
                                         ...);
}

Parameters

screen

a GdkScreen or NULL to use the active screen, see xfce_gdk_screen_get_active().

[nullable]

working_directory

child's current working directory or NULL to inherit parent's.

[nullable]

argv

child's argument vector.

 

envp

child's environment vector or NULL to inherit parent's.

[nullable]

flags

flags from GSpawnFlags. G_SPAWN_DO_NOT_REAP_CHILD is not allowed, you should use the child_watch_closure for this.

 

startup_notify

whether to use startup notification.

 

startup_timestamp

the timestamp to pass to startup notification, use the event time here if possible to make focus stealing prevention work property. If you don't have direct access to the event time you could use gtk_get_current_event_time() or if nothing is available 0 is valid too.

 

startup_icon_name

application icon or NULL.

[nullable]

child_watch_closure

closure that is triggered when the child exists or NULL.

[nullable]

error

return location for errors or NULL.

[out][nullable][transfer full]

Returns

TRUE on success, FALSE if error is set.


xfce_spawn_on_screen ()

gboolean
xfce_spawn_on_screen (GdkScreen *screen,
                      const gchar *working_directory,
                      gchar **argv,
                      gchar **envp,
                      GSpawnFlags flags,
                      gboolean startup_notify,
                      guint32 startup_timestamp,
                      const gchar *startup_icon_name,
                      GError **error);

xfce_spawn_on_screen has been deprecated since version 4.16 and should not be used in newly-written code.

Use xfce_spawn instead.

Like gdk_spawn_on_screen() (GDK 2), but also supports startup notification (if Libxfce4ui was built with startup notification support).

Parameters

screen

a GdkScreen or NULL to use the active screen, see xfce_gdk_screen_get_active().

[nullable]

working_directory

child's current working directory or NULL to inherit parent's.

[nullable]

argv

child's argument vector.

 

envp

child's environment vector or NULL to inherit parent's.

[nullable]

flags

flags from GSpawnFlags. G_SPAWN_DO_NOT_REAP_CHILD is not allowed, use xfce_spawn_on_screen_with_child_watch() if you want a child watch.

 

startup_notify

whether to use startup notification.

 

startup_timestamp

the timestamp to pass to startup notification, use the event time here if possible to make focus stealing prevention work property. If you don't have direct access to the event time you could use gtk_get_current_event_time() or if nothing is available 0 is valid too.

 

startup_icon_name

application icon or NULL.

[nullable]

error

return location for errors or NULL.

[out][nullable][transfer full]

Returns

TRUE on success, FALSE if error is set.


xfce_spawn ()

gboolean
xfce_spawn (GdkScreen *screen,
            const gchar *working_directory,
            gchar **argv,
            gchar **envp,
            GSpawnFlags flags,
            gboolean startup_notify,
            guint32 startup_timestamp,
            const gchar *startup_icon_name,
            gboolean child_process,
            GError **error);

Like gdk_spawn_on_screen() (GDK 2), but also supports startup notification (if Libxfce4ui was built with startup notification support).

Parameters

screen

a GdkScreen or NULL to use the active screen, see xfce_gdk_screen_get_active().

[nullable]

working_directory

child's current working directory or NULL to inherit parent's.

[nullable]

argv

child's argument vector.

 

envp

child's environment vector or NULL to inherit parent's.

[nullable]

flags

flags from GSpawnFlags. G_SPAWN_DO_NOT_REAP_CHILD is not allowed, use xfce_spawn_on_screen_with_child_watch() if you want a child watch.

 

startup_notify

whether to use startup notification.

 

startup_timestamp

the timestamp to pass to startup notification, use the event time here if possible to make focus stealing prevention work property. If you don't have direct access to the event time you could use gtk_get_current_event_time() or if nothing is available 0 is valid too.

 

startup_icon_name

application icon or NULL.

[nullable]

child_process

TRUE if the process should be a child process, FALSE if it should be reparented to init.

 

error

return location for errors or NULL.

[out][nullable][transfer full]

Returns

TRUE on success, FALSE if error is set.

Since: 4.16


xfce_spawn_command_line_on_screen ()

gboolean
xfce_spawn_command_line_on_screen (GdkScreen *screen,
                                   const gchar *command_line,
                                   gboolean in_terminal,
                                   gboolean startup_notify,
                                   GError **error);

xfce_spawn_command_line_on_screen has been deprecated since version 4.16 and should not be used in newly-written code.

Use xfce_spawn_command_line instead.

Executes the given command_line and returns TRUE if the command terminated successfully. Else, the error is set to the standard error output.

Parameters

screen

a GdkScreen or NULL to use the active screen, see xfce_gdk_screen_get_active().

[nullable]

command_line

command line to run.

 

in_terminal

whether to run command_line in a terminal.

 

startup_notify

whether to use startup notification.

 

error

location for a GError or NULL.

[out][nullable][transfer full]

Returns

TRUE if the command_line was executed successfully, FALSE if error is set.


xfce_spawn_command_line ()

gboolean
xfce_spawn_command_line (GdkScreen *screen,
                         const gchar *command_line,
                         gboolean in_terminal,
                         gboolean startup_notify,
                         gboolean child_process,
                         GError **error);

Executes the given command_line and returns TRUE if the command terminated successfully. Else, the error is set to the standard error output.

Parameters

screen

a GdkScreen or NULL to use the active screen, see xfce_gdk_screen_get_active().

[nullable]

command_line

command line to run.

 

in_terminal

whether to run command_line in a terminal.

 

startup_notify

whether to use startup notification.

 

child_process

TRUE if the process should be a child process, FALSE if it should be reparented to init.

 

error

location for a GError or NULL.

[out][nullable][transfer full]

Returns

TRUE if the command_line was executed successfully, FALSE if error is set.

Since: 4.16