/Volumes vs /media/${name}

A fellow Kindle user wrote a simple script to remove adds from the eReader here: https://github.com/mariopepe/KindleAdRemover/blob/master/KindleAdRemover.sh

As you can see it’s removing the .assets folder containing the ads, and creating a malformed file instead so the ads can’t be pulled from it.

On my system (Ubuntu 20.04.4 LTS x86_64), I don’t have a /Volumes folder containing mounted drives, but instead it’s located in /media/franfran.

Is there a way to programatically know this, either by try-catching in the bash script, or by calling a method, and more importantly, did I changed something (probably) in the past that would have made the system mount it to a custom location ?

Thanks, and have a nice day.

Asked By: Franfran

||

I would posit that the script was written by a Mac user, as this draws heavily from BSD and also uses /Volumes as a result.

Speculation aside, it should be a fairly simple edit to be more flexible to suit your use case.

# place this at line 2
for dir in "/Volumes" "/media/${USER}" "" ; do
  [ -d "${dir}" ] && echo "Found mount directory at ${dir}" && break
done

[ -z "${dir} ] && echo "Could not find mount directory" && exit 1

Change all instances of

/Volumes/Kindle/system/.assets

to be

${dir}/Kindle/system/.assets

At your own risk, no warranty expressed or implied

Answered By: bxm
Categories: Answers Tags: , ,
Answers are sorted by their score. The answer accepted by the question owner as the best is marked with
at the top-right corner.