all repos — mgba @ 2155a3017296fbe9de76a6db4ca69515ef113506

mGBA Game Boy Advance Emulator

Merge pull request #326 from linkmauve/fix-xdg-config-home

Core: Obey the XDG basedir specification for environment variables
endrift jeffrey@endrift.com
Sat, 10 Sep 2016 22:24:16 -0700
commit

2155a3017296fbe9de76a6db4ca69515ef113506

parent

67a09eaa1d4132c8ffef3178ea0875102153609d

3 files changed, 36 insertions(+), 10 deletions(-)

jump to
M doc/mgba-qt.6doc/mgba-qt.6

@@ -1,4 +1,4 @@

-.\" Copyright (c) 2015 Anthony J. Bentley <anthony@anjbe.name> +.\" Copyright (c) 2015-2016 Anthony J. Bentley <anthony@anjbe.name> .\" .\" This Source Code Form is subject to the terms of the Mozilla Public .\" License, v. 2.0. If a copy of the MPL was not distributed with this

@@ -103,13 +103,23 @@ .Ao Cm Shift Ac Ns \(hy Ns Cm F1 Ns \(en Ns Cm F9

.It Frame advance .Ao Cm Ctrl Ac Ns \(hy Ns Cm n .El +.Sh ENVIRONMENT +.Bl -tag -width Ds -compact +.It Ev XDG_CONFIG_HOME +The location where +.Nm +will look for the configuration directory. +If not set, +.Pa ~/.config +is used. +.El .Sh FILES -.Bl -tag -width ~/.config/mgba/config.ini -compact -.It Pa ~/.config/mgba/config.ini +.Bl -tag -width Ds -compact +.It Pa $XDG_CONFIG_HOME/mgba/config.ini Default .Xr mgba 6 configuration file. -.It Pa ~/.config/mgba/qt.ini +.It Pa $XDG_CONFIG_HOME/mgba/qt.ini Default .Nm mgba-qt configuration file.

@@ -121,7 +131,7 @@ .Pa config.ini

and .Pa qt.ini from the current directory instead of -.Pa ~/.config/mgba . +.Pa $XDG_CONFIG_HOME/mgba . .El .Sh AUTHORS .An Jeffrey Pfau Aq Mt jeffrey@endrift.com
M doc/mgba.6doc/mgba.6

@@ -1,4 +1,4 @@

-.\" Copyright (c) 2015 Anthony J. Bentley <anthony@anjbe.name> +.\" Copyright (c) 2015-2016 Anthony J. Bentley <anthony@anjbe.name> .\" .\" This Source Code Form is subject to the terms of the Mozilla Public .\" License, v. 2.0. If a copy of the MPL was not distributed with this

@@ -230,11 +230,21 @@ If

.Ar count is not specified, examine 16 bytes, 8 halfwords, or 4 words. .El +.Sh ENVIRONMENT +.Bl -tag -width Ds -compact +.It Ev XDG_CONFIG_HOME +The location where +.Nm +will look for the configuration directory. +If not set, +.Pa ~/.config +is used. +.El .Sh FILES -.Bl -tag -width ~/.config/mgba/config.ini -compact -.It Pa ~/.config/mgba/config.ini +.Bl -tag -width Ds -compact +.It Pa $XDG_CONFIG_HOME/mgba/config.ini Default -.Nm +.Xr mgba 6 configuration file. .It Pa portable.ini If this file exists in the current directory,

@@ -242,7 +252,7 @@ .Nm

will read .Pa config.ini from the current directory instead of -.Pa ~/.config/mgba . +.Pa $XDG_CONFIG_HOME/mgba . .El .Sh AUTHORS .An Jeffrey Pfau Aq Mt jeffrey@endrift.com
M src/core/config.csrc/core/config.c

@@ -227,6 +227,12 @@ portable->close(portable);

return; } + char* xdgConfigHome = getenv("XDG_CONFIG_HOME"); + if (xdgConfigHome && xdgConfigHome[0] == '/') { + snprintf(out, outLength, "%s/%s", xdgConfigHome, binaryName); + mkdir(out, 0755); + return; + } char* home = getenv("HOME"); snprintf(out, outLength, "%s/.config", home); mkdir(out, 0755);