Announcement

Collapse
No announcement yet.

How to creat a launcher that requires your Terminal to be at the target directory

Collapse
This topic is closed.
X
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    How to creat a launcher that requires your Terminal to be at the target directory

    Because we live in a Windows world and many of us are less than titillated by that fact we find ourselves running Ubuntu, trying to run Windows programs. A number of programs which we launch from the CLI require that the terminal's command prompt be the same as the target directory address. This can cause a bit of frustration when we want to create a quick launcher and find that the path line in the .desktop file we are told to create is about as useful as tits on a bull. So what I want to share is how to overcome this problem in one line in your quick launcher without having to do anything else.

    In this example I have Mono installed on my PC which you can see as .Net for linux. It allows me to run .Net programs natively on Ubuntu. The typical usage command is: mono package.exe, where package.exe is usually inside a portable Windows program. I have downloaded my portable Windows program, called SubtitleEdit, which uses .Net, into a folder called Windows Portable Programs. To run the program from the terminal I need to navigate to the folder where it resides and enter mono SubtitleEdit.exe.

    me@ubuntu:~/Windows Portable Programs/SubtitleEdit$ mono SubtitleEdit.exe


    A far easier way to launch this program would be to just set up a desktop launcher as follow:

    Code:
    [Desktop Entry]
    Exec=sh -c 'cd /home/me/"Windows Portable Programs"/SubtitleEdit; mono SubtitleEdit.exe'
    Icon=/home/me/Pictures/icons/SE.bmp
    Name=Subtitle Edit
    StartupNotify=true
    StartupWMClass=subtitleedit.exe
    Terminal=false
    Type=Application
    X-KDE-SubstituteUID=false
    Just copy the above, only change the Exec= line and save to ~/Desktop. I hope this saves you the many hours it took me to discover this quite simple and elegant solution to quick launch a program.

    #2
    You can do that, but you should also be able to use the Path= key in the .desktop file to define a working directory (or is that not working for this program for some reason):
    Code:
    [Desktop Entry]
    Exec=mono SubtitleEdit.exe
    Path=[COLOR=#3E3E3E]/home/me/"Windows Portable Programs"/SubtitleEdit[/COLOR]
    Icon=/home/me/Pictures/icons/SE.bmp
    Name=Subtitle Edit
    StartupNotify=true
    StartupWMClass=subtitleedit.exe
    Terminal=false
    Type=Application
    X-KDE-SubstituteUID=false
    The .desktop spec: https://specifications.freedesktop.o...ec-latest.html

    Alternatively, you could try running 'mono /home/me/"Windows Portable Programs"/SubtitleEdit/SubtitleEdit.exe', defining a path there. There is obviously nothing wrong in using sh -c and cd, either, especially if the other methods aren't working with mono (of which I have no idea, i've never run anything with mono)
    Last edited by kubicle; Jan 03, 2020, 01:59 AM.

    Comment


      #3
      As I said in my post, setting the Path= key as you have shown here does not work.

      I am stretching here but I think that exec line, 'mono /home/me/"Windows Portable Programs"/SubtitleEdit/SubtitleEdit.exe', runs into problems when running Wine programs.
      Last edited by shag00; Jan 03, 2020, 02:36 AM.

      Comment


        #4
        Originally posted by shag00 View Post
        As I said in my post, setting the Path= variable as you have shown here does not work.
        Ah, so you did, I missed it. Tested a test .desktop file with a Path= key and it seemed to work fine (running a simple ls command on a specified directory), but it might be that it doesn't work quite as expected with GUI programs.
        How about the other option: Exec=mono /home/me/"Windows Portable Programs"/SubtitleEdit/SubtitleEdit.exe

        EDIT:
        I am stretching here but I think that exec line, 'mono /home/me/"Windows Portable Programs"/SubtitleEdit/SubtitleEdit.exe', runs into problems when running Wine programs.
        Possible, but like I said, no harm in using what you have (nothing wrong with sticking to something that is working)

        EDIT2: This does suggest that it should work, but as I do not use mono I can't guarantee it:
        https://askubuntu.com/questions/1192...-mono-exe-file
        Last edited by kubicle; Jan 03, 2020, 02:44 AM.

        Comment


          #5
          Exec=mono /home/me/"Windows Portable Programs"/SubtitleEdit/SubtitleEdit.exe, works.

          Comment

          Working...
          X