From f1f61874cdab0e1b3546fd7007bc8ce92437735e Mon Sep 17 00:00:00 2001 From: "Kelvin M. Klann" Date: Mon, 8 Jan 2024 10:05:43 -0300 Subject: [PATCH] firecfg: use ignorelist also for .desktop files Relates to #5876. --- src/firecfg/desktop_files.c | 24 ++++++++++++++++++++++-- src/man/firecfg.1.in | 2 +- 2 files changed, 23 insertions(+), 3 deletions(-) diff --git a/src/firecfg/desktop_files.c b/src/firecfg/desktop_files.c index 5ed15c02b0f..8bd54d3e925 100644 --- a/src/firecfg/desktop_files.c +++ b/src/firecfg/desktop_files.c @@ -118,6 +118,9 @@ void fix_desktop_files(const char *homedir) { exit(1); } + // build ignorelist + parse_config_all(0); + // destination // create ~/.local/share/applications directory if necessary char *user_apps_dir; @@ -173,8 +176,25 @@ void fix_desktop_files(const char *homedir) { continue; // skip if not .desktop file - if (strstr(filename, ".desktop") != (filename + strlen(filename) - 8)) + char *exec = strdup(filename); + if (!exec) + errExit("strdup"); + char *ptr = strstr(exec, ".desktop"); + if (ptr == NULL || *(ptr + 8) != '\0') { + printf(" %s skipped (not a .desktop file)\n", exec); + free(exec); + continue; + } + + // skip if program is in ignorelist + *ptr = '\0'; + if (in_ignorelist(exec)) { + printf(" %s ignored\n", exec); + free(exec); continue; + } + + free(exec); // skip links - Discord on Arch #4235 seems to be a symlink to /opt directory // if (is_link(filename)) @@ -220,7 +240,7 @@ void fix_desktop_files(const char *homedir) { } // get executable name - char *ptr = strstr(buf,"\nExec="); + ptr = strstr(buf,"\nExec="); if (!ptr || strlen(ptr) < 7) { if (arg_debug) printf(" %s - skipped: wrong format?\n", filename); diff --git a/src/man/firecfg.1.in b/src/man/firecfg.1.in index e43a573de5e..79802156ca4 100644 --- a/src/man/firecfg.1.in +++ b/src/man/firecfg.1.in @@ -168,7 +168,7 @@ Configuration file syntax: A line that starts with \fB#\fR is considered a comment. .br A line that starts with \fB!PROGRAM\fR means to ignore "PROGRAM" when creating -symlinks. +symlinks and fixing .desktop files. .br A line that starts with anything else is considered to be the name of an executable and firecfg will attempt to create a symlink for it.