.desktop shortcuts

All questions and problems regarding LXDE components including LXSession, LXAppearance, GPicView, Leafpad, LXTerminal, Xarchiver, LXNM to be discussed here.

For PCManFM questions, please ask in the dedicated forum below.
Locked
jekopsch
Posts: 3
Joined: Tue Feb 09, 2010 5:10 am

.desktop shortcuts

Post by jekopsch »

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

Marty Jack
Posts: 381
Joined: Mon Mar 23, 2009 5:14 am

Re: .desktop shortcuts

Post by Marty Jack »

There is lxshortcut, which admittedly has a very poor interface for specifying the input and output.

Moreover nothing stops you from running alacarte.

If you want a fully GUI-ed experience you might be happier with Gnome or KDE or Xfce.
jekopsch
Posts: 3
Joined: Tue Feb 09, 2010 5:10 am

Re: .desktop shortcuts

Post by jekopsch »

Thanks for the reply, Marty Jack. I tried to install lxshortcut on my computer, but I got an error message when I tried to run ./configuration. I can't remember what the error was and I didn't try to figure it out. The script that I posted actually calls for lxshortcut, but it works without having that installed. I don't understand exactly why.

I've tried Gnome, KDE and XFCE. I'm using Gnome on other computers, but I'm working on this old laptop from around 2002 as a project. I'm trying to keep resource usage to a minimum, since I'm maxed out at 256 megs of RAM (one of the slots is bad). I like LXDE a lot, but there are some things about it that are inconvenient. I'm trying to come up with ways to make it work better for me without taxing my limited resources too much.

Since I posted the script, I added the function to browse the file system for the path of the executable and icon, rather than typing the path in manually. So the script is working pretty well for me. I don't have to create .desktop shortcuts all that often, but for when I do I'm glad that I have a convenient way of getting those shortcuts into the menu.
wrprlp
Posts: 1
Joined: Thu Mar 03, 2011 4:04 pm

Re: .desktop shortcuts

Post by wrprlp »

Hi,I am new to this Desktop I work for a School District and we have some older computers with low resources same as you. I have been trying to figure out how to place a Web link on the desktop. This is what we do for standard setup for the kids. If anyone can help me with this that would be great.

Thanks,
nobange
Posts: 16
Joined: Thu Aug 19, 2010 10:00 pm
Location: Gorzów Wlkp., Poland

Re: .desktop shortcuts

Post by nobange »

Web link on desktop - simple. Open any .desktop file in some text editor, change Name to "Link to website" or something, and most important thing: in Exec type: "firefox http://google.com" (without quotes) or other address you wish. After this, double click on this icon will start Firefox and load Google :) Enjoy and don't forget to install some xxx blocker :D
dodddummy
Posts: 1
Joined: Sun Dec 11, 2011 1:10 pm

Re: .desktop shortcuts

Post by dodddummy »

I added a menu item to 'lxshortcut -o newitem' itself. I used that to create shortcuts.
huihs
Posts: 8
Joined: Tue May 15, 2012 1:23 am

Re: .desktop shortcuts

Post by huihs »

desktop shortcuts in LXDE
seppalta
Posts: 449
Joined: Tue Sep 20, 2011 6:09 am
Location: USA
Contact:

Re: .desktop shortcuts

Post by seppalta »

Lxmed is a super GUI for creating desktop files from which you can shortcut anything to the desktop. See for details:
http://douwil7.100webspace.net/linux/Tuning.html#11 .
Of course, you need a good java program installed for lxmed to work. For installing Sunjava6, see the java section of the aformentioned link.
,
Locked