Bug#854132: [PATCH] Add desktop-entry-lacks-icon-entry tag
Check if a .desktop file contains an Icon entry
Closes: #854132
---
checks/menu-format.desc | 16 ++++++++++++++++
checks/menu-format.pm | 3 +++
t/tests/menu-format-desktop-general/debian/crlf.desktop | 1 +
.../debian/environments.desktop | 1 +
.../menu-format-desktop-general/debian/general.desktop | 1 +
.../debian/reserved-bad.desktop | 1 +
.../menu-format-desktop-general/debian/reserved.desktop | 1 +
t/tests/menu-format-desktop-general/desc | 1 +
t/tests/menu-format-desktop-general/tags | 1 +
9 files changed, 26 insertions(+)
diff --git a/checks/menu-format.desc b/checks/menu-format.desc
index fd6f523b4..7d2ac362f 100644
--- a/checks/menu-format.desc
+++ b/checks/menu-format.desc
@@ -317,6 +317,22 @@ Info: The categories for this desktop entry do not contain any Main
useful for checking the syntax of desktop entries.
Ref: https://specifications.freedesktop.org/menu-spec/1.0/apa.html
+Tag: desktop-entry-lacks-icon-entry
+Severity: wishlist
+Certainty: certain
+Info: This .desktop file does not contain an "Icon" entry.
+ .
+ "Icon" is the name of the file (without the extension) of the icon displayed
+ by this .desktop file. The icon is searched in the different icon themes.
+ If the name is an absolute path, the given file will be used.
+ The icon should be unique enough to help the user to recogninse the application.
+ .
+ The desktop-file-validate tool in the desktop-file-utils package is
+ useful for checking the syntax of desktop entries.
+Ref: https://specifications.freedesktop.org/desktop-entry-spec/latest/ar01s05.html,
+ https://specifications.freedesktop.org/icon-theme-spec/icon-theme-spec-latest.html
+ #854132
+
Tag: desktop-entry-lacks-keywords-entry
Severity: wishlist
Certainty: certain
diff --git a/checks/menu-format.pm b/checks/menu-format.pm
index 89ac19154..3de449050 100644
--- a/checks/menu-format.pm
+++ b/checks/menu-format.pm
@@ -638,6 +638,9 @@ sub verify_desktop_file {
# test if missing Keywords (only if NoDisplay is not set)
if (!defined $vals{NoDisplay}) {
+ if (!defined $vals{Icon}) {
+ tag 'desktop-entry-lacks-icon-entry', $file;
+ }
if (!defined $vals{Keywords}) {
tag 'desktop-entry-lacks-keywords-entry', $file;
}
diff --git a/t/tests/menu-format-desktop-general/debian/crlf.desktop b/t/tests/menu-format-desktop-general/debian/crlf.desktop
index 3c8a8b2bb..4e53c3a63 100644
--- a/t/tests/menu-format-desktop-general/debian/crlf.desktop
+++ b/t/tests/menu-format-desktop-general/debian/crlf.desktop
@@ -3,4 +3,5 @@ Name=general
Comment=An entirely correct desktop entry
Type=Application
Categories=Development;Building;
+Icon=foo
Keywords=Foobar
diff --git a/t/tests/menu-format-desktop-general/debian/environments.desktop b/t/tests/menu-format-desktop-general/debian/environments.desktop
index 7c517d161..51aa67493 100644
--- a/t/tests/menu-format-desktop-general/debian/environments.desktop
+++ b/t/tests/menu-format-desktop-general/debian/environments.desktop
@@ -5,4 +5,5 @@ Comment=Incorrectly limited to particular environments
Categories=Development;
Exec=foo
OnlyShowIn=GNOME;KDE;
+Icon=foo
Keywords=Golf
diff --git a/t/tests/menu-format-desktop-general/debian/general.desktop b/t/tests/menu-format-desktop-general/debian/general.desktop
index f60c102e9..f1ef3bd9d 100644
--- a/t/tests/menu-format-desktop-general/debian/general.desktop
+++ b/t/tests/menu-format-desktop-general/debian/general.desktop
@@ -9,4 +9,5 @@ Categories=Building;Lintian;
Terminal=true
TerminalOptions=-g 80x25
Exec=foo
+#missing Icon
#missing Keywords
diff --git a/t/tests/menu-format-desktop-general/debian/reserved-bad.desktop b/t/tests/menu-format-desktop-general/debian/reserved-bad.desktop
index 7073d757e..a0b71e14b 100644
--- a/t/tests/menu-format-desktop-general/debian/reserved-bad.desktop
+++ b/t/tests/menu-format-desktop-general/debian/reserved-bad.desktop
@@ -4,4 +4,5 @@ Comment=Entry in a reserved category (incorrect)
Type=Application
Categories=Screensaver;
Exec=foo
+Icon=foo
Keywords=Fun
diff --git a/t/tests/menu-format-desktop-general/debian/reserved.desktop b/t/tests/menu-format-desktop-general/debian/reserved.desktop
index dc2730134..925601490 100644
--- a/t/tests/menu-format-desktop-general/debian/reserved.desktop
+++ b/t/tests/menu-format-desktop-general/debian/reserved.desktop
@@ -5,4 +5,5 @@ Type=Application
Categories=Screensaver;
Exec=foo
OnlyShowIn=GNOME;KDE;
+Icon=foo
Keywords=Blur
diff --git a/t/tests/menu-format-desktop-general/desc b/t/tests/menu-format-desktop-general/desc
index d1a90aa5f..ceff9d4a8 100644
--- a/t/tests/menu-format-desktop-general/desc
+++ b/t/tests/menu-format-desktop-general/desc
@@ -8,6 +8,7 @@ Test-For:
desktop-entry-contains-unknown-key
desktop-entry-file-has-crs
desktop-entry-invalid-category
+ desktop-entry-lacks-icon-entry
desktop-entry-lacks-keywords-entry
desktop-entry-lacks-main-category
desktop-entry-limited-to-environments
diff --git a/t/tests/menu-format-desktop-general/tags b/t/tests/menu-format-desktop-general/tags
index c908c278a..d05d1de53 100644
--- a/t/tests/menu-format-desktop-general/tags
+++ b/t/tests/menu-format-desktop-general/tags
@@ -1,5 +1,6 @@
E: menu-format-desktop-general: executable-desktop-file usr/share/applications/general.desktop 0755
I: menu-format-desktop-general: desktop-entry-contains-encoding-key usr/share/applications/general.desktop:7 Encoding
+I: menu-format-desktop-general: desktop-entry-lacks-icon-entry usr/share/applications/general.desktop
I: menu-format-desktop-general: desktop-entry-lacks-keywords-entry usr/share/applications/general.desktop
I: menu-format-desktop-general: desktop-entry-limited-to-environments usr/share/applications/environments.desktop
W: menu-format-desktop-general: desktop-command-not-in-package usr/share/applications/environments.desktop foo
--
2.11.0
Reply to: