way to reproduce: -create a script, I named it 'test': #!/bin/bash notify-send "$1" -create a custom action, add a keyboard shortcut, appearance condition what you want. Command: /path_to_script/test %f -use the custom action with right click on one file, not with keyboard shortcut. You will see that notify-send output it's ok, the right path and file name. -select another file, press the keyboard shortcut now, see notify-send output!!, it's the previous file not the current one. That behave will be the same with another files until we use right click to execute custom action.
Thanksfor reprting! I can reproduce the bug.
I can also reproduce this bug, unfortunately it seems to be caused by a design flaw not predicted when I introduced the hotkeys. The trouble is that the hotkey needs the context menu to be created to the selected files and that only happens when right click is issued. Needs further investigation...
Created attachment 9043 attempt at a fix Here is my go at fixing this. However, I'm certainly not an expert in gtk, so please treat with caution! After a little debugging, I think the problem is that the function thunar_standard_view_merge_custom_actions, which generates the menu items which are activated by pressing keys when a file is selected, is currently being run only during thunar_standard_view_context_menu, with the result that the menu items are only refreshed when a context menu is run. Thus the menu items are not updated to reflect a change in the file selection. The attached patch solves this by moving the call to thunar_standard_view_merge_custom_actions into thunar_standard_view_selection_changed, so that the menu items are regenerated whenever the selection changes and thus should always have the correct path. I have also removed the selected_items argument to thunar_standard_view_merge_custom_actions, since at the moment this parameter is not really being used. Indeed, the existing code just gets the list of selected items from the ThunarStandardView immediately before passing this directly to thunar_standard_view_merge_custom_actions, so I've changed thunar_standard_view_merge_custom_actions to retrieve the selected items itself. One more thing: while testing this patch, I noticed that when running thunar in a terminal in "View as Detailed List" mode, I get a variable (i.e. between none and lots) number of xfconf-WARNINGs of the form (thunar:12028): xfconf-WARNING **: 13:26:13.116: Failed to set property "thunar::/last-details-view-column-widths": Operation was cancelled I don't think these are caused by my patch, since I also get them with a thunar compiled from the master branch. It's *possible* that after applying my patch there are slightly more of these warnings, but the number of them is highly variable both with and without the patch so I can't really tell. In any case, I don't think my patch is the root cause of them. I'll open another bug for this.
Ah, I see that the xfconf-WARNING issue is a known bug (Bug #15305)
Reuben Green referenced this bugreport in commit adca28cea8eeb8efd457cd794271eee72867c23d Ensure user customizable action uses currently selected file path (Bug #15119) https://git.xfce.org/xfce/thunar/commit?id=adca28cea8eeb8efd457cd794271eee72867c23d
Reuben Green referenced this bugreport in commit 1b568d86396e3ec298ca7f06cb7b47db62224e02 Ensure user customizable action uses currently selected file path (Bug #15119) https://git.xfce.org/xfce/thunar/commit?id=1b568d86396e3ec298ca7f06cb7b47db62224e02
Thanks for that nice fix, well done ! Works fine for me and the reasoning makes sense. I pushed it to master and 4.14.
Thanks Reuben for the fix, I really appreciate it.
*** Bug 16055 has been marked as a duplicate of this bug. ***