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 <string.h> /* strlen(3) */
|
||||||
#include <sysexits.h> /* EX_USAGE */
|
#include <sysexits.h> /* EX_USAGE */
|
||||||
#include <unistd.h> /* getopt(3) */
|
#include <unistd.h> /* getopt(3) */
|
||||||
|
|
||||||
#include <X11/Xlib.h>
|
#include <X11/Xlib.h>
|
||||||
#include <X11/Xutil.h>
|
#include <X11/Xutil.h>
|
||||||
#ifdef XINERAMA
|
#ifdef XINERAMA
|
||||||
#include <X11/extensions/Xinerama.h>
|
# include <X11/extensions/Xinerama.h>
|
||||||
#endif
|
#endif
|
||||||
#include <X11/Xft/Xft.h>
|
#include <X11/Xft/Xft.h>
|
||||||
|
|
||||||
#include "drw.h"
|
#include "drw.h"
|
||||||
#include "util.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)) \
|
#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)))
|
* 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 */
|
enum { Scheme, SchemeLast }; /* color schemes */
|
||||||
/* enumerated because Suckless has SchemeNorm, SchemeSel, etc.
|
/* enumerated because Suckless has SchemeNorm, SchemeSel, etc.
|
||||||
* should be made into like one char *Scheme[2] */
|
* 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 char *embed;
|
||||||
static int bh, mw, mh;
|
|
||||||
static int inputw = 0;
|
static int inputw = 0;
|
||||||
static int lrpad; /* sum of left and right padding */
|
static int lrpad; /* sum of left and right padding */
|
||||||
static int mon = -1, screen;
|
static int mh;
|
||||||
|
static int mon = -1;
|
||||||
static Display *dpy;
|
static int mw;
|
||||||
static Window root, parentwin, win;
|
static Window parentwin;
|
||||||
|
static Window root;
|
||||||
static Drw *drw;
|
|
||||||
static Clr *scheme[SchemeLast];
|
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
|
int
|
||||||
main(int argc, char *argv[]){
|
main(int argc, char *argv[]){
|
||||||
int c;
|
int c;
|
||||||
extern char *optarg;
|
|
||||||
char text[text_s];
|
|
||||||
int x, y, i, j;
|
|
||||||
unsigned int du;
|
unsigned int du;
|
||||||
|
Window dw;
|
||||||
|
Window *dws;
|
||||||
|
int i;
|
||||||
|
int j;
|
||||||
|
extern char *optarg;
|
||||||
XSetWindowAttributes swa;
|
XSetWindowAttributes swa;
|
||||||
Window w, dw, *dws;
|
char text[BUFSIZE];
|
||||||
|
int topbar; /* 0=bottom 1=top */
|
||||||
|
Window w;
|
||||||
XWindowAttributes wa;
|
XWindowAttributes wa;
|
||||||
XClassHint ch = {"dmenubar", "dmenubar"};
|
int x;
|
||||||
|
int y;
|
||||||
#ifdef XINERAMA
|
#ifdef XINERAMA
|
||||||
XineramaScreenInfo *info;
|
XineramaScreenInfo *info;
|
||||||
Window pw;
|
Window pw;
|
||||||
int a, di, n, area = 0;
|
int a, di, n, area = 0;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
for(i = 0; i < text_s; ++i) /* initialize text[] */
|
topbar = 1;
|
||||||
text[i] = '\0';
|
|
||||||
|
|
||||||
while((c = getopt(argc, argv, ":bf:m:B:F:w:")) != -1)
|
while((c = getopt(argc, argv, ":bf:m:B:F:w:")) != -1)
|
||||||
switch(c){
|
switch(c){
|
||||||
case 'b':
|
case 'b':
|
||||||
@ -77,13 +91,13 @@ main(int argc, char *argv[]){
|
|||||||
fonts[0] = optarg;
|
fonts[0] = optarg;
|
||||||
break;
|
break;
|
||||||
}case 'F': if(optarg){
|
}case 'F': if(optarg){
|
||||||
colors[Scheme][ColFg] = argv[++i];
|
colors[Scheme][ColFg] = optarg;
|
||||||
break;
|
break;
|
||||||
}case 'm': if(optarg){
|
}case 'm': if(optarg){
|
||||||
mon = atoi(argv[++i]);
|
mon = atoi(optarg);
|
||||||
break;
|
break;
|
||||||
}case 'w': if(optarg){
|
}case 'w': if(optarg){
|
||||||
embed = argv[++i];
|
embed = optarg;
|
||||||
break;
|
break;
|
||||||
}default: /* optarg==0 falls through */
|
}default: /* optarg==0 falls through */
|
||||||
fprintf(stderr,
|
fprintf(stderr,
|
||||||
@ -186,10 +200,13 @@ main(int argc, char *argv[]){
|
|||||||
}
|
}
|
||||||
drw_resize(drw, mw, mh);
|
drw_resize(drw, mw, mh);
|
||||||
|
|
||||||
do {
|
text[0] = '\0';
|
||||||
/* fgets adds a newline which will be printable in some fonts */
|
do{
|
||||||
if (strlen(text) > 0)
|
/* trim newline */
|
||||||
text[strlen(text)-1] = '\0';
|
for(i = 0; text[i] != '\0' && text[i] != '\n';);
|
||||||
|
if(text[i] == '\n')
|
||||||
|
text[i] = '\0';
|
||||||
|
|
||||||
drw_setscheme(drw, scheme[Scheme]);
|
drw_setscheme(drw, scheme[Scheme]);
|
||||||
drw_rect(drw, 0, 0, mw, mh, 1, 1);
|
drw_rect(drw, 0, 0, mw, mh, 1, 1);
|
||||||
|
|
||||||
@ -202,7 +219,10 @@ main(int argc, char *argv[]){
|
|||||||
bh, lrpad / 2, text, 0);
|
bh, lrpad / 2, text, 0);
|
||||||
|
|
||||||
drw_map(drw, win, 0, 0, mw, mh);
|
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++)
|
for (i = 0; i < SchemeLast; i++)
|
||||||
free(scheme[i]);
|
free(scheme[i]);
|
||||||
|
Loading…
Reference in New Issue
Block a user