Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Nemo actions stopped working after Nemo update #2274

Closed
brunetton opened this issue Dec 19, 2019 · 5 comments
Closed

Nemo actions stopped working after Nemo update #2274

brunetton opened this issue Dec 19, 2019 · 5 comments
Assignees

Comments

@brunetton
Copy link

brunetton commented Dec 19, 2019

 * Nemo version 4.4.0
 * windowed nemo (file browser)
 * Distribution: Arch

Issue
Hi, I'm maintaining a Nemo actions pack. This repo contains a lot of Nemo actions I'm using everyday for my work.

For some reason (to use a script that executes the same command for a lot of files, showing a progress bar using zenity) I need to pass arguments to a custom script. This script call bash, making use of parameter expansion to remove file original extension and add .flac extension.

The complete call is:

Exec=<scripts/bash_action.rb "filename=\"{}\"; rm -f \"${filename%.*}.flac\"; flac --best \"$filename\"" %F>

This still worked well in v4.0.6 but stopped working after.

Steps to reproduce

Some tests made me find that the source of the problem is the % symbol in the Exec line, and the problem can be resumed to this POC:

  • create an action like this one:
[Nemo Action]
Name=POC
Exec=<scripts/print.sh "%" %F>
EscapeSpaces=true
Selection=notnone
Mimetypes=text/plain

This action call print.sh script with a first argument: %, and then the list of selected files.

  • create scripts/print.sh that only prints arguments it received:
#!/bin/bash
echo "received:" $*

Expected behaviour

received: % /path/to/the/selected/file.txt

Actual behaviour

received: % %F

Other information

  • this worked well in v4.0.6

  • if I remove the % in the Exec line: Exec=<scripts/print.sh "" %F> this works as expected

  • I'm not sure, but I think that this problem have been included in that commit: 2edf5ff (related to Some issues with nemo actions #2107)

brunetton referenced this issue Dec 19, 2019
line.

As of d41298b, the find_token_type() function was only
finding tokens in the order listed in the function.

For example, if an action exec line was 'foo %P %F', since the parent
token (P) came after the file path token (F) in find_token_type(),
it was completely ignored.

This changes the function to search for occurrences of '%', then
performing a prefix check starting at the result pointer.

Should fix issue one in #2107.
@mtwebster
Copy link
Member

Your expected behavior - is that what you expect based on the action you have there?

Currently I get:

Action Spawning: /home/mtwebster/.local/share/nemo/actions/literal-exec.sh "%" %F
received: % %F

with a fix I was messing with (26f4736), I then get:

Action Spawning: /home/mtwebster/.local/share/nemo/actions/literal-exec.sh "%" /home/mtwebster/.bashrc
received: % /home/mtwebster/.bashrc

If you wish I can do a build for it to test.

@brunetton
Copy link
Author

brunetton commented Oct 20, 2021

@mtwebster Sorry for long delay answer ! And thank you for your time

I made a mistake in my original report and I just re-edited it to make it more clear (I hope).

with a fix I was messing with (26f4736), I then get:

Action Spawning: /home/mtwebster/.local/share/nemo/actions/literal-exec.sh "%" /home/mtwebster/.bashrc
received: % /home/mtwebster/.bashrc

Yes, this fix seems to do the trick 🥳

It would be great is you could add this fix to master !

Thanks again

(@icarter09 can you consider reopening this issue, as this is still a problem in nemo 4.4.2 ?)

@brunetton
Copy link
Author

ps: can't you use regex for parsing those complicated syntax ? I may be wrong but I've the feeling that you're defining a state machine to parse the .nemo_action file. This could be a lot easier by just defining a regex, what do you think ?
Thanks !

brunetton added a commit to brunetton/nemo-actions that referenced this issue Oct 20, 2021
brunetton added a commit to brunetton/nemo-actions that referenced this issue Oct 20, 2021
brunetton added a commit to brunetton/nemo-actions that referenced this issue Oct 20, 2021
@mtwebster
Copy link
Member

When I wrote this, I was a lot more ignorant than I am now - a lot of work in nemo-action.c could be simplified (the command-line construction especially) - as far as actually reading the entries in the action file, I think using the GKeyFile api is still probably the best way to go, if only because it's familiar and simple to use. I've never had a chance to revisit this simply because of the lack of time, and worry about regressions.

I'll try to refamiliarize myself with that patch and see if I can get it in for the next release.

@mtwebster mtwebster self-assigned this Oct 20, 2021
@mtwebster
Copy link
Member

I forgot about this commit: 5802d29

That might be sufficient for this case.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants