How add a launcher to the apps menu for an app that runs from a script?

SongKong works brilliantly as a music files tagger, but its Linux iteration is limited to a folder that sits anywhere you choose to put it and is launched by cd-ing into that folder and launching a shell script: ./songkong.sh

I’m a user not a developer, but I’d have thought it shouldn’t be too difficult to “finish the job” and have that script integrated with the applications menu. There is an icon, which appears in my sidebar when the app is running, and I hoped I might be able to pin it there as a launcher, but right clicking on it just offers “All windows” or “Quit”.

It’s a pain to have to keep opening a terminal, cd-ing to the applications folder and running the script. I’ve done a fair bit of searching on adding launchers, tweaking menus and creating shortcuts, but found nothing yet that quite fits the bill. Any nudges in the right direction would be much appreciated.

I’m running Manjaro Gnome on a desktop pc with top, bottom and side bars, “Applications” and “Places” menus dropping down from the former. Ideally I’d like to have the SongKong icon on the Applications menu under “Sound & Video”.

You could use the concept presented here [root tip] [How To] I have downloaded a program as a jar file - what now?

1 Like

This looks helpful - thanks a lot.

I need a bit more help though regarding step 3, making a script, because although I believe SongKong is written in Java, it doesn’t come as a .jar file. The executable bit is ./songkong.sh so what script would I need to run that? (Sorry if I’m being dim - I’m at the limits of my understanding here!)

Your songkong.sh is a script. :bulb:

Assuming it’s executable:

chmod +x ./songkong.sh

…that should likely run your Java app. You could possibly make an alias to the script, or create a .desktop file to launch it via Terminal.

Much appreciate the help but I’m still struggling here!

I’ve created the bin folder in ~/.local and moved the songkong folder into it.
As it runs from the terminal anyway I assume the ./songkong.sh script is executable, but I chmod it anyway.
I already had a .local/share/applications folder with a couple of .desktop files in it, so I added one for songkong. This may well be where I’m going wrong, so here is that file:

[Desktop Entry]
Encoding=UTF-8
Name=SongKong
Comment=Run SongKong
GenericName=SongKong music tagger
Exec=~/.local/bin/songkong/./songkong.sh
Terminal=true
Type=Application
Icon=~/.local/bin/songkong/style/songkong32.png
Categories=Applications
StartupWMClass=java-app
StartupNotify=true

I put Terminal=true as I notice when I run SongKong it always opens a terminal as well as its GUI, where it reads out all its processing. (At first I set it to false, but changing to true hasn’t made any difference.)

I don’t really understand the significance of the last two keys, so left those as in the tutorial.

I’ve restarted Gnome after each attempt, but still no SongKong in the Applications menu.

I’m totally unfamiliar with whatever may be needed for your app, however, see if this works:

[Desktop Entry]
Encoding=UTF-8
Name=SongKong
Comment=Run SongKong
GenericName=SongKong music tagger
Exec=/home/USER/.local/bin/songkong/songkong.sh
Terminal=true
Type=Application
Icon=/home/USER/.local/bin/songkong/style/songkong32.png
Categories=Applications
StartupWMClass=java-app
StartupNotify=true

Note 1: Change USER to your username.
Note 2: .local/bin/ is generally meant only for single command-line apps (such as rar and unrar) and not for placing entire app folder heirachies under.
Note 3: songkong.sh might very well depend on those files being elsewhere.
Note 4: Creating an alias to songkong.sh might be the better alternative.

this is probably not right
it should be, more likely:
Exec=~/.local/bin/songkong/songkong.sh

or the full PATH - like @soundofthunder just posted a minute before me :slightly_smiling_face:
Exec=/home/username/.local/bin/songkong/songkong.sh

to verify the actual location:

ls -alR ~/.local/bin/
or
ls -al ~/.local/bin/songkong/



ps:

something I just found out:
the script will not run (not successfully) when it is called with the full PATH to it
it will run (successfully) when you cd (change directory) into the directory and call it from there

example:

I put it in /home/username/song
Then the script is here:
/home/username/song/songkong/songkong.sh

cd /home/username/song/songkong
(change directory)
then run:
./songkong.sh

works - but doesn’t make creating the desktop starter any easier :grimacing:

If I remember correctly, things like ~, $HOME, and possibly others shouldn’t be used in a .desktop file…

I was just trying to point out the typo while keeping to the example.

My ps is more important - regardless where you put the unpacked archive - the script will only run when called from within the directory it is in.
The alternative would be: change the script

actually:
he said this right from the start - but I had to see it for myself

So: the only option seems to be to adapt the script.

One idea is:
create an script that does cd and then run the songkong.sh from there
and call this script from the desktop launcher

As much as I’d use this program - I would not bother.
But: that was not what he wanted … :man_shrugging:

I know, just pointing it out for @nickdc :wink:

Thank you, thank you! Making progress - I now have an icon for SongKong in the Applications menu.

However, clicking on it produces a brief whirl of the cursor, then nothing.

Installing SongKong was simply a matter of downloading the tarball and extracting it wherever:

SongKong Installation for Linux

Download SongKong to see the functionality of SongKong, SongKong Pro and SongKong Commercial.

You can see full details of the differences between the versions here

This installer can also be used on a headless environment where no Graphical User Interface is available.

  • If have previous version downloaded delete existing songkong-linux-headless.tgz file
  • Download songkong-linux-headless.tgz
  • Copy file to where you would like to install such as $HOME or /opt
  • tar zxf songkong-linux-headless.tgz
  • cd songkong
  • Run ./songkong.sh to run in desktop mode when have windowing or commandline mode if not
  • Or run ./songkongremote.sh to start songkong in remote mode, accessible via web-browser

It seems to have everything it needs in the one songkong folder. I originally put it in /home/nick/Applications where I have a couple of other apps, but I moved it to ~/.local/bin when following the tutorial in the link provided by @linux-aarhus. It runs fine from there if I open a terminal, cd to that directory and run the shell script - but that’s a hassle I’m seeking to avoid!
In case it helps, here’s the script of songkong.sh:

linuxjre/bin/java  -Xms150m -XX:MaxRAMPercentage=50 -XX:MetaspaceSize=45 -Dcom.mchange.v2.log.MLog=com.mchange.v2.log.jdk14logging.Jdk14MLog -Dorg.jboss.logging.provider=jdk -Djava.util.logging.config.class=com.jthink.songkong.logging.StandardLogging -Dhttps.protocols=TLSv1.1,TLSv1.2 --add-opens java.base/java.lang=ALL-UNNAMED  -jar lib/songkong-10.5.jar "$@"

:

We know (well: I do - because I just tried)
and tried to describe the reason for it in my posts above
… after the ps:

one needs to cd into the folder where the script is
and then start it from there

or adapt the script itself so it works with absolute PATHs

Yes, thanks @Nachlese , I saw that only after I’d posted!

So, now I understand why the developer, who’s a whizz with java but admits he knows little of Linux, left the job, to my mind, unfinished! And I thought it wouldn’t be too difficult to create that last launcher process - apparently not!

Very, very crude solution - but works:

  • open the songkong.sh for editing
  • add as the first line the cd command to change directory to where YOU actually put it

as I said above:

so I added as the first line:
cd /home/username/song/songkong

That’s it. Now your launcher should work.

First try from command line - call it with the full PATH.

This is not universal, but specific to where/which directory you chose to put it.

In your case, the first line would probably have to be:
cd /home/username/.local/bin/songkong

(not in front of the line - as a separate first line)

1 Like

The simplest form of such desktop launcher

[Desktop Entry]
Version=1.0
Name=My Application
Comment=Application to useful stuff with files
Path=/path/to/work/dir
Exec=yourscript.sh
Icon=some-icon-name
Terminal=false
Type=Application
StartupNotify=true
Categories=Utility;
1 Like

Yes, and the whatever/path/./songkong.sh that the OP initially attempted would have been particularly problematic. Using ./ infers that the script is being run from the current directory (wih respect the script) - including that within a path in that way has no option but to fail.

As I pointed out, an alias (or even a symlink) might be better suited.

They should not. I vaguely recall reading there can be exceptions (random Stack Exchange item) but dismissed it as folklore.

There’s yet another reason to use an alias or symlink.

I use mp3tag - Windows app via WINE - which is conveniently available via the AUR. I’ve used it for maybe two years without any issues. Just something for consideration.

Mp3tag has an icon, if that’s a deciding factor. :wink:

Cheers.

That’s what I remember this :point_down: way:

1 Like

@Nachlese you’re a star! That does work indeed! (Still can’t get my head round why we have to change directory when we couldn’t read the script that tells us to if we weren’t already in that directory - but that’s no matter: it works!)

Thanks to everyone who’s contributed.

The thing that’s so good about SongKong is that it’s designed very much with classical music in mind, it works especially well with MinimServer (an outstanding piece of music server software) and it can process an entire music library at a time, adding vast amounts of metadata and creating consistency of tagging and file naming throughout. Plug over!

I’ll keep it “installed” - perhaps I’ll use it one day.
Glad I could help!

This topic was automatically closed 36 hours after the last reply. New replies are no longer allowed.