mywave82 / opencubicplayer

Open Cubic Player (unix fork). Music visualizer for various tracked music formats (amiga modules, S3M, IT), chiptunes and other formats related to demoscene
https://stian.cubic.org/project-ocp.php
GNU General Public License v2.0
280 stars 19 forks source link

XDG Base Directory compliance. #89

Closed SapphirusBeryl closed 1 year ago

SapphirusBeryl commented 1 year ago

This commit introduces basic XDG Base Directory Specification compliance, and a bug fix disallowing blank environmental variables.

OCP successfully loads and creates the ocp.ini configuration file in $XDG_CONFIG_HOME/ocp/ocp.ini, otherwise it falls back to $HOME/.ocp/ocp.ini if the $XDG_CONFIG_HOME environmental variable is missing.

Sample output with $XDG_CONFIG_HOME globally defined:

/home/sapphirus/.config/ocp/ocp.ini created
Setting to cfConfigDir to /home/sapphirus/.config/ocp/
Setting to cfDataDir to /usr/share/ocp/data/
Setting to cfProgramDir to /usr/lib/ocp/
Open Cubic Player for Unix v0.2.101, compiled on Jan 12 2023, 13:53:25
Ported to Unix by Stian Skjelstad
linking default objects...
running initializers...
initializing fileselector...
adbMetaInit: open(cfConfigDir/CPARCMETA.DAT): No such file or directory
Loading /home/sapphirus/.config/ocp/CPMODNFO.DAT .. No header
open(cfConfigDir/CPDIRDB.DAT): No such file or directory
Loading /home/sapphirus/.config/ocp/CPMUSBRN.DAT .. Empty database
Initing console...
Initing curses... (ncurses 6.4.20221231)

Sample output with $XDG_CONFIG_HOME unset:

Setting to cfConfigDir to /home/sapphirus/.ocp/
Setting to cfDataDir to /usr/share/ocp/data/
Setting to cfProgramDir to /usr/lib/ocp/
Open Cubic Player for Unix v0.2.101, compiled on Jan 12 2023, 14:48:48
Ported to Unix by Stian Skjelstad
linking default objects...
running initializers...
initializing fileselector...
adbMetaInit: open(cfConfigDir/CPARCMETA.DAT): No such file or directory
Loading /home/sapphirus/.ocp/CPMODNFO.DAT .. Done
open(cfConfigDir/CPDIRDB.DAT): No such file or directory
Loading /home/sapphirus/.ocp/CPMUSBRN.DAT .. Empty database
Initing console...
Initing curses... (ncurses 6.4.20221231)

Sample output with XDG_CONFIG_HOME or $HOME defined blank:

$ env | grep XDG_CONFIG_HOME
XDG_CONFIG_HOME=
$ ocp -Dcurses
Either $HOME or $XDG_CONFIG_HOME is defined with a zero length variable. Please correctly define the specified path or unset the erroneous variable.