Merge lp:~azzar1/update-notifier/xdg-autostart-path-units into lp:update-notifier/ubuntu

Proposed by Andrea Azzarone
Status: Merged
Merged at revision: 926
Proposed branch: lp:~azzar1/update-notifier/xdg-autostart-path-units
Merge into: lp:update-notifier/ubuntu
Diff against target: 262 lines (+150/-4)
10 files modified
.bzrignore (+4/-0)
data/Makefile.am (+5/-1)
data/update-notifier-avhai.desktop.in (+12/-0)
data/update-notifier-crash.desktop.in (+12/-0)
data/update-notifier-livepatch.desktop.in (+12/-0)
data/update-notifier-release.desktop.in (+12/-0)
debian/update-notifier.install (+1/-1)
po/POTFILES.in (+4/-0)
src/update-notifier.c (+86/-2)
src/update-notifier.h (+2/-0)
To merge this branch: bzr merge lp:~azzar1/update-notifier/xdg-autostart-path-units
Reviewer Review Type Date Requested Status
Sebastien Bacher Approve
Review via email: mp+342808@code.launchpad.net

Commit message

Add /etc/xdg/autostart/ desktop files to start systemd path units that require graphical-session.target.

To post a comment you must log in.
Revision history for this message
Sebastien Bacher (seb128) wrote :

Thank you for your work, I didn't review the code changes yet but some comment for translations
- you need to prefix the translatable key with an underscore in the .desktop.in, e.g "_Name="
- you need to list the new files in po/POTFILES.in
- the strings are new in the template so that's going to require a UIFe

Is the systemd code to see if an unit is active copied from somewhere else/a well defined way to get that info or something new you wrote for this specific need? (to know how much checking that part needs)

review: Needs Fixing
924. By Andrea Azzarone

Make Name and Comment translatable.

Revision history for this message
Andrea Azzarone (azzar1) wrote :

> Thank you for your work, I didn't review the code changes yet but some comment
> for translations
> - you need to prefix the translatable key with an underscore in the
> .desktop.in, e.g "_Name="
> - you need to list the new files in po/POTFILES.in
> - the strings are new in the template so that's going to require a UIFe

Done!

>
> Is the systemd code to see if an unit is active copied from somewhere else/a
> well defined way to get that info or something new you wrote for this specific
> need? (to know how much checking that part needs)

I did not copy it.

Revision history for this message
Sebastien Bacher (seb128) wrote :

looks fine now

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file '.bzrignore'
2--- .bzrignore 2009-11-16 17:10:48 +0000
3+++ .bzrignore 2018-04-11 12:48:56 +0000
4@@ -29,3 +29,7 @@
5 src/update-notifier
6 data/update-notifier.desktop
7 data/update-notifier.schemas
8+data/update-notifier-avhai.desktop
9+data/update-notifier-crash.desktop
10+data/update-notifier-livepatch.desktop
11+data/update-notifier-release.desktop
12
13=== modified file 'data/Makefile.am'
14--- data/Makefile.am 2017-09-29 14:37:12 +0000
15+++ data/Makefile.am 2018-04-11 12:48:56 +0000
16@@ -1,7 +1,11 @@
17 @INTLTOOL_DESKTOP_RULE@
18
19 desktopdir = $(sysconfdir)/xdg/autostart
20-desktop_in_files = update-notifier.desktop.in
21+desktop_in_files = update-notifier.desktop.in \
22+ update-notifier-avhai.desktop.in \
23+ update-notifier-crash.desktop.in \
24+ update-notifier-livepatch.desktop.in \
25+ update-notifier-release.desktop.in
26 desktop_DATA = $(desktop_in_files:.desktop.in=.desktop)
27
28 @INTLTOOL_XML_NOMERGE_RULE@
29
30=== added file 'data/update-notifier-avhai.desktop.in'
31--- data/update-notifier-avhai.desktop.in 1970-01-01 00:00:00 +0000
32+++ data/update-notifier-avhai.desktop.in 2018-04-11 12:48:56 +0000
33@@ -0,0 +1,12 @@
34+[Desktop Entry]
35+Encoding=UTF-8
36+_Name=Avhai Disabled Notifier
37+_Comment=Notification regarding avahi disabled due to .local domain
38+Icon=update-notifier
39+Exec=systemctl --user start unicast-local-avahi.path
40+Terminal=false
41+Type=Application
42+Categories=
43+NotShowIn=KDE;
44+NoDisplay=true
45+X-Ubuntu-Gettext-Domain=update-notifier
46\ No newline at end of file
47
48=== added file 'data/update-notifier-crash.desktop.in'
49--- data/update-notifier-crash.desktop.in 1970-01-01 00:00:00 +0000
50+++ data/update-notifier-crash.desktop.in 2018-04-11 12:48:56 +0000
51@@ -0,0 +1,12 @@
52+[Desktop Entry]
53+Encoding=UTF-8
54+_Name=Crash Report Notifier
55+_Comment=Notification regarding a crash report
56+Icon=update-notifier
57+Exec=systemctl --user start update-notifier-crash.path
58+Terminal=false
59+Type=Application
60+Categories=
61+NotShowIn=KDE;
62+NoDisplay=true
63+X-Ubuntu-Gettext-Domain=update-notifier
64\ No newline at end of file
65
66=== added file 'data/update-notifier-livepatch.desktop.in'
67--- data/update-notifier-livepatch.desktop.in 1970-01-01 00:00:00 +0000
68+++ data/update-notifier-livepatch.desktop.in 2018-04-11 12:48:56 +0000
69@@ -0,0 +1,12 @@
70+[Desktop Entry]
71+Encoding=UTF-8
72+_Name=Livepatch Notifier
73+_Comment=Notification regarding Canonical Livepatch
74+Icon=update-notifier
75+Exec=systemctl --user start update-notifier-livepatch.path
76+Terminal=false
77+Type=Application
78+Categories=
79+NotShowIn=KDE;
80+NoDisplay=true
81+X-Ubuntu-Gettext-Domain=update-notifier
82\ No newline at end of file
83
84=== added file 'data/update-notifier-release.desktop.in'
85--- data/update-notifier-release.desktop.in 1970-01-01 00:00:00 +0000
86+++ data/update-notifier-release.desktop.in 2018-04-11 12:48:56 +0000
87@@ -0,0 +1,12 @@
88+[Desktop Entry]
89+Encoding=UTF-8
90+_Name=New Release Notifier
91+_Comment=Notification regarding a new release of Ubuntu
92+Icon=update-notifier
93+Exec=systemctl --user start update-notifier-release.path
94+Terminal=false
95+Type=Application
96+Categories=
97+NotShowIn=KDE;
98+NoDisplay=true
99+X-Ubuntu-Gettext-Domain=update-notifier
100\ No newline at end of file
101
102=== modified file 'debian/update-notifier.install'
103--- debian/update-notifier.install 2017-09-29 14:37:12 +0000
104+++ debian/update-notifier.install 2018-04-11 12:48:56 +0000
105@@ -1,4 +1,4 @@
106-etc/xdg/autostart/update-notifier.desktop
107+etc/xdg/autostart/
108 usr/share/update-notifier/ui/hooks-dialog.ui
109 usr/share/icons/hicolor/16x16/
110 usr/share/icons/hicolor/22x22/
111
112=== modified file 'po/POTFILES.in'
113--- po/POTFILES.in 2017-08-21 17:30:53 +0000
114+++ po/POTFILES.in 2018-04-11 12:48:56 +0000
115@@ -16,6 +16,10 @@
116 [type: gettext/glade]ui/hooks-dialog.ui
117 data/com.ubuntu.update-notifier.gschema.xml.in
118 data/com.ubuntu.update-notifier.policy.in
119+data/update-notifier-avhai.desktop.in
120+data/update-notifier-crash.desktop.in
121+data/update-notifier-livepatch.desktop.in
122+data/update-notifier-release.desktop.in
123 data/update-notifier.desktop.in
124 [type: gettext/rfc822deb] data/package-data-downloads-failed.in
125 [type: gettext/rfc822deb] data/package-data-downloads-failed-permanently.in
126
127=== modified file 'src/update-notifier.c'
128--- src/update-notifier.c 2017-09-06 09:31:58 +0000
129+++ src/update-notifier.c 2018-04-11 12:48:56 +0000
130@@ -201,6 +201,83 @@
131 return TRUE;
132 }
133
134+static void
135+systemd_dbus_init(UpgradeNotifier *un)
136+{
137+ g_autoptr(GDBusConnection) conn = NULL;
138+ g_autoptr(GError) error = NULL;
139+
140+ conn = g_bus_get_sync(G_BUS_TYPE_SESSION, NULL, &error);
141+
142+ if (!conn) {
143+ g_warning("DBUS cannot connect: %s", error->message);
144+ return;
145+ }
146+
147+
148+ un->sm_proxy = g_dbus_proxy_new_sync(conn,
149+ G_DBUS_PROXY_FLAGS_NONE,
150+ NULL,
151+ "org.freedesktop.systemd1",
152+ "/org/freedesktop/systemd1",
153+ "org.freedesktop.systemd1.Manager",
154+ NULL,
155+ &error);
156+
157+ if (!un->sm_proxy) {
158+ g_debug("Could not get DBUS proxy: org.freedesktop.systemd1: %s", error->message);
159+ return;
160+ }
161+}
162+
163+static gboolean
164+is_systemd_unit_active(UpgradeNotifier *un, const gchar* unit)
165+{
166+ GDBusConnection *conn = NULL;
167+ g_autoptr(GVariant) up_variant = NULL;
168+ g_autoptr(GVariant) ret_variant = NULL;
169+ g_autoptr(GVariant) us_variant = NULL;
170+ g_autofree gchar *unit_path = NULL;
171+ g_autofree gchar *unit_state = NULL;
172+ g_autoptr(GError) error = NULL;
173+
174+ g_return_val_if_fail(un != NULL, FALSE);
175+ g_return_val_if_fail(un->sm_proxy != NULL, FALSE);
176+ g_return_val_if_fail(unit != NULL, FALSE);
177+
178+ up_variant = g_dbus_proxy_call_sync(un->sm_proxy,
179+ "GetUnit",
180+ g_variant_new("(s)", unit),
181+ G_DBUS_CALL_FLAGS_NONE,
182+ -1, NULL, &error);
183+
184+ if (!up_variant) {
185+ g_debug("Failed to call GetUnit method: %s", error->message);
186+ return FALSE;
187+ }
188+
189+ conn = g_dbus_proxy_get_connection(un->sm_proxy);
190+
191+ g_variant_get (up_variant, "(o)", &unit_path);
192+ ret_variant = g_dbus_connection_call_sync(conn,
193+ "org.freedesktop.systemd1",
194+ unit_path,
195+ "org.freedesktop.DBus.Properties",
196+ "Get",
197+ g_variant_new("(ss)", "org.freedesktop.systemd1.Unit", "ActiveState"),
198+ G_VARIANT_TYPE("(v)"),
199+ G_DBUS_CALL_FLAGS_NONE,
200+ -1, NULL, &error);
201+
202+ if (!ret_variant) {
203+ g_warning("Failed to get the ActiveState property of %s unit: %s", unit, error->message);
204+ return FALSE;
205+ }
206+
207+ g_variant_get (ret_variant, "(v)", &us_variant);
208+ return g_strcmp0("active", g_variant_get_string(us_variant, NULL)) == 0;
209+}
210+
211 /*
212 the following files change:
213 on "install":
214@@ -377,9 +454,11 @@
215 CRASHREPORT_DIR,
216 NULL};
217 for(i=0;monitor_dirs[i] != NULL;i++) {
218- if (getenv("UPSTART_SESSION") && monitor_dirs[i] == CRASHREPORT_DIR) {
219+ if ((g_strcmp0(CRASHREPORT_DIR, monitor_dirs[i]) == 0) &&
220+ (getenv("UPSTART_SESSION") || is_systemd_unit_active(un, "update-notifier-crash.path"))) {
221 continue;
222 }
223+
224 GError *error = NULL;
225 GFile *gf = g_file_new_for_path(monitor_dirs[i]);
226 monitor_handle = g_file_monitor_directory(gf, 0, NULL, &error);
227@@ -397,9 +476,11 @@
228 UNICAST_LOCAL_AVAHI_FILE,
229 NULL};
230 for(i=0;monitor_files[i] != NULL;i++) {
231- if (getenv("UPSTART_SESSION") && monitor_files[i] == UNICAST_LOCAL_AVAHI_FILE) {
232+ if ((g_strcmp0(UNICAST_LOCAL_AVAHI_FILE, monitor_dirs[i]) == 0) &&
233+ (getenv("UPSTART_SESSION") || is_systemd_unit_active(un, "unicast-local-avahi.path"))) {
234 continue;
235 }
236+
237 GError *error = NULL;
238 GFile *gf = g_file_new_for_path(monitor_files[i]);
239 monitor_handle = g_file_monitor_file(gf, 0, NULL, &error);
240@@ -610,6 +691,9 @@
241 #ifdef ENABLE_SCP
242 uevent_init();
243 #endif
244+ // init systemd dbus proxy
245+ systemd_dbus_init (un);
246+
247 // init gio file monitoring
248 monitor_init (un);
249
250
251=== modified file 'src/update-notifier.h'
252--- src/update-notifier.h 2016-07-20 17:23:40 +0000
253+++ src/update-notifier.h 2018-04-11 12:48:56 +0000
254@@ -90,6 +90,8 @@
255 {
256 GSettings *settings;
257
258+ GDBusProxy *sm_proxy;
259+
260 TrayApplet *update;
261 TrayApplet *hook;
262 TrayApplet *crashreport;

Subscribers

People subscribed via source and target branches

to all changes: