2

Using ChromeOS with Linux installed, I've a .jar file that I use daily and running it from the command line is easy...but I don't work in a Linux terminal on my Chromebook regularly.

So to save some steps, I'd love to be able to pin the command so it launches, similarly to how Android Studio launches without having to open a terminal first.

I'm clearly not searching for the right terms on Google as I can find tons of links to pin websites, or to work within the Linux terminal, but not how to get a command for the terminal to be pinned.

Edit: I tried to right-click on the dock icon but only have a "Close" option. ChromeOS linux dock icon with a close option

2 Answers 2

3

Part 1

Copy and paste this into a text editor (I recommend this. https://www.onlinetexteditor.com/)

#!/bin/bash

java -jar /path/to/jar/file.jar

Save the lines above this to any folder in linux files. Rename the file to end with .sh.

Use the cd command to get to the directory where you put it in and run chmod +x <name>.sh to make it executable.

Part 2

Then copy this to a text editor.

#!/usr/bin/xdg-open

[Desktop Entry]
Encoding=UTF-8
Version=1.0
Type=Application
Terminal=false
Exec=/path/to/file/you/made/above.sh
Name=<app-name>
Icon=/path/to/icon.png

If you don't have an icon then just remove that line from the script.

Save this and name it with a .desktop extension. Save it in ~/.local/share/applications.

Finally, navigate to the folder where you saved the .desktop file and run chmod +x <name>.desktop.

This should make it available by searching for an app called <app-name>. Comment if you have questions!

4
  • Couldn't the desktop file be created such that you don't need the helper script?
    – robartsd
    Commented Mar 4, 2021 at 19:14
  • I tried to use it that way. It would not work (for me) without the helper script Commented Mar 5, 2021 at 20:29
  • You don't actually need a "shebang" in a .desktop file. And instead of pointing the desktop file to a script that calls the JAR, you can just put the "java -jar /path/to/jar/file.jar" directly in the "Exec" clause (it works fine for me, but YMMV there, as Mr. O'Brien noted). Also, if you aren't looking to pin it, but just to make it executable from the "Linux apps" section of the launcher, you'll find that just creating the .desktop file makes it visible there. Commented Jan 26, 2022 at 19:39
  • Another good option for a text online editor is pasteepad.com
    – Glauber
    Commented Mar 16 at 3:47
1

Yes you can.

The easiest way is :

  • Start the app from the command line.
  • Right click on the icon for the application and choose Pin.

To add one manually, you can create a .desktop file in .local/share/application and it should get added to the launcher drawer. You should then be able to pin it.

Note that the icon will show up in the "Linux Apps" subfolder in the Laucher drawer.

see This google support thread for more info.

2
  • That was my first try, but when I right-click, I only have a "Close" option. Is there a way to create a dock icon/link manually? Or have it added from the command line? Commented Jan 2, 2020 at 17:53
  • @MatthewBakaitis - I added information on how to do it manually.
    – mhhollomon
    Commented Jan 2, 2020 at 20:44

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .