Light application-icon executable maker for XFCE? yup!

Forum rules
Before you post please read how to get help

Light application-icon executable maker for XFCE? yup!

Postby sagirfahmid3 on Sat Aug 25, 2012 6:24 pm

Hi everyone, I have here a simple bash script that I made to create application icons (for the times when they are not automatically created--eg. compiled programs, etc..)
What you basically do is run it in a terminal, it asks you a few questions (like where the executable of the application is, the icon, etc), and it makes a .desktop file.
It THEN moves over to /usr/share/applications/ (so it can be seen by all users of the pc--you can change the line to /usr/local/share/applications/ for single-user).

I know for LXDE there's LXMed, but seriously, I don't want to install Java to be able to use that--yes I know LXMed is fancy and all that, but I can live with the command line.
I know Gnome and KDE have their own menu editors, but I don't know one for XFCE (unless you want to follow this method--too time consuming)
The script is less than 3 KBs so you could say it's the lightest editor there is (non-GUI of course). It works for all desktop environments and windows managers too, but I just put this in the XFCE section because we need some more apps (or in this case a script).

Things you should know:
1. The prompts which ask for the executable's location and application's icon come with tab-completion enabled so it will make things MUCH easier to type the locations, etc..
2. The chances of overwriting an already existing application icon is virtually zero (unless you don't know how to read)--I made the command an interactive one (mv -i).
3. I am going to make a better one using Zenity hopefully (so it's going to be a GUI script). In the meanwhile, I think you can live with commandline.

Here is the download link to the script. Make sure you chmod +X it and also chmod 777 it (chmod +X appicon.sh && chmod 777 appicon.sh):
https://docs.google.com/open?id=0B-Pkn6 ... VRVUkNOYk0

This is what the script contains:
Code: Select all
#!/bin/bash

echo 'Hello there, thanks for checking out this simple script!
(Note: A future version will use zenity, so it will be a GUI script)

What does this script do? It makes a .desktop file for an application that
does not automatically make one (for example some programs that are compiled)

Choose a number that describes the category your application falls under from below:

      ###########################################
      | 0 System      | 4 Graphics    |
      | 1 Office      | 5 Development |
      | 2 Network      | 6 Accessories |
      | 3 Multimedia      | 7 Other       |
      ###########################################'

echo ""
echo "What category does the application fall under? (Pick ONE number)."
read number

if [ $number -gt 7 ]; then
echo "Incorrect input. Please enter a number between 0 to 7 from chart."
exit 0;
fi

echo "What is the name of the application?"; read name
echo "Where is the executable of the application located?
Please enter the full path (i.e. NOT ~/program/app.bin, BUT /home/user/program/app.bin
Note: Tab completion is enabled :D"; read -e loc
echo "Where is the icon of the application located? (you may keep it blank)
Please enter the full path (i.e. NOT ~/program/app.png, BUT /home/user/program/app.png
Note: Tab completion is enabled :D"; read -e icon
echo "Enter a comment. (Ex: Firefox, the awesomest web browser)
You can leave this blank if you want."; read comment

echo '[Desktop Entry]
Name='$name'
Type=Application
Exec='$loc'
Terminal=false
Icon='$icon'
Comment='$comment'' | tee "$name".desktop &>/dev/null

if [ $number = "0" ]; then
echo "Categories=System;" >> "$name".desktop
fi
if [ $number = "1" ]; then
echo "Categories=Office;" >> "$name".desktop
fi
if [ $number = "2" ]; then
echo "Categories=Network;" >> "$name".desktop
fi
if [ $number = "3" ]; then
echo "Categories=Multimedia;" >> "$name".desktop
fi
if [ $number = "4" ]; then
echo "Categories=Graphics;" >> "$name".desktop
fi
if [ $number = "5" ]; then
echo "Categories=Development;" >> "$name".desktop
fi
if [ $number = "6" ]; then
echo "Categories=Accessories;" >> "$name".desktop
fi
if [ $number = "7" ]; then
echo "Categories=Other;" >> "$name".desktop
fi

sudo mv -i "$name".desktop /usr/share/applications/
echo "Done!"
exit


Here's a screenshot. This is with a compiled Hedgewars on Debian Squeeze (it didn't make an icon by default):
Image
User avatar
sagirfahmid3
Level 6
Level 6
 
Posts: 1054
Joined: Sun Sep 04, 2011 12:39 pm

Linux Mint is funded by ads and donations.
 

Return to XFCE

Who is online

Users browsing this forum: No registered users and 2 guests