aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/FbTk/App.cc9
-rw-r--r--src/FbTk/FileUtil.cc11
-rw-r--r--src/FbTk/StringUtil.cc2
-rw-r--r--src/Makefile.am1
-rw-r--r--src/main.cc17
5 files changed, 26 insertions, 14 deletions
diff --git a/src/FbTk/App.cc b/src/FbTk/App.cc
index 8157839..f494a0e 100644
--- a/src/FbTk/App.cc
+++ b/src/FbTk/App.cc
@@ -60,8 +60,13 @@ App::App(const char *displayname):m_done(false), m_display(0) {
60 if (displayname != 0 && displayname[0] == '\0') 60 if (displayname != 0 && displayname[0] == '\0')
61 displayname = 0; 61 displayname = 0;
62 m_display = XOpenDisplay(displayname); 62 m_display = XOpenDisplay(displayname);
63 if (!m_display) 63 if (!m_display) {
64 throw std::string("Couldn't connect to XServer"); 64 if (displayname) {
65 throw std::string("Couldn't connect to XServer") + displayname;
66 } else {
67 throw std::string("Couldn't connect to XServer passing null display");
68 }
69 }
65 70
66 FbStringUtil::init(); 71 FbStringUtil::init();
67} 72}
diff --git a/src/FbTk/FileUtil.cc b/src/FbTk/FileUtil.cc
index 5de560b..c92b336 100644
--- a/src/FbTk/FileUtil.cc
+++ b/src/FbTk/FileUtil.cc
@@ -63,9 +63,14 @@ bool FileUtil::isExecutable(const char* filename) {
63 if (!filename || stat(filename, &buf)) 63 if (!filename || stat(filename, &buf))
64 return false; 64 return false;
65 65
66 return buf.st_mode & S_IXUSR || 66 return buf.st_mode & S_IXUSR
67 buf.st_mode & S_IXGRP || 67#ifdef S_IXGRP
68 buf.st_mode & S_IXOTH; 68 || buf.st_mode & S_IXGRP
69#endif
70#ifdef S_IXOTH
71 || buf.st_mode & S_IXOTH
72#endif
73 ;
69} 74}
70 75
71bool FileUtil::copyFile(const char* from, const char* to) { 76bool FileUtil::copyFile(const char* from, const char* to) {
diff --git a/src/FbTk/StringUtil.cc b/src/FbTk/StringUtil.cc
index 0a7ebd3..f76a1f9 100644
--- a/src/FbTk/StringUtil.cc
+++ b/src/FbTk/StringUtil.cc
@@ -176,7 +176,7 @@ string expandFilename(const string &filename) {
176 size_t pos = filename.find_first_not_of(" \t"); 176 size_t pos = filename.find_first_not_of(" \t");
177 if (pos != string::npos && filename[pos] == '~') { 177 if (pos != string::npos && filename[pos] == '~') {
178 retval = getenv("HOME"); 178 retval = getenv("HOME");
179 if (pos != filename.size()) { 179 if (pos + 1 < filename.size()) {
180 // copy from the character after '~' 180 // copy from the character after '~'
181 retval += static_cast<const char *>(filename.c_str() + pos + 1); 181 retval += static_cast<const char *>(filename.c_str() + pos + 1);
182 } 182 }
diff --git a/src/Makefile.am b/src/Makefile.am
index 8c204db..1a04e4e 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -63,6 +63,7 @@ defaults.hh: Makefile
63defaults.cc: force 63defaults.cc: force
64 @( \ 64 @( \
65 GITDIR=$(top_srcdir)/.git; \ 65 GITDIR=$(top_srcdir)/.git; \
66 echo '// This file is generated from Makefile. Do not edit!'; \
66 echo '#include "defaults.hh"'; \ 67 echo '#include "defaults.hh"'; \
67 echo ''; \ 68 echo ''; \
68 echo 'std::string realProgramName(const std::string& name) {'; \ 69 echo 'std::string realProgramName(const std::string& name) {'; \
diff --git a/src/main.cc b/src/main.cc
index aab583f..7541a28 100644
--- a/src/main.cc
+++ b/src/main.cc
@@ -34,6 +34,7 @@
34#include "FbTk/I18n.hh" 34#include "FbTk/I18n.hh"
35#include "FbTk/CommandParser.hh" 35#include "FbTk/CommandParser.hh"
36#include "FbTk/FileUtil.hh" 36#include "FbTk/FileUtil.hh"
37#include "FbTk/StringUtil.hh"
37 38
38//use GNU extensions 39//use GNU extensions
39#ifndef _GNU_SOURCE 40#ifndef _GNU_SOURCE
@@ -114,22 +115,22 @@ static void showInfo(ostream &ostr) {
114 115
115 ostr <<_FB_CONSOLETEXT(Common, DefaultMenuFile, " menu", "default menu file (right aligned - make sure same width as other default values)") 116 ostr <<_FB_CONSOLETEXT(Common, DefaultMenuFile, " menu", "default menu file (right aligned - make sure same width as other default values)")
116 << ": " 117 << ": "
117 << DEFAULTMENU << endl; 118 << FbTk::StringUtil::expandFilename(DEFAULTMENU) << endl;
118 ostr << _FB_CONSOLETEXT(Common, DefaultStyle, " style", "default style (right aligned - make sure same width as other default values)") 119 ostr << _FB_CONSOLETEXT(Common, DefaultStyle, " style", "default style (right aligned - make sure same width as other default values)")
119 << ": " 120 << ": "
120 << DEFAULTSTYLE << endl; 121 << FbTk::StringUtil::expandFilename(DEFAULTSTYLE) << endl;
121 122
122 ostr << _FB_CONSOLETEXT(Common, DefaultKeyFile, " keys", "default key file (right aligned - make sure same width as other default values)") 123 ostr << _FB_CONSOLETEXT(Common, DefaultKeyFile, " keys", "default key file (right aligned - make sure same width as other default values)")
123 << ": " 124 << ": "
124 << DEFAULTKEYSFILE << endl; 125 << FbTk::StringUtil::expandFilename(DEFAULTKEYSFILE) << endl;
125 ostr << _FB_CONSOLETEXT(Common, DefaultInitFile, " init", "default init file (right aligned - make sure same width as other default values)") 126 ostr << _FB_CONSOLETEXT(Common, DefaultInitFile, " init", "default init file (right aligned - make sure same width as other default values)")
126 << ": " 127 << ": "
127 << DEFAULT_INITFILE << endl; 128 << FbTk::StringUtil::expandFilename(DEFAULT_INITFILE) << endl;
128 129
129#ifdef NLS 130#ifdef NLS
130 ostr << _FB_CONSOLETEXT(Common, DefaultLocalePath, " nls", "location for localization files (right aligned - make sure same width as other default values)") 131 ostr << _FB_CONSOLETEXT(Common, DefaultLocalePath, " nls", "location for localization files (right aligned - make sure same width as other default values)")
131 << ": " 132 << ": "
132 << LOCALEPATH << endl; 133 << FbTk::StringUtil::expandFilename(LOCALEPATH) << endl;
133#endif 134#endif
134 135
135 const char NOT[] = "-"; 136 const char NOT[] = "-";
@@ -220,12 +221,12 @@ struct Options {
220 const char* env; 221 const char* env;
221 222
222 env = getenv("DISPLAY"); 223 env = getenv("DISPLAY");
223 if (env) { 224 if (env && strlen(env) > 0) {
224 session_display.assign(env); 225 session_display.assign(env);
225 } 226 }
226 227
227 env = getenv("HOME"); 228 env = getenv("HOME");
228 if (env) { 229 if (env && strlen(env) > 0) {
229 rc_path.assign(std::string(env) + "/." + realProgramName("fluxbox")); 230 rc_path.assign(std::string(env) + "/." + realProgramName("fluxbox"));
230 rc_file = rc_path + "/init"; 231 rc_file = rc_path + "/init";
231 } 232 }
@@ -369,7 +370,7 @@ void setupConfigFiles(const std::string& dirname, const std::string& rc) {
369 // copy default files if needed 370 // copy default files if needed
370 for (size_t i = 0; i < nr_of_cfiles; ++i) { 371 for (size_t i = 0; i < nr_of_cfiles; ++i) {
371 if (cfiles[i].create_file) { 372 if (cfiles[i].create_file) {
372 FbTk::FileUtil::copyFile(cfiles[i].default_name, cfiles[i].filename.c_str()); 373 FbTk::FileUtil::copyFile(FbTk::StringUtil::expandFilename(cfiles[i].default_name).c_str(), cfiles[i].filename.c_str());
373 sync_fs = true; 374 sync_fs = true;
374 } 375 }
375 } 376 }