??t ??h wrote:
>
> I'll check the error log. I'm running Debian v2.2 on a 68k Mac 630 -- 40 MB
> RAM -- and starting blackbox from xdm via .xsession script. My .blackboxrc
> file is written in the absolute form as /home/scott/.blackboxrc
>
> I have edited /home/scott/.blackbox/Menu -- first copied from the clean
> /etc/X11/blackbox/blackbox-menu file -- both as user and root, with the same
> results. When my edited file failed -- everytime so far -- I delete the
> /home/scott/.blackboxrc file and restart blackbox so that it generates a
> clean copy of /home/scott/.blackboxrc, so that by default it refers backs to
> /etc/X11/blackbox/blackbox-menu and runs properly.
>
> I have tried several naming schemes for my edited copy of
> /home/scott/.blackbox/Menu -- like /home/scott/.blackbox/menu ,
> /home/scott/.blackbox-menu , and /home/scott/blackbox/menu -- all with the
> same result.
>
> Here's the process I have been following: the Mac boots up Debian, then xdm,
> then blackbox. I will exit blackbox via th root menu, going back to the user
> prompt. At that point I would go Control-Alt-F1 and log in as user and edit
> the /home/scott/.blackbox/Menu and edit the sesion.menuFile pointer in
> /home/scott/.blackboxrc. Then I would go Control-F7 to the user prompt and
> log back in. Blackbox will boot but with a very basic root menu and the tool
> bar below.
>
> Any thoughts about what I'm doing wrong? thanks! scott
>
> > On Fri, Jul 27, 2001 at 09:11:05AM -0500, ??t ??h wrote:
> > > I am stumped. Every time I edit the session.Menu pointer in
> > > /home/scott/.blackboxrc to a menu file other than the default
> > > file /etc/X11/blackbox/blackbox-menu, I get a basic root
> > > menu that has only xterm, restart, and exit and none of the
> > > applications listed.
> > >
> > [snippity]
> >
> > Hmm. When you edited .blackboxrc, did you use
> > session.menuFile: /home/scott/.blackbox/Menu
> > or
> > session.menuFile: ~/.blackbox/Menu
> >
> > The second form won't work as things stand in 0.61.1.
> >
> > If that's not the problem, check your X error logs and see
> > what error message blackbox is generating. Where these are
> > depend your distribution (looks like debian?) and how you
> > run X... if you run it manually via startx, it's probably
> > just logging to the initial console (Alt+Ctrl F1).
>
> Here's a small patch that makes it possible to use the ~ alias. The only
> semi-bug is that when BB rewrites the config file, it uses the expanded
> version of the path.
I wrote a patch that expands the two forms of ~ expansion:
- ~/ : a simple getenv("HOME")
- ~jeff/ : a getpwname
and when blackbox rewrites .blackboxrc it takes the '~' form.
I have coded it with a class, so i have replace the '~'
expansion old code in Screen.cc by the new code
(for the menu file).
here is the patch, I have posted it in blackbox.thelinuxcommunity.org
too.
>
> --gile
> --
> "i think when somebody goes to a software site and sees TITS, they are
> obligated to click" -dingo
> << bb.diff >>
>
> _________________________________________________________________
> Get your FREE download of MSN Explorer at http://explorer.msn.com/intl.asp
--
| Nicolas Delon --- EPITA student |
| e-mail at home: [EMAIL PROTECTED] |
| at school: [EMAIL PROTECTED] |
| web site: http://www.epita.fr/~delon_n |
| GNU/Linux User |
diff -x Makefile* -x *.o -x *.patch -x blackbox -cr /goinfre/test/src/BaseDisplay.cc
./BaseDisplay.cc
*** /goinfre/test/src/BaseDisplay.cc Thu Jul 26 18:27:53 2001
--- ./BaseDisplay.cc Sat Jul 28 18:04:14 2001
***************
*** 217,222 ****
--- 217,233 ----
strncpy(n, s, l);
return n;
}
+
+
+ char *bstrndup(const char *s, unsigned int i) {
+ unsigned int l = ((i <= strlen(s)) ? i : strlen(s)) + 1;
+ char *n = new char[l];
+
+ strncpy(n, s, l - 1);
+ n[l - 1] = 0;
+ return n;
+ }
+
BaseDisplay::BaseDisplay(char *app_name, char *dpy_name) {
diff -x Makefile* -x *.o -x *.patch -x blackbox -cr /goinfre/test/src/BaseDisplay.hh
./BaseDisplay.hh
*** /goinfre/test/src/BaseDisplay.hh Thu Jul 26 18:27:53 2001
--- ./BaseDisplay.hh Sat Jul 28 15:15:48 2001
***************
*** 68,73 ****
--- 68,74 ----
#endif // !__EMX__
char *bstrdup(const char *);
+ char *bstrndup(const char *, unsigned int);
template <typename Z> inline Z min(Z a, Z b) { return ((a < b) ? a : b); }
template <typename Z> inline Z max(Z a, Z b) { return ((a > b) ? a : b); }
diff -x Makefile* -x *.o -x *.patch -x blackbox -cr /goinfre/test/src/Screen.cc
./Screen.cc
*** /goinfre/test/src/Screen.cc Thu Jul 26 18:22:23 2001
--- ./Screen.cc Sat Jul 28 22:39:37 2001
***************
*** 1971,1998 ****
continue;
}
! char style[MAXPATHLEN];
! // perform shell style ~ home directory expansion
! char *homedir = 0;
! int homedir_len = 0;
! if (*command == '~' && *(command + 1) == '/') {
! homedir = getenv("HOME");
! homedir_len = strlen(homedir);
! }
!
! if (homedir && homedir_len != 0) {
! strncpy(style, homedir, homedir_len);
!
! strncpy(style + homedir_len, command + 1,
! command_length - 1);
! *(style + command_length + homedir_len - 1) = '\0';
! } else {
! strncpy(style, command, command_length);
! *(style + command_length) = '\0';
! }
!
! menu->insert(label, BScreen::SetStyle, style);
}
break;
--- 1971,1979 ----
continue;
}
! Path style(command);
! menu->insert(label, BScreen::SetStyle, style.getReal());
}
break;
***************
*** 2032,2091 ****
continue;
}
! char newfile[MAXPATHLEN];
!
! // perform shell style ~ home directory expansion
! char *homedir = 0;
! int homedir_len = 0;
! if (*label == '~' && *(label + 1) == '/') {
! homedir = getenv("HOME");
! homedir_len = strlen(homedir);
! }
!
! if (homedir && homedir_len != 0) {
! strncpy(newfile, homedir, homedir_len);
!
! strncpy(newfile + homedir_len, label + 1,
! label_length - 1);
! *(newfile + label_length + homedir_len - 1) = '\0';
! } else {
! strncpy(newfile, label, label_length);
! *(newfile + label_length) = '\0';
! }
!
! if (newfile) {
! FILE *submenufile = fopen(newfile, "r");
! if (submenufile) {
! struct stat buf;
! if (fstat(fileno(submenufile), &buf) ||
! (! S_ISREG(buf.st_mode))) {
! fprintf(stderr,
! i18n->
! getMessage(
#ifdef NLS
! ScreenSet, ScreenINCLUDEErrorReg,
#else // !NLS
! 0, 0,
#endif // NLS
! "BScreen::parseMenuFile: [include] error: "
! "'%s' is not a regular file\n"), newfile);
! break;
! }
!
! if (! feof(submenufile)) {
! if (! parseMenuFile(submenufile, menu))
! blackbox->saveMenuFilename(newfile);
!
! fclose(submenufile);
! }
! } else
! perror(newfile);
! }
}
!
break;
!
case 767: // submenu
{
if (! *label) {
--- 2013,2051 ----
continue;
}
! Path newfile(label);
! FILE *submenufile = fopen(newfile.getReal(), "r");
!
! if (submenufile) {
! struct stat buf;
! if (fstat(fileno(submenufile), &buf) ||
! (! S_ISREG(buf.st_mode))) {
! fprintf(stderr,
! i18n->
! getMessage(
#ifdef NLS
! ScreenSet, ScreenINCLUDEErrorReg,
#else // !NLS
! 0, 0,
#endif // NLS
! "BScreen::parseMenuFile: [include] error: "
! "'%s' is not a regular file\n"), newfile.getReal());
! break;
! }
!
! if (! feof(submenufile)) {
! if (! parseMenuFile(submenufile, menu))
! blackbox->saveMenuFilename(newfile.getReal());
!
! fclose(submenufile);
! }
! } else
! perror(newfile.getReal());
}
!
break;
!
case 767: // submenu
{
if (! *label) {
***************
*** 2133,2140 ****
continue;
}
! if (*command)
! menu->insert(label, BScreen::RestartOther, command);
else
menu->insert(label, BScreen::Restart);
}
--- 2093,2103 ----
continue;
}
! if (*command) {
! Path cmd(command);
!
! menu->insert(label, BScreen::RestartOther, cmd.getReal());
! }
else
menu->insert(label, BScreen::Restart);
}
***************
*** 2181,2214 ****
continue;
}
! char stylesdir[MAXPATHLEN];
!
! char *directory = ((newmenu) ? command : label);
! int directory_length = ((newmenu) ? command_length : label_length);
!
! // perform shell style ~ home directory expansion
! char *homedir = 0;
! int homedir_len = 0;
!
! if (*directory == '~' && *(directory + 1) == '/') {
! homedir = getenv("HOME");
! homedir_len = strlen(homedir);
! }
!
! if (homedir && homedir_len != 0) {
! strncpy(stylesdir, homedir, homedir_len);
!
! strncpy(stylesdir + homedir_len, directory + 1,
! directory_length - 1);
! *(stylesdir + directory_length + homedir_len - 1) = '\0';
! } else {
! strncpy(stylesdir, directory, directory_length);
! *(stylesdir + directory_length) = '\0';
! }
struct stat statbuf;
! if (! stat(stylesdir, &statbuf)) {
if (S_ISDIR(statbuf.st_mode)) {
Rootmenu *stylesmenu;
--- 2144,2154 ----
continue;
}
! Path stylesdir(newmenu ? command : label);
struct stat statbuf;
! if (! stat(stylesdir.getReal(), &statbuf)) {
if (S_ISDIR(statbuf.st_mode)) {
Rootmenu *stylesmenu;
***************
*** 2217,2223 ****
else
stylesmenu = menu;
! DIR *d = opendir(stylesdir);
int entries = 0;
struct dirent *p;
--- 2157,2163 ----
else
stylesmenu = menu;
! DIR *d = opendir(stylesdir.getReal());
int entries = 0;
struct dirent *p;
***************
*** 2232,2243 ****
qsort(ls, entries, sizeof(char *), dcmp);
! int n, slen = strlen(stylesdir);
for (n = 0; n < entries; n++) {
int nlen = strlen(ls[n]);
char style[MAXPATHLEN + 1];
! strncpy(style, stylesdir, slen);
*(style + slen) = '/';
strncpy(style + slen + 1, ls[n], nlen + 1);
--- 2172,2183 ----
qsort(ls, entries, sizeof(char *), dcmp);
! int n, slen = strlen(stylesdir.getReal());
for (n = 0; n < entries; n++) {
int nlen = strlen(ls[n]);
char style[MAXPATHLEN + 1];
! strncpy(style, stylesdir.getReal(), slen);
*(style + slen) = '/';
strncpy(style + slen + 1, ls[n], nlen + 1);
***************
*** 2257,2263 ****
rootmenuList->insert(stylesmenu);
}
! blackbox->saveMenuFilename(stylesdir);
} else {
fprintf(stderr,
i18n->
--- 2197,2203 ----
rootmenuList->insert(stylesmenu);
}
! blackbox->saveMenuFilename(stylesdir.getReal());
} else {
fprintf(stderr,
i18n->
***************
*** 2281,2287 ****
0, 0,
#endif // NLS
"BScreen::parseMenuFile: [stylesdir/stylesmenu]"
! " error, %s does not exist\n"), stylesdir);
}
break;
--- 2221,2227 ----
0, 0,
#endif // NLS
"BScreen::parseMenuFile: [stylesdir/stylesmenu]"
! " error, %s does not exist\n"), stylesdir.getReal());
}
break;
diff -x Makefile* -x *.o -x *.patch -x blackbox -cr /goinfre/test/src/blackbox.cc
./blackbox.cc
*** /goinfre/test/src/blackbox.cc Thu Jul 26 18:27:53 2001
--- ./blackbox.cc Sat Jul 28 21:25:09 2001
***************
*** 140,145 ****
--- 140,187 ----
return False;
}
+
+ Path::Path(const char *str) {
+ real = (char *) 0;
+ sym = bstrdup(str);
+
+ if (sym[0] == '~') {
+ char *home = 0, *path = 0;
+
+ if (sym[1] == '/' || sym[1] == 0) {
+ home = getenv("HOME");
+ path = sym + 1;
+ } else {
+ char *name;
+ char *ptr;
+ int len;
+ struct passwd *pw;
+
+ ptr = sym + 1;
+ len = strchr(ptr, '/') ? (strchr(ptr, '/') - ptr) : strlen(ptr);
+ name = bstrndup(ptr, len);
+ if ((pw = getpwnam(name)) && pw->pw_dir) {
+ home = pw->pw_dir;
+ path = ptr + len;
+ }
+ delete [] name;
+ }
+ if (home) {
+ real = new char[strlen(home) + strlen(path) + 1];
+ sprintf(real, "%s%s", home, path);
+ }
+ }
+ }
+
+
+ Path::~Path() {
+ if (real)
+ delete [] real;
+ delete [] sym;
+ }
+
+
+
Blackbox *blackbox;
***************
*** 161,167 ****
no_focus = False;
! resource.menu_file = resource.style_file = (char *) 0;
resource.auto_raise_delay.tv_sec = resource.auto_raise_delay.tv_usec = 0;
focused_window = masked_window = (BlackboxWindow *) 0;
--- 203,209 ----
no_focus = False;
! resource.menu_file = resource.style_file = (Path *) 0;
resource.auto_raise_delay.tv_sec = resource.auto_raise_delay.tv_usec = 0;
focused_window = masked_window = (BlackboxWindow *) 0;
***************
*** 240,249 ****
}
if (resource.menu_file)
! delete [] resource.menu_file;
if (resource.style_file)
! delete [] resource.style_file;
delete timer;
--- 282,291 ----
}
if (resource.menu_file)
! delete resource.menu_file;
if (resource.style_file)
! delete resource.style_file;
delete timer;
***************
*** 1019,1025 ****
load_rc();
! sprintf(rc_string, "session.menuFile: %s", resource.menu_file);
XrmPutLineResource(&new_blackboxrc, rc_string);
sprintf(rc_string, "session.colorsPerChannel: %d",
--- 1061,1067 ----
load_rc();
! sprintf(rc_string, "session.menuFile: %s", resource.menu_file->getSym());
XrmPutLineResource(&new_blackboxrc, rc_string);
sprintf(rc_string, "session.colorsPerChannel: %d",
***************
*** 1255,1267 ****
char *value_type;
if (resource.menu_file)
! delete [] resource.menu_file;
if (XrmGetResource(database, "session.menuFile", "Session.MenuFile",
&value_type, &value))
! resource.menu_file = bstrdup(value.addr);
else
! resource.menu_file = bstrdup(DEFAULTMENU);
if (XrmGetResource(database, "session.colorsPerChannel",
"Session.ColorsPerChannel", &value_type, &value)) {
--- 1297,1309 ----
char *value_type;
if (resource.menu_file)
! delete resource.menu_file;
if (XrmGetResource(database, "session.menuFile", "Session.MenuFile",
&value_type, &value))
! resource.menu_file = new Path(value.addr);
else
! resource.menu_file = new Path(DEFAULTMENU);
if (XrmGetResource(database, "session.colorsPerChannel",
"Session.ColorsPerChannel", &value_type, &value)) {
***************
*** 1275,1287 ****
resource.colors_per_channel = 4;
if (resource.style_file)
! delete [] resource.style_file;
if (XrmGetResource(database, "session.styleFile", "Session.StyleFile",
&value_type, &value))
! resource.style_file = bstrdup(value.addr);
else
! resource.style_file = bstrdup(DEFAULTSTYLE);
if (XrmGetResource(database, "session.doubleClickInterval",
"Session.DoubleClickInterval", &value_type, &value)) {
--- 1317,1329 ----
resource.colors_per_channel = 4;
if (resource.style_file)
! delete resource.style_file;
if (XrmGetResource(database, "session.styleFile", "Session.StyleFile",
&value_type, &value))
! resource.style_file = new Path(value.addr);
else
! resource.style_file = new Path(DEFAULTSTYLE);
if (XrmGetResource(database, "session.doubleClickInterval",
"Session.DoubleClickInterval", &value_type, &value)) {
***************
*** 1685,1691 ****
} else
dbfile = bstrdup(rc_file);
! sprintf(style, "session.styleFile: %s", resource.style_file);
XrmPutLineResource(&new_blackboxrc, style);
XrmDatabase old_blackboxrc = XrmGetFileDatabase(dbfile);
--- 1727,1733 ----
} else
dbfile = bstrdup(rc_file);
! sprintf(style, "session.styleFile: %s", resource.style_file->getSym());
XrmPutLineResource(&new_blackboxrc, style);
XrmDatabase old_blackboxrc = XrmGetFileDatabase(dbfile);
***************
*** 1762,1770 ****
void Blackbox::saveStyleFilename(const char *filename) {
if (resource.style_file)
! delete [] resource.style_file;
! resource.style_file = bstrdup(filename);
}
--- 1804,1812 ----
void Blackbox::saveStyleFilename(const char *filename) {
if (resource.style_file)
! delete resource.style_file;
! resource.style_file = new Path(filename);
}
diff -x Makefile* -x *.o -x *.patch -x blackbox -cr /goinfre/test/src/blackbox.hh
./blackbox.hh
*** /goinfre/test/src/blackbox.hh Thu Jul 26 18:22:23 2001
--- ./blackbox.hh Sat Jul 28 22:17:27 2001
***************
*** 40,45 ****
--- 40,47 ----
# endif // HAVE_SYS_TIME_H
#endif // TIME_WITH_SYS_TIME
+ #include <pwd.h>
+
//forward declaration
class Blackbox;
***************
*** 68,73 ****
--- 70,87 ----
inline Z *getData(void) { return data; }
};
+ class Path {
+ private:
+ char *sym;
+ char *real;
+
+ public:
+ Path(const char *);
+ ~Path();
+
+ inline char *getSym(void) const { return sym; }
+ inline char *getReal(void) const { return real ? real : sym; }
+ };
class Blackbox : public BaseDisplay, public TimeoutHandler {
private:
***************
*** 79,85 ****
struct resource {
Time double_click_interval;
! char *menu_file, *style_file;
int colors_per_channel;
timeval auto_raise_delay;
unsigned long cache_life, cache_max;
--- 93,99 ----
struct resource {
Time double_click_interval;
! Path *menu_file, *style_file;
int colors_per_channel;
timeval auto_raise_delay;
unsigned long cache_life, cache_max;
***************
*** 148,156 ****
Toolbar *searchToolbar(Window);
inline const char *getStyleFilename(void) const
! { return resource.style_file; }
inline const char *getMenuFilename(void) const
! { return resource.menu_file; }
inline const int &getColorsPerChannel(void) const
{ return resource.colors_per_channel; }
--- 162,170 ----
Toolbar *searchToolbar(Window);
inline const char *getStyleFilename(void) const
! { return resource.style_file->getReal(); }
inline const char *getMenuFilename(void) const
! { return resource.menu_file->getReal(); }
inline const int &getColorsPerChannel(void) const
{ return resource.colors_per_channel; }