config in dmenubar.c
This commit is contained in:
parent
ef4963523e
commit
9dd2e49295
@ -1,26 +0,0 @@
|
||||
/* See LICENSE file for copyright and license details. */
|
||||
/* Default settings; some can be overriden by command line. */
|
||||
|
||||
/* if this is true, dmenubar will exit 0 when it receives EOF from
|
||||
* standard input. otherwise it'll just keep reading until you pkill
|
||||
* it. */
|
||||
#define BREAK_ON_EOF 0
|
||||
|
||||
/* output stdin */
|
||||
static int stdin_passthrough = 1;
|
||||
|
||||
/* -b option; if 0, dmenu appears at bottom */
|
||||
static int topbar = 1;
|
||||
|
||||
/* -fn option overrides fonts[0]; default X11 font or font set */
|
||||
static const char *fonts[] = {
|
||||
"monospace:size=10"
|
||||
};
|
||||
|
||||
/* chars to be allocated for the text displayed in the bar */
|
||||
static const int text_s = 1024;
|
||||
|
||||
static const char *colors[SchemeLast][2] = {
|
||||
/* fg, bg */
|
||||
[Scheme] = { "#eeeeee", "#005577" }
|
||||
};
|
@ -9,62 +9,76 @@
|
||||
#include <string.h> /* strlen(3) */
|
||||
#include <sysexits.h> /* EX_USAGE */
|
||||
#include <unistd.h> /* getopt(3) */
|
||||
|
||||
#include <X11/Xlib.h>
|
||||
#include <X11/Xutil.h>
|
||||
#ifdef XINERAMA
|
||||
#include <X11/extensions/Xinerama.h>
|
||||
# include <X11/extensions/Xinerama.h>
|
||||
#endif
|
||||
#include <X11/Xft/Xft.h>
|
||||
|
||||
#include "drw.h"
|
||||
#include "util.h"
|
||||
|
||||
/* macros */
|
||||
#define INTERSECT(x,y,w,h,r) (MAX(0, MIN((x)+(w),(r).x_org+(r).width) - MAX((x),(r).x_org)) \
|
||||
* MAX(0, MIN((y)+(h),(r).y_org+(r).height) - MAX((y),(r).y_org)))
|
||||
|
||||
/* enums */
|
||||
/* chars to be allocated for the text displayed in the bar */
|
||||
#define BUFSIZE 1024
|
||||
|
||||
enum { Scheme, SchemeLast }; /* color schemes */
|
||||
/* enumerated because Suckless has SchemeNorm, SchemeSel, etc.
|
||||
* should be made into like one char *Scheme[2] */
|
||||
/* BTW SchemeLast is the size of an array of the schemes and it's used
|
||||
* in this program for iteration. */
|
||||
|
||||
static int bh;
|
||||
static XClassHint ch = {"dmenubar", "dmenubar"};
|
||||
static Display *dpy;
|
||||
static Drw *drw;
|
||||
static char *embed;
|
||||
static int bh, mw, mh;
|
||||
static int inputw = 0;
|
||||
static int lrpad; /* sum of left and right padding */
|
||||
static int mon = -1, screen;
|
||||
|
||||
static Display *dpy;
|
||||
static Window root, parentwin, win;
|
||||
|
||||
static Drw *drw;
|
||||
static int mh;
|
||||
static int mon = -1;
|
||||
static int mw;
|
||||
static Window parentwin;
|
||||
static Window root;
|
||||
static Clr *scheme[SchemeLast];
|
||||
static int screen;
|
||||
static Window win;
|
||||
|
||||
#include "config.h"
|
||||
#define BREAK_ON_EOF 0
|
||||
|
||||
/* -f option overrides fonts[0]; default X11 font or font set */
|
||||
static const char *fonts[] = {
|
||||
"monospace:size=10"
|
||||
};
|
||||
|
||||
static const char *colors[SchemeLast][2] = {
|
||||
/* fg, bg */
|
||||
[Scheme] = { "#eeeeee", "#005577" }
|
||||
};
|
||||
|
||||
int
|
||||
main(int argc, char *argv[]){
|
||||
int c;
|
||||
extern char *optarg;
|
||||
char text[text_s];
|
||||
int x, y, i, j;
|
||||
unsigned int du;
|
||||
Window dw;
|
||||
Window *dws;
|
||||
int i;
|
||||
int j;
|
||||
extern char *optarg;
|
||||
XSetWindowAttributes swa;
|
||||
Window w, dw, *dws;
|
||||
char text[BUFSIZE];
|
||||
int topbar; /* 0=bottom 1=top */
|
||||
Window w;
|
||||
XWindowAttributes wa;
|
||||
XClassHint ch = {"dmenubar", "dmenubar"};
|
||||
int x;
|
||||
int y;
|
||||
#ifdef XINERAMA
|
||||
XineramaScreenInfo *info;
|
||||
Window pw;
|
||||
int a, di, n, area = 0;
|
||||
#endif
|
||||
|
||||
for(i = 0; i < text_s; ++i) /* initialize text[] */
|
||||
text[i] = '\0';
|
||||
|
||||
topbar = 1;
|
||||
while((c = getopt(argc, argv, ":bf:m:B:F:w:")) != -1)
|
||||
switch(c){
|
||||
case 'b':
|
||||
@ -77,13 +91,13 @@ main(int argc, char *argv[]){
|
||||
fonts[0] = optarg;
|
||||
break;
|
||||
}case 'F': if(optarg){
|
||||
colors[Scheme][ColFg] = argv[++i];
|
||||
colors[Scheme][ColFg] = optarg;
|
||||
break;
|
||||
}case 'm': if(optarg){
|
||||
mon = atoi(argv[++i]);
|
||||
mon = atoi(optarg);
|
||||
break;
|
||||
}case 'w': if(optarg){
|
||||
embed = argv[++i];
|
||||
embed = optarg;
|
||||
break;
|
||||
}default: /* optarg==0 falls through */
|
||||
fprintf(stderr,
|
||||
@ -186,10 +200,13 @@ main(int argc, char *argv[]){
|
||||
}
|
||||
drw_resize(drw, mw, mh);
|
||||
|
||||
do {
|
||||
/* fgets adds a newline which will be printable in some fonts */
|
||||
if (strlen(text) > 0)
|
||||
text[strlen(text)-1] = '\0';
|
||||
text[0] = '\0';
|
||||
do{
|
||||
/* trim newline */
|
||||
for(i = 0; text[i] != '\0' && text[i] != '\n';);
|
||||
if(text[i] == '\n')
|
||||
text[i] = '\0';
|
||||
|
||||
drw_setscheme(drw, scheme[Scheme]);
|
||||
drw_rect(drw, 0, 0, mw, mh, 1, 1);
|
||||
|
||||
@ -202,7 +219,10 @@ main(int argc, char *argv[]){
|
||||
bh, lrpad / 2, text, 0);
|
||||
|
||||
drw_map(drw, win, 0, 0, mw, mh);
|
||||
} while (fgets(text, text_s, stdin) != NULL || !BREAK_ON_EOF);
|
||||
}while(
|
||||
fgets(text, (sizeof text) / (sizeof *text), stdin) != NULL
|
||||
|| !BREAK_ON_EOF
|
||||
);
|
||||
|
||||
for (i = 0; i < SchemeLast; i++)
|
||||
free(scheme[i]);
|
||||
|
Loading…
Reference in New Issue
Block a user