20
850
Fork
You've already forked fuzzel
83

Add --list-executables-in-path command line option #284

Manually merged
gmorer merged 1 commit from gmorer/fuzzel:feat/include_path into master 2024年02月05日 12:19:24 +01:00
Contributor
Copy link

This option include executable from the PATH environment variable to be included in the list.
Will fix #11 (already close tho).

This option include executable from the PATH environment variable to be included in the list. Will fix #11 (already close tho).
Collaborator
Copy link

The name sounds like "the path of include files".

I'm not the maintainer, but a clearer name would be more explicit. Maybe "--include-bins-from-path".

Personally, I don't relate to this feature, since all the binaries from $PATH will include mostly results that don't make sense to launch interactively. For the few that do, .desktop files can be added that include icons for them, include other keywords that might be useful to search for, and specify whether they should be launched as GUI apps or in a terminal.

I understand that dmenu_run allowed selecting binaries likethis with dmenu, but I didn't relate to that either.

The name sounds like "the path of include files". I'm not the maintainer, but a clearer name would be more explicit. Maybe "--include-bins-from-path". Personally, I don't relate to this feature, since all the binaries from $PATH will include mostly results that don't make sense to launch interactively. For the few that do, `.desktop` files can be added that include icons for them, include other keywords that might be useful to search for, and specify whether they should be launched as GUI apps or in a terminal. I understand that `dmenu_run` allowed selecting binaries likethis with dmenu, but I didn't relate to that either.
Author
Contributor
Copy link

Hello, yes the name isn't really nice, i was thinking of something with bins/binaries first in it, which would not be 100% acccurate since you can have scripts which are not binaries in your $PATH.

But i can definitely change it to that.

An example of usage for me, is to run scripts that are in my $PATH from the launcher, doesn't look super nice without icons, but since Fuzzel already execute commands supplied even without desktop files, a visual help to see that an executable exist is I think nice.

I was thinking of switching to Fuzzel coming from Rofi that i use with the following command: rofi -show combi which combine desktop and executable.

Hello, yes the name isn't really nice, i was thinking of something with bins/binaries first in it, which would not be 100% acccurate since you can have scripts which are not binaries in your $PATH. But i can definitely change it to that. An example of usage for me, is to run scripts that are in my $PATH from the launcher, doesn't look super nice without icons, but since Fuzzel already execute commands supplied even without desktop files, a visual help to see that an executable exist is I think nice. I was thinking of switching to Fuzzel coming from Rofi that i use with the following command: `rofi -show combi` which combine desktop and executable.
Author
Contributor
Copy link

I think i found a nice on (been thinking about it a lot lately) --list-path-execs, does it sound ok to you @markstos ?

I think i found a nice on (been thinking about it a lot lately) `--list-path-execs`, does it sound ok to you @markstos ?
Collaborator
Copy link

I think the name is better but @dnkl will make the final decison.

I think the name is better but @dnkl will make the final decison.
Owner
Copy link

I need to think about whether this is a feature I want in fuzzel, but I agree --list-path-execs is a better name than the original one. However, if we're going with such a long name, we might as well make it even more descriptive - perhaps --list-executables-in-path?

I need to think about whether this is a feature I want in fuzzel, but I agree `--list-path-execs` is a better name than the original one. However, if we're going with such a long name, we might as well make it even more descriptive - perhaps `--list-executables-in-path`?
First-time contributor
Copy link

Thank you so much for the patch, it was exactly what i was missing, almost went back to dmenu

Thank you so much for the patch, it was exactly what i was missing, almost went back to dmenu
dnkl left a comment
Copy link

In addition to the changes requested below, I'd also like to see a changelog entry.

In addition to the changes requested below, I'd also like to see a changelog entry.
config.c Outdated
@ -782,6 +782,9 @@ parse_section_main(struct context *ctx)
else if (strcmp(key, "icons-enabled") == 0)
return value_to_bool(ctx, &conf->icons_enabled);
else if (strcmp(key, "include-path") == 0)
Owner
Copy link

Please rename include-path to either list-executables-in-path, or include-executables-from-path, or something else that is less ambiguous.

Please rename `include-path` to either `list-executables-in-path`, or `include-executables-from-path`, or something else that is less ambiguous.
Author
Contributor
Copy link

list-executables-in-path

list-executables-in-path ❗
dnkl marked this conversation as resolved
path.c Outdated
@ -0,0 +1,88 @@
#include "path.h"
Owner
Copy link

Indentation is wrong in this entire file; we use 4 spaces in fuzzel.

Indentation is wrong in this entire file; we use 4 spaces in fuzzel.
dnkl marked this conversation as resolved
path.c Outdated
@ -0,0 +13,4 @@
#include "xdg.h"
#include "char32.h"
void path_find_programs(struct application_list *applications)
Owner
Copy link

nit:

void
path_find_programs(struct application_list *applications)
{
 ...
}
nit: ```c void path_find_programs(struct application_list *applications) { ... } ```
dnkl marked this conversation as resolved
path.c Outdated
@ -0,0 +57,4 @@
struct stat st;
if (fstatat(it->item.fd, e->d_name, &st, 0) == -1) {
LOG_WARN("%s: failed to stat", e->d_name);
continue;
Owner
Copy link

wtitle is leaked here.

`wtitle` is leaked here.
dnkl marked this conversation as resolved
path.c Outdated
@ -0,0 +59,4 @@
LOG_WARN("%s: failed to stat", e->d_name);
continue;
}
if (S_ISREG(st.st_mode) && st.st_mode & S_IXUSR) {
Owner
Copy link

wtitle is leaked here, when the if statement is not taken.

`wtitle` is leaked here, when the `if` statement is **not** taken.
Author
Contributor
Copy link

I moved the variable creation after checking the file type.

I moved the variable creation after checking the file type.
dnkl marked this conversation as resolved
path.c Outdated
@ -0,0 +63,4 @@
char *exec = malloc(path_size + 1 + strlen(e->d_name) + 1);
strcpy(exec, it->item.path);
exec[path_size] = '/';
strcpy(exec + path_size + 1, e->d_name);
Owner
Copy link

I'd suggest using either snprintf() to build the entire string in a single call, or strcpy() followed by two strcat(). It makes it easier to read, and the small performance boost you get from doing it with strcpy() with offsets just isn't worth it, imho.

I'd suggest using either `snprintf()` to build the entire string in a single call, or `strcpy()` followed by two `strcat()`. It makes it easier to read, and the _small_ performance boost you get from doing it with `strcpy()` with offsets just isn't worth it, imho.
dnkl marked this conversation as resolved
path.c Outdated
@ -0,0 +82,4 @@
tll_foreach(entries, it) {
applications->v[applications->count++] = it->item;
tll_remove(entries, it);
Owner
Copy link

This leaks both the fd you opened in the first for loop, as well as the path element.

This leaks both the `fd` you opened in the first `for` loop, as well as the `path` element.
Author
Contributor
Copy link

even with the xdg_data_dirs_destroy(paths);?

even with the `xdg_data_dirs_destroy(paths);`?
Author
Contributor
Copy link

I made changes to only loop once, so the directory fd should now be closed by closedir

I made changes to only loop once, so the directory fd should now be closed by `closedir`
dnkl marked this conversation as resolved
path.c Outdated
@ -0,0 +84,4 @@
applications->v[applications->count++] = it->item;
tll_remove(entries, it);
}
tll_free(entries);
Owner
Copy link

tll_free() isn't necessary when you've tll_remove():ed all elements in the list.

`tll_free()` isn't necessary when you've `tll_remove()`:ed all elements in the list.
dnkl marked this conversation as resolved
path.h Outdated
@ -0,0 +2,4 @@
#include "application.h"
#include "icon.h"
#include "tllist.h"
Owner
Copy link

Neither icon.h nor tllist.h are needed, are they?

Neither `icon.h` nor `tllist.h` are needed, are they?
dnkl marked this conversation as resolved
gmorer force-pushed feat/include_path from a72381676a to 19c168a1f1 2023年12月28日 20:53:57 +01:00 Compare
gmorer changed title from (削除) Add --include-path command line option (削除ここまで) to Add --list-executables-in-path command line option 2023年12月28日 20:59:39 +01:00
gmorer force-pushed feat/include_path from 19c168a1f1 to 649c6a769c 2023年12月28日 21:02:25 +01:00 Compare
Author
Contributor
Copy link

I made the requested changes (except fd/path leak (not sure it leak)) sorry for the resolved/unresolved spam, not sure I should be the one doing that.

I added an entry in the CHANGELOG.md as well.

I made the requested changes (except fd/path leak (not sure it leak)) sorry for the resolved/unresolved spam, not sure I should be the one doing that. I added an entry in the CHANGELOG.md as well.
gmorer force-pushed feat/include_path from 649c6a769c to 06560cdc12 2024年01月03日 19:07:11 +01:00 Compare
Author
Contributor
Copy link

I added a check to not list multiple times an executable with the same name.

I added a check to not list multiple times an executable with the same name.
dnkl left a comment
Copy link

Overall, this looks good. A couple of minor issues, see below.

I'm also missing updated shell completions (completions/zsh + completions/fish).

Overall, this looks good. A couple of minor issues, see below. I'm also missing updated shell completions (`completions/zsh` + `completions/fish`).
meson.build Outdated
@ -152,3 +152,3 @@
'render.c','render.h',
'shm.c','shm.h',
'stride.h',
'stride.h','path.c',
Owner
Copy link

nit: this list is a) sorted, and b) also includes the corresponding header file

nit: this list is a) sorted, and b) also includes the corresponding header file
path.c Outdated
@ -0,0 +60,4 @@
bool already_exist = false;
tll_foreach(entries, it) {
if (c32cmp(wtitle, it->item.title) == 0) {
already_exist = true;
Owner
Copy link

minor performance tweak: break out of the loop after setting already_exist = true.

minor performance tweak: break out of the loop after setting `already_exist = true`.
gmorer force-pushed feat/include_path from 06560cdc12 to cb95154e50 2024年01月05日 12:13:49 +01:00 Compare
gmorer force-pushed feat/include_path from cb95154e50 to c1fdcb7d2f 2024年01月05日 12:14:59 +01:00 Compare
Author
Contributor
Copy link

Done

Done
gmorer manually merged commit c1fdcb7d2f into master 2024年02月05日 12:19:24 +01:00
Sign in to join this conversation.
No reviewers
Milestone
Clear milestone
No items
No milestone
Projects
Clear projects
No items
No project
Assignees
Clear assignees
No assignees
4 participants
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
dnkl/fuzzel!284
Reference in a new issue
dnkl/fuzzel
No description provided.
Delete branch "gmorer/fuzzel:feat/include_path"

Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?