1
0
mirror of https://github.com/rkd77/elinks.git synced 2024-06-05 22:00:54 +00:00

[.config] Read/write configuration from ~/.config/elinks . Refs #199

Note, configs and other files from ~/.elinks/ are not moved
to ~/.config/elinks/ automatically. You must do it yourself.

ELINKS_CONFDIR and HOME_ETC also are no longer supported.
This commit is contained in:
Witold Filipczyk 2022-12-26 17:36:31 +01:00
parent 86a54ca33d
commit 7ea7cacade
29 changed files with 171 additions and 93 deletions

View File

@ -56,10 +56,11 @@ EDITOR::
The program to use for external editor (when editing textareas).
ELINKS_CONFDIR::
XDG_CONFIG_HOME::
The location of the directory containing configuration files. If not
set the default is `~/.elinks/`.
The location of the directory containing configuration files. If set
configuration files are located in `$XDG_CONFIG_HOME/elinks/`.
Otherwise in `~/.config/elinks/`.
ELINKS_TWTERM, LINKS_TWTERM::
@ -83,10 +84,6 @@ HOME::
The path to the users home directory. Used when expanding `~/`.
HOME_ETC::
If set the location of the directory containing configuration files
is `$HOME_ETC/.elinks/` instead of `~/.elinks/`.
WWW_HOME::
@ -96,41 +93,41 @@ FILES
-----
Configuration files controlled by ELinks are located in the user
configuration directory, defaulting to '~/.elinks/'. In addition to the
configuration directory, defaulting to '~/.config/elinks/'. In addition to the
files listed below, a user defined CSS stylesheet can be defined using
the 'document.css.stylesheet' option.
@sysconfdir@/elinks.conf::
Site-wide configuration file.
~/.elinks/elinks.conf::
~/.config/elinks/elinks.conf::
Per-user config file, loaded after site-wide configuration.
~/.elinks/bookmarks::
~/.config/elinks/bookmarks::
Bookmarks file.
~/.elinks/cookies::
~/.config/elinks/cookies::
Cookies file.
~/.elinks/exmodehist::
~/.config/elinks/exmodehist::
Exmode history file.
~/.elinks/formhist::
~/.config/elinks/formhist::
Form history file.
~/.elinks/globhist::
~/.config/elinks/globhist::
History file containing most recently visited URLs.
~/.elinks/gotohist::
~/.config/elinks/gotohist::
GoTo URL dialog history file.
~/.elinks/hooks.{js,lua,pl,py,rb,scm}::
~/.config/elinks/hooks.{js,lua,pl,py,rb,scm}::
Browser scripting hooks.
~/.elinks/searchhist::
~/.config/elinks/searchhist::
Search history file.
~/.elinks/socket::
~/.config/elinks/socket::
Internal 'ELinks' socket for communication between its instances.
~/.mailcap, /etc/mailcap::

View File

@ -14,7 +14,7 @@ keybindings.
DESCRIPTION
-----------
Key binding for elinks should be placed in the file `~/.elinks/elinks.conf`.
Key binding for elinks should be placed in the file `~/.config/elinks/elinks.conf`.
Note that any information regarding their format/structure may not be
up-to-date. If you will discover that, please feed us with a patch.
@ -98,7 +98,7 @@ include::{builddir}keymap-actions.txt[]
DEFAULT BINDINGS
----------------
The default bindings are shown below. Any bindings in `~/.elinks/elinks.conf`
The default bindings are shown below. Any bindings in `~/.config/elinks/elinks.conf`
will override these.
include::{builddir}keymap-defaults.txt[]

View File

@ -206,7 +206,7 @@ Arguments:
Description:
Makes it possible to periodically save files in ~/.elinks to disk.
Makes it possible to periodically save files in ~/.config/elinks to disk.
-------------------------------------------------------------------------------
Name: pre-format-html

View File

@ -128,7 +128,7 @@ Config file
On startup, ELinks reads in two Lua scripts. Firstly, a system-wide
configuration file called `/etc/elinks/hooks.lua`, then a file in your home
directory called `~/.elinks/hooks.lua`. From these files, you can include
directory called `~/.config/elinks/hooks.lua`. From these files, you can include
other Lua files with `dofile`, if necessary.
To see what kind of things you should put in here, look at
@ -243,7 +243,7 @@ WARNING: The `tmpname` function creates the file but does not
bind_key (keymap, keystroke, function)::
Currently, `keymap` must be the string `"main"`. Keystroke is a
keystroke as you would write it in the ELinks config file
`~/.elinks/elinks.conf`. The function `function` should take no
`~/.config/elinks/elinks.conf`. The function `function` should take no
arguments, and should return the same values as `lua_console_hook`.
edit_bookmark_dialog (cat, name, url, function)::

View File

@ -15,7 +15,7 @@ DESCRIPTION
If ELinks is compiled with an embedded Python interpreter, it will try
to import a Python module called hooks when the browser starts up. To
use Python code from within ELinks, create a file called hooks.py in
the ~/.elinks directory, or in the system-wide configuration directory
the ~/.config/elinks directory, or in the system-wide configuration directory
(defined when ELinks was compiled), or in the standard Python search path.
An example hooks.py file can be found in the contrib/python directory of
the ELinks source distribution.
@ -112,7 +112,7 @@ DESCRIPTION
Other public objects:
home -- A string containing the pathname of the ~/.elinks directory, or
home -- A string containing the pathname of the ~/.config/elinks directory, or
None if ELinks has no configuration directory.
FUNCTIONS

View File

@ -31,7 +31,7 @@ Limitations and outstanding issues
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Remote control is implemented using the intercommunication socket created in
~/.elinks/, so the command has to be run on the same machine as the instance
~/.config/elinks/, so the command has to be run on the same machine as the instance
you want to control; or put differently: the two ELinkses need to share a file
system that supports socket files, which rules out usage of -remote over NFS.
This also implies that the ELinks instance you want to control should be

View File

@ -20,7 +20,7 @@ you don't have a `hooks.js` file, there is not much risk in enabling the
feature at compile time.
When ELinks starts up, it evaluates the ECMAScript file `hooks.js` in
your ELinks configuration directory (thus normally `~/.elinks/hooks.js`
your ELinks configuration directory (thus normally `~/.config/elinks/hooks.js`
on Unix-like systems), or if the file does not exist there, then in
the system-wide ELinks configuration directory (the location depends
on how ELinks was built, but `/etc/elinks/hooks.js` is typical).
@ -47,7 +47,7 @@ Global Object Methods
+
--
----------------------------------------------------------------------
do_file("/home/me/.elinks/hooks.js");
do_file("/home/me/.config/elinks/hooks.js");
----------------------------------------------------------------------
will reload your hooks file.

View File

@ -286,19 +286,20 @@ add_to_input_history(struct input_history *history, char *data,
int
load_input_history(struct input_history *history, const char *filename)
{
char *xdg_config_home = get_xdg_config_home();
char *history_file = (char *)filename;
char line[MAX_STR_LEN];
FILE *file;
if (get_cmd_opt_bool("anonymous")) return 0;
if (elinks_home) {
history_file = straconcat(elinks_home, filename,
if (xdg_config_home) {
history_file = straconcat(xdg_config_home, filename,
(char *) NULL);
if (!history_file) return 0;
}
file = fopen(history_file, "rb");
if (elinks_home) mem_free(history_file);
if (xdg_config_home) mem_free(history_file);
if (!file) return 0;
history->nosave = 1;
@ -329,17 +330,18 @@ load_input_history(struct input_history *history, const char *filename)
int
save_input_history(struct input_history *history, const char *filename)
{
char *xdg_config_home = get_xdg_config_home();
struct input_history_entry *entry;
struct secure_save_info *ssi;
char *history_file;
int i = 0;
if (!history->dirty
|| !elinks_home
|| !xdg_config_home
|| get_cmd_opt_bool("anonymous"))
return 0;
history_file = straconcat(elinks_home, filename,
history_file = straconcat(xdg_config_home, filename,
(char *) NULL);
if (!history_file) return -1;

View File

@ -45,6 +45,7 @@ static int loaded_backend_num = -1;
void
bookmarks_read(void)
{
char *xdg_config_home = get_xdg_config_home();
int backend_num = get_opt_int("bookmarks.file_format", NULL);
struct bookmarks_backend *backend = bookmarks_backends[backend_num];
char *file_name;
@ -57,8 +58,8 @@ bookmarks_read(void)
file_name_orig = backend->filename(0);
if (!file_name_orig) return;
if (elinks_home) {
file_name = straconcat(elinks_home, file_name_orig,
if (xdg_config_home) {
file_name = straconcat(xdg_config_home, file_name_orig,
(char *) NULL);
if (!file_name) return;
f = fopen(file_name, "rb");
@ -84,11 +85,12 @@ bookmarks_write(LIST_OF(struct bookmark) *bookmarks_list)
struct secure_save_info *ssi;
char *file_name;
const char *file_name_orig;
char *xdg_config_home = get_xdg_config_home();
if (!bookmarks_are_dirty() && backend_num == loaded_backend_num) return;
if (!backend
|| !backend->write
|| !elinks_home
|| !xdg_config_home
|| !backend->filename) return;
/* We do this two-passes because we want backend to possibly decide to
@ -96,7 +98,7 @@ bookmarks_write(LIST_OF(struct bookmark) *bookmarks_list)
* they would be just truncated to zero by secure_open()). */
file_name_orig = backend->filename(1);
if (!file_name_orig) return;
file_name = straconcat(elinks_home, file_name_orig, (char *) NULL);
file_name = straconcat(xdg_config_home, file_name_orig, (char *) NULL);
if (!file_name) return;
ssi = secure_open(file_name);

View File

@ -578,6 +578,7 @@ static enum parse_error
parse_include(struct option *opt_tree, struct conf_parsing_state *state,
struct string *mirror, int is_system_conf)
{
char *xdg_config_home = get_xdg_config_home();
char *fname;
struct string dumbstring;
struct conf_parsing_pos before_error;
@ -609,7 +610,7 @@ parse_include(struct option *opt_tree, struct conf_parsing_state *state,
/* XXX: We should try CONFDIR/<file> when proceeding
* CONFDIR/<otherfile> ;). --pasky */
if (load_config_file(fname[0] == '/' ? (char *) ""
: elinks_home,
: xdg_config_home,
fname, opt_tree,
mirror ? &dumbstring : NULL, 1)) {
done_string(&dumbstring);
@ -837,7 +838,7 @@ static void
load_config_from(char *file, struct option *tree)
{
load_config_file(CONFDIR, file, tree, NULL, 1);
load_config_file(empty_string_or_(elinks_home), file, tree, NULL, 0);
load_config_file(empty_string_or_(get_xdg_config_home()), file, tree, NULL, 0);
}
void
@ -1306,7 +1307,9 @@ free_cfg_str:
int
write_config(struct terminal *term)
{
if (!elinks_home) {
char *xdg_config_home = get_xdg_config_home();
if (!xdg_config_home) {
if (term) {
write_config_dialog(term, get_cmd_opt_str("config-file"),
SS_ERR_DISABLED, 0);
@ -1314,7 +1317,7 @@ write_config(struct terminal *term)
return -1;
}
return write_config_file(elinks_home, get_cmd_opt_str("config-file"),
return write_config_file(xdg_config_home, get_cmd_opt_str("config-file"),
term);
}

View File

@ -24,8 +24,8 @@
#include "util/string.h"
char *elinks_home = NULL;
int first_use = 0;
static char *xdg_config_home = NULL;
static inline void
strip_trailing_dir_sep(char *path)
@ -106,6 +106,58 @@ elinks_dirname(char *path)
return dir;
}
char *
get_xdg_config_home(void)
{
if (xdg_config_home) {
return xdg_config_home;
}
char *g_xdg_config_home = getenv("XDG_CONFIG_HOME");
if (g_xdg_config_home && *g_xdg_config_home) {
xdg_config_home = test_confdir(g_xdg_config_home,
get_cmd_opt_str("config-dir"),
N_("Commandline options -config-dir set to %s, "
"but could not create directory %s."));
if (xdg_config_home) {
return xdg_config_home;
}
xdg_config_home = test_confdir(g_xdg_config_home, "elinks", NULL);
if (xdg_config_home) {
return xdg_config_home;
}
return NULL;
}
char *home = getenv("HOME");
if (!home || !*home) {
return NULL;
}
char *config_dir = straconcat(home, STRING_DIR_SEP, ".config", NULL);
if (!config_dir) {
return NULL;
}
xdg_config_home = test_confdir(config_dir,
get_cmd_opt_str("config-dir"),
N_("Commandline options -config-dir set to %s, "
"but could not create directory %s."));
if (xdg_config_home) {
mem_free(config_dir);
return xdg_config_home;
}
xdg_config_home = test_confdir(config_dir, "elinks", NULL);
if (xdg_config_home) {
mem_free(config_dir);
return xdg_config_home;
}
return NULL;
}
static char *
get_home(void)
{
@ -151,8 +203,8 @@ void
init_home(void)
{
first_use = 1;
elinks_home = get_home();
if (!elinks_home) {
xdg_config_home = get_xdg_config_home();
if (!xdg_config_home) {
ERROR(gettext("Unable to find or create ELinks config "
"directory. Please check if you have $HOME "
"variable set correctly and if you have "
@ -165,5 +217,5 @@ init_home(void)
void
done_home(void)
{
mem_free_if(elinks_home);
mem_free_set(&xdg_config_home, NULL);
}

View File

@ -5,11 +5,11 @@
extern "C" {
#endif
extern char *elinks_home;
extern int first_use;
void init_home(void);
void done_home(void);
char *get_xdg_config_home(void);
#ifdef __cplusplus
}

View File

@ -886,7 +886,8 @@ change_hook_ui_double_esc(struct session *ses, struct option *current, struct op
static int
change_hook_ui_mouse_disable(struct session *ses, struct option *current, struct option *changed)
{
char *lock_filename = straconcat(empty_string_or_(elinks_home), "mouse.lock", (char *)NULL);
char *xdg_config_home = get_xdg_config_home();
char *lock_filename = straconcat(empty_string_or_(xdg_config_home), "mouse.lock", (char *)NULL);
if (lock_filename) {
if (changed->value.number) {

View File

@ -691,6 +691,7 @@ static void done_cookies(struct module *module);
void
load_cookies(void) {
char *xdg_config_home = get_xdg_config_home();
/* Buffer size is set to be enough to read long lines that
* save_cookies may write. 6 is choosen after the fprintf(..) call
* in save_cookies(). --Zas */
@ -700,8 +701,8 @@ load_cookies(void) {
FILE *fp;
time_t now;
if (elinks_home) {
cookfile = straconcat(elinks_home, cookfile_orig,
if (xdg_config_home) {
cookfile = straconcat(xdg_config_home, cookfile_orig,
(char *) NULL);
if (!cookfile) return;
}
@ -712,7 +713,7 @@ load_cookies(void) {
done_cookies(&cookies_module);
cookies_nosave = 0;
if (elinks_home) {
if (xdg_config_home) {
fp = fopen(cookfile, "rb");
mem_free(cookfile);
} else {
@ -821,6 +822,7 @@ save_cookies(struct terminal *term) {
char *cookfile;
struct secure_save_info *ssi;
time_t now;
char *xdg_config_home = get_xdg_config_home();
#ifdef CONFIG_SMALL
# define CANNOT_SAVE_COOKIES(flags, message)
@ -838,7 +840,7 @@ save_cookies(struct terminal *term) {
if_assert_failed {}
return;
}
if (!elinks_home) {
if (!xdg_config_home) {
CANNOT_SAVE_COOKIES(0, N_("ELinks was started without a home directory."));
return;
}
@ -849,7 +851,7 @@ save_cookies(struct terminal *term) {
return;
}
cookfile = straconcat(elinks_home, COOKIES_FILENAME,
cookfile = straconcat(xdg_config_home, COOKIES_FILENAME,
(char *) NULL);
if (!cookfile) {
CANNOT_SAVE_COOKIES(0, N_("Out of memory"));

View File

@ -155,6 +155,7 @@ static void
import_css_file(struct css_stylesheet *css, struct uri *base_uri,
const char *url, int urllen)
{
char *xdg_config_home = get_xdg_config_home();
struct string string, filename;
if (!*url
@ -162,8 +163,8 @@ import_css_file(struct css_stylesheet *css, struct uri *base_uri,
|| !init_string(&filename))
return;
if (*url != '/' && elinks_home) {
add_to_string(&filename, elinks_home);
if (*url != '/' && xdg_config_home) {
add_to_string(&filename, xdg_config_home);
}
add_bytes_to_string(&filename, url, urllen);

View File

@ -163,15 +163,16 @@ is_prefix(char *prefix, char *url, int dl)
static void
read_url_list(void)
{
char *xdg_config_home = get_xdg_config_home();
char line[4096];
char *filename;
FILE *f;
if (!elinks_home) {
if (!xdg_config_home) {
return;
}
filename = straconcat(elinks_home, STRING_DIR_SEP, ALLOWED_ECMASCRIPT_URL_PREFIXES, NULL);
filename = straconcat(xdg_config_home, STRING_DIR_SEP, ALLOWED_ECMASCRIPT_URL_PREFIXES, NULL);
if (filename) {
@ -186,7 +187,7 @@ read_url_list(void)
mem_free(filename);
}
filename = straconcat(elinks_home, STRING_DIR_SEP, DISALLOWED_ECMASCRIPT_URL_PREFIXES, NULL);
filename = straconcat(xdg_config_home, STRING_DIR_SEP, DISALLOWED_ECMASCRIPT_URL_PREFIXES, NULL);
if (filename) {
@ -829,17 +830,18 @@ ecmascript_set_timeout2m(js_State *J, const char *handle, int timeout)
static void
init_ecmascript_module(struct module *module)
{
char *xdg_config_home = get_xdg_config_home();
read_url_list();
if (elinks_home) {
if (xdg_config_home) {
/* ecmascript console log */
console_log_filename = straconcat(elinks_home, "/console.log", NULL);
console_error_filename = straconcat(elinks_home, "/console.err", NULL);
console_log_filename = straconcat(xdg_config_home, "/console.log", NULL);
console_error_filename = straconcat(xdg_config_home, "/console.err", NULL);
/* ecmascript local storage db location */
#ifdef CONFIG_OS_DOS
local_storage_filename = stracpy("elinks_ls.db");
#else
local_storage_filename = straconcat(elinks_home, "/elinks_ls.db", NULL);
local_storage_filename = straconcat(xdg_config_home, "/elinks_ls.db", NULL);
#endif
}
ecmascript_enabled = get_opt_bool("ecmascript.enable", NULL);

View File

@ -90,6 +90,7 @@ static int loaded = 0;
int
load_formhist_from_file(void)
{
char *xdg_config_home = get_xdg_config_home();
struct formhist_data *form;
char tmp[MAX_STR_LEN];
char *file;
@ -97,9 +98,9 @@ load_formhist_from_file(void)
if (loaded) return 1;
if (!elinks_home) return 0;
if (!xdg_config_home) return 0;
file = straconcat(elinks_home, FORMS_HISTORY_FILENAME,
file = straconcat(xdg_config_home, FORMS_HISTORY_FILENAME,
(char *) NULL);
if (!file) return 0;
@ -215,15 +216,16 @@ fail:
int
save_formhist_to_file(void)
{
char *xdg_config_home = get_xdg_config_home();
struct secure_save_info *ssi;
char *file;
struct formhist_data *form;
int r;
if (!elinks_home || get_cmd_opt_bool("anonymous"))
if (!xdg_config_home || get_cmd_opt_bool("anonymous"))
return 0;
file = straconcat(elinks_home, FORMS_HISTORY_FILENAME,
file = straconcat(xdg_config_home, FORMS_HISTORY_FILENAME,
(char *) NULL);
if (!file) return 0;

View File

@ -327,6 +327,7 @@ globhist_simple_search(char *search_url, char *search_title)
static void
read_global_history(void)
{
char *xdg_config_home = get_xdg_config_home();
char in_buffer[MAX_STR_LEN * 3];
char *title;
FILE *f;
@ -335,8 +336,8 @@ read_global_history(void)
|| get_cmd_opt_bool("anonymous"))
return;
if (elinks_home) {
char *file_name = straconcat(elinks_home, GLOBAL_HISTORY_FILENAME,
if (xdg_config_home) {
char *file_name = straconcat(xdg_config_home, GLOBAL_HISTORY_FILENAME,
(char *) NULL);
if (!file_name) return;
@ -375,16 +376,17 @@ read_global_history(void)
static void
write_global_history(void)
{
char *xdg_config_home = get_xdg_config_home();
struct global_history_item *history_item;
char *file_name;
struct secure_save_info *ssi;
if (!global_history.dirty || !elinks_home
if (!global_history.dirty || !xdg_config_home
|| !get_globhist_enable()
|| get_cmd_opt_bool("anonymous"))
return;
file_name = straconcat(elinks_home, GLOBAL_HISTORY_FILENAME,
file_name = straconcat(xdg_config_home, GLOBAL_HISTORY_FILENAME,
(char *) NULL);
if (!file_name) return;

View File

@ -114,14 +114,16 @@ enum addr_type {
static int
get_sun_path(struct string *sun_path)
{
char *xdg_config_home = get_xdg_config_home();
assert(sun_path);
if_assert_failed return 0;
if (!elinks_home) return 0;
if (!xdg_config_home) return 0;
if (!init_string(sun_path)) return 0;
add_to_string(sun_path, elinks_home);
add_to_string(sun_path, xdg_config_home);
add_to_string(sun_path, ELINKS_SOCK_NAME);
add_long_to_string(sun_path,
get_cmd_opt_int("session-ring"));

View File

@ -334,7 +334,7 @@ static union option_info gnutls_options[] = {
* change the file name via the option manager. Distributors
* of binary packages should of course change the default to
* suit their systems.
* TODO: If the file name is relative, look in elinks_home? */
* TODO: If the file name is relative, look in xdg_config_home? */
INIT_OPT_STRING("connection.ssl", N_("Trusted CA file"),
"trusted_ca_file", OPT_ZERO,
#ifdef HAVE_GNUTLS_CERTIFICATE_SET_X509_SYSTEM_TRUST

View File

@ -45,6 +45,7 @@ static char elguileversion[32];
void
init_guile(struct module *module)
{
char *xdg_config_home = get_xdg_config_home();
SCM user_module;
char *path;
@ -53,12 +54,12 @@ init_guile(struct module *module)
snprintf(elguileversion, 31, "Guile %s", scm_to_locale_string(scm_version()));
module->name = elguileversion;
if (!elinks_home) return;
if (!xdg_config_home) return;
/* Remember the current module. */
user_module = scm_current_module();
path = straconcat(elinks_home, GUILE_HOOKS_FILENAME,
path = straconcat(xdg_config_home, GUILE_HOOKS_FILENAME,
(char *) NULL);
if (!path) return;
@ -81,7 +82,7 @@ init_guile(struct module *module)
mem_free(path);
path = straconcat(elinks_home, GUILE_USERHOOKS_FILENAME,
path = straconcat(xdg_config_home, GUILE_USERHOOKS_FILENAME,
(char *) NULL);
if (!path) return;
if (file_can_read(path))

View File

@ -720,6 +720,8 @@ static char elluaversion[32];
void
init_lua(struct module *module)
{
char *xdg_config_home = get_xdg_config_home();
L = luaL_newstate();
luaL_openlibs(L);
@ -741,12 +743,12 @@ init_lua(struct module *module)
lua_register(L, "reload", l_reload);
lua_register(L, "goto_url", l_goto_url);
lua_pushstring(L, elinks_home ? elinks_home
lua_pushstring(L, xdg_config_home ? xdg_config_home
: (char *) CONFDIR);
lua_setglobal(L, "elinks_home");
do_hooks_file(L, CONFDIR, LUA_HOOKS_FILENAME);
if (elinks_home) do_hooks_file(L, elinks_home, LUA_HOOKS_FILENAME);
if (xdg_config_home) do_hooks_file(L, xdg_config_home, LUA_HOOKS_FILENAME);
strncpy(elluaversion, LUA_RELEASE, 31);
module->name = elluaversion;

View File

@ -45,14 +45,14 @@ static char *
get_local_hook_file(void)
{
static char buf[1024]; /* TODO: MAX_PATH ??? --Zas */
char *xdg_config_home = get_xdg_config_home();
if (!elinks_home) return NULL;
snprintf(buf, sizeof(buf), "%s%s", elinks_home, PERL_HOOKS_FILENAME);
if (!xdg_config_home) return NULL;
snprintf(buf, sizeof(buf), "%s%s", xdg_config_home, PERL_HOOKS_FILENAME);
if (file_exists(buf)) return buf;
return NULL;
}
static void
precleanup_perl(struct module *module)
{

View File

@ -101,11 +101,12 @@ set_python_search_path(void)
struct string new_python_path;
char *old_python_path;
int result = -1;
char *xdg_config_home = get_xdg_config_home();
if (!init_string(&new_python_path)) return result;
if (elinks_home && !add_format_to_string(&new_python_path, "%s%c",
elinks_home, DELIM))
if (xdg_config_home && !add_format_to_string(&new_python_path, "%s%c",
xdg_config_home, DELIM))
goto end;
if (!add_to_string(&new_python_path, CONFDIR))
@ -329,6 +330,7 @@ PyMODINIT_FUNC
PyInit_elinks(void)
{
PyObject *elinks_module, *module_dict, *module_name;
char *xdg_config_home = get_xdg_config_home();
if (replace_showwarning() != 0) {
goto python_error;
@ -344,9 +346,9 @@ PyInit_elinks(void)
goto python_error;
}
/* If @elinks_home is NULL, Py_BuildValue() returns a None reference. */
/* If @xdg_config_home is NULL, Py_BuildValue() returns a None reference. */
if (PyModule_AddObject(elinks_module, "home",
Py_BuildValue("s", elinks_home)) != 0) {
Py_BuildValue("s", xdg_config_home)) != 0) {
goto python_error;
}

View File

@ -206,12 +206,12 @@ erb_module_method_missing(int argc, VALUE *argv, VALUE self)
static void
init_erb_module(void)
{
char *home;
char *home = get_xdg_config_home();
erb_module = rb_define_module("ELinks");
rb_define_const(erb_module, "VERSION", rb_str_new2(VERSION_STRING));
home = elinks_home ? elinks_home : (char *) CONFDIR;
home = home ?: (char *) CONFDIR;
rb_define_const(erb_module, "HOME", rb_str_new2(home));
rb_define_module_function(erb_module, "message", (VALUE (*)(ANYARGS))erb_module_message, 1);
@ -225,6 +225,7 @@ static char elrubyversion[32];
void
init_ruby(struct module *module)
{
char *xdg_config_home = get_xdg_config_home();
char *path;
/* Set up and initialize the interpreter. This function should be called
@ -243,8 +244,8 @@ init_ruby(struct module *module)
snprintf(elrubyversion, 31, "Ruby %s", ruby_version);
module->name = elrubyversion;
if (elinks_home) {
path = straconcat(elinks_home, RUBY_HOOKS_FILENAME,
if (xdg_config_home) {
path = straconcat(xdg_config_home, RUBY_HOOKS_FILENAME,
(char *) NULL);
} else {

View File

@ -121,11 +121,12 @@ static void
smjs_load_hooks(void)
{
char *path;
char *xdg_config_home = get_xdg_config_home();
assert(smjs_ctx);
if (elinks_home) {
path = straconcat(elinks_home, SMJS_HOOKS_FILENAME,
if (xdg_config_home) {
path = straconcat(xdg_config_home, SMJS_HOOKS_FILENAME,
(char *) NULL);
} else {
path = stracpy(CONFDIR STRING_DIR_SEP SMJS_HOOKS_FILENAME);

View File

@ -183,6 +183,7 @@ smjs_invoke_elinks_object_method(const char *method, int argc, JS::Value *argv,
static bool
elinks_get_property_home(JSContext *ctx, unsigned int argc, JS::Value *vp)
{
char *xdg_config_home = get_xdg_config_home();
JS::CallArgs args = CallArgsFromVp(argc, vp);
JS::RootedObject hobj(ctx, &args.thisv().toObject());
@ -192,7 +193,7 @@ elinks_get_property_home(JSContext *ctx, unsigned int argc, JS::Value *vp)
if (!JS_InstanceOf(ctx, hobj, (JSClass *) &elinks_class, NULL))
return false;
args.rval().setString(JS_NewStringCopyZ(smjs_ctx, elinks_home));
args.rval().setString(JS_NewStringCopyZ(smjs_ctx, xdg_config_home));
return true;
}

View File

@ -964,7 +964,9 @@ setup_first_session(struct session *ses, struct uri *uri)
N_("Welcome"), ALIGN_CENTER,
N_("Welcome to ELinks!\n\n"
"Press ESC for menu. Documentation is available in "
"Help menu."),
"Help menu.\n"
"ATTENTION. Since 0.17.GIT configuration is read from and written to $XDG_CONFIG_HOME/elinks or ~/.config/elinks.\n"
"So if you did not copy it yet from ~/.elinks, do it now and start again."),
ses, 1,
MSG_BOX_BUTTON(N_("~OK"), (void (*)(void *))handler, B_ENTER | B_ESC));

View File

@ -88,7 +88,7 @@ disable_mouse(void)
static int
mouse_lock_exists(void)
{
char *lock_filename = straconcat(empty_string_or_(elinks_home), "mouse.lock", (char *) NULL);
char *lock_filename = straconcat(empty_string_or_(get_xdg_config_home()), "mouse.lock", (char *) NULL);
int res = 0;
if (lock_filename) {