commit 82fb812965821f398c925f6dc1576e579d2c61c8 parent 9ce6bcda8dc078cde153eade1b13d0336ab18666 Author: Dominik Schmidt <dominik@schm1dt.ch> Date: Fri, 16 Sep 2022 20:25:13 +0200 Improve parsing of .desktop entries a bit Before, we just took the last Exec= line (or any other line), now we check in which section we are before saving it to the structure, only taking the "Desktop Entry" and ignoring the rest (what would the proper behaviour be there, adding multiple entries?) Diffstat:
M | src/xdg/desktop.d | | | 38 | ++++++++++++++++++++++---------------- |
1 file changed, 22 insertions(+), 16 deletions(-)
diff --git a/src/xdg/desktop.d b/src/xdg/desktop.d @@ -70,23 +70,29 @@ struct Database{ } path = file.idup; baseName = .baseName(path); + string entry = ""; foreach(l; f.byLine){ - auto s = l.findSplit("="); - switch(s[0]){ - case "Name": - name = s[2].idup; - break; - case "Exec": - exec = s[2].idup; - break; - case "Icon": - icon = s[2].idup; - break; - case "MimeType": - mimeTypes = s[2].idup.split(";"); - break; - default: - break; + if(l[0]=='['){ + entry = l[1..$-1].idup; + } + if(entry == "Desktop Entry"){ + auto s = l.findSplit("="); + switch(s[0]){ + case "Name": + name = s[2].idup; + break; + case "Exec": + exec = s[2].idup; + break; + case "Icon": + icon = s[2].idup; + break; + case "MimeType": + mimeTypes = s[2].idup.split(";"); + break; + default: + break; + } } } }