Skip to content

Commit

Permalink
firecfg: use ignorelist also for .desktop files
Browse files Browse the repository at this point in the history
Fixes #5245.

Relates to #5876.
  • Loading branch information
kmk3 committed Jan 11, 2024
1 parent 7bce244 commit cc2d087
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 3 deletions.
24 changes: 22 additions & 2 deletions src/firecfg/desktop_files.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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))
Expand Down Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion src/man/firecfg.1.in
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down

0 comments on commit cc2d087

Please sign in to comment.