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)
- can aria2 support git downloader?
- ng cant find aria2
- Some bittorrent peers have the wrong port and fail to connect
- [SocketCore.cc:1019] errorCode=1 SSL/TLS handshake failure: The TLS connection was non-properly terminated.
- Get size of track in mpd
- aria2 can't find the certificate.
- J
- [Question] about User-Agent in both options and request headers
- Downloads churn and churn but never complete.
- Allow passing --select-file multiple times
- downloader aria2c seems forbidden download file with yt-dlp.exe
- [Feature Request] System-wide configuration file HOT 2
- Aria2 config not being respected. HOT 3
- Safe curve secp521r1 is not supported, please update your TLS libraries
- allow specifying file-wide common config options directly in the file
- make check fail HOT 1
- Compile the aria2 code into a static library
- Filename Whitespace Converted to `%20` During Download
- Issue with installing Multiplatform UUP converter requirements on macos 12.7.6
- Building require LZMA development library
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.