You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
# A simple Nautilus script to create Unity launchers by right-clicking on files
5
+
#
6
+
# by Hasan N. Genc
7
+
8
+
file="$NAUTILUS_SCRIPT_SELECTED_FILE_PATHS"
9
+
file=${file%$'\n'}
10
+
11
+
# Make sure only one file has been selected
12
+
if [[ $(printf "$file"| wc -l)> 0 ]];then
13
+
zenity --error --text="Do not select more than one file."
14
+
exit 1
15
+
fi
16
+
17
+
# Make sure that selected file is an executable
18
+
if! [[ -x$file ]];then
19
+
zenity --error --text="You must select a file which can be executed."
20
+
exit 1
21
+
fi
22
+
23
+
# Get the launcher's name
24
+
launcher_name=$(zenity --entry --title="Enter launcher name" --text="Enter name of launcher" --entry-text "${file##*/}" --cancel-label=Quit --width=300)
25
+
26
+
if [[ $?!= 0 ]];then
27
+
exit 1
28
+
fi
29
+
30
+
# Get the launcher's exec command
31
+
launcher_exec=$(zenity --entry --title="Enter command" --text="Enter command to be executed by launcher" --entry-text "\"$file\"" --cancel-label=Quit --width=500)
32
+
33
+
if [[ $?!= 0 ]];then
34
+
exit 1
35
+
fi
36
+
37
+
# Get the launcher's icon
38
+
if zenity --question --text="Do you want to give the launcher a specific icon?";then
39
+
launcher_icon=$(zenity --file-selection --title="Select icon (cancel if you want to use default icon)")
40
+
fi
41
+
42
+
# Create the launcher file using the previously obtained information
# If the script tries to create the launcher in a folder that it does not have permission to do so, the previous printf command will fail. In that case, let the user choose where to save the launcher
47
+
if [[ $?!= 0 ]];then
48
+
zenity --error --text="The launcher cannot be saved in your current directory. Please select a new location to save the launcher."
49
+
50
+
destination=$(zenity --file-selection --title="Select where to save launcher" --save --confirm-overwrite --file-filter="All files | *.*" --file-filter="Desktop files (.desktop) | *.desktop")
"Create Launcher" is a simple Nautilus script used to create Unity launchers (.desktop files) by right-clicking on executable files. Currently, the script only works for non-terminal applications.
11
+
12
+
To set up the script, copy the "Create Launcher" file to your Nautilus scripts directory (~/.local/share/nautilus/scripts/ for Ubuntu 14.04 and later). Give the script permission to be executed. Finally, make sure to visit the script directory with Nautilus so that your new script will appear on the context menu whenever you right-click a file.
13
+
14
+
======================
15
+
DEPENDENCIES
16
+
======================
17
+
18
+
The only dependency is Zenity, which is installed by default on Ubuntu releases anyway.
0 commit comments