Comments (4)
Here's a patch to make use of XDG for the config file:
3 files changed, 22 insertions(+), 1 deletion(-)
src/OptionHandlerFactory.cc | 2 +-
src/util.cc | 17 +++++++++++++++++
src/util.h | 4 ++++
Modified src/OptionHandlerFactory.cc
diff --git a/src/OptionHandlerFactory.cc b/src/OptionHandlerFactory.cc
index 768d847..077fc4f 100644
--- a/src/OptionHandlerFactory.cc
+++ b/src/OptionHandlerFactory.cc
@@ -174,7 +174,7 @@ std::vector<OptionHandler*> OptionHandlerFactory::createOptionHandlers()
OptionHandler* op(new DefaultOptionHandler
(PREF_CONF_PATH,
TEXT_CONF_PATH,
- util::getHomeDir()+"/.aria2/aria2.conf",
+ util::getConfigFile(),
PATH_TO_FILE));
op->addTag(TAG_ADVANCED);
handlers.push_back(op);
Modified src/util.cc
diff --git a/src/util.cc b/src/util.cc
index 68310aa..16a9ab0 100644
--- a/src/util.cc
+++ b/src/util.cc
@@ -1336,6 +1336,23 @@ std::string getHomeDir()
}
#endif // __MINGW32__
+std::string getXDGConfigHomeDir()
+{
+ const char* p = getenv("XDG_CONFIG_HOME");
+ if (p) {
+ return p;
+ }
+ return getHomeDir()+"/.config";
+}
+
+std::string getConfigFile() {
+ std::string filename = getXDGConfigHomeDir() + "/aria2/aria2.conf";
+ if (File(filename).exists()) {
+ return filename;
+ }
+ return getHomeDir()+"/.aria2/aria2.conf";
+}
+
int64_t getRealSize(const std::string& sizeWithUnit)
{
std::string::size_type p = sizeWithUnit.find_first_of("KMkm");
Modified src/util.h
diff --git a/src/util.h b/src/util.h
index 6e5eb8c..a71dbaf 100644
--- a/src/util.h
+++ b/src/util.h
@@ -349,6 +349,10 @@ void setGlobalSignalHandler(int signal, sigset_t* mask,
std::string getHomeDir();
+std::string getXDGConfigHomeDir();
+
+std::string getConfigFile();
+
int64_t getRealSize(const std::string& sizeWithUnit);
std::string abbrevSize(int64_t size);
I'll have to look into corresponding changes for ~/.aria2/dht.dat
. ~/.aria2/dht6.dat
and the docs.
from aria2.
Thank you! This is awesome. Could you send PR for this once you finish the patch? We can discuss this in detail there.
from aria2.
See #395.
from aria2.
Fix committed, closing.
from aria2.
Related Issues (20)
- aira2 Does Not Support IPv6 Domain Remote Management?
- Failed to download file from ipv6 server HOT 2
- Using aria2c with yt-dlp returns Unrecognized URI HOT 4
- Aria2 Download queue
- aria2.session cannot write and this issue leads not to dowload
- Why is the executable file called 'aria2c' (instead of 'aria2')
- Aria2c RPC Method changeUri doesn't work HOT 1
- 关于开启https无法访问的问题 HOT 8
- How to request SFTP compression?
- Aria2 control files regularly fail to rename from aria2__temp to aria2 and do not get deleted post-download
- Support file uri scheme
- msys2-mingw64 提示 error: 'gettimeofday' was not declared in this scope; did you mean 'gettimeofday_ms'?
- HLS fragments
- Problem compiling in mingw static. undefined reference to `libiconv_set_ relocation_prefix HOT 2
- option --follow-torrent=false doesn't work
- aria2c incompatible with most CDNs
- Subfolder support for metalink HOT 1
- File Version property shouldn't be empty
- OSError: [Errno 99] Cannot assign requested address HOT 1
- OSX10.7 aria2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from aria2.