Make link open target file, not file at link location
![Creative The name of the picture](https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgO9GURib1T8z7lCwjOGLQaGtrueEthgQ8LO42ZX8cOfTqDK4jvDDpKkLFwf2J49kYCMNW7d4ABih_XCb_2UXdq5fPJDkoyg7-8g_YfRUot-XnaXkNYycsNp7lA5_TW9td0FFpLQ2APzKcZ/s1600/1.jpg)
![Creative The name of the picture](https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhYQ0N5W1qAOxLP7t7iOM6O6AzbZnkXUy16s7P_CWfOb5UbTQY_aDsc727chyphenhyphen5W4IppVNernMMQeaUFTB_rFzAd95_CDt-tnwN-nBx6JyUp2duGjPaL5-VgNO41AVsA_vu30EJcipdDG409/s400/Clash+Royale+CLAN+TAG%2523URR8PPP.png)
up vote
2
down vote
favorite
Sorry for the tags. I don't know whih one applies. Please remove not pertaining ones, then delete this line. Or comment, and I'll do it myself.
Background
I want to put a link to a file located in /home/myname/some/path/file.tex
on my desktop. This TeX file calls other TeX files inside it. Now, when I open the link, which is located on the desktop, my TeX editor, it says I opened the file /home/myname/Desktop/file.tex
. I can't compile this file, because the other TeX files the main TeX file relies upon are not located where the program expects them.
Main question
How can I make a link file open the target file in its actual location instead of on the desktop?
EDIT
The solution advertised here does not work as intended. With
#!/bin/bash
exec /home/myname/some/path/file.tex "$@"
I get
/tmp/geany_run_script_JVX1HZ.sh: 7: /tmp/geany_run_script_JVX1HZ.sh: ./open-file.sh: Permission denied
âÂÂ----------------
(program exited with code: 126)
Press return to continue
Where open-file.sh
is the wrapper script located on my desktop.
EDIT 2
Although, if I open a terminal and do
chmod a+x ./open-file.sh
and change exec
to texstudio
, which incidentally is the program I use to open .tex
files, then I can open a terminal and do
bash open-file.sh
it will launch TeXStudio with the desired file loaded in the desired target location. I still can't just double-click open-file.sh on my desktop, since that will open my text editor, letting me edit the bash script. I want to double-click the open-file.sh
script file and have TeXStudio open up my file.tex
file.
### EDIT 3
From this question, I deduct that I have done everything right and the file should be clickable and be executed upon clicking. Unfortunately, it doesn't. I think my permissions are correct, afaik
and same here
-rwxr-xr-x me me 94 Apr 27 12:00 open-file
symbolic-link hard-link static-linking
add a comment |Â
up vote
2
down vote
favorite
Sorry for the tags. I don't know whih one applies. Please remove not pertaining ones, then delete this line. Or comment, and I'll do it myself.
Background
I want to put a link to a file located in /home/myname/some/path/file.tex
on my desktop. This TeX file calls other TeX files inside it. Now, when I open the link, which is located on the desktop, my TeX editor, it says I opened the file /home/myname/Desktop/file.tex
. I can't compile this file, because the other TeX files the main TeX file relies upon are not located where the program expects them.
Main question
How can I make a link file open the target file in its actual location instead of on the desktop?
EDIT
The solution advertised here does not work as intended. With
#!/bin/bash
exec /home/myname/some/path/file.tex "$@"
I get
/tmp/geany_run_script_JVX1HZ.sh: 7: /tmp/geany_run_script_JVX1HZ.sh: ./open-file.sh: Permission denied
âÂÂ----------------
(program exited with code: 126)
Press return to continue
Where open-file.sh
is the wrapper script located on my desktop.
EDIT 2
Although, if I open a terminal and do
chmod a+x ./open-file.sh
and change exec
to texstudio
, which incidentally is the program I use to open .tex
files, then I can open a terminal and do
bash open-file.sh
it will launch TeXStudio with the desired file loaded in the desired target location. I still can't just double-click open-file.sh on my desktop, since that will open my text editor, letting me edit the bash script. I want to double-click the open-file.sh
script file and have TeXStudio open up my file.tex
file.
### EDIT 3
From this question, I deduct that I have done everything right and the file should be clickable and be executed upon clicking. Unfortunately, it doesn't. I think my permissions are correct, afaik
and same here
-rwxr-xr-x me me 94 Apr 27 12:00 open-file
symbolic-link hard-link static-linking
add a comment |Â
up vote
2
down vote
favorite
up vote
2
down vote
favorite
Sorry for the tags. I don't know whih one applies. Please remove not pertaining ones, then delete this line. Or comment, and I'll do it myself.
Background
I want to put a link to a file located in /home/myname/some/path/file.tex
on my desktop. This TeX file calls other TeX files inside it. Now, when I open the link, which is located on the desktop, my TeX editor, it says I opened the file /home/myname/Desktop/file.tex
. I can't compile this file, because the other TeX files the main TeX file relies upon are not located where the program expects them.
Main question
How can I make a link file open the target file in its actual location instead of on the desktop?
EDIT
The solution advertised here does not work as intended. With
#!/bin/bash
exec /home/myname/some/path/file.tex "$@"
I get
/tmp/geany_run_script_JVX1HZ.sh: 7: /tmp/geany_run_script_JVX1HZ.sh: ./open-file.sh: Permission denied
âÂÂ----------------
(program exited with code: 126)
Press return to continue
Where open-file.sh
is the wrapper script located on my desktop.
EDIT 2
Although, if I open a terminal and do
chmod a+x ./open-file.sh
and change exec
to texstudio
, which incidentally is the program I use to open .tex
files, then I can open a terminal and do
bash open-file.sh
it will launch TeXStudio with the desired file loaded in the desired target location. I still can't just double-click open-file.sh on my desktop, since that will open my text editor, letting me edit the bash script. I want to double-click the open-file.sh
script file and have TeXStudio open up my file.tex
file.
### EDIT 3
From this question, I deduct that I have done everything right and the file should be clickable and be executed upon clicking. Unfortunately, it doesn't. I think my permissions are correct, afaik
and same here
-rwxr-xr-x me me 94 Apr 27 12:00 open-file
symbolic-link hard-link static-linking
Sorry for the tags. I don't know whih one applies. Please remove not pertaining ones, then delete this line. Or comment, and I'll do it myself.
Background
I want to put a link to a file located in /home/myname/some/path/file.tex
on my desktop. This TeX file calls other TeX files inside it. Now, when I open the link, which is located on the desktop, my TeX editor, it says I opened the file /home/myname/Desktop/file.tex
. I can't compile this file, because the other TeX files the main TeX file relies upon are not located where the program expects them.
Main question
How can I make a link file open the target file in its actual location instead of on the desktop?
EDIT
The solution advertised here does not work as intended. With
#!/bin/bash
exec /home/myname/some/path/file.tex "$@"
I get
/tmp/geany_run_script_JVX1HZ.sh: 7: /tmp/geany_run_script_JVX1HZ.sh: ./open-file.sh: Permission denied
âÂÂ----------------
(program exited with code: 126)
Press return to continue
Where open-file.sh
is the wrapper script located on my desktop.
EDIT 2
Although, if I open a terminal and do
chmod a+x ./open-file.sh
and change exec
to texstudio
, which incidentally is the program I use to open .tex
files, then I can open a terminal and do
bash open-file.sh
it will launch TeXStudio with the desired file loaded in the desired target location. I still can't just double-click open-file.sh on my desktop, since that will open my text editor, letting me edit the bash script. I want to double-click the open-file.sh
script file and have TeXStudio open up my file.tex
file.
### EDIT 3
From this question, I deduct that I have done everything right and the file should be clickable and be executed upon clicking. Unfortunately, it doesn't. I think my permissions are correct, afaik
and same here
-rwxr-xr-x me me 94 Apr 27 12:00 open-file
symbolic-link hard-link static-linking
edited Apr 27 at 18:46
asked Apr 26 at 16:30
![](https://i.stack.imgur.com/u2M8p.jpg?s=32&g=1)
![](https://i.stack.imgur.com/u2M8p.jpg?s=32&g=1)
thymaro
13617
13617
add a comment |Â
add a comment |Â
1 Answer
1
active
oldest
votes
up vote
0
down vote
I don't know how to make a link itself work like this, but there's a relatively easy way to get it done.
The problem appears to be that program invoked to process your data is not running with its working directory set to the location of your data file.
Instead of linking the file itself, write a launcher script and pass your file location to it as a parameter. Then, link to the script from your desktop entry.
At least in KDE, this is easier to do by adding an entry to your Application Launcher with all the parameters set the way you want them and then dragging the entry from the menu to the desktop. It has a bunch of placeholder variables that let you modify the command and even lets you specify the working directory to use.
This could be simple or fancy. Start with simple:
#!/bin/bash
## Usage: launcheroo working-directory data-file
## defending this script is left as an exercise for the reader
## ... or you can ask in the comments ;)
cd "$1"
myprog "$2" ## or your more fancy exec that will figure out
## what program to run by itself
invoked as:
launcheroo path-to-data-files data-file
This handles the most basic usage, and illustrates the approach, but doesn't handle any errors like bad or missing parameters
To get a little fancier, you could extract the path from the specified data file path using dirname
or bash parameter editing instead of passing it as a separate parameter.
A quick and dirty way to get this done - especially for testing how it works - would be to just edit the desktop icon to run
cd where-the-files-are ; exec ...
Since this is Linux, there are probably many other ways to do this as well.
If you add the file as an icon on the desktop, you can directly edit its .desktop file and get it to do all sorts of interesting things. I haven't done much with those.
Just saw this answer which is essentially the same as mine with a slightly different spin to it.
A faint idea in the style of "and get it to do all sorts of interesting things" is what got me to start using linux in the first place, but as I'm not a programmer and find it hard to get into the matter without a direct tutor, since I have a day job I try to do to the best of my abilities, it's very hard for me to get the machines do my bidding. Thanks for the answer, I'll look into it.
â thymaro
May 3 at 11:43
Everyone has different skills and priorities.That's what makes the world work. I'd be happy to do a step by step on this, but it should probably be done outside of the Q&A here. I don't know how to get from here to there without publishing my personal email address, etc. I'll see what they say on meta.
â Joe
May 3 at 21:35
uhm... you can hit me up on telegram, github or twitter. I use the same handle on those three as on the SE network. are such comments allowed, when not explicitly posting the respective links?
â thymaro
May 4 at 7:30
add a comment |Â
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
0
down vote
I don't know how to make a link itself work like this, but there's a relatively easy way to get it done.
The problem appears to be that program invoked to process your data is not running with its working directory set to the location of your data file.
Instead of linking the file itself, write a launcher script and pass your file location to it as a parameter. Then, link to the script from your desktop entry.
At least in KDE, this is easier to do by adding an entry to your Application Launcher with all the parameters set the way you want them and then dragging the entry from the menu to the desktop. It has a bunch of placeholder variables that let you modify the command and even lets you specify the working directory to use.
This could be simple or fancy. Start with simple:
#!/bin/bash
## Usage: launcheroo working-directory data-file
## defending this script is left as an exercise for the reader
## ... or you can ask in the comments ;)
cd "$1"
myprog "$2" ## or your more fancy exec that will figure out
## what program to run by itself
invoked as:
launcheroo path-to-data-files data-file
This handles the most basic usage, and illustrates the approach, but doesn't handle any errors like bad or missing parameters
To get a little fancier, you could extract the path from the specified data file path using dirname
or bash parameter editing instead of passing it as a separate parameter.
A quick and dirty way to get this done - especially for testing how it works - would be to just edit the desktop icon to run
cd where-the-files-are ; exec ...
Since this is Linux, there are probably many other ways to do this as well.
If you add the file as an icon on the desktop, you can directly edit its .desktop file and get it to do all sorts of interesting things. I haven't done much with those.
Just saw this answer which is essentially the same as mine with a slightly different spin to it.
A faint idea in the style of "and get it to do all sorts of interesting things" is what got me to start using linux in the first place, but as I'm not a programmer and find it hard to get into the matter without a direct tutor, since I have a day job I try to do to the best of my abilities, it's very hard for me to get the machines do my bidding. Thanks for the answer, I'll look into it.
â thymaro
May 3 at 11:43
Everyone has different skills and priorities.That's what makes the world work. I'd be happy to do a step by step on this, but it should probably be done outside of the Q&A here. I don't know how to get from here to there without publishing my personal email address, etc. I'll see what they say on meta.
â Joe
May 3 at 21:35
uhm... you can hit me up on telegram, github or twitter. I use the same handle on those three as on the SE network. are such comments allowed, when not explicitly posting the respective links?
â thymaro
May 4 at 7:30
add a comment |Â
up vote
0
down vote
I don't know how to make a link itself work like this, but there's a relatively easy way to get it done.
The problem appears to be that program invoked to process your data is not running with its working directory set to the location of your data file.
Instead of linking the file itself, write a launcher script and pass your file location to it as a parameter. Then, link to the script from your desktop entry.
At least in KDE, this is easier to do by adding an entry to your Application Launcher with all the parameters set the way you want them and then dragging the entry from the menu to the desktop. It has a bunch of placeholder variables that let you modify the command and even lets you specify the working directory to use.
This could be simple or fancy. Start with simple:
#!/bin/bash
## Usage: launcheroo working-directory data-file
## defending this script is left as an exercise for the reader
## ... or you can ask in the comments ;)
cd "$1"
myprog "$2" ## or your more fancy exec that will figure out
## what program to run by itself
invoked as:
launcheroo path-to-data-files data-file
This handles the most basic usage, and illustrates the approach, but doesn't handle any errors like bad or missing parameters
To get a little fancier, you could extract the path from the specified data file path using dirname
or bash parameter editing instead of passing it as a separate parameter.
A quick and dirty way to get this done - especially for testing how it works - would be to just edit the desktop icon to run
cd where-the-files-are ; exec ...
Since this is Linux, there are probably many other ways to do this as well.
If you add the file as an icon on the desktop, you can directly edit its .desktop file and get it to do all sorts of interesting things. I haven't done much with those.
Just saw this answer which is essentially the same as mine with a slightly different spin to it.
A faint idea in the style of "and get it to do all sorts of interesting things" is what got me to start using linux in the first place, but as I'm not a programmer and find it hard to get into the matter without a direct tutor, since I have a day job I try to do to the best of my abilities, it's very hard for me to get the machines do my bidding. Thanks for the answer, I'll look into it.
â thymaro
May 3 at 11:43
Everyone has different skills and priorities.That's what makes the world work. I'd be happy to do a step by step on this, but it should probably be done outside of the Q&A here. I don't know how to get from here to there without publishing my personal email address, etc. I'll see what they say on meta.
â Joe
May 3 at 21:35
uhm... you can hit me up on telegram, github or twitter. I use the same handle on those three as on the SE network. are such comments allowed, when not explicitly posting the respective links?
â thymaro
May 4 at 7:30
add a comment |Â
up vote
0
down vote
up vote
0
down vote
I don't know how to make a link itself work like this, but there's a relatively easy way to get it done.
The problem appears to be that program invoked to process your data is not running with its working directory set to the location of your data file.
Instead of linking the file itself, write a launcher script and pass your file location to it as a parameter. Then, link to the script from your desktop entry.
At least in KDE, this is easier to do by adding an entry to your Application Launcher with all the parameters set the way you want them and then dragging the entry from the menu to the desktop. It has a bunch of placeholder variables that let you modify the command and even lets you specify the working directory to use.
This could be simple or fancy. Start with simple:
#!/bin/bash
## Usage: launcheroo working-directory data-file
## defending this script is left as an exercise for the reader
## ... or you can ask in the comments ;)
cd "$1"
myprog "$2" ## or your more fancy exec that will figure out
## what program to run by itself
invoked as:
launcheroo path-to-data-files data-file
This handles the most basic usage, and illustrates the approach, but doesn't handle any errors like bad or missing parameters
To get a little fancier, you could extract the path from the specified data file path using dirname
or bash parameter editing instead of passing it as a separate parameter.
A quick and dirty way to get this done - especially for testing how it works - would be to just edit the desktop icon to run
cd where-the-files-are ; exec ...
Since this is Linux, there are probably many other ways to do this as well.
If you add the file as an icon on the desktop, you can directly edit its .desktop file and get it to do all sorts of interesting things. I haven't done much with those.
Just saw this answer which is essentially the same as mine with a slightly different spin to it.
I don't know how to make a link itself work like this, but there's a relatively easy way to get it done.
The problem appears to be that program invoked to process your data is not running with its working directory set to the location of your data file.
Instead of linking the file itself, write a launcher script and pass your file location to it as a parameter. Then, link to the script from your desktop entry.
At least in KDE, this is easier to do by adding an entry to your Application Launcher with all the parameters set the way you want them and then dragging the entry from the menu to the desktop. It has a bunch of placeholder variables that let you modify the command and even lets you specify the working directory to use.
This could be simple or fancy. Start with simple:
#!/bin/bash
## Usage: launcheroo working-directory data-file
## defending this script is left as an exercise for the reader
## ... or you can ask in the comments ;)
cd "$1"
myprog "$2" ## or your more fancy exec that will figure out
## what program to run by itself
invoked as:
launcheroo path-to-data-files data-file
This handles the most basic usage, and illustrates the approach, but doesn't handle any errors like bad or missing parameters
To get a little fancier, you could extract the path from the specified data file path using dirname
or bash parameter editing instead of passing it as a separate parameter.
A quick and dirty way to get this done - especially for testing how it works - would be to just edit the desktop icon to run
cd where-the-files-are ; exec ...
Since this is Linux, there are probably many other ways to do this as well.
If you add the file as an icon on the desktop, you can directly edit its .desktop file and get it to do all sorts of interesting things. I haven't done much with those.
Just saw this answer which is essentially the same as mine with a slightly different spin to it.
edited May 3 at 8:26
answered May 3 at 8:18
Joe
1,161721
1,161721
A faint idea in the style of "and get it to do all sorts of interesting things" is what got me to start using linux in the first place, but as I'm not a programmer and find it hard to get into the matter without a direct tutor, since I have a day job I try to do to the best of my abilities, it's very hard for me to get the machines do my bidding. Thanks for the answer, I'll look into it.
â thymaro
May 3 at 11:43
Everyone has different skills and priorities.That's what makes the world work. I'd be happy to do a step by step on this, but it should probably be done outside of the Q&A here. I don't know how to get from here to there without publishing my personal email address, etc. I'll see what they say on meta.
â Joe
May 3 at 21:35
uhm... you can hit me up on telegram, github or twitter. I use the same handle on those three as on the SE network. are such comments allowed, when not explicitly posting the respective links?
â thymaro
May 4 at 7:30
add a comment |Â
A faint idea in the style of "and get it to do all sorts of interesting things" is what got me to start using linux in the first place, but as I'm not a programmer and find it hard to get into the matter without a direct tutor, since I have a day job I try to do to the best of my abilities, it's very hard for me to get the machines do my bidding. Thanks for the answer, I'll look into it.
â thymaro
May 3 at 11:43
Everyone has different skills and priorities.That's what makes the world work. I'd be happy to do a step by step on this, but it should probably be done outside of the Q&A here. I don't know how to get from here to there without publishing my personal email address, etc. I'll see what they say on meta.
â Joe
May 3 at 21:35
uhm... you can hit me up on telegram, github or twitter. I use the same handle on those three as on the SE network. are such comments allowed, when not explicitly posting the respective links?
â thymaro
May 4 at 7:30
A faint idea in the style of "and get it to do all sorts of interesting things" is what got me to start using linux in the first place, but as I'm not a programmer and find it hard to get into the matter without a direct tutor, since I have a day job I try to do to the best of my abilities, it's very hard for me to get the machines do my bidding. Thanks for the answer, I'll look into it.
â thymaro
May 3 at 11:43
A faint idea in the style of "and get it to do all sorts of interesting things" is what got me to start using linux in the first place, but as I'm not a programmer and find it hard to get into the matter without a direct tutor, since I have a day job I try to do to the best of my abilities, it's very hard for me to get the machines do my bidding. Thanks for the answer, I'll look into it.
â thymaro
May 3 at 11:43
Everyone has different skills and priorities.That's what makes the world work. I'd be happy to do a step by step on this, but it should probably be done outside of the Q&A here. I don't know how to get from here to there without publishing my personal email address, etc. I'll see what they say on meta.
â Joe
May 3 at 21:35
Everyone has different skills and priorities.That's what makes the world work. I'd be happy to do a step by step on this, but it should probably be done outside of the Q&A here. I don't know how to get from here to there without publishing my personal email address, etc. I'll see what they say on meta.
â Joe
May 3 at 21:35
uhm... you can hit me up on telegram, github or twitter. I use the same handle on those three as on the SE network. are such comments allowed, when not explicitly posting the respective links?
â thymaro
May 4 at 7:30
uhm... you can hit me up on telegram, github or twitter. I use the same handle on those three as on the SE network. are such comments allowed, when not explicitly posting the respective links?
â thymaro
May 4 at 7:30
add a comment |Â
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
var $window = $(window),
onScroll = function(e)
var $elem = $('.new-login-left'),
docViewTop = $window.scrollTop(),
docViewBottom = docViewTop + $window.height(),
elemTop = $elem.offset().top,
elemBottom = elemTop + $elem.height();
if ((docViewTop elemBottom))
StackExchange.using('gps', function() StackExchange.gps.track('embedded_signup_form.view', location: 'question_page' ); );
$window.unbind('scroll', onScroll);
;
$window.on('scroll', onScroll);
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2faskubuntu.com%2fquestions%2f1028474%2fmake-link-open-target-file-not-file-at-link-location%23new-answer', 'question_page');
);
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
var $window = $(window),
onScroll = function(e)
var $elem = $('.new-login-left'),
docViewTop = $window.scrollTop(),
docViewBottom = docViewTop + $window.height(),
elemTop = $elem.offset().top,
elemBottom = elemTop + $elem.height();
if ((docViewTop elemBottom))
StackExchange.using('gps', function() StackExchange.gps.track('embedded_signup_form.view', location: 'question_page' ); );
$window.unbind('scroll', onScroll);
;
$window.on('scroll', onScroll);
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
var $window = $(window),
onScroll = function(e)
var $elem = $('.new-login-left'),
docViewTop = $window.scrollTop(),
docViewBottom = docViewTop + $window.height(),
elemTop = $elem.offset().top,
elemBottom = elemTop + $elem.height();
if ((docViewTop elemBottom))
StackExchange.using('gps', function() StackExchange.gps.track('embedded_signup_form.view', location: 'question_page' ); );
$window.unbind('scroll', onScroll);
;
$window.on('scroll', onScroll);
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
var $window = $(window),
onScroll = function(e)
var $elem = $('.new-login-left'),
docViewTop = $window.scrollTop(),
docViewBottom = docViewTop + $window.height(),
elemTop = $elem.offset().top,
elemBottom = elemTop + $elem.height();
if ((docViewTop elemBottom))
StackExchange.using('gps', function() StackExchange.gps.track('embedded_signup_form.view', location: 'question_page' ); );
$window.unbind('scroll', onScroll);
;
$window.on('scroll', onScroll);
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password