Hari's Corner

Humour, comics, tech, law, software, reviews, essays, articles and HOWTOs intermingled with random philosophy now and then

Simple HOWTO: set "working directory" with the Gnome launcher

Filed under: Tutorials and HOWTOs by Hari
Posted on Wed, Jul 22, 2009 at 22:40 IST (last updated: Wed, Jul 22, 2009 @ 22:52 IST)

Today I made a momentous decision; at least in terms of my personal history with Linux and switched to the Gnome desktop completely. While the migration story including my reasons for dropping KDE is another topic (and will most likely be covered in a future entry) I wanted to explain a very annoying problem which most former KDE users are likely to face when using Gnome. And that is how to set the working path for any executable for which you create a desktop launcher. This is a useful, and occasionally important setting which are required by some programs.

Gnome Launcher

The Gnome launcher creation tool provides no way to specify a working directory as you can see. I searched the web for numerous solutions, all of which were quite unsatisfactory and didn't work. All I needed was a simple solution to the problem. While I hope the Gnome developers will fix this somewhat annoying issue in the future, I have devised a reasonable workaround for the problem. After a bit of thought I merely used a gnome-terminal to wrap around the executable program/script. Seems a very obvious ploy on hindsight, but it took me a while to hit upon the solution.

Here's the necessary command for the launcher window:
gnome-terminal --working-directory /path/to/working/dir/ -e /path/to/executable

Just replace the /path/to/working/dir/ and /peth/to/executable with your own and you're set. Hope you find it useful. :)

12 comment(s)

  1. I am sure that I will. :biggrin:

    Comment by MrCorey (visitor) on Thu, Jul 23, 2009 @ 09:56 IST #
  2. I am sure that I will. :biggrin:
    You're still using Ubuntu?

    Comment by Hari (blog owner) on Thu, Jul 23, 2009 @ 10:56 IST #
  3. I am, sir. My computer still has 8.04 LTS on it. After all of the abuse it took and is still working, I cannot really justify changing to something different, really. My children are comfortable with how it works and the murderfs, er reiserfs 3.whatever, has been fast and stable since I installed.

    So, this is an upgrade from 7.04 and its still kicking. Its like using Debian Testing with fewer binary incompatibilities.

    That doesn't mean that I'm not going to continue playing around. I've still got VirtualBox to play with until I can get another hard drive or another computer. I would still like a laptop to put something interesting on but that's not feasible right now.

    Comment by MrCorey (visitor) on Thu, Jul 23, 2009 @ 18:18 IST #
  4. MrCorey, true. I am beginning to understand Gnome a lot better now and I think with a bit of polish it can be so much more productive than KDE 4.x. I think KDE has gone backwards from 3.5.x to 4, but I hope Gnome won't go down that route.

    I think with KDE, they could have built on top of the 3.5.x series or at least kept an active 3.5.x branch alive. I hope somebody takes up that as a project and maintains it.

    Comment by Hari (blog owner) on Thu, Jul 23, 2009 @ 19:11 IST #
  5. Apidi vaa vazhiku... (No i will not translate this) :-P

    Comment by Teknomancer (visitor) on Sun, Aug 9, 2009 @ 17:03 IST #
  6. Tahk you so much for d :
    gnome-terminal --working-directory /path/to/working/dir/ -e /path/to/executable

    commd :-)

    Comment by yash (visitor) on Sat, Sep 12, 2009 @ 17:34 IST #
  7. it's worked as expected, but the terminal is shown during the application launched (it's java GUI application), how to hide it? Thanks

    Comment by William (visitor) on Fri, Oct 1, 2010 @ 08:47 IST #
  8. No idea. I don't think it's technically possible, but there might be a command line switch in gnome-terminal which does this. You should check the manual pages.

    Comment by Hari (blog owner) on Fri, Oct 1, 2010 @ 12:39 IST #
  9. If you don't want to see the terminal window, try this command:

    bash -c "cd /path/to/working/dir && ./executable"

    Comment by mech (visitor) on Thu, Nov 11, 2010 @ 18:45 IST #
  10. Thanks, mech.

    Comment by Hari (blog owner) on Thu, Nov 11, 2010 @ 20:37 IST #
  11. You can also just open up the relevant .desktop file (from ~/.gnome2/panel2.d/default/launchers/) and add a Path= value (see the relevant standard here: http://standards.freedesktop.org/desktop-entry-spec/latest/ar01s05.html )

    Comment by John Bartholomew (visitor) on Mon, Sep 19, 2011 @ 20:05 IST #
  12. Thanks for the useful tip, John. I didn't know where the file was located earlier. :-)

    Comment by Hari (blog owner) on Mon, Sep 19, 2011 @ 22:06 IST #

Comments closed

The blog owner has closed further commenting on this entry.