how associate an icon with a script? (solved)

About writing shell scripts and making the most of your shell
Forum rules
Topics in this forum are automatically closed 6 months after creation.
Locked
Asimov

how associate an icon with a script? (solved)

Post by Asimov »

Many desktop lack a tool to switch keyboard layout. Thrust me, you don't want't make C programming on a canadian layout.
Last edited by LockBot on Wed Dec 28, 2022 7:16 am, edited 2 times in total.
Reason: Topic automatically closed 6 months after creation. New replies are no longer allowed.
Gazpacho

Re: how associate an icon with a script?

Post by Gazpacho »

Try this:

Once you have the script, right click over the folder you want to have the shortcut, create/new, and look for "link", or similar. finally, give the route to your script
Jamesc359

Re: how associate an icon with a script?

Post by Jamesc359 »

With XFCE you can right click on the Desktop and click Create Launcher.

Otherwise you can just open a text editor and use this as a template.

Code: Select all

[Desktop Entry]
Version=1.0
Name=<NAME>
Comment=<COMMENT>
Icon=<ICONNAME>
Terminal=true
Exec=<INTERPRETER> <PATH_TO_SCRIPT>
Type=Application
Categories=Accessories;
Save the file as a .desktop file where you want it to appear. e.g. ~/Desktop/myscript.desktop

You can look into /usr/share/icons/ for the names of various icons. Don't include an extension. e.g. text-x-script.png would be Icon=text-x-script

If you script is executable you don't have to included the interpreter. For shell scripts you'll want the interpreter to be sh.

You can place it in additional categories by using a semi-colon seperated list. e.g. System; Accessories;

If you want it to appear in your menu place the .desktop file in ~/.local/share/applications

Remember to enclose pathnames with spaces in them in quotes. :-)
Asimov

Re: how associate an icon with a script?

Post by Asimov »

My script work inside a terminal, but not outside. I make a test with my script in /usr/local. But even with the path the script do not start. Any idea on the cause of my problem?
User avatar
Pilosopong Tasyo
Level 6
Level 6
Posts: 1432
Joined: Mon Jun 22, 2009 3:26 am
Location: Philippines

Re: how associate an icon with a script?

Post by Pilosopong Tasyo »

Asimov wrote:My script work inside a terminal, but not outside. I make a test with my script in /usr/local. But even with the path the script do not start. Any idea on the cause of my problem?
Post the actual script you wrote here. It might help pinpoint the cause.
o Give a man a fish and he will eat for a day. Teach him how to fish and he will eat for a lifetime!
o If an issue has been fixed, please edit your first post and add the word [SOLVED].
Asimov

Re: how associate an icon with a script? (Solved)

Post by Asimov »

I solved the problem by creating two icons, no more need for a script. Just two icon with specific command. Thank you!
Asimov

Re: how associate an icon with a script? (solved)

Post by Asimov »

thank
Locked

Return to “Scripts & Bash”