From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp2 ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms11 with LMTPS id EhgyK2NYs18aYQAA0tVLHw (envelope-from ) for ; Tue, 17 Nov 2020 04:58:11 +0000 Received: from aspmx1.migadu.com ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp2 with LMTPS id GHOUJmNYs191MwAAB5/wlQ (envelope-from ) for ; Tue, 17 Nov 2020 04:58:11 +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 1E03A940222 for ; Tue, 17 Nov 2020 04:58:11 +0000 (UTC) Received: from localhost ([::1]:43142 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ket4D-0006H7-PI for larch@yhetil.org; Mon, 16 Nov 2020 23:58:09 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:50426) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ket46-0006Gq-9z for bug-guix@gnu.org; Mon, 16 Nov 2020 23:58:02 -0500 Received: from debbugs.gnu.org ([209.51.188.43]:46497) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1ket45-0004iN-Tj for bug-guix@gnu.org; Mon, 16 Nov 2020 23:58:02 -0500 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1ket45-0004vB-Qh for bug-guix@gnu.org; Mon, 16 Nov 2020 23:58:01 -0500 X-Loop: help-debbugs@gnu.org Subject: bug#35594: bug#36376: Application menu of desktop environment not automatically updated Resent-From: Maxim Cournoyer Original-Sender: "Debbugs-submit" Resent-CC: bug-guix@gnu.org Resent-Date: Tue, 17 Nov 2020 04:58:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 35594 X-GNU-PR-Package: guix X-GNU-PR-Keywords: To: Ludovic =?UTF-8?Q?Court=C3=A8s?= Received: via spool by 35594-submit@debbugs.gnu.org id=B35594.160558905918887 (code B ref 35594); Tue, 17 Nov 2020 04:58:01 +0000 Received: (at 35594) by debbugs.gnu.org; 17 Nov 2020 04:57:39 +0000 Received: from localhost ([127.0.0.1]:58043 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ket3j-0004uZ-CA for submit@debbugs.gnu.org; Mon, 16 Nov 2020 23:57:39 -0500 Received: from mail-qv1-f66.google.com ([209.85.219.66]:47050) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ket3Y-0004u0-Gk; Mon, 16 Nov 2020 23:57:31 -0500 Received: by mail-qv1-f66.google.com with SMTP id r12so10030752qvq.13; Mon, 16 Nov 2020 20:57:28 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:references:date:in-reply-to:message-id :user-agent:mime-version:content-transfer-encoding; bh=yhMlf/JNRiKsnlOh27ToU6cC0XGJm+ns0LmNRNTfgCs=; b=nhUuZq6odN+MZVnbbkv4k0rX+QqC5aa5tEKPET+5BP4XQo1P4eB1iAit4Tg2HeBT0t 1o3PW6eftNbIzNVJ5CaQFBiW8wN21tqye+zIqH2dBg/7zRCvXSWwiDUerab9ubHTZHLd 9F6UEoaAngKVntsv9erI62EN/aDZpmrrU5RBukiMmftGtzX2KAPSqUGTZoO4p/GTwApl Fl7gekMQNAzbhDAG64PILoRqE2qcMWnPN8U6lLf5SthoJYvkknFEQtbFk7NGqTBXi8C+ b0w7dgnCYZHQeFwKvfaM6/ll7vG49/Gk2HvTVdIoPExts0r9fwsf4c79a9YcEv2ieHVt FCuQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:references:date:in-reply-to :message-id:user-agent:mime-version:content-transfer-encoding; bh=yhMlf/JNRiKsnlOh27ToU6cC0XGJm+ns0LmNRNTfgCs=; b=l548cZsCehS2fGT53dgfyv4mfvA5s7JkaGo374bJjC/Xl4lRhnKmfCaWHS7UEkFw6G oBk4c8wdBnxTuqCgxHn2JQFsbzJTzZnmBdKyAp9QZZcwYGuNuOsHdhF/jcSWDw5coSu4 mfgw0ZhZY9nn9423YJ8E1urqFU9MfvyGfqiFCIswhw2cck1V3ujBiAWqMNqzaDoe7i/s qnN6rafrUq5DfccAjXBFSqPK6RFKGO6mvMNN3561x2hn4MiXRkEXxs/rrxm0S5C7CRvJ 7ruy33JCdtwvnSF+I2nbZ+MDjFV1dZkUeHEZTnFcY2q6W+2O2fZcV91fS9WUVICxt9gV 0fVw== X-Gm-Message-State: AOAM532fXjvt7hHq5pGxyhXw8ukFvx8LxkwKxXnNQy6MJOKiuZk0c4RQ NVXbAnzhglqdcwA422hvy9DhmCtioXU= X-Google-Smtp-Source: ABdhPJx5cHl1YTZM+lfqTs6imzkiDbRKc2Xqg1iqgLMflz1IFNkdcLoJxh4if1CfPtQ6qdLhSTtdyw== X-Received: by 2002:a0c:e585:: with SMTP id t5mr18454770qvm.6.1605589042438; Mon, 16 Nov 2020 20:57:22 -0800 (PST) Received: from hurd (dsl-205-236-230-198.b2b2c.ca. [205.236.230.198]) by smtp.gmail.com with ESMTPSA id o125sm13544914qke.56.2020.11.16.20.57.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 16 Nov 2020 20:57:21 -0800 (PST) From: Maxim Cournoyer References: <871rzhn483.fsf@gnu.org> <87o8keawju.fsf@gnu.org> <87d00swboe.fsf@gmail.com> <878sbexylp.fsf@gnu.org> <87r1p6tiut.fsf@gmail.com> <87lff9nsl0.fsf@gnu.org> <87d00iin6w.fsf@gnu.org> Date: Mon, 16 Nov 2020 23:57:20 -0500 In-Reply-To: <87d00iin6w.fsf@gnu.org> ("Ludovic =?UTF-8?Q?Court=C3=A8s?="'s message of "Thu, 12 Nov 2020 16:56:07 +0100") Message-ID: <875z64d1hr.fsf@gmail.com> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.1 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Spam-Score: 0.0 (/) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-Spam-Score: -1.0 (-) 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 , 35594@debbugs.gnu.org, 36376@debbugs.gnu.org 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=fail (headers rsa verify failed) header.d=gmail.com header.s=20161025 header.b=nhUuZq6o; dmarc=fail reason="SPF not aligned (relaxed)" header.from=gmail.com (policy=none); 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: 0.09 X-TUID: 1m3EEcS7xHz7 Hello Ludovic! Ludovic Court=C3=A8s writes: [...] > So with this new patch it=E2=80=99s monitoring /var/guix/profiles/per-use= r/USER > and /var/guix/profiles instead, which correctly detects changes. It > detects a bit =E2=80=9Ctoo much=E2=80=9D (for instance, running =E2=80=98= guix pull=E2=80=99 triggers the > inotify hook because it changes > /var/guix/profiles/per-user/USER/current-guix) but that=E2=80=99s probabl= y OK. > > If you=E2=80=99re using GNOME, Xfce, or another GLib-based desktop enviro= nment, > I=E2=80=99d welcome tests on the bare metal! Just apply the patch on a c= heckout > of =E2=80=98master=E2=80=99 and run: I've now done so! It works :-)! I do have noticed something a bit off, see the comments below. [...] > diff --git a/gnu/packages/patches/glib-appinfo-watch.patch b/gnu/packages= /patches/glib-appinfo-watch.patch > new file mode 100644 > index 0000000000..638a5e0949 > --- /dev/null > +++ b/gnu/packages/patches/glib-appinfo-watch.patch > @@ -0,0 +1,92 @@ > +This patch lets GLib's GDesktopAppInfo API watch and notice changes > +to the Guix user and system profiles. That way, the list of available > +applications shown by the desktop environment is immediately updated > +when the user runs "guix install", "guix remove", or "guix system > +reconfigure" (see ). > + > +It does so by monitoring /var/guix/profiles (for changes to the system > +profile) and /var/guix/profiles/per-user/USER (for changes to the user > +profile) and crawling their share/applications sub-directory when > +changes happen. > + > +diff --git a/gio/gdesktopappinfo.c b/gio/gdesktopappinfo.c > +index f1e2fdd..095c110 100644 > +--- a/gio/gdesktopappinfo.c > ++++ b/gio/gdesktopappinfo.c > +@@ -148,6 +148,7 @@ typedef struct > + gchar *alternatively_watching; > + gboolean is_config; > + gboolean is_setup; > ++ gchar *guix_profile_watch_dir; > + GFileMonitor *monitor; > + GHashTable *app_names; > + GHashTable *mime_tweaks; > +@@ -180,6 +181,7 @@ desktop_file_dir_unref (DesktopFileDir *dir) > + { > + desktop_file_dir_reset (dir); > + g_free (dir->path); > ++ g_free (dir->guix_profile_watch_dir); > + g_free (dir); > + } > + } > +@@ -204,6 +206,13 @@ desktop_file_dir_get_alternative_dir (DesktopFileDi= r *dir) > + { > + gchar *parent; > + > ++ /* If DIR is a profile, watch the specified directory--e.g., > ++ * /var/guix/profiles/per-user/$USER/ for the user profile. Do not w= atch > ++ * ~/.guix-profile or /run/current-system/profile because GFileMonito= r does > ++ * not pass IN_DONT_FOLLOW and thus cannot notice any change. */ > ++ if (dir->guix_profile_watch_dir !=3D NULL) > ++ return g_strdup (dir->guix_profile_watch_dir); > ++ > + /* If the directory itself exists then we need no alternative. */ > + if (g_access (dir->path, R_OK | X_OK) =3D=3D 0) > + return NULL; > +@@ -249,11 +258,11 @@ desktop_file_dir_changed (GFileMonitor *monit= or, > + * > + * If this is a notification for a parent directory (because the > + * desktop directory didn't exist) then we shouldn't fire the signal > +- * unless something actually changed. > ++ * unless something actually changed or it's in /var/guix/profiles. > + */ > + g_mutex_lock (&desktop_file_dir_lock); > + > +- if (dir->alternatively_watching) > ++ if (dir->alternatively_watching && dir->guix_profile_watch_dir =3D=3D= NULL) ^^^^^^ Why is this needed/desirable? OK, I think I get it. The API seems to imply that users (such as gnome-shell) need to keep asking about a desktop directory entry as they are otherwise "forgotten". Since we are inserting entries at the level of glib ourselves, these will never be asked for by gnome-shell, so must not be cleared. Is that correct? > + { > + gchar *alternative_dir; > + > +@@ -1555,6 +1564,32 @@ desktop_file_dirs_lock (void) > + for (i =3D 0; dirs[i]; i++) > + g_ptr_array_add (desktop_file_dirs, desktop_file_dir_new (dirs[= i])); > + > ++ { > ++ /* Monitor the system and user profile under /var/guix/profiles= and > ++ * treat modifications to them as if they were modifications to= their > ++ * /share sub-directory. */ > ++ const gchar *user; > ++ DesktopFileDir *system_profile_dir, *user_profile_dir; > ++ > ++ system_profile_dir =3D > ++ desktop_file_dir_new ("/var/guix/profiles/system/profile/shar= e"); > ++ system_profile_dir->guix_profile_watch_dir =3D g_strdup ("/var/= guix/profiles"); > ++ g_ptr_array_add (desktop_file_dirs, desktop_file_dir_ref (syste= m_profile_dir)); > ++ > ++ user =3D g_get_user_name (); This seems to get the user of the running glib application; e.g. for GNOME Shell it returns 'gdm'... > ++ if (user !=3D NULL) > ++ { > ++ gchar *profile_dir, *user_data_dir; > ++ > ++ profile_dir =3D g_build_filename ("/var/guix/profiles/per-u= ser", user, NULL); > ++ user_data_dir =3D g_build_filename (profile_dir, "guix-prof= ile", "share", NULL); > ++ user_profile_dir =3D desktop_file_dir_new (user_data_dir); > ++ user_profile_dir->guix_profile_watch_dir =3D profile_dir; > ++ g_ptr_array_add (desktop_file_dirs, desktop_file_dir_ref (u= ser_profile_dir)); > ++ g_free (user_data_dir); > ++ } > ++ } > ++ ...which means the above puts the watch on the "/var/guix/profiles/per-user/gdm" directory, which doesn't exist. sudo strace -f -s200 -p$(pgrep gnome-shell | head -n1) reports entries such as: --8<---------------cut here---------------start------------->8--- 92 00:48:47 poll([{fd=3D6, events=3DPOLLIN}, {fd=3D7, events=3DPOLLIN}, {= fd=3D9, events=3DPOLLIN}, {fd=3D19, events=3DPOLLIN}, {fd=3D28, events=3DPO= LLIN}], 5, -1 390 00:48:47 <... poll resumed>) =3D 0 (Timeout) 390 00:48:47 inotify_add_watch(17, "/var/guix/profiles/per-user/gdm", IN_= MODIFY|IN_ATTRIB|IN_CLOSE_WRITE|IN_MOVED_FROM|IN_MOVED_TO|IN_CREATE|IN_DELE= TE|IN_DELETE_SELF|IN_MOVE_SELF|IN_UNMOUNT|IN_ONLYDIR) =3D -1 ENOENT (No suc= h file or directory) 390 00:48:47 poll([{fd=3D3, events=3DPOLLIN}, {fd=3D17, events=3DPOLLIN}]= , 2, 3996) =3D 0 (Timeout) 390 00:48:51 inotify_add_watch(17, "/var/guix/profiles/per-user/gdm", IN_= MODIFY|IN_ATTRIB|IN_CLOSE_WRITE|IN_MOVED_FROM|IN_MOVED_TO|IN_CREATE|IN_DELE= TE|IN_DELETE_SELF|IN_MOVE_SELF|IN_UNMOUNT|IN_ONLYDIR) =3D -1 ENOENT (No suc= h file or directory) 390 00:48:51 poll([{fd=3D3, events=3DPOLLIN}, {fd=3D17, events=3DPOLLIN}]= , 2, 3998) =3D 0 (Timeout) 390 00:48:55 inotify_add_watch(17, "/var/guix/profiles/per-user/gdm", IN_= MODIFY|IN_ATTRIB|IN_CLOSE_WRITE|IN_MOVED_FROM|IN_MOVED_TO|IN_CREATE|IN_DELE= TE|IN_DELETE_SELF|IN_MOVE_SELF|IN_UNMOUNT|IN_ONLYDIR) =3D -1 ENOENT (No suc= h file or directory) --8<---------------cut here---------------end--------------->8--- The fallback mechanism should have been disabled in desktop_file_dir_changed (dir->guix-profile_watch_dir !=3D NULL so desktop_file_dir_get_alternative_dir doesn't get called), so it seems this shouldn't work. Could it be that the watches used by glib implement a recursive inotify-based watch and that it works because any changes under the /var/guix/profiles directory get picked up, including those of user profiles. The sources seem to suggest so, for example in gio/inotify/inotify-path.c. If that is the case, it could lead to a new interesting problems: applications from other users could end up being shown inadvertently. I'll try to validate the above hypothesis, but this takes time. In any case, the current situation is already an improvement, so thank you for your efforts! Maxim