Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

auto-start m-n-d with session #214

Merged
merged 3 commits into from
Aug 9, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -284,6 +284,7 @@ AM_CONDITIONAL([ICON_UPDATE], [test -n "$UPDATE_ICON_CACHE"])
AC_CONFIG_FILES([
Makefile
data/Makefile
data/mate-notification-daemon.desktop.in
data/org.freedesktop.mate.Notifications.service
data/org.mate.applets.MateNotificationApplet.desktop.in
data/org.mate.NotificationDaemon.gschema.xml
Expand Down
13 changes: 13 additions & 0 deletions data/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,17 @@ servicedir = $(DBUS_SERVICES_DIR)
service_DATA = org.freedesktop.mate.Notifications.service org.mate.panel.applet.MateNotificationAppletFactory.service
service_in_files = $(service_DATA:=.in)

autostartdir = $(sysconfdir)/xdg/autostart
autostart_in_files = mate-notification-daemon.desktop.in
autostart_DATA = $(autostart_in_files:.desktop.in=.desktop)

$(autostart_DATA): $(autostart_in_files)
if USE_NLS
$(AM_V_GEN) $(MSGFMT) --desktop --template $< -d $(top_srcdir)/po -o $@
else
$(AM_V_GEN) sed '/^# Translators/d' < $< > $@
endif

appletdir = $(datadir)/mate-panel/applets
applet_DATA = org.mate.applets.MateNotificationApplet.mate-panel-applet
applet_in_files = $(applet_DATA:.mate-panel-applet=.desktop.in)
Expand Down Expand Up @@ -43,6 +54,7 @@ gsettingsschema_in_files = $(gsettings_SCHEMAS:=.in)
@GSETTINGS_RULES@

EXTRA_DIST = \
$(autostart_in_files) \
$(desktop_in_files) \
$(gsettingsschema_in_files) \
$(icon16_DATA) \
Expand All @@ -53,6 +65,7 @@ EXTRA_DIST = \
$(iconscalable_DATA)

CLEANFILES = \
$(autostart_DATA) \
$(applet_DATA) \
$(desktop_DATA) \
$(gsettings_SCHEMAS)
Expand Down
14 changes: 14 additions & 0 deletions data/mate-notification-daemon.desktop.in.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
[Desktop Entry]
Name=MATE Notification Daemon
Comment=Display notifications
Exec=@LIBEXECDIR@/mate-notification-daemon
Terminal=false
Type=Application
OnlyShowIn=MATE;
NoDisplay=true
X-MATE-Autostart-Phase=Application
X-MATE-Autostart-Notify=true
X-MATE-Bugzilla-Bugzilla=MATE
X-MATE-Bugzilla-Product=mate-notification-daemon
X-MATE-Bugzilla-Component=general
X-MATE-Bugzilla-Version=@VERSION@
2 changes: 1 addition & 1 deletion data/org.freedesktop.mate.Notifications.service.in
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
[D-BUS Service]
Name=org.freedesktop.Notifications
Exec=@LIBEXECDIR@/mate-notification-daemon
Exec=@LIBEXECDIR@/mate-notification-daemon --idle-exit
AssumedAppArmorLabel=unconfined
22 changes: 20 additions & 2 deletions src/daemon/daemon.c
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@
enum {
PROP_0,
PROP_REPLACE,
PROP_IDLE_EXIT,
LAST_PROP
};

Expand Down Expand Up @@ -119,6 +120,7 @@ struct _NotifyDaemon {
NotifyDaemonNotifications *skeleton;
guint bus_name_id;
gboolean replace;
gboolean idle_exit;

NotifyStackLocation stack_location;
NotifyScreen* screen;
Expand Down Expand Up @@ -220,6 +222,9 @@ static void notify_daemon_set_property (GObject *object,
case PROP_REPLACE:
daemon->replace = g_value_get_boolean (value);
break;
case PROP_IDLE_EXIT:
daemon->idle_exit = g_value_get_boolean (value);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
Expand All @@ -237,6 +242,12 @@ static void notify_daemon_class_init(NotifyDaemonClass* daemon_class)
g_param_spec_boolean ("replace", "replace", "replace", FALSE,
G_PARAM_CONSTRUCT_ONLY | G_PARAM_WRITABLE |
G_PARAM_STATIC_STRINGS);
properties[PROP_IDLE_EXIT] =
g_param_spec_boolean ("idle-exit", "idle-exit",
"Whether to exit when idle", FALSE,
G_PARAM_CONSTRUCT_ONLY |
G_PARAM_WRITABLE |
G_PARAM_STATIC_STRINGS);

g_object_class_install_properties (object_class, LAST_PROP, properties);
}
Expand All @@ -263,6 +274,9 @@ static void add_exit_timeout(NotifyDaemon* daemon)
{
g_assert (daemon != NULL);

if (! daemon->idle_exit)
return;

if (daemon->exit_timeout_source > 0)
return;

Expand Down Expand Up @@ -1126,6 +1140,7 @@ static gboolean screensaver_active(GtkWidget* nw)
if (proxy == NULL) {
g_warning("Failed to get dbus connection: %s", error->message);
g_error_free (error);
return active;
}

variant = g_dbus_proxy_call_sync (proxy,
Expand Down Expand Up @@ -1690,7 +1705,10 @@ static gboolean notify_daemon_get_server_information (NotifyDaemonNotifications
return TRUE;
}

NotifyDaemon* notify_daemon_new (gboolean replace)
NotifyDaemon* notify_daemon_new (gboolean replace, gboolean idle_exit)
{
return g_object_new (NOTIFY_TYPE_DAEMON, "replace", replace, NULL);
return g_object_new (NOTIFY_TYPE_DAEMON,
"replace", replace,
"idle-exit", idle_exit,
NULL);
}
3 changes: 2 additions & 1 deletion src/daemon/daemon.h
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,8 @@ typedef enum {

G_BEGIN_DECLS

NotifyDaemon* notify_daemon_new (gboolean replace);
NotifyDaemon* notify_daemon_new (gboolean replace,
gboolean idle_exit);

GQuark notify_daemon_error_quark(void);

Expand Down
9 changes: 8 additions & 1 deletion src/daemon/mnd-daemon.c
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@

static gboolean debug = FALSE;
static gboolean replace = FALSE;
static gboolean idle_exit = FALSE;

static GOptionEntry entries[] =
{
Expand All @@ -46,6 +47,12 @@ static GOptionEntry entries[] =
"Replace a currently running application",
NULL
},
{
"idle-exit", 'i', G_OPTION_FLAG_NONE,
G_OPTION_ARG_NONE, &idle_exit,
"Auto-exit when idle, useful if run through D-Bus activation",
NULL
},
{
NULL, 0, 0, G_OPTION_ARG_NONE, NULL, NULL, NULL
}
Expand Down Expand Up @@ -95,7 +102,7 @@ int main (int argc, char *argv[])
if (!parse_arguments (&argc, &argv))
return EXIT_FAILURE;

daemon = notify_daemon_new (replace);
daemon = notify_daemon_new (replace, idle_exit);

gtk_main();

Expand Down