nixpkgs/pkgs/applications/misc/gmrun/gmrun-0.9.2-xdg.patch
Baptist BENOIST ca264f8da0 Add gmrun-0.9.2
Signed-off-by: Baptist BENOIST <return_0@live.com>
2012-10-16 18:03:13 +02:00

58 lines
1.6 KiB
Diff

diff -ur a/src/history.cc src/history.cc
--- a/src/history.cc 2002-08-17 15:19:31.000000000 +0200
+++ a/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 a/src/prefs.cc src/prefs.cc
--- a/src/prefs.cc 2012-06-04 22:35:00.671949439 +0200
+++ a/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);
}
}