Mapping all download folders to one folder
With the introduction of non-root client applications, there are
multiple download folders. For example, firefox runs as user 'firefox',
with home folder 'home/firefox', and default download path
/home/firefox/Downloads'.
OK, but if we have more non-root client apps, each with its own
Download folder, it is starting to become inconvenient. Perhaps. Forum
member hundido was showing a grandma how to use EasyOS, and she liked
it, except for all these different download paths:
https://forum.puppylinux.com/viewtopic.php?p=42967#p42967
I have fixed the YouTube downloader, it now defaults to /files/downloads. Here is a photo showing the current situation:
Clicking on "files" icon at top-left of screen, opens ROX-Filer at
/files. This is where you expect to find all of your personal files.
Quite reasonable for grandma to expect downloaded files to be in
/files/downloads.
However, firefox defaults to downloading to /home/firefox/Downloads.
Yes, I could change the default download path, however, many apps
default to saving at ~/Downloads, so rather than try and fix every
future non-root client app, I thought of a different solution.
I don't really know if this is a good solution. Perhaps it would be
better to try and set all non-root apps to download to /files/downloads.
I know there are XDG path variables, but don't know of one that would
just affect download and file-save paths.
So, this is what I have done. In /etc/rc.d/rc.sysinit have inserted this code:
#20211204 map all download folders to /files/download
# all the non-root clients belong to group fscryptgrp...
chgrp fscryptgrp /files/downloads
# allow clients to write to this folder...
chmod 775 /files/downloads
for aDL in `ls -1 -d /home/*/Downloads 2>/dev/null`
do
if [ -d "${aDL}" ];then
busybox mount --rbind /files/downloads ${aDL}
fi
done
The effect of this will be that if, while running firefox, a file is
downloaded to /home/firefox/Downloads, it will also appear in
/files/downloads. Ha ha, but it will also appear in
/home/chromium/Downloads
One detail, it will not be necessary to set group and permissions of /files/downloads at every bootup.
I might have to rethink this, but will go with this solution for now.
Now, grandma can click on "files" and immediately see downloaded files.
Of course, another solution is symlinks, for example symlink
/home/firefox/Downloads to /files/downloads. Yet another possibility is
to have subfolders /files/downloads/firefox, etc., and either bind-mount
or symlink from /home/firefox/Downloads etc.
EDIT 2021-12-05:
Wasn't happy with the above solution. A train of thought was set in
process, that has resulted in significant changes. Have opted for the
symlink solution.
Furthermore, /files is no longer a symlink to /mnt/wkg/files. Instead,
/mnt/wkg/files is bind-mounted on /files. /files exists without the
bind-mount, which simplifies things in containers.
A bit complicated to explain, but the end result should be good, simpler.
EDIT 2021-12-07:
A lot more rethinking, end result here:
https://bkhome.org/news/202112/all-downloads-now-to-files-folder.html
Tags: easy