From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp0 ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms11 with LMTPS id lubzOfPdoV9QKwAA0tVLHw (envelope-from ) for ; Tue, 03 Nov 2020 22:47:15 +0000 Received: from aspmx1.migadu.com ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp0 with LMTPS id iGEsNfPdoV/9PQAA1q6Kng (envelope-from ) for ; Tue, 03 Nov 2020 22:47:15 +0000 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by aspmx1.migadu.com (Postfix) with ESMTPS id 1B6A09403A6 for ; Tue, 3 Nov 2020 22:47:15 +0000 (UTC) Received: from localhost ([::1]:60790 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ka556-0004f3-F6 for larch@yhetil.org; Tue, 03 Nov 2020 17:47:12 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:45432) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ka54x-0004ee-3s for bug-guix@gnu.org; Tue, 03 Nov 2020 17:47:03 -0500 Received: from debbugs.gnu.org ([209.51.188.43]:35193) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1ka54w-0008J0-Kb for bug-guix@gnu.org; Tue, 03 Nov 2020 17:47:02 -0500 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1ka54w-00027L-A9 for bug-guix@gnu.org; Tue, 03 Nov 2020 17:47:02 -0500 X-Loop: help-debbugs@gnu.org Subject: bug#36376: Application menu of desktop environment not automatically updated Resent-From: Ludovic =?UTF-8?Q?Court=C3=A8s?= Original-Sender: "Debbugs-submit" Resent-CC: bug-guix@gnu.org Resent-Date: Tue, 03 Nov 2020 22:47:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 36376 X-GNU-PR-Package: guix X-GNU-PR-Keywords: To: 36376@debbugs.gnu.org Received: via spool by 36376-submit@debbugs.gnu.org id=B36376.16044435858092 (code B ref 36376); Tue, 03 Nov 2020 22:47:02 +0000 Received: (at 36376) by debbugs.gnu.org; 3 Nov 2020 22:46:25 +0000 Received: from localhost ([127.0.0.1]:46739 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ka54L-00026S-6n for submit@debbugs.gnu.org; Tue, 03 Nov 2020 17:46:25 -0500 Received: from eggs.gnu.org ([209.51.188.92]:45196) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ka54J-00026F-CG for 36376@debbugs.gnu.org; Tue, 03 Nov 2020 17:46:23 -0500 Received: from fencepost.gnu.org ([2001:470:142:3::e]:54087) by eggs.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ka54C-0008FC-Iv; Tue, 03 Nov 2020 17:46:16 -0500 Received: from [2a01:e0a:1d:7270:af76:b9b:ca24:c465] (port=33372 helo=ribbon) by fencepost.gnu.org with esmtpsa (TLS1.2:RSA_AES_256_CBC_SHA1:256) (Exim 4.82) (envelope-from ) id 1ka54C-0003FV-5a; Tue, 03 Nov 2020 17:46:16 -0500 From: Ludovic =?UTF-8?Q?Court=C3=A8s?= References: <871rzhn483.fsf@gnu.org> Date: Tue, 03 Nov 2020 23:46:13 +0100 In-Reply-To: <871rzhn483.fsf@gnu.org> ("Ludovic =?UTF-8?Q?Court=C3=A8s?="'s message of "Tue, 25 Jun 2019 16:12:44 +0200") Message-ID: <87o8keawju.fsf@gnu.org> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.1 (gnu/linux) MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" X-Spam-Score: -2.3 (--) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-Spam-Score: -3.3 (---) X-BeenThere: bug-guix@gnu.org List-Id: Bug reports for GNU Guix List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Leo Prikler , Maxim Cournoyer Errors-To: bug-guix-bounces+larch=yhetil.org@gnu.org Sender: "bug-Guix" X-Scanner: ns3122888.ip-94-23-21.eu Authentication-Results: aspmx1.migadu.com; dkim=none; dmarc=pass (policy=none) header.from=gnu.org; spf=pass (aspmx1.migadu.com: domain of bug-guix-bounces@gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=bug-guix-bounces@gnu.org X-Spam-Score: -1.51 X-TUID: 3YiooQkukQK1 --=-=-= Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Ludovic Court=C3=A8s skribis: > This is not news to us, but as > notes, the > application menu of desktop environments is not automatically updated > when a package is installed or removed. It=E2=80=99d be great if we could > somehow notify the desktop environment. We=E2=80=99ve investigated today on IRC with Maxim and Leo P. and here=E2= =80=99s the summary of our findings: =E2=80=A2 GNOME Shell, in =E2=80=98appDisplay.js=E2=80=99, =E2=80=9Cliste= ns=E2=80=9D to the =E2=80=98installed-changed=E2=80=99 GLib signals and uses that to rebui= ld its application menu. =E2=80=A2 In =E2=80=98shell-app-system.c=E2=80=99, =E2=80=98installed-cha= nged=E2=80=99 is emitted when the GAppInfoMonitor emits =E2=80=98changed=E2=80=99: monitor =3D g_app_info_monitor_get (); g_signal_connect (monitor, "changed", G_CALLBACK (installed_changed),= self); installed_changed (monitor, self); =E2=80=A2 GLib emits the =E2=80=98changed=E2=80=99 signal when =E2=80=98g= _app_info_monitor_fire=E2=80=99 is called from =E2=80=98desktop_file_dir_changed=E2=80=99, itself called w= hen one of the directories in $XDG_DATA_DIRS (among others) changes. It uses =E2=80=98GFileMonitor=E2=80=99 under the hood, which is essentially ino= tify. The GLib patch below is an attempt to monitor ~/.guix-profile and to treat changes to that symlink as if they were changes to ~/.guix-profile/share/applications (which contains =E2=80=98.desktop=E2=80= =99 files.) It actually builds but I haven=E2=80=99t tested it yet. :-) WDYT? If we take that route, we could add a =E2=80=98replacement=E2=80=99 for GLi= b. Thanks, Ludo=E2=80=99. --=-=-= Content-Type: text/x-patch Content-Disposition: inline diff --git a/gio/gdesktopappinfo.c b/gio/gdesktopappinfo.c index f1e2fdd..96dcc32 100644 --- a/gio/gdesktopappinfo.c +++ b/gio/gdesktopappinfo.c @@ -161,6 +161,7 @@ static DesktopFileDir *desktop_file_dir_user_config = NULL; /* (owned) */ static DesktopFileDir *desktop_file_dir_user_data = NULL; /* (owned) */ static GMutex desktop_file_dir_lock; static const gchar *gio_launch_desktop_path = NULL; +static GFileMonitor *guix_profile_monitor = NULL; /* Monitor 'changed' signal handler {{{2 */ static void desktop_file_dir_reset (DesktopFileDir *dir); @@ -230,6 +231,22 @@ desktop_file_dir_get_alternative_dir (DesktopFileDir *dir) return parent; } +static void +guix_profile_changed (GFileMonitor *monitor, + GFile *file, + GFile *other_file, + GFileMonitorEvent event_type, + gpointer user_data) +{ + DesktopFileDir *dir = user_data; + + desktop_file_dir_reset (dir); + + /* When ~/.guix-profile changes, emit the 'changed' signal so everyone + knows. */ + g_app_info_monitor_fire (); +} + static void desktop_file_dir_changed (GFileMonitor *monitor, GFile *file, @@ -1531,6 +1548,7 @@ desktop_file_dirs_lock (void) if (desktop_file_dirs == NULL || desktop_file_dirs->len == 0) { + const gchar *home; const char * const *dirs; gint i; @@ -1555,6 +1573,27 @@ desktop_file_dirs_lock (void) for (i = 0; dirs[i]; i++) g_ptr_array_add (desktop_file_dirs, desktop_file_dir_new (dirs[i])); + home = g_get_home_dir (); + if (guix_profile_monitor == NULL && home != NULL) + { + DesktopFileDir *dir; + const gchar *profile, *data_dir; + profile = g_build_filename (home, ".guix-profile", NULL); + data_dir = g_build_filename (profile, "share", NULL); + dir = desktop_file_dir_new (data_dir); + + /* Monitor ~/.guix-profile and treat modifications to + ~/.guix-profile as if they were modifications to + ~/.guix-profile/share. */ + guix_profile_monitor = + g_local_file_monitor_new_in_worker (profile, FALSE, G_FILE_MONITOR_NONE, + guix_profile_changed, + desktop_file_dir_ref (dir), + closure_notify_cb, NULL); + + g_ptr_array_add (desktop_file_dirs, desktop_file_dir_ref (dir)); + } + /* The list of directories will never change after this, unless * g_get_user_config_dir() changes due to %G_TEST_OPTION_ISOLATE_DIRS. */ desktop_file_dirs_config_dir = user_config_dir; --=-=-=--