[gnome-session/wip/benzea/systemd-user-switch: 1/16] autostart-app: Add X-GNOME-HiddenUnderSystemd for hiding
- From: Benjamin Berg <bberg src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-session/wip/benzea/systemd-user-switch: 1/16] autostart-app: Add X-GNOME-HiddenUnderSystemd for hiding
- Date: Thu, 1 Aug 2019 13:42:12 +0000 (UTC)
commit 3b73720f2b6e81644949fd9eef16f9752134edc8
Author: Benjamin Berg <bberg redhat com>
Date: Sat Apr 20 00:59:40 2019 +0200
autostart-app: Add X-GNOME-HiddenUnderSystemd for hiding
This way applications can install both a systemd unit and an XDG
autostart file. gnome-session-manager will simply treat any XDG
application with the option set as Hidden and ignore it.
This even hides required applications from gnome-session-manager.
gnome-session/gsm-autostart-app.c | 30 +++++++++++++++++++++++++++++-
gnome-session/gsm-autostart-app.h | 2 ++
gnome-session/gsm-manager.c | 2 +-
3 files changed, 32 insertions(+), 2 deletions(-)
---
diff --git a/gnome-session/gsm-autostart-app.c b/gnome-session/gsm-autostart-app.c
index aa460f5e..01ba5f9a 100644
--- a/gnome-session/gsm-autostart-app.c
+++ b/gnome-session/gsm-autostart-app.c
@@ -56,6 +56,7 @@ enum {
#define GSM_SESSION_CLIENT_DBUS_INTERFACE "org.gnome.SessionClient"
struct _GsmAutostartAppPrivate {
+ gboolean mask_systemd;
char *desktop_filename;
char *desktop_id;
char *startup_id;
@@ -85,7 +86,8 @@ enum {
enum {
PROP_0,
- PROP_DESKTOP_FILENAME
+ PROP_DESKTOP_FILENAME,
+ PROP_MASK_SYSTEMD
};
static guint signals[LAST_SIGNAL] = { 0 };
@@ -138,6 +140,17 @@ is_disabled (GsmApp *app)
return TRUE;
}
+ /* Check if app is systemd enabled and mask-systemd is set. */
+ if (priv->mask_systemd &&
+ g_desktop_app_info_has_key (priv->app_info,
+ GSM_AUTOSTART_APP_SYSTEMD_KEY) &&
+ g_desktop_app_info_get_boolean (priv->app_info,
+ GSM_AUTOSTART_APP_SYSTEMD_KEY)) {
+ g_debug ("app %s is disabled by " GSM_AUTOSTART_APP_SYSTEMD_KEY,
+ gsm_app_peek_id (app));
+ return TRUE;
+ }
+
/* Do not check AutostartCondition - this method is only to determine
if the app is unconditionally disabled */
@@ -656,6 +669,9 @@ gsm_autostart_app_set_property (GObject *object,
case PROP_DESKTOP_FILENAME:
gsm_autostart_app_set_desktop_filename (self, g_value_get_string (value));
break;
+ case PROP_MASK_SYSTEMD:
+ self->priv->mask_systemd = g_value_get_boolean (value);
+ break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
@@ -680,6 +696,9 @@ gsm_autostart_app_get_property (GObject *object,
g_value_set_string (value, NULL);
}
break;
+ case PROP_MASK_SYSTEMD:
+ g_value_set_boolean (value, self->priv->mask_systemd);
+ break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
@@ -1450,6 +1469,13 @@ gsm_autostart_app_class_init (GsmAutostartAppClass *klass)
"Freedesktop .desktop file",
NULL,
G_PARAM_READWRITE | G_PARAM_CONSTRUCT));
+ g_object_class_install_property (object_class,
+ PROP_MASK_SYSTEMD,
+ g_param_spec_boolean ("mask-systemd",
+ "Mask if systemd started",
+ "Mask if GNOME systemd flag is set in desktop
file",
+ FALSE,
+ G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY));
signals[CONDITION_CHANGED] =
g_signal_new ("condition-changed",
G_OBJECT_CLASS_TYPE (object_class),
@@ -1465,9 +1491,11 @@ gsm_autostart_app_class_init (GsmAutostartAppClass *klass)
GsmApp *
gsm_autostart_app_new (const char *desktop_file,
+ gboolean mask_systemd,
GError **error)
{
return (GsmApp*) g_initable_new (GSM_TYPE_AUTOSTART_APP, NULL, error,
"desktop-filename", desktop_file,
+ "mask-systemd", mask_systemd,
NULL);
}
diff --git a/gnome-session/gsm-autostart-app.h b/gnome-session/gsm-autostart-app.h
index a4cd9af1..17faf75f 100644
--- a/gnome-session/gsm-autostart-app.h
+++ b/gnome-session/gsm-autostart-app.h
@@ -56,11 +56,13 @@ struct _GsmAutostartAppClass
GType gsm_autostart_app_get_type (void) G_GNUC_CONST;
GsmApp *gsm_autostart_app_new (const char *desktop_file,
+ gboolean mask_systemd,
GError **error);
void gsm_autostart_app_add_provides (GsmAutostartApp *aapp,
const char *provides);
+#define GSM_AUTOSTART_APP_SYSTEMD_KEY "X-GNOME-HiddenUnderSystemd"
#define GSM_AUTOSTART_APP_ENABLED_KEY "X-GNOME-Autostart-enabled"
#define GSM_AUTOSTART_APP_PHASE_KEY "X-GNOME-Autostart-Phase"
#define GSM_AUTOSTART_APP_PROVIDES_KEY "X-GNOME-Provides"
diff --git a/gnome-session/gsm-manager.c b/gnome-session/gsm-manager.c
index 6eeea4a6..aef0a74d 100644
--- a/gnome-session/gsm-manager.c
+++ b/gnome-session/gsm-manager.c
@@ -3542,7 +3542,7 @@ add_autostart_app_internal (GsmManager *manager,
}
}
- app = gsm_autostart_app_new (path, &error);
+ app = gsm_autostart_app_new (path, FALSE, &error);
if (app == NULL) {
g_warning ("%s", error->message);
g_clear_error (&error);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]