[Moved to Github] Submenus for Nemo Actions?

Suggestions and feedback for Linux Mint and the forums
Forum rules
Do not post support questions here. Before you post read: Where to post ideas & feature requests
Post Reply
User avatar
sadi
Level 2
Level 2
Posts: 65
Joined: Sat Aug 21, 2010 3:16 pm
Location: Istanbul

[Moved to Github] Submenus for Nemo Actions?

Post by sadi »

Coming from Nautilus, I loved Nemo Actions!
Even though there's a graphical tool for Nautilus Actions, I've found it much more simpler to create Nemo Actions.
It's also so nice to have all those actions and scripts listed in the Preferences (and individually enabled or disabled, etc.)

Now, one more step could bring us closer to perfection in this regard: submenus!
KDE's Dolphin has it, so why not Nemo as well ;-)
Last edited by sadi on Wed Jul 05, 2017 4:44 pm, edited 1 time in total.
Linux Mint 19.3 Cinnamon
User avatar
xenopeek
Level 25
Level 25
Posts: 29507
Joined: Wed Jul 06, 2011 3:58 am

Re: Submenus for Nemo Actions?

Post by xenopeek »

You can post feature requests to the Nemo developers here: https://github.com/linuxmint/nemo/issues
Image
Cosmo.
Level 24
Level 24
Posts: 22968
Joined: Sat Dec 06, 2014 7:34 am

Re: Submenus for Nemo Actions?

Post by Cosmo. »

Open nemo and press alt-p and you have the graphical option to enable / disable actions individually.
User avatar
sadi
Level 2
Level 2
Posts: 65
Joined: Sat Aug 21, 2010 3:16 pm
Location: Istanbul

Re: Submenus for Nemo Actions?

Post by sadi »

Thank you both!

As a second-time newcomer, I didn't know about LM github repositories; it's a great place for issues, ideas, etc. indeed!

As for Actions GUI, although the one inside Nemo has very limited functionality, I don't miss the Nautilus one really -- a good sample nemo.action does the job just fine (although something more like a tutorial/manual could be better).
Linux Mint 19.3 Cinnamon
ciniset
Level 2
Level 2
Posts: 71
Joined: Thu Dec 28, 2017 10:14 am

Re: [Moved to Github] Submenus for Nemo Actions?

Post by ciniset »

hi. I'm new to linux mint/bash/aso but want 2 share a possible solution for those - like me - who need to have right click with nemo_action files organized by submenus. the idea is 2 simulate ur own menus on right click. is just a skeleton but is working and prove the idea.

0. apt install yad
1.

Code: Select all

mkdir ~/.local/share/nemo/custom
2. create the file ~/.local/share/nemo/actions/Custom\ Nemo\ extender.nemo_action
3. put in that file :

Code: Select all

[Nemo Action]
Name=Custom Nemo extender
Comment=Launch custom nemo menu extender

Exec=/home/ciniset/.local/share/nemo/custom/nemoext main
Icon-Name=media-playback-start
Selection=any
Extensions=dir;
Conditions=desktop;
4. create the file /home/ciniset/.local/share/nemo/custom/nemoext

Code: Select all

#! /bin/bash

read_menu_file() {
    unset file_name work_string menu line lenght_dim lines_dim histogram
    file_name=$1
    work_string="$(cat $file_name | cut -f 1 -d "+")"
    menu=$(cat $file_name | tr "+" " ")

    while read line; do
        ((histogram[${#line}]++))
    done <<< "$work_string"

    for length in "${!histogram[@]}"; do
        lenght_dim=$(( ${length} * 10 ))
    done
    lines_dim=$(( ${#histogram[@]} * 28 ))
}


if [ "$#" -ne 1 ]; then
    exit        # no menu file
fi

pushd . > /dev/null
SCRIPT_PATH="${BASH_SOURCE[0]}"
if ([ -h "${SCRIPT_PATH}" ]); then
  while([ -h "${SCRIPT_PATH}" ]); do cd `dirname "$SCRIPT_PATH"`; 
  SCRIPT_PATH=`readlink "${SCRIPT_PATH}"`; done
fi
cd `dirname ${SCRIPT_PATH}` > /dev/null
SCRIPT_PATH=`pwd`;
popd  > /dev/null

menu_name=$(echo $SCRIPT_PATH"/"$1)
read_menu_file $menu_name

while true; do
    ANSWER=`yad --mouse --no-buttons --undecorated --skip-taskbar --width=$lenght_dim --height=$lines_dim --list --separator="+" --no-headers --column=Name --column=Type:HD --column=Function:HD  $menu`
    type=$(echo $ANSWER | cut -f 2 -d "+")
    case "$type" in
            "M")
                submenu=$(echo $ANSWER | cut -f 1 -d "+")
                submenu=${submenu::-4}
                read_menu_file $SCRIPT_PATH/$submenu
                continue
            ;;
            *)
                command=$(echo $ANSWER | cut -f 3 -d "+")
                $command &
                exit
            ;;
    esac
done
5. create the file /home/ciniset/.local/share/nemo/custom/main

Code: Select all

Firefox+C+firefox
Editor+C+gedit
Terminal+C+gnome-terminal
Utils[=>]+M+Utils
and create the file /home/ciniset/.local/share/nemo/custom/Utils

Code: Select all

VirtualBox[=>]+M+VirtualBox
Kalarm+C+kalarm
ur ready 4 test now :)

short explanation:
create nemo_action file who call a bash script from ~/.local/share/nemo/custom/ who read menu file/files from same folder.
link between menu files are made by name. inside files is <name>+<C(for command)/M(for submenu)>+<command/menu info>

2 cents thoughts: it would be very nice if the submenu feature will be implemented in the future, having already the structure for nemo_action/scripts and being (i believe) relatively easy to create extra folder(submenus) in .local/share/nemo/actions containing .nemo_action files.


LAST MINUTE UPDATE
I'm ashamed I didn't look also into scripting capability of nemo :oops:
Scripting is solving the whole problem.
Nemo IS great!
caetano
Level 2
Level 2
Posts: 81
Joined: Tue May 24, 2016 5:23 am

Re: [Moved to Github] Submenus for Nemo Actions?

Post by caetano »

ciniset wrote: Fri Dec 29, 2017 9:19 am I'm ashamed I didn't look also into scripting capability of nemo :oops:
Scripting is solving the whole problem.
Nemo IS great!
Are you saying there's a simpler solution to the one you proposed above?
If so could you show an example (preferably with a simpler script item than the one you showed, e.g just a command to launch a terminal) ?
ciniset
Level 2
Level 2
Posts: 71
Joined: Thu Dec 28, 2017 10:14 am

Re: [Moved to Github] Submenus for Nemo Actions?

Post by ciniset »

open terminal ( :D )

cd ~/.local/share/nemo/scripts
echo -e "\n" > termtest
sed -i '1 i #!/bin/bash\nterminal\nexit 0' termtest
chmod +x termtest

U have now termtest executable file in ~/.local/share/nemo/scripts
Just open nemo, right click on desktop, go to Scripts menu and there u'll find termtest.
Post Reply

Return to “Suggestions & Feedback”