6

I recently installed an IDE into /opt (I know that some recommend putting software into /usr/local but this was entirely self-contained) because the application was not available in my ditro's repositories and I had to install it from a .sh file.

The application runs fine when launching from the terminal; however, I would like to run it without having to declare the path to executable each time. I use Rofi as my application launcher but when I search for my IDE, it is not found(probably because I installed it without using a package manager - don't understand the reasons behind this behavior though).

How can I get this application that I installed to /opt to be searchable by an application launcher like Dmenu or Rofi?

anon2332
  • 101
  • 1
  • 1
  • 5

3 Answers3

4

1. $PATH

PATH is an environmental variable in Linux and other Unix-like operating systems that tells the shell which directories to search for executable files (i.e., ready-to-run programs) in response to commands issued by a user.

Since I decided to install software into '/opt', I had to make sure that '/opt' was listed in PATH; it was not. I amended the '/etc/profile' file with

:/opt

at the end of the PATH variable. Note: editing '/etc/profile' will affect all users on the system, you should use the file in your home directory if you just want it changed for that specific user.

2. Symlink

Symbolic links are like shortcuts or references to the actual file or directory. Most of the time these links are transparent when working with them through other programs... Symbolic links are used all the time to link libraries and make sure files are in consistent places without moving or copying the original.

Amending the $PATH variable only addressed part of the problem. Adding /opt to the $PATH variable only added that directory and not the specific application located inside. I also needed to create a symbolic link - or symlink - in the /opt directory to the specific application so it was searchable in my application launcher.

ln -s /opt/applicationFolder/executable /opt/applicationName

This creates a symlink for the the executable located in '/opt/applicationFolder' in the directory '/opt/' with the name 'applicationName'. Had to logout/restart to see changes.

Resources:

anon2332
  • 101
  • 1
  • 1
  • 5
  • 2
    Why not just put a symlink into a directory that is already in `PATH`? For example `ln -s /opt/applicationFolder/executable /usr/local/bin/applicationName`. That way, you do not have to modify any configuration file (that may be overwritten when updating). – Adaephon Jun 16 '17 at 09:45
  • My problem is that `/opt` is in `PATH` when I do `echo $PATH`, but not when xmonad spawns my launcher. I've prefixed my launcher command with `echo $PATH >/tmp/path.log`, and it's not empty, but hasn't `/opt` in it. – Gauthier Feb 27 '21 at 21:40
0
  1. Run

Shows a list of executables in $PATH and can launch them (optional in a terminal). Pressing the delete-entry binding (shift-delete) will remove this entry from the run history. Pressing the accept-custom binding (control-enter or shift-enter) will run the command in a terminal.

  1. DRun

Same as the run launches, but the list is created from the installed desktop files. It automati‐ cally launches them in a terminal if specified in the Desktop File. Pressing the delete-entry binding (shift-delete) will remove this entry from the run history. Pressing the accept-custom binding (control-enter or shift-enter) with custom input (no entry matching) will run the com‐ mand in a terminal.

If you want to run your IDE using rofi -show drun, you should add a .desktop file to ~/.local/share/applications with the following content :

[Desktop Entry]
Exec=/opt/path/to/IDE
Type=Application
Categories=Development
Name=name of the IDE, for example : Qt Creator

More about desktop entry files: developer.gnome.org

0

Make sure rofi is installed:

sudo apt update
sudo apt install rofi

To get list of installed and running applications on rofi:

rofi -show combi -combi-modi "window,drun,ssh" -modi combi

Bind above command to a key for launching from key directly

To show application installed in non bin directory, add a desktop file your_app.desktop in ~/.local/share/applications

The your_app.desktop should contain following:

[Desktop Entry]
Exec=/absolute_path/to/YourApp
Type=Application
Categories=Development
Name=name of the Your App, for example : Eclipse