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