Possible to change the $HOME/.filebot path?

Running FileBot from the console, Groovy / FileBot scripting, shell scripts, etc
Post Reply
danemacmillan
Posts: 2
Joined: 13 Mar 2019, 15:09

Possible to change the $HOME/.filebot path?

Post by danemacmillan » 13 Mar 2019, 15:22

I bought FileBot a few months ago and it works fantastic.

My question is about the `$HOME/.filebot` path. Is it possible to change it? I'm on MacOS. I noted that the `filebot.sh` script references `APP_DATA="$HOME/.filebot"` as the application data folder. I realize I can just create my own script and add that to my `$PATH`, but I was hoping for a less nuclear approach.

If it's not possible, would you consider making this an environment variable that users can modify?

I'm big on the XDG Base Directory Specification, where the ultimate purpose is to help keep a clean home directory, so barring full support of the XDG spec (which would be fantastic if FileBot supported it), would you be willing to add an environment variable to at least specify where the application data gets stored, instead of always in `$HOME/.filebot`?

Thanks!

User avatar
rednoah
The Source
Posts: 16585
Joined: 16 Nov 2011, 08:59
Location: Taipei
Contact:

Re: Possible to change the $HOME/.filebot path?

Post by rednoah » 13 Mar 2019, 16:59

Well, yes. You can change $HOME and thus change $HOME/.filebot:

Code: Select all

export HOME="$XDG_CONFIG_HOME"
filebot ...

:!: Since macOS doesn't make it easy to change global environment variables, adding special support for XDG_* environment variables that you can't really set anyway (on the system level, like on Windows and Linux) makes little sense.
:idea: Please read the FAQ and How to Request Help.

danemacmillan
Posts: 2
Joined: 13 Mar 2019, 15:09

Re: Possible to change the $HOME/.filebot path?

Post by danemacmillan » 16 Mar 2019, 16:58

Changing the `$HOME` variable is a super destructive recommendation. Just about every script on earth in the Linux/Unix/BSD/MacOS (i.e., POSIX-compliant) universe treat the tilde (~) and `$HOME` environment variable identically and expect it to exist at a certain place; that doesn't mean $HOME can just willy-nilly be something else. `$XDG_CONFIG_HOME` is not interchangeable with `$HOME` at all. You're recommending setting my user home directory to `~/.config`. That would break an immense number of core OS scripts and utilities in anyone's environment ever--on every POSIX-compliant OS, which is just about everything non-Windows. This is not even hyperbole.

The POSIX standard even explicitly states not to do this:
It is unwise to conflict with certain variables that are frequently exported by widely used command interpreters and applications:
It then proceeds to list `$HOME` among them. It and the others are so core to the POSIX experience. One does not just change `$HOME`.

http://pubs.opengroup.org/onlinepubs/00 ... hap08.html

Since macOS doesn't make it easy to change global environment variables, adding special support for XDG_* environment variables that you can't really set anyway (on the system level, like on Windows and Linux) makes little sense.
That's simply incorrect; I don't know how to respond to that. It's arbitrarily simple to set environment variables on MacOS, just like any other Linux/UNIX/BSD, etc, operating system. Just plop a bunch of exports into a `~/.bashrc` or `~/.bash_profile` on literally any of those operating systems and we've got those environment variables set.

I don't mean to sound harsh, but the things you've written are not things anyone mildly familiar with non-Windows environments would recommend or state.

User avatar
rednoah
The Source
Posts: 16585
Joined: 16 Nov 2011, 08:59
Location: Taipei
Contact:

Re: Possible to change the $HOME/.filebot path?

Post by rednoah » 16 Mar 2019, 17:44

1.
AFAIK, there is no way to set $XDG_CONFIG_HOME for macOS GUI applications. Sure, ~/.profile and friends work but we ideally don't want to have different ~/.filebot folders for GUI and CLI applications.

:idea: By global environment variables, I mean an /etc/environment equivalent which applies globally to all processes. AFAIK, there's no equivalent in macOS. Adding a few exports to your personal login shell scripts is not the same, and has no effect on GUI apps or CLI programs executed via Automator and friends.


2.
I see no reason why you can't have a script (with its own environment) calling filebot with a different $HOME value:

Code: Select all

!/bin/sh
export HOME="$XDG_CONFIG_HOME"
filebot ...
exit 0
:!: export HOME="$XDG_CONFIG_HOME" is indeed a very bad idea if you do it in your ~/.profile but I never suggested that. The idea is to just have your own glue logic script that overrides $HOME for the filebot process, and only the filebot process.


3.
Alternatively, if you don't mind setting the user home for all java applications, this should work as well:

Code: Select all

export JAVA_OPTS="-Duser.home=$XDG_CONFIG_HOME"
:!: Adding this to your ~/.profile works for you login shell only, and won't have any effect on the GUI application, or the CLI application if called by Automator. Make sure to keep that in mind.
:idea: Please read the FAQ and How to Request Help.

Post Reply