0

I am having the following problem / question and I am seeking for help / answers here. :) I am using Debian 9 with Cinnamon UI and it works fine so far.

I recently started to get myself familiar with the nemo actions, in order to extend the context menu with my entries. While this works, I could not figure out how to determine in which order the menu points are shown. I tried the common method of using two-digit starts for the .nemo_action files (like for udev rules etc), changing zhe action names, .... However, I could not figure out what algorithm is behind this

Can anyone shed some light on this?

I can even live with an answer like: “you need to modify the code here...” The only thing I found on the internet so far: https://forums.linuxmint.com/viewtopic.php?t=178757

Thanks in advance.

jww
  • 97,681
  • 90
  • 411
  • 885
AlexG
  • 11
  • 1
  • It's apparently a well-kept secret. I speak from experience, and could also point you to this: https://forums.linuxmint.com/viewtopic.php?t=178757 –  Jul 30 '19 at 20:53
  • Thanks for your answer. Actually, the forum thread (which I also found and for which the last answer is 3 years old) is not really helpful as there is only guessing too and no definite answer... Hasn't anybody found the code in nemo that creates the context menu? To the best of my knowledge it is open source and I am pretty sure that one day I would find that code, but I was hoping that someone probably already found it and could point me to it ;) – AlexG Jul 31 '19 at 07:39
  • The nemo sources are here: https://github.com/linuxmint/nemo. If you locate the relevant portion I'll upvote you! But somehow I doubt it's in the nemo sources. Anyway -- good luck! –  Jul 31 '19 at 17:33
  • 1
    Thanks for pointing me to the sources. After a lot of searching through the files etc., my guess is that in nemo-action-manager.c set_up_actions() line 273 an unsorted list is returned (or at least it is not ensured to be sorted by name), causing a weird list of actions (order swapped / not logical / ...) I wanted to give it a try but fail to build nemo-master from source. README / INSTALL are not helpful here. Right now, it looks like libxapp-dev >= 1.4.0 is the only remaining and missing build dependency (working under Ubuntu here, to not mess up my debian PC) – AlexG Jul 31 '19 at 23:00

2 Answers2

1

O.K., found it...nemo_action_manager.c, set_up_actions():

file_list = nemo_directory_get_file_list (directory);
// AlexG: List seems to be retrieved unsorted, so let's sort it.
// Then the order of menu items is == alphabetical order of nemo action file names
file_list = g_list_sort(file_list, _cbSortFileList);
[...]
AlexG
  • 11
  • 1
  • Does that work? You should report this (on the named github page) as a new (and wanted) feature. –  Aug 01 '19 at 20:15
  • Actually, it does work. I verified with a few printf() outputs that the initial list was messed up and that the menu points were added in exactly the order they were in the list. After adding my sort() I verified things again, the list was in order and the menu items have been added in exactly the expected order. I will place that as a bug report + fix proposal, as the current situation is not really usable. Who can work with moving context menu entries?... Even bad things can happen if you rely on your mostly used point to be at position xyz and it is suddenly somewhere else? – AlexG Aug 02 '19 at 06:51
0

I obtained a small bash script mints nemo github that allow sorting of Nemo Actions based on name; on demand. The default order is by modification date.

Below you find the script to sort actions and to set the order i named them alphabetically.

#!/bin/bash
if ! zenity --question --no-wrap --icon-name="folder" --title="Sort Nemo Actions?" --no-wrap --text="Sorting actions will close down all existing nemo instances.\n\nWould you like to proceed?"; then
 exit 1
fi
mkdir -p /tmp/actions/
mv "$HOME"/.local/share/nemo/actions/*.nemo_action /tmp/actions/
ACTIONS=$(find /tmp/actions -iname '*.nemo_action' | sort -n)
for i in $ACTIONS; do
 touch "$i"
done
mv /tmp/actions/*.nemo_action "$HOME"/.local/share/nemo/actions/
nemo -q 
nemo-desktop -q
nemo-desktop & disown