Tomas-M / xlunch

Graphical app launcher for X with minimal dependencies
http://xlunch.org
GNU General Public License v3.0
219 stars 35 forks source link

Moved removal of desktop % fields to genconf #35

Closed PMunch closed 7 years ago

PMunch commented 7 years ago

The tokenize and run with execvp approach didn't work correctly with queries using quotes as the arguments would be split across multiple ones. This moves the removal of the % fields to the genconf script and simply runs the command found blindly from the C code.

Tomas-M commented 7 years ago

Hm actually while thinking about it, the run_command should be rewritten to support quoted arguments, because even user can use quotes in the command - if he types the command instead of clicking on an icon.

PMunch commented 7 years ago

Yeah, the execve procedure doesn't really work here since it requires the arguments to be split which would require unnecessary parsing of the Exec field. So we should look for something that can take an arbitrary command, but still replace the process.

PMunch commented 7 years ago

Another thing to take into account is environment variables. A .desktop file is fine with "MYVARIABLE=hello program --option".

Tomas-M commented 7 years ago

I think we can ignore this :)

PMunch commented 7 years ago

Ignore what? The entire issue? What about something like:

void run_command(char * cmd_orig){
  char *array[4] = {0};
  array[0] = "sh";
  array[1] = "-c";
  array[2] = cmd_orig;

  int err = execvp(array[0], array);
}
Tomas-M commented 7 years ago

I'm not sure if I want to run shell on each exec. There may be users who do not have sh, rarely.

I think better would be to detect double-quotes in the splitted arguments and if found, join back those arguments which have them, cutting the quotes away.

Tomas-M commented 7 years ago

I really appreciate your effort, thank you for helping with this, because without you, there would be no update whatsoever, I almost forgot about this project at all :)

PMunch commented 7 years ago

Hmm, but that won't work with environment variables, or things like $(). I think there are just too many things that might appear in a Exec statement to be run without actually passing it to a shell, or implementing parsing equivalent to what a shell would do. Maybe we could check if the command starts with "xlunch " and then run exec, otherwise run system? Or better yet have a special way to flag an xlunch command in the conf format.

PMunch commented 7 years ago

I have actually thought about creating a launcher like this on my own so I really enjoy working on it. The simplicity and customisability is really nice as well!