spmenu/libs/argv.c

452 lines
22 KiB
C
Raw Normal View History

2023-03-02 16:06:11 +01:00
void
readargs(int argc, char *argv[])
{
int i = 0;
2023-03-14 21:31:24 +01:00
int j = 0;
2023-03-02 16:06:11 +01:00
2023-03-16 16:01:53 +01:00
// check if we should load the xrdb/config, because it needs to be loaded before arguments are checked (internal -> xresources -> arguments)
2023-03-14 21:31:24 +01:00
for (j = 1; j < argc; j++) {
2023-03-16 16:01:53 +01:00
if (!strcmp(argv[j], "-xrdb")) {
2023-03-02 16:06:11 +01:00
xresources = 1;
2023-03-16 16:01:53 +01:00
} else if (!strcmp(argv[j], "-nxrdb")) {
2023-03-02 16:06:11 +01:00
xresources = 0;
2023-03-16 16:01:53 +01:00
} else if (!strcmp(argv[j], "-lcfg")) {
2023-03-14 21:31:24 +01:00
loadconfig = 1;
2023-03-16 16:01:53 +01:00
} else if (!strcmp(argv[j], "-ncfg")) {
2023-03-14 21:31:24 +01:00
loadconfig = 0;
}
2023-03-02 16:06:11 +01:00
}
2023-03-16 16:01:53 +01:00
// init/read xrdb
2023-03-02 16:06:11 +01:00
if (xresources) {
XrmInitialize();
2023-03-13 21:39:58 +01:00
if (loadconfig) {
2023-03-13 21:31:13 +01:00
int cxrdb = system("[ -e $HOME/.config/spmenu/spmenurc ] && xrdb -override $HOME/.config/spmenu/spmenurc");
int hxrdb = system("[ -e $HOME/.spmenurc ] && xrdb -override $HOME/.spmenurc");
}
2023-03-02 16:06:11 +01:00
load_xresources();
}
2023-03-16 16:01:53 +01:00
// no arguments
2023-03-02 16:06:11 +01:00
for (i = 1; i < argc; i++)
2023-03-16 16:01:53 +01:00
if (!strcmp(argv[i], "-v")) { // prints version information
2023-03-02 16:06:11 +01:00
puts("spmenu-"VERSION);
exit(0);
2023-03-16 16:01:53 +01:00
} else if (!strcmp(argv[i], "-h")) { // help
usage();
2023-03-16 16:01:53 +01:00
} else if (!strcmp(argv[i], "-it")) { // image: top
2023-03-02 16:06:11 +01:00
imageposition = 0;
2023-03-16 16:01:53 +01:00
} else if (!strcmp(argv[i], "-ib")) { // image: bottom
2023-03-02 16:06:11 +01:00
imageposition = 1;
2023-03-16 16:01:53 +01:00
} else if (!strcmp(argv[i], "-ic")) { // image: center
2023-03-02 16:06:11 +01:00
imageposition = 2;
2023-03-16 16:01:53 +01:00
} else if (!strcmp(argv[i], "-itc")) { // image: top center
2023-03-02 16:06:11 +01:00
imageposition = 3;
2023-03-16 16:01:53 +01:00
} else if (!strcmp(argv[i], "-b")) { // appears at the bottom of the screen
2023-03-02 16:06:11 +01:00
menuposition = 0;
2023-03-16 16:01:53 +01:00
} else if (!strcmp(argv[i], "-t")) { // appears at the top of the screen
2023-03-02 16:06:11 +01:00
menuposition = 1;
2023-03-16 16:01:53 +01:00
} else if (!strcmp(argv[i], "-nm")) { // normal mode
2023-03-02 16:06:11 +01:00
mode = 0;
2023-03-16 16:01:53 +01:00
} else if (!strcmp(argv[i], "-im")) { // insert mode
2023-03-02 16:06:11 +01:00
mode = 1;
2023-03-16 16:01:53 +01:00
} else if (!strcmp(argv[i], "-c")) { // appears at the center of the screen
2023-03-02 16:06:11 +01:00
centered = 1;
2023-03-16 16:01:53 +01:00
} else if (!strcmp(argv[i], "-f")) { // grabs keyboard before reading stdin
2023-03-02 16:06:11 +01:00
fast = 1;
2023-03-16 16:01:53 +01:00
} else if (!strcmp(argv[i], "-rw")) { // relative width
2023-03-02 16:06:11 +01:00
accuratewidth = 1;
2023-03-16 16:01:53 +01:00
} else if (!strcmp(argv[i], "-nrw")) { // no relative width
2023-03-02 16:06:11 +01:00
accuratewidth = 0;
2023-03-16 16:01:53 +01:00
} else if (!strcmp(argv[i], "-xrdb")) { // xresources
2023-03-02 16:06:11 +01:00
xresources = 1;
2023-03-16 16:01:53 +01:00
} else if (!strcmp(argv[i], "-nxrdb")) { // no xresources
2023-03-02 16:06:11 +01:00
xresources = 0;
2023-03-16 16:01:53 +01:00
} else if (!strcmp(argv[i], "-F")) { // fuzzy matching
2023-03-02 16:06:11 +01:00
fuzzy = 0;
2023-03-16 16:01:53 +01:00
} else if (!strcmp(argv[i], "-s")) { // case-sensitive item matching
casesensitive = 1;
} else if (!strcmp(argv[i], "-ns")) { // case-insensitive item matching
casesensitive = 0;
} else if (!strcmp(argv[i], "-S")) { // don't sort
2023-03-04 15:51:26 +01:00
sortmatches = 0;
2023-03-16 16:01:53 +01:00
} else if (!strcmp(argv[i], "-nso")) { // don't sort
2023-03-04 15:51:26 +01:00
sortmatches = 0;
2023-03-16 16:01:53 +01:00
} else if (!strcmp(argv[i], "-so")) { // don't sort
2023-03-04 15:51:26 +01:00
sortmatches = 1;
2023-03-16 16:01:53 +01:00
} else if (!strcmp(argv[i], "-gc")) { // generate image cache
2023-03-02 16:06:11 +01:00
generatecache = 1;
2023-03-16 16:01:53 +01:00
} else if (!strcmp(argv[i], "-ngc")) { // don't generate image cache
2023-03-06 20:06:00 +01:00
generatecache = 0;
2023-03-16 16:01:53 +01:00
} else if (!strcmp(argv[i], "-wm")) { // display as managed wm window
2023-03-02 16:06:11 +01:00
managed = 1;
2023-03-16 16:01:53 +01:00
} else if (!strcmp(argv[i], "-nwm")) { // don't display as managed wm window
2023-03-13 21:31:13 +01:00
managed = 0;
2023-03-16 16:01:53 +01:00
} else if (!strcmp(argv[i], "-na")) { // disable alpha
2023-03-02 16:06:11 +01:00
alpha = 0;
2023-03-16 16:01:53 +01:00
} else if (!strcmp(argv[i], "-a")) { // alpha
2023-03-02 16:06:11 +01:00
alpha = 1;
2023-03-16 16:01:53 +01:00
} else if (!strcmp(argv[i], "-tp")) { // allow the user to type
2023-03-02 16:06:11 +01:00
type = 1;
2023-03-16 16:01:53 +01:00
} else if (!strcmp(argv[i], "-nt")) { // don't allow the user to type
2023-03-02 16:06:11 +01:00
type = 0;
2023-03-16 16:01:53 +01:00
} else if (!strcmp(argv[i], "-P")) { // is the input a password
2023-03-02 16:06:11 +01:00
passwd = 1;
2023-03-16 16:01:53 +01:00
} else if (!strcmp(argv[i], "-hmc")) { // hide match count
2023-03-02 16:06:11 +01:00
hidematchcount = 1;
2023-03-16 16:01:53 +01:00
} else if (!strcmp(argv[i], "-smc")) { // don't hide match count
2023-03-02 16:06:11 +01:00
hidematchcount = 0;
2023-03-16 16:01:53 +01:00
} else if (!strcmp(argv[i], "-hm")) { // hide mode indicator
2023-03-02 16:06:11 +01:00
hidemode = 1;
2023-03-16 16:01:53 +01:00
} else if (!strcmp(argv[i], "-sm")) { // don't hide mode indicator
2023-03-02 16:06:11 +01:00
hidemode = 0;
2023-03-16 16:01:53 +01:00
} else if (!strcmp(argv[i], "-hla")) { // hide left arrow
hidelarrow = 1;
2023-03-16 16:01:53 +01:00
} else if (!strcmp(argv[i], "-sla")) { // don't hide left arrow
hidelarrow = 0;
2023-03-16 16:01:53 +01:00
} else if (!strcmp(argv[i], "-hra")) { // hide right arrow
hiderarrow = 1;
2023-03-16 16:01:53 +01:00
} else if (!strcmp(argv[i], "-sra")) { // don't hide right arrow
hiderarrow = 0;
2023-03-16 16:01:53 +01:00
} else if (!strcmp(argv[i], "-hpr")) { // hide prompt
hideprompt = 1;
2023-03-16 16:01:53 +01:00
} else if (!strcmp(argv[i], "-spr")) { // don't hide prompt
hideprompt = 0;
2023-03-16 16:01:53 +01:00
} else if (!strcmp(argv[i], "-hc")) { // hide cursor
hidecursor = 1;
2023-03-16 16:01:53 +01:00
} else if (!strcmp(argv[i], "-sc")) { // don't hide cursor
hidecursor = 0;
2023-03-16 16:01:53 +01:00
} else if (!strcmp(argv[i], "-hhl")) { // hide highlighting
hidehighlight = 1;
2023-03-16 16:01:53 +01:00
} else if (!strcmp(argv[i], "-shl")) { // don't hide highlighting
hidehighlight = 0;
2023-03-16 16:01:53 +01:00
} else if (!strcmp(argv[i], "-hi")) { // hide image
hideimage = 1;
2023-03-16 16:01:53 +01:00
} else if (!strcmp(argv[i], "-si")) { // don't hide image
hideimage = 0;
2023-03-16 16:01:53 +01:00
} else if (!strcmp(argv[i], "-ip")) { // indent to prompt width
indentitems = 1;
2023-03-16 16:01:53 +01:00
} else if (!strcmp(argv[i], "-nip")) { // don't indent to prompt width
indentitems = 0;
2023-03-13 21:21:40 +01:00
} else if (i + 1 == argc) {
2023-03-13 21:47:28 +01:00
int arg = i;
2023-03-14 21:31:24 +01:00
int pr = 1;
if (strcmp(argv[i-1], "-xrdb")
|| strcmp(argv[i-1], "-nxrdb")
|| strcmp(argv[i-1], "-lcfg")
|| strcmp(argv[i-1], "-ncfg")
)
pr = 0;
2023-03-13 21:47:28 +01:00
2023-03-14 21:31:24 +01:00
if (arg != 1 && pr)
2023-03-13 21:47:28 +01:00
fprintf(stderr, "spmenu: The '%s' option requires an argument.\n", argv[i-1]);
2023-03-14 21:31:24 +01:00
else if (pr)
2023-03-13 21:47:28 +01:00
fprintf(stderr, "spmenu: Invalid argument: '%s'\n", argv[i]);
2023-03-02 16:06:11 +01:00
2023-03-16 16:01:53 +01:00
// dmenu compatibility arguments
} else if (!strcmp(argv[i], "-i")) { // case-insensitive item matching, for compatibility reasons
casesensitive = 0;
2023-03-16 14:56:41 +01:00
// these options take one argument
2023-03-16 16:01:53 +01:00
} else if (!strcmp(argv[i], "-g")) { // number of columns in grid
2023-03-02 16:06:11 +01:00
columns = atoi(argv[++i]);
if (lines == 0) lines = 1;
2023-03-16 14:56:41 +01:00
} else if (!strcmp(argv[i], "-Ps")) { // password symbol
password = argv[++i];
2023-03-16 14:56:41 +01:00
} else if (!strcmp(argv[i], "-l")) { // number of lines in grid
2023-03-02 16:06:11 +01:00
lines = atoi(argv[++i]);
2023-03-16 14:56:41 +01:00
} else if (!strcmp(argv[i], "-mh")) { // minimum height of one menu line
lineheight += atoi(argv[++i]);
2023-03-02 16:06:11 +01:00
if (columns == 0) columns = 1;
2023-03-16 16:01:53 +01:00
} else if (!strcmp(argv[i], "-lp")) { // vertical padding
2023-03-02 16:06:11 +01:00
menupaddingv = atoi(argv[++i]);
2023-03-16 16:01:53 +01:00
} else if (!strcmp(argv[i], "-hp")) { // horizontal padding
2023-03-02 16:06:11 +01:00
menupaddingh = atoi(argv[++i]);
2023-03-16 16:01:53 +01:00
} else if (!strcmp(argv[i], "-pri")) { // high priority (csv)
2023-03-09 11:56:44 +01:00
hpitems = tokenize(argv[++i], ",", &hplength);
2023-03-16 16:01:53 +01:00
} else if (!strcmp(argv[i], "-ig")) { // gaps between image
2023-03-02 16:06:11 +01:00
imagegaps = atoi(argv[++i]);
2023-03-16 16:01:53 +01:00
} else if (!strcmp(argv[i], "-la")) { // left arrow symbol
2023-03-02 16:06:11 +01:00
leftarrow = argv[++i];
2023-03-16 16:01:53 +01:00
} else if (!strcmp(argv[i], "-ra")) { // right arrow symbol
2023-03-02 16:06:11 +01:00
rightarrow = argv[++i];
2023-03-16 16:01:53 +01:00
} else if (!strcmp(argv[i], "-m")) // monitor
2023-03-02 16:06:11 +01:00
mon = atoi(argv[++i]);
2023-03-16 16:01:53 +01:00
else if (!strcmp(argv[i], "-bw")) { // border width
2023-03-02 16:06:11 +01:00
borderwidth = atoi(argv[++i]);
2023-03-16 16:01:53 +01:00
} else if (!strcmp(argv[i], "-H")) // hist file location
2023-03-02 16:06:11 +01:00
histfile = argv[++i];
2023-03-16 16:01:53 +01:00
else if (!strcmp(argv[i], "-x")) // window x offset
2023-03-02 16:06:11 +01:00
dmx = atoi(argv[++i]);
2023-03-16 16:01:53 +01:00
else if (!strcmp(argv[i], "-y")) // window y offset (from bottom up if -b)
2023-03-02 16:06:11 +01:00
dmy = atoi(argv[++i]);
2023-03-16 16:01:53 +01:00
else if (!strcmp(argv[i], "-z")) // make spmenu this wide
2023-03-02 16:06:11 +01:00
dmw = atoi(argv[++i]);
2023-03-16 16:01:53 +01:00
else if (!strcmp(argv[i], "-p")) // adds prompt to left of input field
2023-03-02 16:06:11 +01:00
prompt = argv[++i];
2023-03-16 16:01:53 +01:00
else if (!strcmp(argv[i], "-fn")) // font or font set
fonts[0] = argv[++i];
2023-03-16 16:01:53 +01:00
else if (!strcmp(argv[i], "-nmt")) // normal mode text
2023-03-02 16:06:11 +01:00
strcpy(normtext, argv[++i]);
2023-03-16 16:01:53 +01:00
else if (!strcmp(argv[i], "-imt")) { // insert mode text
2023-03-02 16:06:11 +01:00
strcpy(instext, argv[++i]);
2023-03-16 16:01:53 +01:00
// dmenu compatibility options
} else if (!strcmp(argv[i], "-nb")) { // normal background color
2023-03-02 16:06:11 +01:00
colors[SchemeItemNorm][ColBg] = argv[++i];
colors[SchemeMenu][ColBg] = argv[++i];
colors[SchemeInput][ColBg] = argv[++i];
colors[SchemePrompt][ColBg] = argv[++i];
2023-03-16 16:01:53 +01:00
} else if (!strcmp(argv[i], "-nf")) { // normal foreground color
2023-03-02 16:06:11 +01:00
colors[SchemeItemNorm][ColFg] = argv[++i];
colors[SchemeMenu][ColFg] = argv[++i];
colors[SchemeInput][ColFg] = argv[++i];
colors[SchemePrompt][ColFg] = argv[++i];
2023-03-16 16:01:53 +01:00
} else if (!strcmp(argv[i], "-sb")) { // selected background color
2023-03-02 16:06:11 +01:00
colors[SchemeItemSel][ColBg] = argv[++i];
colors[SchemeMenu][ColBg] = argv[++i];
colors[SchemeInput][ColBg] = argv[++i];
colors[SchemePrompt][ColBg] = argv[++i];
2023-03-16 16:01:53 +01:00
} else if (!strcmp(argv[i], "-sf")) { // selected foreground color
2023-03-02 16:06:11 +01:00
colors[SchemeItemSel][ColFg] = argv[++i];
colors[SchemeMenu][ColFg] = argv[++i];
colors[SchemeInput][ColBg] = argv[++i];
colors[SchemePrompt][ColFg] = argv[++i];
2023-03-16 16:01:53 +01:00
} else if (!strcmp(argv[i], "-is")) { // image size
2023-03-02 16:06:11 +01:00
char buf[255];
memset(buf, 0, sizeof(buf));
memcpy(buf, argv[++i], sizeof(buf)-1);
if(sscanf(buf, "%dx%d", &imagewidth, &imageheight) == 1)
imageheight = imagewidth;
2023-03-16 16:01:53 +01:00
} else if (!strcmp(argv[i], "-w")) { // embedding window id
embed = argv[++i];
2023-03-16 16:01:53 +01:00
} else if (!strcmp(argv[i], "-n")) { // preselected item
preselected = atoi(argv[++i]);
2023-03-16 16:01:53 +01:00
// spmenu colors
} else if (!strcmp(argv[i], "-nif")) { // normal item foreground color
2023-03-02 16:06:11 +01:00
colors[SchemeItemNorm][ColFg] = argv[++i];
2023-03-16 16:01:53 +01:00
} else if (!strcmp(argv[i], "-nib")) { // normal item background color
2023-03-02 16:06:11 +01:00
colors[SchemeItemNorm][ColBg] = argv[++i];
2023-03-16 16:01:53 +01:00
} else if (!strcmp(argv[i], "-sif")) { // selected item foreground color
2023-03-02 16:06:11 +01:00
colors[SchemeItemSel][ColFg] = argv[++i];
2023-03-16 16:01:53 +01:00
} else if (!strcmp(argv[i], "-sib")) { // selected item background color
2023-03-02 16:06:11 +01:00
colors[SchemeItemSel][ColBg] = argv[++i];
2023-03-16 16:01:53 +01:00
} else if (!strcmp(argv[i], "-npf")) { // normal item priority foreground color
2023-03-09 10:10:29 +01:00
colors[SchemeItemNormPri][ColFg] = argv[++i];
2023-03-16 16:01:53 +01:00
} else if (!strcmp(argv[i], "-npb")) { // normal item priority background color
2023-03-09 10:10:29 +01:00
colors[SchemeItemNormPri][ColBg] = argv[++i];
2023-03-16 16:01:53 +01:00
} else if (!strcmp(argv[i], "-spf")) { // selected item priority foreground color
2023-03-09 10:10:29 +01:00
colors[SchemeItemSelPri][ColFg] = argv[++i];
2023-03-16 16:01:53 +01:00
} else if (!strcmp(argv[i], "-spb")) { // selected item priority background color
2023-03-09 10:10:29 +01:00
colors[SchemeItemSelPri][ColBg] = argv[++i];
2023-03-16 16:01:53 +01:00
} else if (!strcmp(argv[i], "-mbg")) { // menu color
2023-03-02 16:06:11 +01:00
colors[SchemeMenu][ColBg] = argv[++i];
2023-03-16 16:01:53 +01:00
} else if (!strcmp(argv[i], "-pfg")) { // prompt fg color
2023-03-02 16:06:11 +01:00
colors[SchemePrompt][ColFg] = argv[++i];
2023-03-16 16:01:53 +01:00
} else if (!strcmp(argv[i], "-pbg")) { // prompt bg color
2023-03-02 16:06:11 +01:00
colors[SchemePrompt][ColBg] = argv[++i];
2023-03-16 16:01:53 +01:00
} else if (!strcmp(argv[i], "-ifg")) { // input fg color
2023-03-02 16:06:11 +01:00
colors[SchemeInput][ColFg] = argv[++i];
2023-03-16 16:01:53 +01:00
} else if (!strcmp(argv[i], "-pfg")) { // input bg color
2023-03-02 16:06:11 +01:00
colors[SchemeInput][ColBg] = argv[++i];
2023-03-16 16:01:53 +01:00
} else if (!strcmp(argv[i], "-shf")) { // selected highlight foreground color
2023-03-02 16:06:11 +01:00
colors[SchemeSelHighlight][ColBg] = argv[++i];
2023-03-16 16:01:53 +01:00
} else if (!strcmp(argv[i], "-shf")) { // selected highlight foreground color
2023-03-02 16:06:11 +01:00
colors[SchemeSelHighlight][ColBg] = argv[++i];
2023-03-16 16:01:53 +01:00
} else if (!strcmp(argv[i], "-nhf")) { // normal highlight foreground color
2023-03-02 16:06:11 +01:00
colors[SchemeNormHighlight][ColFg] = argv[++i];
2023-03-16 16:01:53 +01:00
} else if (!strcmp(argv[i], "-shb")) { // selected highlight foreground color
2023-03-02 16:06:11 +01:00
colors[SchemeSelHighlight][ColBg] = argv[++i];
2023-03-16 16:01:53 +01:00
} else if (!strcmp(argv[i], "-nhb")) { // normal highlight foreground color
2023-03-02 16:06:11 +01:00
colors[SchemeNormHighlight][ColFg] = argv[++i];
2023-03-16 16:01:53 +01:00
} else if (!strcmp(argv[i], "-nbg")) { // numbgcolor
2023-03-02 16:06:11 +01:00
colors[SchemeNumber][ColBg] = argv[++i];
2023-03-16 16:01:53 +01:00
} else if (!strcmp(argv[i], "-nfg")) { // numfgcolor
2023-03-02 16:06:11 +01:00
colors[SchemeNumber][ColFg] = argv[++i];
2023-03-16 16:01:53 +01:00
} else if (!strcmp(argv[i], "-mbg")) { // mode
2023-03-02 16:06:11 +01:00
colors[SchemeMode][ColBg] = argv[++i];
2023-03-16 16:01:53 +01:00
} else if (!strcmp(argv[i], "-mfg")) { // mode
2023-03-02 16:06:11 +01:00
colors[SchemeMode][ColFg] = argv[++i];
2023-03-16 16:01:53 +01:00
} else if (!strcmp(argv[i], "-laf")) { // left arrow fg
2023-03-02 16:06:11 +01:00
colors[SchemeLArrow][ColFg] = argv[++i];
2023-03-16 16:01:53 +01:00
} else if (!strcmp(argv[i], "-raf")) { // right arrow fg
2023-03-02 16:06:11 +01:00
colors[SchemeRArrow][ColFg] = argv[++i];
2023-03-16 16:01:53 +01:00
} else if (!strcmp(argv[i], "-lab")) { // left arrow bg
2023-03-02 16:06:11 +01:00
colors[SchemeLArrow][ColFg] = argv[++i];
2023-03-16 16:01:53 +01:00
} else if (!strcmp(argv[i], "-rab")) { // right arrow bg
2023-03-02 16:06:11 +01:00
colors[SchemeRArrow][ColFg] = argv[++i];
2023-03-16 16:01:53 +01:00
} else if (!strcmp(argv[i], "-bc")) { // border
2023-03-02 16:06:11 +01:00
colors[SchemeBorder][ColBg] = argv[++i];
2023-03-16 16:01:53 +01:00
} else if (!strcmp(argv[i], "-cc")) // caret color
colors[SchemeCaret][ColFg] = argv[++i];
2023-03-02 16:06:11 +01:00
2023-03-16 16:01:53 +01:00
// sgr colors
else if (!strcmp(argv[i], "-sgr0")) textcolors[0] = argv[++i]; // sgr color 0
else if (!strcmp(argv[i], "-sgr1")) textcolors[1] = argv[++i]; // sgr color 1
else if (!strcmp(argv[i], "-sgr2")) textcolors[2] = argv[++i]; // sgr color 2
else if (!strcmp(argv[i], "-sgr3")) textcolors[3] = argv[++i]; // sgr color 3
else if (!strcmp(argv[i], "-sgr4")) textcolors[4] = argv[++i]; // sgr color 4
else if (!strcmp(argv[i], "-sgr5")) textcolors[5] = argv[++i]; // sgr color 5
else if (!strcmp(argv[i], "-sgr6")) textcolors[6] = argv[++i]; // sgr color 6
else if (!strcmp(argv[i], "-sgr7")) textcolors[7] = argv[++i]; // sgr color 7
else if (!strcmp(argv[i], "-sgr8")) textcolors[8] = argv[++i]; // sgr color 8
else if (!strcmp(argv[i], "-sgr9")) textcolors[9] = argv[++i]; // sgr color 9
else if (!strcmp(argv[i], "-sgr10")) textcolors[10] = argv[++i]; // sgr color 10
else if (!strcmp(argv[i], "-sgr11")) textcolors[11] = argv[++i]; // sgr color 11
else if (!strcmp(argv[i], "-sgr12")) textcolors[12] = argv[++i]; // sgr color 12
else if (!strcmp(argv[i], "-sgr13")) textcolors[13] = argv[++i]; // sgr color 13
else if (!strcmp(argv[i], "-sgr14")) textcolors[14] = argv[++i]; // sgr color 14
else if (!strcmp(argv[i], "-sgr15")) textcolors[15] = argv[++i]; // sgr color 15
2023-03-02 16:06:11 +01:00
else
fprintf(stderr, "spmenu: Invalid argument: '%s'\n", argv[i]);
2023-03-16 16:01:53 +01:00
if (casesensitive) {
fstrncmp = strncmp;
fstrstr = strstr;
} else {
fstrncmp = strncasecmp;
fstrstr = cistrstr;
}
2023-03-02 16:06:11 +01:00
}
2023-03-02 18:17:11 +01:00
void
usage(void)
{
fputs("spmenu: dynamic menu\n\n"
"- Arguments -\n"
"spmenu -l <line> Set line count to stdin\n"
2023-03-16 14:56:41 +01:00
"spmenu -mh <height> Set spmenu line height to <height>\n"
2023-03-02 18:17:11 +01:00
"spmenu -g <grid> Set the number of grids to <grid>\n"
"spmenu -gc Generate image cache\n"
2023-03-06 20:06:00 +01:00
"spmenu -ngc Don't generate image cache\n"
2023-03-02 18:17:11 +01:00
"spmenu -rw Enable relative input width\n"
"spmenu -nrw Disable relative input width\n"
"spmenu -f Grabs keyboard before reading stdin\n"
"spmenu -F Enable fuzzy matching\n"
"spmenu -P Hide characters\n"
"spmenu -Ps <symbol> Set the password symbol to <symbol>\n"
2023-03-02 18:17:11 +01:00
"spmenu -p <text> Set spmenu prompt text to <text>\n"
"spmenu -ip Indent items to prompt width\n"
"spmenu -nip Don't indent items to prompt width\n"
2023-03-02 18:17:11 +01:00
"spmenu -a Enable alpha\n"
"spmenu -na Disable alpha\n"
"spmenu -tp Allow the user to type\n"
"spmenu -nt Don't allow typing, the user must select an option\n"
"spmenu -x <x offset> Offset spmenu x position by <x offset>\n"
"spmenu -y <y offset> Offset spmenu y position by <y offset>\n"
"spmenu -n <line> Preselect <line> in the list of items\n"
"spmenu -z <width> Width of the spmenu window\n"
"spmenu -nmt <text> Set normal mode text to <text>\n"
"spmenu -imt <text> Set insert mode text to <text>\n"
"spmenu -bw Width of the border. 0 will disable the border\n"
2023-03-04 15:51:26 +01:00
"spmenu -so Sort matches\n"
"spmenu -nso Don't sort matches\n"
2023-03-09 10:10:29 +01:00
"spmenu -pri <pri> Specify a list of items that take priority\n"
2023-03-02 18:17:11 +01:00
"spmenu -s Use case-sensitive matching\n"
2023-03-16 16:01:53 +01:00
"spmenu -ns Use case-insensitive matching\n"
2023-03-02 18:17:11 +01:00
"spmenu -nm Start spmenu in normal mode\n"
"spmenu -im Start spmenu in insert mode\n"
"spmenu -t Position spmenu at the top of the screen\n"
"spmenu -b Position spmenu at the bottom of the screen\n"
"spmenu -c Position spmenu at the center of the screen\n"
"spmenu -hm Hide mode indicator\n"
"spmenu -hmc Hide match count\n"
"spmenu -hla Hide left arrow\n"
"spmenu -hra Hide right arrow\n"
"spmenu -hpr Hide prompt\n"
"spmenu -hc Hide cursor\n"
"spmenu -hhl Hide highlight\n"
"spmenu -hi Hide image\n"
2023-03-02 18:17:11 +01:00
"spmenu -sm Show mode indicator\n"
"spmenu -smc Show match count\n"
"spmenu -sla Show left arrow\n"
"spmenu -sra Show right arrow\n"
"spmenu -spr Show prompt\n"
"spmenu -sc Show cursor\n"
"spmenu -shl Show highlight\n"
"spmenu -si Show image\n"
2023-03-02 18:17:11 +01:00
"spmenu -xrdb Load .Xresources on runtime\n"
"spmenu -nxrdb Don't load .Xresources on runtime\n"
"spmenu -m <monitor> Specify a monitor to run spmenu on\n"
"spmenu -w <window id> Embed spmenu inside <window id>\n"
"spmenu -H <hist file> Specify a path to save the history to\n"
"spmenu -ig <gaps> Set image gaps to <gaps>\n"
"spmenu -lp <padding> Set the vertical padding\n"
"spmenu -hp <padding> Set the horizontal padding\n"
"spmenu -la <symbol> Set the left arrow to <symbol>\n"
"spmenu -ra <symbol> Set the right arrow to <symbol>\n"
"spmenu -is <size> Image size\n"
"spmenu -it Position the image at the top\n"
"spmenu -ib Position the image at the bottom\n"
"spmenu -ic Position the image in the center\n"
"spmenu -itc Position the image in the top center\n"
"spmenu -wm Spawn spmenu as a window manager controlled client/window. Useful for testing\n"
2023-03-13 21:31:13 +01:00
"spmenu -nwm Don't spawn spmenu as a window manager controlled client/window. Useful for testing\n"
"spmenu -lcfg Load spmenu configuration (~/.spmenu or ~/.config/spmenu/spmenurc)\n"
"spmenu -ncfg Don't load spmenu configuration (~/.spmenu or ~/.config/spmenu/spmenurc)\n"
2023-03-02 18:17:11 +01:00
"spmenu -v Print spmenu version to stdout\n"
"\n", stdout);
fputs("- Appearance arguments -\n"
"spmenu -fn <font> Set the spmenu font to <font>\n"
"spmenu -nif <color> Set the normal item foreground color\n"
"spmenu -nib <color> Set the normal item background color\n"
"spmenu -sif <color> Set the selected item foreground color\n"
"spmenu -sib <color> Set the selected item background color\n"
2023-03-09 10:10:29 +01:00
"spmenu -npf <color> Set the normal item (high priority) foreground color\n"
"spmenu -npb <color> Set the normal item (high priority) background color\n"
"spmenu -spf <color> Set the selected item (high priority) foreground color\n"
"spmenu -spb <color> Set the selected item (high priority) background color\n"
2023-03-02 18:17:11 +01:00
"spmenu -pfg <color> Set the prompt foreground color\n"
"spmenu -pbg <color> Set the prompt background color\n"
"spmenu -ifg <color> Set input foreground color\n"
"spmenu -ibg <color> Set input background color\n"
"spmenu -mbg <color> Set the menu background color\n"
"spmenu -nhf <color> Set the normal highlight foreground color\n"
"spmenu -nhb <color> Set the normal highlight background color\n"
"spmenu -shf <color> Set the selected highlight foreground color\n"
"spmenu -shb <color> Set the selected highlight background color\n"
"spmenu -shb <color> Set the selected highlight background color\n"
"spmenu -nfg <color> Set the foreground color for the match count\n"
"spmenu -nbg <color> Set the background color for the match count\n"
"spmenu -mfg <color> Set the foreground color for the mode indicator\n"
"spmenu -mbg <color> Set the background color for the mode indicator\n"
"spmenu -laf <color> Set the left arrow foreground color\n"
"spmenu -raf <color> Set the right arrow foreground color\n"
"spmenu -lab <color> Set the left arrow background color\n"
"spmenu -rab <color> Set the right arrow background color\n"
"spmenu -cc <color> Set the caret color\n"
"spmenu -bc <color> Set the border color\n"
"spmenu -sgr0 Set the SGR 0 color\n"
"spmenu -sgr1 Set the SGR 1 color\n"
"spmenu -sgr2 Set the SGR 2 color\n"
"spmenu -sgr3 Set the SGR 3 color\n"
"spmenu -sgr4 Set the SGR 4 color\n"
"spmenu -sgr5 Set the SGR 5 color\n"
"spmenu -sgr6 Set the SGR 6 color\n"
"spmenu -sgr7 Set the SGR 7 color\n"
"spmenu -sgr8 Set the SGR 8 color\n"
"spmenu -sgr9 Set the SGR 9 color\n"
"spmenu -sgr10 Set the SGR 10 color\n"
"spmenu -sgr11 Set the SGR 11 color\n"
"spmenu -sgr12 Set the SGR 12 color\n"
"spmenu -sgr13 Set the SGR 13 color\n"
"spmenu -sgr14 Set the SGR 14 color\n"
"spmenu -sgr15 Set the SGR 15 color\n"
"\n", stdout);
fputs("- dmenu compatibility -\n"
2023-03-04 15:51:26 +01:00
"spmenu -S Don't sort matches\n"
2023-03-16 16:01:53 +01:00
"spmenu -i Use case-insensitive matching\n"
2023-03-02 18:17:11 +01:00
"spmenu -nb <color> Set the normal background color\n"
"spmenu -nf <color> Set the normal foreground color\n"
"spmenu -sb <color> Set the selected background color\n"
"spmenu -sf <color> Set the selected foreground color\n"
, stdout);
exit(1);
}