.desktop shortcuts
Posted: Tue Nov 30, 2010 11:51 pm
Hi. I've been working with LXDE for about a year, and I'm stuck on the idea of having GUIs for everything. It's been annoying to me that I haven't been able to find a good GUI for creating .desktop shortcuts. Yes, I know it's easy to just create the file in text, but I used a really crappy proprietary operating system for 15 years. I'm used to GUIs. Unless I'm missing something obvious, there aren't GUI tools for creating .desktop shortcuts in LXDE. I found some code on the ubuntu forum using zenity, so I installed zenity in Arch. I modified the code and got it working to create shortcuts. I thought it might be helpful to others. I don't know any programming languages, except for teaching myself some HTML in the late 1990s. I was just doing my best to work off of the original poster's code and get it working. Any suggestions for improvement would be appreciated. Here's the code:
Code: Select all
#!/bin/bash
###
# this is a script to add some gui features to lxshortcut for a more user friendly experience
# must have zenity package installed
# found on ubuntu forums posted by kerry_s March 20th, 2010, 06:23 PM
# created on lubuntu 10.04 3/19/2010
# modified by Jason Kopsch on 2010-11-30 jasonkopsch at gmail dot com
# it's a script to fill a need, you may do with it as you please
###
## this part is the choices to choose from ##
chose=`zenity --list --title="Create a New Shortcut" --column= "Make Launcher"`
## this part makes the launcher ##
if [ "$chose" = "Make Launcher" ]; then
## enter name for .desktop file ##
name=`zenity --entry --text="Enter a Name (example: xterm)
this will not be the name shown, it's only the name for the *.desktop file"`
## if name is entered, remove existing .desktop file of the same name if it exists ##
if [ "$name" ]; then
rm -f $HOME/.local/share/applications/$name.desktop
## create .desktop file using entered name in the user's directory from which LXDE will create menu entries ##
lxshortcut -o $HOME/.local/share/applications/$name.desktop
## indicate desktop entry, required for LXDE shortcuts ##
echo "[Desktop Entry]" >> $HOME/.local/share/applications/$name.desktop
## indicate startupnotify, may be true or false, setting to true to make it simple ##
echo "StartupNotify=true" >> $HOME/.local/share/applications/$name.desktop
## indicate application ##
echo "Type=Application" >> $HOME/.local/share/applications/$name.desktop
## choose category for placement in menu ##
select_cat=`zenity --list --height="400" --text="Choose the Menu Section" --column= Utility Graphics Network Office AudioVideo System Settings Other`
echo "Categories=$select_cat;" >> $HOME/.local/share/applications/$name.desktop
## enter name of application ##
enter_name=`zenity --entry --text="Enter Name of Application"`
echo "Name=$enter_name" >> $HOME/.local/share/applications/$name.desktop
## enter path of application ##
enter_path=`zenity --entry --text="Enter Path of Application"`
echo "Exec=$enter_path" >> $HOME/.local/share/applications/$name.desktop
## enter icon for application ##
enter_icon=`zenity --entry --text="Enter Name or Path of Icon"`
echo "Icon=$enter_icon" >> $HOME/.local/share/applications/$name.desktop
else
exit 0
fi
fi
## to be implemented later , feel free to have a go at it##
## this part is to edit the launcher ##
#
#if [ "$chose" = "Edit Launcher" ]; then
#
#scan=`ls $HOME/.local/share/applications | grep .desktop`
#selected=`zenity --list --height="400" --column="" $scan`
#if [ $selected ]; then
#lxshortcut -i $selected
#sed -e '/;$/d' -i $HOME/.local/share/applications/$selected
#select=`zenity --list --height="400" --text="Choose the Menu Section" --column="" Utility Graphics Network Office AudioVideo System Settings Other`
#echo "Categories=$select;" >> $HOME/.local/share/applications/$selected
#else
#exit0
#fi
#fi
## to be implemented later, feel free to have a go at it ##
## this part is to delete the launcher ##
#
#if [ "$chose" = "Delete Launcher" ]; then
#
#scan=`ls $HOME/.local/share/applications | grep .desktop`
#selected=`zenity --list --height="400" --column="" $scan`
#if [ $selected ]; then
#rm $HOME/.local/share/applications/$selected
#zenity --info --text="Launcher removed"
#else
#exit 0
#fi
#fi
exit 0