CWD after opening file is home directory. how to change it?
Posted: Wed May 16, 2018 3:36 pm
Hello,
I have a question about PCManFM,
is it possible to change it so that if a file is opened by double-clicking then the current working directory (CWD) will be the directory where I clicked it and not my home directory?
More detailed:
I have Debian 9 with LXDE and the default file manager is PCManFM.
I observed the following behavior:
If I double-click an executable program I will get a choice to run it. If I do so, then the program will be launched and its CWD will be the directory where I clicked it. And this is expected behavior.
But if I double-click a different file which is not an executable program then it will open the file by launching the command from the appropriate .desktop file and then the program launched this way will have the CWD set to my home directory which is not what would be expected.
Normally, this is not a problem except these two situations where I start a program this way:
1. Windows programs
When I double-click a windows program, the associated command is "/usr/bin/wine %f". So PCManFM launches Wine with the CWD set to my home directory (which is "/b") and Wine runs the Windows program which sees the CWD as "Z:\b". This is problematic because I would expect the Windows program to be run with the CWD set to the directory where I clicked it.
2. PIE executables
In Debian 9 the default format of executable programs is PIE (Position Independent Executable). Unfortunately the MIME system cannot distinguish them from shared objects. Because of this PCManFM also sees these programs as shared objects and if I double-click such a program PCManFM does not give me the choice to run it but instead asks what program to open the file with.
(Actually, I believe this is a bug that it is not possible to run a PIE executable by double clicking. Shouldn't just the executable bit be enough for PCManFM to know what is an executable file and what not? And if not, at least "shared object" + executable bit should be treated as an executable program, I think)
There is a workaround. I can set the command associated with this file type to "xterm -e %f" so clicking the executable file will make PCManFM run xterm which will execute the file. But again with CWD set to my home directory.
So, that's why I'm asking. Is it possible to change this behavior so that If I double-click a file in PCManFM then the program launched this way will have the CWD set to the directory where I clicked and not my home directory?
I have a question about PCManFM,
is it possible to change it so that if a file is opened by double-clicking then the current working directory (CWD) will be the directory where I clicked it and not my home directory?
More detailed:
I have Debian 9 with LXDE and the default file manager is PCManFM.
I observed the following behavior:
If I double-click an executable program I will get a choice to run it. If I do so, then the program will be launched and its CWD will be the directory where I clicked it. And this is expected behavior.
But if I double-click a different file which is not an executable program then it will open the file by launching the command from the appropriate .desktop file and then the program launched this way will have the CWD set to my home directory which is not what would be expected.
Normally, this is not a problem except these two situations where I start a program this way:
1. Windows programs
When I double-click a windows program, the associated command is "/usr/bin/wine %f". So PCManFM launches Wine with the CWD set to my home directory (which is "/b") and Wine runs the Windows program which sees the CWD as "Z:\b". This is problematic because I would expect the Windows program to be run with the CWD set to the directory where I clicked it.
2. PIE executables
In Debian 9 the default format of executable programs is PIE (Position Independent Executable). Unfortunately the MIME system cannot distinguish them from shared objects. Because of this PCManFM also sees these programs as shared objects and if I double-click such a program PCManFM does not give me the choice to run it but instead asks what program to open the file with.
(Actually, I believe this is a bug that it is not possible to run a PIE executable by double clicking. Shouldn't just the executable bit be enough for PCManFM to know what is an executable file and what not? And if not, at least "shared object" + executable bit should be treated as an executable program, I think)
There is a workaround. I can set the command associated with this file type to "xterm -e %f" so clicking the executable file will make PCManFM run xterm which will execute the file. But again with CWD set to my home directory.
So, that's why I'm asking. Is it possible to change this behavior so that If I double-click a file in PCManFM then the program launched this way will have the CWD set to the directory where I clicked and not my home directory?