XWindowAttributes wa;
if (r->ws == NULL) {
- fprintf(stderr, "dumpwins: invalid workspace\n");
+ warnx("dumpwins: invalid workspace");
return;
}
- fprintf(stderr, "=== managed window list ws %02d ===\n", r->ws->idx);
+ warnx("=== managed window list ws %02d ===", r->ws->idx);
TAILQ_FOREACH(win, &r->ws->winlist, entry) {
state = getstate(win->id);
if (!XGetWindowAttributes(display, win->id, &wa))
- fprintf(stderr, "window: 0x%lx, failed "
- "XGetWindowAttributes\n", win->id);
- fprintf(stderr, "window: 0x%lx, map_state: %d, state: %d, "
- "transient: 0x%lx\n",
- win->id, wa.map_state, state, win->transient);
+ warnx("window: 0x%lx, failed XGetWindowAttributes",
+ win->id);
+ warnx("window: 0x%lx, map_state: %d, state: %d, "
+ "transient: 0x%lx", win->id, wa.map_state, state,
+ win->transient);
}
- fprintf(stderr, "===== unmanaged window list =====\n");
+ warnx("===== unmanaged window list =====");
TAILQ_FOREACH(win, &r->ws->unmanagedlist, entry) {
state = getstate(win->id);
if (!XGetWindowAttributes(display, win->id, &wa))
- fprintf(stderr, "window: 0x%lx, failed "
- "XGetWindowAttributes\n", win->id);
- fprintf(stderr, "window: 0x%lx, map_state: %d, state: %d, "
- "transient: 0x%lx\n",
- win->id, wa.map_state, state, win->transient);
+ warnx("window: 0x%lx, failed XGetWindowAttributes",
+ win->id);
+ warnx("window: 0x%lx, map_state: %d, state: %d, "
+ "transient: 0x%lx", win->id, wa.map_state, state,
+ win->transient);
}
- fprintf(stderr, "=================================\n");
+ warnx("=================================");
}
#else
void
if (status)
result = screen_def.pixel;
else
- fprintf(stderr, "color '%s' not found.\n", colorname);
+ warnx("color '%s' not found", colorname);
return (result);
}
y > DisplayHeight(display, sidx) ||
w + x > DisplayWidth(display, sidx) ||
h + y > DisplayHeight(display, sidx)) {
- fprintf(stderr, "ignoring region %ux%u+%u+%u "
- "- not within screen boundaries "
- "(%ux%u)\n", w, h, x, y,
+ warnx("ignoring region %ux%u+%u+%u - not within screen "
+ "boundaries (%ux%u)", w, h, x, y,
DisplayWidth(display, sidx), DisplayHeight(display, sidx));
return;
}
strlcpy((char *)bar_ext, b, sizeof bar_ext);
}
if (b == NULL && errno != EAGAIN) {
- fprintf(stderr, "bar_update: bar_extra failed: "
- "errno: %d %s\n", errno, strerror(errno));
+ warn("bar_update: bar_extra failed");
bar_extra_stop();
}
} else
unmap_all();
XCloseDisplay(display);
execvp(start_argv[0], start_argv);
- fprintf(stderr, "execvp failed\n");
- perror(" failed");
+ warn("execvp failed");
quit(NULL, NULL);
}
setenv("LD_PRELOAD", SWM_LIB, 1);
if (asprintf(&ret, "%d", ws_idx) == -1) {
- perror("_SWM_WS");
+ warn("spawn: asprintf SWM_WS");
_exit(1);
}
setenv("_SWM_WS", ret, 1);
ret = NULL;
if (asprintf(&ret, "%d", getpid()) == -1) {
- perror("_SWM_PID");
+ warn("spawn: asprintf _SWM_PID");
_exit(1);
}
setenv("_SWM_PID", ret, 1);
ret = NULL;
if (setsid() == -1) {
- perror("setsid");
+ warn("spawn: setsid");
_exit(1);
}
* leave stderr open to record errors
*/
if ((fd = open(_PATH_DEVNULL, O_RDWR, 0)) == -1) {
- perror("open");
+ warn("spawn: open");
_exit(1);
}
dup2(fd, STDIN_FILENO);
execvp(args->argv[0], args->argv);
- perror("execvp");
+ warn("spawn: execvp");
_exit(1);
}
if (win->transient) {
parent = find_window(win->transient);
if (parent == NULL) {
- fprintf(stderr, "not possible bug\n");
+ warnx("not possible bug");
continue;
}
TAILQ_REMOVE(wl, win, entry);
sw = calloc(1, sizeof(struct search_window));
if (sw == NULL) {
- fprintf(stderr, "search_win: calloc: %s",
- strerror(errno));
+ warn("search_win: calloc");
fclose(lfile);
search_win_cleanup();
return;
searchpid = 0;
if ((resp = calloc(1, MAX_RESP_LEN + 1)) == NULL) {
- fprintf(stderr, "search: calloc\n");
+ warn("search: calloc");
goto done;
}
rbytes = read(select_resp_pipe[0], resp, MAX_RESP_LEN);
if (rbytes <= 0) {
- fprintf(stderr, "search: read error: %s\n", strerror(errno));
+ warn("search: read error");
goto done;
}
resp[rbytes] = '\0';
prog = &spawns[i];
}
if (prog == NULL) {
- fprintf(stderr, "spawn_custom: program %s not found\n",
- spawn_name);
+ warnx("spawn_custom: program %s not found", spawn_name);
return (-1);
}
}
if (prog->argv == NULL) {
- fprintf(stderr,
- "error: setspawn: cannot find program: %s", prog->name);
+ warnx("error: setspawn: cannot find program: %s", prog->name);
free(prog);
return;
}
spawns = malloc((size_t)spawns_size *
sizeof(struct spawn_prog));
if (spawns == NULL) {
- fprintf(stderr, "setspawn: malloc failed\n");
- perror(" failed");
+ warn("setspawn: malloc failed");
quit(NULL, NULL);
}
} else if (spawns_length == spawns_size) {
spawns = realloc(spawns, (size_t)spawns_size *
sizeof(struct spawn_prog));
if (spawns == NULL) {
- fprintf(stderr, "setspawn: realloc failed\n");
- perror(" failed");
+ warn("setspawn: realloc failed");
quit(NULL, NULL);
}
}
i = spawns_length++;
spawns[i] = *prog;
} else {
- fprintf(stderr, "spawns array problem?\n");
+ warnx("spawns array problem?");
if (spawns == NULL) {
- fprintf(stderr, "spawns array is NULL!\n");
+ warnx("spawns array is NULL!");
quit(NULL, NULL);
}
}
DNPRINTF(SWM_D_CONF, "conf_load: begin\n");
if (filename == NULL) {
- fprintf(stderr, "conf_load: no filename\n");
+ warnx("conf_load: no filename");
return (1);
}
if ((config = fopen(filename, "r")) == NULL) {
optval = strdup(cp);
/* call function to deal with it all */
if (configopt[optind].func(optsub, optval,
- configopt[optind].funcflags) != 0) {
- fprintf(stderr, "%s line %zd: %s\n",
- filename, lineno, line);
+ configopt[optind].funcflags) != 0)
errx(1, "%s: line %zd: invalid data for %s",
filename, lineno, configopt[optind].optname);
- }
free(optval);
free(optsub);
free(line);
" for 0x%lx trans 0x%lx\n", win->id, win->transient);
if (win->hints == NULL) {
- fprintf(stderr, "no hints for 0x%lx\n", win->id);
+ warnx("no hints for 0x%lx", win->id);
return;
}
XFree(wmh);
if ((wmh = XGetWMHints(display, w->id)) == NULL) {
- fprintf(stderr, "can't get hints for 0x%lx\n",
- w->id);
+ warnx("can't get hints for 0x%lx", w->id);
continue;
}
if (ww->ws->r)
r = ww->ws->r;
else
- fprintf(stderr,
- "manage_window: fix this "
- "bug mcbride\n");
+ warnx("manage_window: fix this "
+ "bug mcbride");
border_me = 1;
}
}
SWM_S_COLOR_FOCUS : SWM_S_COLOR_UNFOCUS].color);
break;
default:
- fprintf(stderr, "ignoring focusevent\n");
+ warnx("ignoring focusevent");
DNPRINTF(SWM_D_FOCUS, "ignoring focusevent\n");
break;
}
case XA_WM_NORMAL_HINTS:
long mask;
XGetWMNormalHints(display, win->id, &win->sh, &mask);
- fprintf(stderr, "normal hints: flag 0x%x\n", win->sh.flags);
+ warnx("normal hints: flag 0x%x", win->sh.flags);
if (win->sh.flags & PMinSize) {
WIDTH(win) = win->sh.min_width;
HEIGHT(win) = win->sh.min_height;
- fprintf(stderr, "min %d %d\n", WIDTH(win), HEIGHT(win));
+ warnx("min %d %d", WIDTH(win), HEIGHT(win));
}
XMoveResizeWindow(display, win->id,
X(win), Y(win), WIDTH(win), HEIGHT(win));
int
xerror(Display *d, XErrorEvent *ee)
{
- /* fprintf(stderr, "error: %p %p\n", display, ee); */
+ /* warnx("error: %p %p", display, ee); */
return (-1);
}
struct sigaction sact;
start_argv = argv;
- fprintf(stderr, "Welcome to scrotwm V%s Build: %s\n",
- SCROTWM_VERSION, buildstr);
+ warnx("Welcome to scrotwm V%s Build: %s", SCROTWM_VERSION, buildstr);
if (!setlocale(LC_CTYPE, "") || !setlocale(LC_TIME, "") ||
!XSupportsLocale())
warnx("no locale support");