[gnome-usage/benzea/simple-systemd-appid-lookup: 7/9] app-item: Add application ID based on .desktop file name




commit 07f7b4246434aad153aabee4eead245282f18121
Author: Benjamin Berg <bberg redhat com>
Date:   Wed Jul 22 17:03:14 2020 +0200

    app-item: Add application ID based on .desktop file name
    
    We use this ID as-is to name the systemd units, so we need to be able to
    do lookups based on it.

 src/app-item.vala | 11 ++++++++++-
 1 file changed, 10 insertions(+), 1 deletion(-)
---
diff --git a/src/app-item.vala b/src/app-item.vala
index 810a5d1..d7816d3 100644
--- a/src/app-item.vala
+++ b/src/app-item.vala
@@ -23,9 +23,18 @@ namespace Usage
 
             foreach (AppInfo info in _apps_info) {
                 GLib.DesktopAppInfo? dai = info as GLib.DesktopAppInfo;
+                string ?id = null;
 
                 if (dai != null) {
-                    string id = dai.get_string ("X-Flatpak");
+                    id = dai.get_string ("X-Flatpak");
+                    if (id != null)
+                        appid_map.insert (id, info);
+                }
+
+                if (id == null) {
+                    id = info.get_id();
+                    if (id != null && id.has_suffix (".desktop"))
+                        id = id[0:id.length - 8];
                     if (id != null)
                         appid_map.insert (id, info);
                 }


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]