How can I assign keyboard shortcut for nautilus scripts?How can I create keyboard shortcuts for my nautilus scripts?How to set folder icons of multiple folders automatically?How can I set a shortcut key to open selected file in nautilus?Creating a hotkey for an aliasIf active window is file manager then store selected files in variableHow can I create keyboard shortcuts for my nautilus scripts?How can I instruct Nautilus to pre-generate thumbnails?How can I stop Nautilus from dereferencing symlinks?Program/Keyboard shortcut to work with multiple monitorsUbuntu Gnome: Custom Keyboard Shortcut for “gnome-screenshot -a(--area)” not working rightNautilus scripts not showing up (although on the right folder and executable)How to write a script to open current path from nautilus in guakeBash script cannot run with keyboard shortcutNautilus: Custom Action on selected files via keyboard short-cutAdd nautilus scripts to the context menu/actions
How much attack damage does the AC boost from a shield prevent on average?
Examples of a statistic that is not independent of sample's distribution?
How could our ancestors have domesticated a solitary predator?
What is the likely impact of grounding an entire aircraft series?
How much stiffer are 23c tires over 28c?
The bar has been raised
Good for you! in Russian
Is Gradient Descent central to every optimizer?
Subset counting for even numbers
Are babies of evil humanoid species inherently evil?
If the Captain's screens are out, does he switch seats with the co-pilot?
Why does the negative sign arise in this thermodynamic relation?
Rejected in 4th interview round citing insufficient years of experience
Should I tell my boss the work he did was worthless
Does a Catoblepas statblock appear in an official D&D 5e product?
Best approach to update all entries in a list that is paginated?
Peter's Strange Word
How to pass a string to a command that expects a file?
Latest web browser compatible with Windows 98
BitNot does not flip bits in the way I expected
Why doesn't this Google Translate ad use the word "Translation" instead of "Translate"?
Should I take out a loan for a friend to invest on my behalf?
PTIJ: How can I halachically kill a vampire?
They call me Inspector Morse
How can I assign keyboard shortcut for nautilus scripts?
How can I create keyboard shortcuts for my nautilus scripts?How to set folder icons of multiple folders automatically?How can I set a shortcut key to open selected file in nautilus?Creating a hotkey for an aliasIf active window is file manager then store selected files in variableHow can I create keyboard shortcuts for my nautilus scripts?How can I instruct Nautilus to pre-generate thumbnails?How can I stop Nautilus from dereferencing symlinks?Program/Keyboard shortcut to work with multiple monitorsUbuntu Gnome: Custom Keyboard Shortcut for “gnome-screenshot -a(--area)” not working rightNautilus scripts not showing up (although on the right folder and executable)How to write a script to open current path from nautilus in guakeBash script cannot run with keyboard shortcutNautilus: Custom Action on selected files via keyboard short-cutAdd nautilus scripts to the context menu/actions
I've setup a Nautilus Script. I've put the script in /home/sumeet/.local/share/nautilus/scripts
and it does appear in right click menu. and also works as expected. I just want to assign a shortcut to the script.
How can I create keyboard shortcuts for my nautilus scripts?
Answers given in the question above target a specific release and are completely outdated, and I couldn't find anything other than this question concerning this topic.
nautilus shortcut-keys
|
show 5 more comments
I've setup a Nautilus Script. I've put the script in /home/sumeet/.local/share/nautilus/scripts
and it does appear in right click menu. and also works as expected. I just want to assign a shortcut to the script.
How can I create keyboard shortcuts for my nautilus scripts?
Answers given in the question above target a specific release and are completely outdated, and I couldn't find anything other than this question concerning this topic.
nautilus shortcut-keys
Can be done, but you need to edit the nautilus script a bit too. Is that possible in your case? (I suspect it is :) ). Bothe Serg and I did something like that here: askubuntu.com/questions/886642/…. That solution can be applied here, but it takes the targeted script to receive the file or directory as argument.
– Jacob Vlijm
May 31 '17 at 5:36
@JacobVlijm it's the same script (you know which one)
– Sumeet Deshmukh
May 31 '17 at 6:15
1
AHAAA, then the answer is quite simple. I hope I can post it somewhere today.
– Jacob Vlijm
May 31 '17 at 6:16
@JacobVlijm appreciate it man.
– Sumeet Deshmukh
May 31 '17 at 6:31
Hi Sumeet, I promiss I will apply the lost&found fix to all occurrences of the script, including the one I just posted. Immediately if I can breathe again :)
– Jacob Vlijm
May 31 '17 at 18:45
|
show 5 more comments
I've setup a Nautilus Script. I've put the script in /home/sumeet/.local/share/nautilus/scripts
and it does appear in right click menu. and also works as expected. I just want to assign a shortcut to the script.
How can I create keyboard shortcuts for my nautilus scripts?
Answers given in the question above target a specific release and are completely outdated, and I couldn't find anything other than this question concerning this topic.
nautilus shortcut-keys
I've setup a Nautilus Script. I've put the script in /home/sumeet/.local/share/nautilus/scripts
and it does appear in right click menu. and also works as expected. I just want to assign a shortcut to the script.
How can I create keyboard shortcuts for my nautilus scripts?
Answers given in the question above target a specific release and are completely outdated, and I couldn't find anything other than this question concerning this topic.
nautilus shortcut-keys
nautilus shortcut-keys
edited May 31 '17 at 23:33
Ali Razmdideh
3,58311838
3,58311838
asked May 24 '17 at 14:04
Sumeet DeshmukhSumeet Deshmukh
4,45063172
4,45063172
Can be done, but you need to edit the nautilus script a bit too. Is that possible in your case? (I suspect it is :) ). Bothe Serg and I did something like that here: askubuntu.com/questions/886642/…. That solution can be applied here, but it takes the targeted script to receive the file or directory as argument.
– Jacob Vlijm
May 31 '17 at 5:36
@JacobVlijm it's the same script (you know which one)
– Sumeet Deshmukh
May 31 '17 at 6:15
1
AHAAA, then the answer is quite simple. I hope I can post it somewhere today.
– Jacob Vlijm
May 31 '17 at 6:16
@JacobVlijm appreciate it man.
– Sumeet Deshmukh
May 31 '17 at 6:31
Hi Sumeet, I promiss I will apply the lost&found fix to all occurrences of the script, including the one I just posted. Immediately if I can breathe again :)
– Jacob Vlijm
May 31 '17 at 18:45
|
show 5 more comments
Can be done, but you need to edit the nautilus script a bit too. Is that possible in your case? (I suspect it is :) ). Bothe Serg and I did something like that here: askubuntu.com/questions/886642/…. That solution can be applied here, but it takes the targeted script to receive the file or directory as argument.
– Jacob Vlijm
May 31 '17 at 5:36
@JacobVlijm it's the same script (you know which one)
– Sumeet Deshmukh
May 31 '17 at 6:15
1
AHAAA, then the answer is quite simple. I hope I can post it somewhere today.
– Jacob Vlijm
May 31 '17 at 6:16
@JacobVlijm appreciate it man.
– Sumeet Deshmukh
May 31 '17 at 6:31
Hi Sumeet, I promiss I will apply the lost&found fix to all occurrences of the script, including the one I just posted. Immediately if I can breathe again :)
– Jacob Vlijm
May 31 '17 at 18:45
Can be done, but you need to edit the nautilus script a bit too. Is that possible in your case? (I suspect it is :) ). Bothe Serg and I did something like that here: askubuntu.com/questions/886642/…. That solution can be applied here, but it takes the targeted script to receive the file or directory as argument.
– Jacob Vlijm
May 31 '17 at 5:36
Can be done, but you need to edit the nautilus script a bit too. Is that possible in your case? (I suspect it is :) ). Bothe Serg and I did something like that here: askubuntu.com/questions/886642/…. That solution can be applied here, but it takes the targeted script to receive the file or directory as argument.
– Jacob Vlijm
May 31 '17 at 5:36
@JacobVlijm it's the same script (you know which one)
– Sumeet Deshmukh
May 31 '17 at 6:15
@JacobVlijm it's the same script (you know which one)
– Sumeet Deshmukh
May 31 '17 at 6:15
1
1
AHAAA, then the answer is quite simple. I hope I can post it somewhere today.
– Jacob Vlijm
May 31 '17 at 6:16
AHAAA, then the answer is quite simple. I hope I can post it somewhere today.
– Jacob Vlijm
May 31 '17 at 6:16
@JacobVlijm appreciate it man.
– Sumeet Deshmukh
May 31 '17 at 6:31
@JacobVlijm appreciate it man.
– Sumeet Deshmukh
May 31 '17 at 6:31
Hi Sumeet, I promiss I will apply the lost&found fix to all occurrences of the script, including the one I just posted. Immediately if I can breathe again :)
– Jacob Vlijm
May 31 '17 at 18:45
Hi Sumeet, I promiss I will apply the lost&found fix to all occurrences of the script, including the one I just posted. Immediately if I can breathe again :)
– Jacob Vlijm
May 31 '17 at 18:45
|
show 5 more comments
2 Answers
2
active
oldest
votes
How it can be done
When you right- click a file or folder for a nautilus script, the selected file is passed as an argument to the script. In most cases by something like:
import os
subject = os.getenv("NAUTILUS_SCRIPT_CURRENT_URI")
...using python3, in its simplest form.
If you replace this by:
import pyperclip
subprocess.call(["xdotool", "key", "Control_L+c"])
subject = pyperclip.paste()
...the currently selected file is used inside the script as an argument
What you need
To use this solution (16.04 and up), you need to install both xdotool
and python3-pyperclip
:
sudo apt-get install python3-pyperclip xdotool
The complete script, mentioned in comments
then becomes:
#!/usr/bin/env python3
import subprocess
import os
import sys
import pyperclip
# --- set the list of valid extensions below (lowercase)
# --- use quotes, *don't* include the dot!
ext = ["jpg", "jpeg", "png", "gif", "icns", "ico"]
# --- set the list of preferred filenames
# --- use quotes
specs = ["folder.png", "cover.png", "monkey.png"]
# ---
# retrieve the path of the targeted folder
subprocess.call(["xdotool", "key", "Control_L+c"])
dr = pyperclip.paste()
for root, dirs, files in os.walk(dr):
for directory in dirs:
folder = os.path.join(root, directory)
fls = os.listdir(folder)
try:
first = [p for p in fls if p in specs]
first = first[0] if first else min(
p for p in fls if p.split(".")[-1].lower() in ext
)
except ValueError:
pass
else:
subprocess.Popen([
"gvfs-set-attribute", "-t", "string",
os.path.abspath(folder), "metadata::custom-icon",
"file://"+os.path.abspath(os.path.join(folder, first))
])
Adding this to a shortcut key will set the icons for all directories inside the selected one.
Adding it to a shortcut key (!)
Adding shortcut keys, running (scripts using-) xdotool
commands to press another key combination can be tricky. To prevent both key combinations to interfere with each other, use:
/bin/bash -c "sleep 1 && python3 /path/to/script.py"
Explanation
When Ctrl+C is pressed while a file is selected, the path to the file is copied to the clipboard. We are simulating the key press with:
subprocess.call(["xdotool", "key", "Control_L+c"])
python
's pyperclip
module simply produces the path, stripped from file://
when using pyperclip.paste()
(this will not literally paste, but make the path available inside the script).
add a comment |
If the goal is to select files and execute actions it's possible to do it using just shell script with xdotool
and xclip
. So first install them:
sudo apt-get install xdotool xclip
And then create the following script with the actions inside the loop:
#!/bin/bash
file=$(mktemp)
xdotool key "Control_L+c"
variable="$( xclip -out -selection clipboard)"
variable="$( echo -e "$variable" |
awk 'BEGIN FS = "n" printf ""%s" ", $1 ' |
sed -e s#""## |
sed 's/" "/"n"/g')"
echo "$variable" > $file
if [ -s "$file" ]; then
while read absolute_path_file; do
absolute_path_file="$(eval echo "$absolute_path_file")"
base_name="$(basename "$absolute_path_file")"
### Execute the actions with the selected files here
### echo "$absolute_path_file"
### echo "$base_name"
done < $file
fi
This script doesn't rely on the NAUTILUS variables and you can create a shortcut with it:
/bin/bash -c "sleep 1 && /path/script.bash"
add a comment |
Your Answer
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "89"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2faskubuntu.com%2fquestions%2f918464%2fhow-can-i-assign-keyboard-shortcut-for-nautilus-scripts%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
How it can be done
When you right- click a file or folder for a nautilus script, the selected file is passed as an argument to the script. In most cases by something like:
import os
subject = os.getenv("NAUTILUS_SCRIPT_CURRENT_URI")
...using python3, in its simplest form.
If you replace this by:
import pyperclip
subprocess.call(["xdotool", "key", "Control_L+c"])
subject = pyperclip.paste()
...the currently selected file is used inside the script as an argument
What you need
To use this solution (16.04 and up), you need to install both xdotool
and python3-pyperclip
:
sudo apt-get install python3-pyperclip xdotool
The complete script, mentioned in comments
then becomes:
#!/usr/bin/env python3
import subprocess
import os
import sys
import pyperclip
# --- set the list of valid extensions below (lowercase)
# --- use quotes, *don't* include the dot!
ext = ["jpg", "jpeg", "png", "gif", "icns", "ico"]
# --- set the list of preferred filenames
# --- use quotes
specs = ["folder.png", "cover.png", "monkey.png"]
# ---
# retrieve the path of the targeted folder
subprocess.call(["xdotool", "key", "Control_L+c"])
dr = pyperclip.paste()
for root, dirs, files in os.walk(dr):
for directory in dirs:
folder = os.path.join(root, directory)
fls = os.listdir(folder)
try:
first = [p for p in fls if p in specs]
first = first[0] if first else min(
p for p in fls if p.split(".")[-1].lower() in ext
)
except ValueError:
pass
else:
subprocess.Popen([
"gvfs-set-attribute", "-t", "string",
os.path.abspath(folder), "metadata::custom-icon",
"file://"+os.path.abspath(os.path.join(folder, first))
])
Adding this to a shortcut key will set the icons for all directories inside the selected one.
Adding it to a shortcut key (!)
Adding shortcut keys, running (scripts using-) xdotool
commands to press another key combination can be tricky. To prevent both key combinations to interfere with each other, use:
/bin/bash -c "sleep 1 && python3 /path/to/script.py"
Explanation
When Ctrl+C is pressed while a file is selected, the path to the file is copied to the clipboard. We are simulating the key press with:
subprocess.call(["xdotool", "key", "Control_L+c"])
python
's pyperclip
module simply produces the path, stripped from file://
when using pyperclip.paste()
(this will not literally paste, but make the path available inside the script).
add a comment |
How it can be done
When you right- click a file or folder for a nautilus script, the selected file is passed as an argument to the script. In most cases by something like:
import os
subject = os.getenv("NAUTILUS_SCRIPT_CURRENT_URI")
...using python3, in its simplest form.
If you replace this by:
import pyperclip
subprocess.call(["xdotool", "key", "Control_L+c"])
subject = pyperclip.paste()
...the currently selected file is used inside the script as an argument
What you need
To use this solution (16.04 and up), you need to install both xdotool
and python3-pyperclip
:
sudo apt-get install python3-pyperclip xdotool
The complete script, mentioned in comments
then becomes:
#!/usr/bin/env python3
import subprocess
import os
import sys
import pyperclip
# --- set the list of valid extensions below (lowercase)
# --- use quotes, *don't* include the dot!
ext = ["jpg", "jpeg", "png", "gif", "icns", "ico"]
# --- set the list of preferred filenames
# --- use quotes
specs = ["folder.png", "cover.png", "monkey.png"]
# ---
# retrieve the path of the targeted folder
subprocess.call(["xdotool", "key", "Control_L+c"])
dr = pyperclip.paste()
for root, dirs, files in os.walk(dr):
for directory in dirs:
folder = os.path.join(root, directory)
fls = os.listdir(folder)
try:
first = [p for p in fls if p in specs]
first = first[0] if first else min(
p for p in fls if p.split(".")[-1].lower() in ext
)
except ValueError:
pass
else:
subprocess.Popen([
"gvfs-set-attribute", "-t", "string",
os.path.abspath(folder), "metadata::custom-icon",
"file://"+os.path.abspath(os.path.join(folder, first))
])
Adding this to a shortcut key will set the icons for all directories inside the selected one.
Adding it to a shortcut key (!)
Adding shortcut keys, running (scripts using-) xdotool
commands to press another key combination can be tricky. To prevent both key combinations to interfere with each other, use:
/bin/bash -c "sleep 1 && python3 /path/to/script.py"
Explanation
When Ctrl+C is pressed while a file is selected, the path to the file is copied to the clipboard. We are simulating the key press with:
subprocess.call(["xdotool", "key", "Control_L+c"])
python
's pyperclip
module simply produces the path, stripped from file://
when using pyperclip.paste()
(this will not literally paste, but make the path available inside the script).
add a comment |
How it can be done
When you right- click a file or folder for a nautilus script, the selected file is passed as an argument to the script. In most cases by something like:
import os
subject = os.getenv("NAUTILUS_SCRIPT_CURRENT_URI")
...using python3, in its simplest form.
If you replace this by:
import pyperclip
subprocess.call(["xdotool", "key", "Control_L+c"])
subject = pyperclip.paste()
...the currently selected file is used inside the script as an argument
What you need
To use this solution (16.04 and up), you need to install both xdotool
and python3-pyperclip
:
sudo apt-get install python3-pyperclip xdotool
The complete script, mentioned in comments
then becomes:
#!/usr/bin/env python3
import subprocess
import os
import sys
import pyperclip
# --- set the list of valid extensions below (lowercase)
# --- use quotes, *don't* include the dot!
ext = ["jpg", "jpeg", "png", "gif", "icns", "ico"]
# --- set the list of preferred filenames
# --- use quotes
specs = ["folder.png", "cover.png", "monkey.png"]
# ---
# retrieve the path of the targeted folder
subprocess.call(["xdotool", "key", "Control_L+c"])
dr = pyperclip.paste()
for root, dirs, files in os.walk(dr):
for directory in dirs:
folder = os.path.join(root, directory)
fls = os.listdir(folder)
try:
first = [p for p in fls if p in specs]
first = first[0] if first else min(
p for p in fls if p.split(".")[-1].lower() in ext
)
except ValueError:
pass
else:
subprocess.Popen([
"gvfs-set-attribute", "-t", "string",
os.path.abspath(folder), "metadata::custom-icon",
"file://"+os.path.abspath(os.path.join(folder, first))
])
Adding this to a shortcut key will set the icons for all directories inside the selected one.
Adding it to a shortcut key (!)
Adding shortcut keys, running (scripts using-) xdotool
commands to press another key combination can be tricky. To prevent both key combinations to interfere with each other, use:
/bin/bash -c "sleep 1 && python3 /path/to/script.py"
Explanation
When Ctrl+C is pressed while a file is selected, the path to the file is copied to the clipboard. We are simulating the key press with:
subprocess.call(["xdotool", "key", "Control_L+c"])
python
's pyperclip
module simply produces the path, stripped from file://
when using pyperclip.paste()
(this will not literally paste, but make the path available inside the script).
How it can be done
When you right- click a file or folder for a nautilus script, the selected file is passed as an argument to the script. In most cases by something like:
import os
subject = os.getenv("NAUTILUS_SCRIPT_CURRENT_URI")
...using python3, in its simplest form.
If you replace this by:
import pyperclip
subprocess.call(["xdotool", "key", "Control_L+c"])
subject = pyperclip.paste()
...the currently selected file is used inside the script as an argument
What you need
To use this solution (16.04 and up), you need to install both xdotool
and python3-pyperclip
:
sudo apt-get install python3-pyperclip xdotool
The complete script, mentioned in comments
then becomes:
#!/usr/bin/env python3
import subprocess
import os
import sys
import pyperclip
# --- set the list of valid extensions below (lowercase)
# --- use quotes, *don't* include the dot!
ext = ["jpg", "jpeg", "png", "gif", "icns", "ico"]
# --- set the list of preferred filenames
# --- use quotes
specs = ["folder.png", "cover.png", "monkey.png"]
# ---
# retrieve the path of the targeted folder
subprocess.call(["xdotool", "key", "Control_L+c"])
dr = pyperclip.paste()
for root, dirs, files in os.walk(dr):
for directory in dirs:
folder = os.path.join(root, directory)
fls = os.listdir(folder)
try:
first = [p for p in fls if p in specs]
first = first[0] if first else min(
p for p in fls if p.split(".")[-1].lower() in ext
)
except ValueError:
pass
else:
subprocess.Popen([
"gvfs-set-attribute", "-t", "string",
os.path.abspath(folder), "metadata::custom-icon",
"file://"+os.path.abspath(os.path.join(folder, first))
])
Adding this to a shortcut key will set the icons for all directories inside the selected one.
Adding it to a shortcut key (!)
Adding shortcut keys, running (scripts using-) xdotool
commands to press another key combination can be tricky. To prevent both key combinations to interfere with each other, use:
/bin/bash -c "sleep 1 && python3 /path/to/script.py"
Explanation
When Ctrl+C is pressed while a file is selected, the path to the file is copied to the clipboard. We are simulating the key press with:
subprocess.call(["xdotool", "key", "Control_L+c"])
python
's pyperclip
module simply produces the path, stripped from file://
when using pyperclip.paste()
(this will not literally paste, but make the path available inside the script).
edited Jun 1 '17 at 21:08
answered May 31 '17 at 18:38
Jacob VlijmJacob Vlijm
64.9k9129225
64.9k9129225
add a comment |
add a comment |
If the goal is to select files and execute actions it's possible to do it using just shell script with xdotool
and xclip
. So first install them:
sudo apt-get install xdotool xclip
And then create the following script with the actions inside the loop:
#!/bin/bash
file=$(mktemp)
xdotool key "Control_L+c"
variable="$( xclip -out -selection clipboard)"
variable="$( echo -e "$variable" |
awk 'BEGIN FS = "n" printf ""%s" ", $1 ' |
sed -e s#""## |
sed 's/" "/"n"/g')"
echo "$variable" > $file
if [ -s "$file" ]; then
while read absolute_path_file; do
absolute_path_file="$(eval echo "$absolute_path_file")"
base_name="$(basename "$absolute_path_file")"
### Execute the actions with the selected files here
### echo "$absolute_path_file"
### echo "$base_name"
done < $file
fi
This script doesn't rely on the NAUTILUS variables and you can create a shortcut with it:
/bin/bash -c "sleep 1 && /path/script.bash"
add a comment |
If the goal is to select files and execute actions it's possible to do it using just shell script with xdotool
and xclip
. So first install them:
sudo apt-get install xdotool xclip
And then create the following script with the actions inside the loop:
#!/bin/bash
file=$(mktemp)
xdotool key "Control_L+c"
variable="$( xclip -out -selection clipboard)"
variable="$( echo -e "$variable" |
awk 'BEGIN FS = "n" printf ""%s" ", $1 ' |
sed -e s#""## |
sed 's/" "/"n"/g')"
echo "$variable" > $file
if [ -s "$file" ]; then
while read absolute_path_file; do
absolute_path_file="$(eval echo "$absolute_path_file")"
base_name="$(basename "$absolute_path_file")"
### Execute the actions with the selected files here
### echo "$absolute_path_file"
### echo "$base_name"
done < $file
fi
This script doesn't rely on the NAUTILUS variables and you can create a shortcut with it:
/bin/bash -c "sleep 1 && /path/script.bash"
add a comment |
If the goal is to select files and execute actions it's possible to do it using just shell script with xdotool
and xclip
. So first install them:
sudo apt-get install xdotool xclip
And then create the following script with the actions inside the loop:
#!/bin/bash
file=$(mktemp)
xdotool key "Control_L+c"
variable="$( xclip -out -selection clipboard)"
variable="$( echo -e "$variable" |
awk 'BEGIN FS = "n" printf ""%s" ", $1 ' |
sed -e s#""## |
sed 's/" "/"n"/g')"
echo "$variable" > $file
if [ -s "$file" ]; then
while read absolute_path_file; do
absolute_path_file="$(eval echo "$absolute_path_file")"
base_name="$(basename "$absolute_path_file")"
### Execute the actions with the selected files here
### echo "$absolute_path_file"
### echo "$base_name"
done < $file
fi
This script doesn't rely on the NAUTILUS variables and you can create a shortcut with it:
/bin/bash -c "sleep 1 && /path/script.bash"
If the goal is to select files and execute actions it's possible to do it using just shell script with xdotool
and xclip
. So first install them:
sudo apt-get install xdotool xclip
And then create the following script with the actions inside the loop:
#!/bin/bash
file=$(mktemp)
xdotool key "Control_L+c"
variable="$( xclip -out -selection clipboard)"
variable="$( echo -e "$variable" |
awk 'BEGIN FS = "n" printf ""%s" ", $1 ' |
sed -e s#""## |
sed 's/" "/"n"/g')"
echo "$variable" > $file
if [ -s "$file" ]; then
while read absolute_path_file; do
absolute_path_file="$(eval echo "$absolute_path_file")"
base_name="$(basename "$absolute_path_file")"
### Execute the actions with the selected files here
### echo "$absolute_path_file"
### echo "$base_name"
done < $file
fi
This script doesn't rely on the NAUTILUS variables and you can create a shortcut with it:
/bin/bash -c "sleep 1 && /path/script.bash"
edited 28 mins ago
answered Jun 29 '18 at 2:02
Rafael MuynarskRafael Muynarsk
547520
547520
add a comment |
add a comment |
Thanks for contributing an answer to Ask Ubuntu!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2faskubuntu.com%2fquestions%2f918464%2fhow-can-i-assign-keyboard-shortcut-for-nautilus-scripts%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Can be done, but you need to edit the nautilus script a bit too. Is that possible in your case? (I suspect it is :) ). Bothe Serg and I did something like that here: askubuntu.com/questions/886642/…. That solution can be applied here, but it takes the targeted script to receive the file or directory as argument.
– Jacob Vlijm
May 31 '17 at 5:36
@JacobVlijm it's the same script (you know which one)
– Sumeet Deshmukh
May 31 '17 at 6:15
1
AHAAA, then the answer is quite simple. I hope I can post it somewhere today.
– Jacob Vlijm
May 31 '17 at 6:16
@JacobVlijm appreciate it man.
– Sumeet Deshmukh
May 31 '17 at 6:31
Hi Sumeet, I promiss I will apply the lost&found fix to all occurrences of the script, including the one I just posted. Immediately if I can breathe again :)
– Jacob Vlijm
May 31 '17 at 18:45