mirror of
https://github.com/Dushistov/sdcv.git
synced 2025-12-15 17:31:56 +00:00
Comply with the XDG Base Directory Specification
This commit is contained in:
12
doc/sdcv.1
12
doc/sdcv.1
@@ -64,7 +64,7 @@ Use ANSI escape codes for colorizing sdcv output (does not work with json output
|
||||
.TP
|
||||
/usr/share/stardict/dic
|
||||
.TP
|
||||
$(HOME)/.stardict/dic
|
||||
$(XDG_DATA_HOME)/stardict/dic
|
||||
|
||||
Place where sdcv expects to find dictionaries.
|
||||
Instead of /usr/share/stardict/dic you can use any directory
|
||||
@@ -72,12 +72,12 @@ you want, just set the STARDICT_DATA_DIR environment variable.
|
||||
For example, if you have dictionaries in /mnt/data/stardict-dicts/dic,
|
||||
set STARDICT_DATA_DIR to /mnt/data/stardict-dicts.
|
||||
.TP
|
||||
$(HOME)/.sdcv_history
|
||||
$(XDG_DATA_HOME)/sdcv_history
|
||||
|
||||
This file includes the last $(SDCV_HISTSIZE) words, which you sought with sdcv.
|
||||
SDCV uses this file only if it was compiled with readline library support.
|
||||
.TP
|
||||
$(HOME)/.sdcv_ordering
|
||||
$(XDG_CONFIG_HOME)/sdcv_ordering
|
||||
|
||||
This is a text file containing one dictionary bookname per line.
|
||||
It specifies in which order the results of a search should be shown.
|
||||
@@ -89,11 +89,11 @@ If set, sdcv uses this variable as the data directory, this means that sdcv
|
||||
searches dictionaries in $\fBSTARDICT_DATA_DIR\fR\\dic
|
||||
.TP 20
|
||||
.B SDCV_HISTSIZE
|
||||
If set, sdcv writes in $(HOME)/.sdcv_history (or $(SDCV_HISTFILE)) the last $(SDCV_HISTSIZE) words,
|
||||
which you look up using sdcv. If it is not set, then the last 2000 words are saved in $(HOME)/.sdcv_history.
|
||||
If set, sdcv writes in $(XDG_DATA_HOME)/sdcv_history (or $(SDCV_HISTFILE)) the last $(SDCV_HISTSIZE) words,
|
||||
which you look up using sdcv. If it is not set, then the last 2000 words are saved in $(XDG_DATA_HOME)/sdcv_history.
|
||||
.TP 20
|
||||
.B SDCV_HISTFILE
|
||||
If set, sdcv writes it's history to $(SDCV_HISTFILE). If it is not set, then the default $(HOME)/.sdcv_history path will be used.
|
||||
If set, sdcv writes it's history to $(SDCV_HISTFILE). If it is not set, then the default $(XDG_DATA_HOME)/sdcv_history path will be used.
|
||||
.TP 20
|
||||
.B SDCV_PAGER
|
||||
If SDCV_PAGER is set, its value is used as the name of the program
|
||||
|
||||
@@ -50,7 +50,7 @@ sdcv проста, міжплатформена текстова утиліта
|
||||
.TP
|
||||
/usr/share/stardict/dic
|
||||
.TP
|
||||
$(HOME)/.stardict/dic
|
||||
$(XDG_DATA_HOME)/stardict/dic
|
||||
|
||||
Місце, де sdcv очікує знайти словники.
|
||||
Замість шляху /usr/share/stardict/dic Ви можете використовувати все,
|
||||
@@ -58,7 +58,7 @@ $(HOME)/.stardict/dic
|
||||
Наприклад, якщо Ви маєте словники у теці /mnt/data/stardict-dicts/dic,
|
||||
встановіть STARDICT_DATA_DIR у /mnt/data/stardict-dicts.
|
||||
.TP
|
||||
$(HOME)/.sdcv_history
|
||||
$(XDG_DATA_HOME)/sdcv_history
|
||||
|
||||
Цей файл містить останні $(SDCV_HISTSIZE) слова, які Ви шукали з sdcv.
|
||||
SDCV використовує цей файл при умові, якщо sdcv був скомпільований
|
||||
@@ -72,9 +72,9 @@ SDCV використовує цей файл при умові, якщо sdcv
|
||||
що sdcv шукатиме словники у $\fBSTARDICT_DATA_DIR\fR\dic
|
||||
.TP 20
|
||||
.B SDCV_HISTSIZE
|
||||
Якщо встановлена, sdcv писатиме у $(HOME)/.sdcv_history лише
|
||||
Якщо встановлена, sdcv писатиме у $(XDG_DATA_HOME)/sdcv_history лише
|
||||
останні $(SDCV_HISTSIZE) слова, які Ви шукали з sdcv. Якщо не встановлена,
|
||||
то збірігатиметься останніх 2000 слів у $(HOME)/.sdcv_history.
|
||||
то збірігатиметься останніх 2000 слів у $(XDG_DATA_HOME)/sdcv_history.
|
||||
.SH BUGS
|
||||
Звіти про помилки висилайте на адресу dushistov на mail крапка ru.
|
||||
Не забувайте включати слово "sdcv" десь у полі "Тема:".
|
||||
|
||||
@@ -69,7 +69,7 @@ std::string get_hist_file_path()
|
||||
if (hist_file_str != nullptr)
|
||||
return std::string(hist_file_str);
|
||||
else
|
||||
return std::string(g_get_home_dir()) + G_DIR_SEPARATOR + ".sdcv_history";
|
||||
return std::string(g_get_user_data_dir()) + G_DIR_SEPARATOR + "sdcv_history";
|
||||
}
|
||||
|
||||
class real_readline : public IReadLine
|
||||
|
||||
10
src/sdcv.cpp
10
src/sdcv.cpp
@@ -141,13 +141,9 @@ int main(int argc, char *argv[]) try {
|
||||
data_dir = get_impl(opt_data_dir);
|
||||
}
|
||||
|
||||
const char *homedir = g_getenv("HOME");
|
||||
if (!homedir)
|
||||
homedir = g_get_home_dir();
|
||||
|
||||
std::list<std::string> dicts_dir_list;
|
||||
if (!only_data_dir)
|
||||
dicts_dir_list.push_back(std::string(homedir) + G_DIR_SEPARATOR + ".stardict" + G_DIR_SEPARATOR + "dic");
|
||||
dicts_dir_list.push_back(std::string(g_get_user_data_dir()) + G_DIR_SEPARATOR + "stardict" + G_DIR_SEPARATOR + "dic");
|
||||
dicts_dir_list.push_back(data_dir);
|
||||
if (show_list_dicts) {
|
||||
list_dicts(dicts_dir_list, json_output);
|
||||
@@ -186,7 +182,7 @@ int main(int argc, char *argv[]) try {
|
||||
++p;
|
||||
}
|
||||
} else {
|
||||
const std::string odering_cfg_file = std::string(homedir) + G_DIR_SEPARATOR_S ".sdcv_ordering";
|
||||
const std::string odering_cfg_file = std::string(g_get_user_config_dir()) + G_DIR_SEPARATOR_S "sdcv_ordering";
|
||||
FILE *ordering_file = fopen(odering_cfg_file.c_str(), "r");
|
||||
if (ordering_file != nullptr) {
|
||||
std::string line;
|
||||
@@ -197,7 +193,7 @@ int main(int argc, char *argv[]) try {
|
||||
}
|
||||
}
|
||||
|
||||
const std::string conf_dir = std::string(g_get_home_dir()) + G_DIR_SEPARATOR + ".stardict";
|
||||
const std::string conf_dir = std::string(g_get_user_data_dir()) + G_DIR_SEPARATOR + "stardict";
|
||||
if (g_mkdir(conf_dir.c_str(), S_IRWXU) == -1 && errno != EEXIST) {
|
||||
fprintf(stderr, _("g_mkdir failed: %s\n"), strerror(errno));
|
||||
}
|
||||
|
||||
BIN
tests/stardict-test_synonyms-2.4.2/test.idx.oft
Normal file
BIN
tests/stardict-test_synonyms-2.4.2/test.idx.oft
Normal file
Binary file not shown.
@@ -6,7 +6,7 @@ unset SDCV_PAGER
|
||||
have=`"$PATH_TO_SDCV" --data-dir /tmp/bugagaga -l | wc -l`
|
||||
#do not count header
|
||||
have=$(($have-1))
|
||||
ndicts=`find "${HOME}"/.stardict/dic -name "*.ifo" -print | wc -l`
|
||||
ndicts=`find "${XDG_DATA_HOME:-$HOME/.local/share}"/stardict/dic -name "*.ifo" -print | wc -l`
|
||||
#ndicts=$(($ndicts+1))
|
||||
if [ $have -ne $ndicts ]; then
|
||||
ndicts=$(($ndicts-1))
|
||||
|
||||
@@ -4,7 +4,7 @@ PATH_TO_SDCV="$1"
|
||||
ndicts=`"$PATH_TO_SDCV" -l | wc -l`
|
||||
ndicts=$(($ndicts-1))
|
||||
ncom=`find /usr/share/stardict/dic -name "*.ifo" | wc -l`
|
||||
nspe=`find "${HOME}"/.stardict/dic -name "*.ifo" | wc -l`
|
||||
nspe=`find "${XDG_DATA_HOME:-$HOME/.local/share}"/stardict/dic -name "*.ifo" | wc -l`
|
||||
nmy=$(($ncom+$nspe))
|
||||
|
||||
if [ $nmy -ne $ndicts ]; then
|
||||
|
||||
@@ -5,8 +5,8 @@ set -e
|
||||
PATH_TO_SDCV="$1"
|
||||
TESTS_DIR="$2"
|
||||
|
||||
mkdir -p "${HOME}"/.stardict/dic
|
||||
cp -R "${TESTS_DIR}/stardict-test_dict-2.4.2" "${HOME}"/.stardict/dic
|
||||
mkdir -p "${XDG_DATA_HOME:-$HOME/.local/share}"/stardict/dic
|
||||
cp -R "${TESTS_DIR}/stardict-test_dict-2.4.2" "${XDG_DATA_HOME:-$HOME/.local/share}"/stardict/dic
|
||||
unset SDCV_PAGER
|
||||
RES=`"$PATH_TO_SDCV" -n -u test_dict test | grep "test passed"`
|
||||
|
||||
@@ -15,6 +15,6 @@ if [ -z "$RES" ]; then
|
||||
exit 1
|
||||
fi
|
||||
|
||||
rm -fr "${HOME}"/.stardict/dic/stardict-test_dict-2.4.2
|
||||
rm -fr "${XDG_DATA_HOME:-$HOME/.local/share}"/stardict/dic/stardict-test_dict-2.4.2
|
||||
|
||||
exit 0
|
||||
|
||||
@@ -4,9 +4,8 @@ set -e
|
||||
|
||||
PATH_TO_SDCV="$1"
|
||||
TESTS_DIR="$2"
|
||||
|
||||
mkdir -p "${HOME}"/.stardict/dic
|
||||
cp -R "${TESTS_DIR}/rus-eng-stardict-2.4.2" "${HOME}"/.stardict/dic/
|
||||
mkdir -p "${XDG_DATA_HOME:-$HOME/.local/share}"/stardict/dic
|
||||
cp -R "${TESTS_DIR}/rus-eng-stardict-2.4.2" "${XDG_DATA_HOME:-$HOME/.local/share}"/stardict/dic/
|
||||
|
||||
unset SDCV_PAGER
|
||||
export LANG=ru_RU.KOI8-R
|
||||
|
||||
Reference in New Issue
Block a user