Group :: Desktop gráfico/Outros
RPM: jwm
Main Changelog Spec Patches Sources Download Gear Bugs e FR Repocop
Patch: jwm-alt-config-file.patch
Download
Download
--- jwm-2.0.1/src/main.c.fix 2009-03-31 04:11:27 +0400
+++ jwm-2.0.1/src/main.c 2009-03-31 04:11:27 +0400
@@ -80,9 +80,9 @@ int shapeEvent;
#ifdef USE_XRENDER
int haveRender;
#endif
-static const char *CONFIG_FILE = "/.jwmrc";
+static const char *CONFIG_FILE = "config";
static void Initialize();
static void Startup();
static void Shutdown();
@@ -103,22 +103,16 @@ static char *displayString = NULL;
/** The main entry point. */
int main(int argc, char *argv[]) {
- char *temp;
int x;
StartDebug();
/* Get the name of the user's local configuration file. */
- temp = getenv("HOME");
- if(temp) {
- configPath = Allocate(strlen(temp) + strlen(CONFIG_FILE) + 1);
- strcpy(configPath, temp);
- strcat(configPath, CONFIG_FILE);
- } else {
- configPath = CopyString(CONFIG_FILE);
- }
+ configPath = Allocate(strlen(USER_DIR) + 1 + strlen(CONFIG_FILE) + 1);
+ sprintf(configPath, "%s/%s", USER_DIR, CONFIG_FILE);
+ ExpandPath(&configPath);
/* Parse command line options. */
for(x = 1; x < argc; x++) {
if(!strcmp(argv[x], "-v")) {
--- jwm-2.0.1/src/parse.c.fix 2009-03-31 04:11:27 +0400
+++ jwm-2.0.1/src/parse.c 2009-03-31 04:19:51 +0400
@@ -184,10 +184,11 @@ static void ParseError(const TokenNode *
/** Parse the JWM configuration. */
void ParseConfig(const char *fileName) {
if(!ParseFile(fileName, 0)) {
+ ParseError(NULL, "could not open user config %s", fileName);
if(!ParseFile(SYSTEM_CONFIG, 0)) {
- ParseError(NULL, "could not open %s or %s", fileName, SYSTEM_CONFIG);
+ ParseError(NULL, "could not open system config %s", SYSTEM_CONFIG);
}
}
ValidateTrayButtons();
ValidateKeys();
@@ -726,9 +727,9 @@ MenuItem *ParseMenuItem(const TokenNode
MenuItem *ParseMenuInclude(const TokenNode *tp, Menu *menu,
MenuItem *last) {
FILE *fd;
- char *path;
+ char *path, *dir;
char *buffer = NULL;
TokenNode *start;
Assert(tp);
@@ -747,20 +748,39 @@ MenuItem *ParseMenuInclude(const TokenNo
ParseError(tp, "could not execute included program: %s", path);
}
} else {
-
path = CopyString(tp->value);
ExpandPath(&path);
- fd = fopen(path, "r");
- if(fd) {
- buffer = ReadFile(fd);
- fclose(fd);
+ if (path[0] != '/') {
+ dir = Allocate(strlen(USER_DIR) + 1 + strlen(path) + 1);
+ sprintf(dir, "%s/%s", USER_DIR, path);
+ ExpandPath(&dir);
+
+ if ((fd = fopen(dir, "r")) == NULL) {
+ dir = Reallocate(dir, strlen(SYSTEM_DIR) + 1 + strlen(path) + 1);
+ sprintf(dir, "%s/%s", SYSTEM_DIR, path);
+
+ if ((fd = fopen(dir, "r")) != NULL) {
+ buffer = ReadFile(fd);
+ fclose(fd);
+ } else
+ ParseError(tp, "could not open include: %s", path);
+
+ } else {
+ buffer = ReadFile(fd);
+ fclose(fd);
+ }
+ Release(dir);
} else {
- ParseError(tp, "could not open include: %s", path);
+ if ((fd = fopen(path, "r")) != NULL) {
+ buffer = ReadFile(fd);
+ fclose(fd);
+ } else {
+ ParseError(tp, "could not open include: %s", path);
+ }
}
-
}
if(!buffer) {
Release(path);
@@ -929,9 +949,9 @@ void ParseInactiveWindowStyle(const Toke
/** Parse an include. */
void ParseInclude(const TokenNode *tp, int depth) {
- char *temp;
+ char *temp = NULL, *dir = NULL;
Assert(tp);
if(!tp->value) {
@@ -943,12 +963,29 @@ void ParseInclude(const TokenNode *tp, i
temp = CopyString(tp->value);
ExpandPath(&temp);
- if(!ParseFile(temp, depth)) {
- ParseError(tp, "could not open included file %s", temp);
+ if (temp[0] != '/') {
+ /* Try relative path */
+
+ dir = Allocate(strlen(USER_DIR) + 1 + strlen(temp) + 1);
+ sprintf(dir, "%s/%s", USER_DIR, temp);
+ ExpandPath(&dir);
+
+ if (!ParseFile(dir, depth)) {
+
+ dir = Reallocate(dir, strlen(SYSTEM_DIR) + 1 + strlen(temp) + 1);
+ sprintf(dir, "%s/%s", SYSTEM_DIR, temp);
+
+ if (!ParseFile(dir, depth))
+ ParseError(tp, "could not open included file %s", temp);
+ }
+ Release(dir);
+ } else if(!ParseFile(temp, depth)) {
+ ParseError(tp, "could not open included file %s", temp);
}
+
Release(temp);
}
--- jwm-2.0.1/configure.in.fix 2009-03-31 04:11:27 +0400
+++ jwm-2.0.1/configure.in 2009-03-31 04:11:27 +0400
@@ -388,11 +388,17 @@ BINDIR=`eval echo \""$bindir"\"`
SYSCONF=`eval echo \""$sysconfdir"\"`
MANDIR=`eval echo \""$mandir"\"`
MANDIR=`eval echo \""$MANDIR"\"`
-AC_DEFINE_UNQUOTED(SYSTEM_CONFIG, "$SYSCONF/system.jwmrc",
+AC_DEFINE_UNQUOTED(SYSTEM_CONFIG, "$SYSCONF/config",
[default system configuration path])
+AC_DEFINE_UNQUOTED(SYSTEM_DIR, "$SYSCONF",
+ [default system path])
+
+AC_DEFINE_UNQUOTED(USER_DIR, "\$HOME/.jwm",
+ [default user path])
+
AC_SUBST(CFLAGS)
AC_SUBST(LDFLAGS)
AC_SUBST(VERSION, "$PACKAGE_VERSION")
AC_SUBST(INSTVERSION, `echo $PACKAGE_VERSION | tr -d .`)