MilhouseVH / texturecache.py

Utility script to manage the XBMC texture cache
http://forum.xbmc.org/showthread.php?tid=158373
GNU General Public License v2.0
181 stars 34 forks source link

Make script read texturecache.cfg from a standard location #18

Closed graysky2 closed 10 years ago

graysky2 commented 10 years ago

I am supplying this script in package for Arch Linux. My package will install texturecache.py to /usr/bin/texturecache Please modify the script to look for the texturecache.cfg from a standard location.

  1. If you wish it to be a root-only editable file, I propose /etc/conf.d/texturecache.cfg
  2. I think a more flexible solution would be to have the script itself check for ~/.config/texturecache.cfg and if it does not exist, write it (all commented).
MilhouseVH commented 10 years ago

By default the script looks in the users current working directory for a config file (default name, texturecache.cfg, configurable with @config=), and if nothing is found it will then look for texturecache.cfg in the script directory.

I don't mind adding the ability to look for ~/.config/texturecache.cfg as a last resort if nothing is found in the cwd of the user and/or script.

I won't however create it when it doesn't exist. If a user needs it they can create it.

How does that sound?

graysky2 commented 10 years ago

Where is "the script directory" as you call it?

I will have the package provide the cfg file as /usr/share/texturecache/texturecache.cfg and show a post install message directing the user to copy it to ~/.config/texturecache.cfg if they want it.

MilhouseVH commented 10 years ago

The "script directory" is wherever texturecache.py is located, so in your case it would be /usr/bin

So the checking order could be (3 to be added): 1) Current users working directory 2) Script directory 3) ~/.config directory

I don't know what config file you are planning on offering, but please limit options in the config file to those needing non-default values, and try not to set options using their (current) default value as this causes me grief if/when I change a default value in future! Essentially the config file should be the smallest subset of options you need to set, and nothing more.

The user can see their current config (and what configuration options are available) by running texturecache.py config. Most don't need setting at all.

graysky2 commented 10 years ago

Options 1-3 look good to me.

I am planning to offer your config file texturecache.cfg.defaults unmodified. I will simply rename it to /usr/share/texturecache/texturecache.cfg and have a statement print when the user installs the package:

==> The xbmc webserver must be enabled and running on port 8080.
==> Optionally copy /usr/share/texturecache/texturecache.cfg to ~/.config
==> and uncomment options therein for additional flexibility.

How does that sound? I am open to changing the wording per your preferences.