5

I have an custom nemo action as explained here: https://wiki.archlinux.org/index.php/Nemo#Nemo_Actions

How can I add an shortcut for this action?

(If it can be done adding a line in ~/.gnome2/accels/nemo, then I have the additional problem that on my system this file is auto generated on every reboot, so editing something here will not help. I have Cinnamon 3.2.7 and nemo 3.2.2.)

Any suggestions? Thanks in advance! :)

flix
  • 85
  • 7

2 Answers2

4

Nemo Action

First, you should place the myaction.nemo_action under ~/.local/share/nemo/actions/.

Then, to make a keystroke put an underscore _ in front of the letter you want. For example in the Hello _Shortcut the s is the key. So you press the right-click and then s.

Bellow is an example of my action to open files and directories with Atom:

# Custom action for Nemo File Manager for Cinnamon.
# Adds right-click open file/files or directory with Atom.
# Place it under: ~/.local/share/nemo/actions/atom.nemo_action
# For more info: https://github.com/linuxmint/nemo/blob/master/files/usr/share/nemo/actions/sample.nemo_action

[Nemo Action]
Active=true
Name=Open in _Atom
Comment=Open %F in Atom
Exec=atom %F
Icon-Name=atom
Selection=any
Extensions=any;
Dependencies=atom;
Quote=double

Global Shortcut

If you want a global shortcut, you should use the Cinnamon Keyboard setting under the System settings, go to the second tab and add your custom shortcut.
Or, if you prefer more control over CLI you can use the dconf. For example, the bellow configuration will add the shortcut Shift><Alt>a

/org/cinnamon/desktop/keybindings/custom-keybindings/custom0/name
  'Open Atom'
/org/cinnamon/desktop/keybindings/custom-keybindings/custom0/command
  'atom'
/org/cinnamon/desktop/keybindings/custom-keybindings/custom0/binding
  ['<Shift><Alt>a']
/org/cinnamon/desktop/keybindings/custom-list
  ['custom0']
tvl
  • 3,868
  • 2
  • 16
  • 35
  • Is there any way without needing the extra right-clicking and menu navigation? I don't want to just find the item in the menu quickly - that's not that useful. Instead I want to select files, and then just press a keyboard shortcut, and have it be as though I right clicked and clicked on the action. Is that possible? – Duncan Marshall Nov 07 '21 at 18:15
1

Am trying to respond to Duncan Marshall but the post ended up in the mainthread. Yes, it's possible. Your file ~/.gnome2/accels/nemo can contain a line such as the following, which would execute a scrip file named edit.sh when F4 is pressed. The scripfile must be located in this special path (~/.local/share/nemo/scripts) and it must be enabled via a checkbox in User Interface>Edit>Preferences>Plugins>Scripts. Also i was unable to specify a script path such as ~/... instead of /home/username... When the syntax in the accels/nemo file is incorrect, nemo will prepend the incorrect line with ; and it will also delete the keycode at the end of the line and it also likes to resort lines in the accels file. I will also dismiss a line when the keycode was already used in another line. So it couldn't be more tricky to get this right.

(gtk_accel_path "<Actions>/ScriptsGroup/script_file:\\s\\s\\shome\\sUSERNAME\\s.local\\sshare\\snemo\\sscripts\\sedit.sh" "F4")

the script file might look like this

#!/bin/bash
export FILETOEDIT="$1"
FILEOWNER=$(stat -c %U "$1")
if [ "$FILEOWNER" = "$USER" ]; then
  subl "$1"
else
  sudo xed -w "$FILETOEDIT"
fi
pine wheel
  • 11
  • 1
  • As it’s currently written, your answer is unclear. Please [edit] to add additional details that will help others understand how this addresses the question asked. You can find more information on how to write good answers [in the help center](/help/how-to-answer). – taylor.2317 Feb 07 '22 at 13:23