Merge pull request #268619 from tweag/lib-descriptions
[NixPkgs.git] / pkgs / applications / misc / gmrun / gmrun-0.9.2-xdg.patch
blobb5cd41a3c5b41ea2172ebff91e7cbec243e6559d
1 diff -ur a/src/history.cc src/history.cc
2 --- a/src/history.cc 2002-08-17 15:19:31.000000000 +0200
3 +++ a/src/history.cc 2012-06-04 23:42:35.314653414 +0200
4 @@ -24,8 +24,15 @@
5 HistoryFile::HistoryFile()
7 m_file_entries = 0;
8 - m_filename = g_get_home_dir();
9 - m_filename += "/.gmrun_history";
10 + const char* filename = getenv("XDG_CACHE_HOME");
11 + if (filename != 0 && *filename != '\0') {
12 + m_filename = filename;
13 + m_filename += "/gmrun_history";
14 + }
15 + else {
16 + m_filename = g_get_home_dir();
17 + m_filename += "/.gmrun_history";
18 + }
19 m_current = 0;
20 m_default_set = false;
21 read_the_file();
22 diff -ur a/src/prefs.cc src/prefs.cc
23 --- a/src/prefs.cc 2012-06-04 22:35:00.671949439 +0200
24 +++ a/src/prefs.cc 2012-06-04 23:24:24.184445962 +0200
25 @@ -35,12 +35,29 @@
26 file_name += GMRUNRC;
27 init(file_name);
29 - file_name = getenv("HOME");
30 - if (!file_name.empty()) {
31 + file_name.clear();
32 + const char* filename = getenv("XDG_CONFIG_HOME");
33 + if (filename != 0 && *filename != '\0') {
34 + file_name = filename;
35 string::iterator i = file_name.end() - 1;
36 - if (*i == '/') file_name.erase(i);
37 - file_name += "/.";
38 + if (*i != '/') {
39 + file_name += '/';
40 + }
41 file_name += GMRUNRC;
42 + }
43 + else {
44 + filename = getenv("HOME");
45 + if (filename != 0 && *filename != '\0') {
46 + file_name = filename;
47 + string::iterator i = file_name.end() - 1;
48 + if (*i != '/') {
49 + file_name += '/';
50 + }
51 + file_name += '.';
52 + file_name += GMRUNRC;
53 + }
54 + }
55 + if (!file_name.empty()) {
56 init(file_name);