1

Sorry if this seems a daft question but I'm still new to Linux. Is there an equivalent of a Windows Shortcut in Linux (as opposed to a link)

The problem I have is this:

I have an application that sits in /home/user/appDirectory/application.exe (its a Windows App running under Wine)

I then have a monitoring script that looks for that application to see if it is running.

e.g.

application="/home/user/appDirectory/application.exe"

if pgrep -f "$application" > /dev/null 
then
    is_running=1
else
    is_running=0
fi

So far so good. But I need to put a 'shortcut' on the desktop so that anyone can go in and easily stop/start the application.

If I create a link (and put that on the desktop) and start it from that then the path becomes /home/user/desktop/link to appDirectory/application.exe and the monitoring script can't see it.

Is it possible to create a shortcut, that when opened opens as the original location, so the application then starts from the original location?

4
  • it is GNOME ( I think ) on a Debian Server.
    – IGGt
    Jan 12, 2016 at 10:41
  • 2
    Have a look at .desktop files.
    – jofel
    Jan 12, 2016 at 10:46
  • Which link you're talking about i.e of link application.exe? or of script you mentioned in question?
    – Pandya
    Jan 12, 2016 at 11:13
  • it's the link to the application. If I click on /home/user/desktop/link to appDirectory/application.exe I need it start as /home/user/appDirectory/application.exe
    – IGGt
    Jan 12, 2016 at 11:54

1 Answer 1

2

Since your request seems to be for GUI only, I'd suggest following jofels comment about .desktop files. Archlinux has a quite good short summary over the interesting keys in .desktop files. A suggestion would be

[Desktop Entry]
Name=Whatever you want
Type=Application
Path=/home/user
Exec=env WINEPREFIX="<prefix>" wine appDirectory/application.exe

The env WINEPREFIXpart may not be required, but use it if you have multiple prefixes or for good measure.

Place the <Whatever you want>.desktop file in your $HOME/Desktop folder and you should be set with a new icon that you can click. This file would give you at least appDirectory/application.exe to grep for. Path is where the command will be executed. As such, you can modify the Path and Exec proportions to get more of the path in Exec if you need it for grepping. So with Path=/ and the rest in Exec, you will get the requested behaviour.

However, the need for grepping like this is not clear to me. If it's only run as one instance at a time, you could create a PID file instead and check for if the PID exists, like presented here but modified to your needs. This answer might also be of interest if you decide to go for a PID file.

1
  • Cheers, the .desktop file looks exactly like what I was after.
    – IGGt
    Jan 12, 2016 at 14:13

You must log in to answer this question.

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