forked from speedie/spmenu
some minor changes + better docs
This commit is contained in:
parent
e3767da0f8
commit
b29bb4510f
55
docs/docs.md
55
docs/docs.md
|
@ -2,7 +2,7 @@ spmenu
|
||||||
======
|
======
|
||||||
![image](/docs/preview.png)
|
![image](/docs/preview.png)
|
||||||
|
|
||||||
## 1. What is spmenu?
|
## What is spmenu?
|
||||||
|
|
||||||
spmenu is a program for X11 that reads standard input and allows the user to
|
spmenu is a program for X11 that reads standard input and allows the user to
|
||||||
select items separated by a newline. It is a fork of suckless's dmenu which is
|
select items separated by a newline. It is a fork of suckless's dmenu which is
|
||||||
|
@ -13,7 +13,7 @@ support, Vim-like modes, image support, proper keybind configuration, and more.
|
||||||
|
|
||||||
Most of these features can be disabled during compile time by editing `toggle.mk`.
|
Most of these features can be disabled during compile time by editing `toggle.mk`.
|
||||||
|
|
||||||
## 2. Usage
|
## Usage
|
||||||
|
|
||||||
On runtime, spmenu reads from standard input (stdin). spmenu items are
|
On runtime, spmenu reads from standard input (stdin). spmenu items are
|
||||||
separated by a newline (`\n`). When (by default) Enter is pressed, the selected
|
separated by a newline (`\n`). When (by default) Enter is pressed, the selected
|
||||||
|
@ -26,7 +26,7 @@ This can be used in shell scripts to create interactive menus.
|
||||||
On top of this, you can specify arguments to change the behavior of spmenu.
|
On top of this, you can specify arguments to change the behavior of spmenu.
|
||||||
See a list below for a list.
|
See a list below for a list.
|
||||||
|
|
||||||
## 3. Arguments
|
## Arguments
|
||||||
|
|
||||||
- spmenu -l line - Set line count to stdin
|
- spmenu -l line - Set line count to stdin
|
||||||
- spmenu -h height - Set spmenu line height to height
|
- spmenu -h height - Set spmenu line height to height
|
||||||
|
@ -154,11 +154,11 @@ There are also extra arguments recognized for dmenu compatibility. These are:
|
||||||
- spmenu -sb color - Set the selected background color
|
- spmenu -sb color - Set the selected background color
|
||||||
- spmenu -sf color - Set the selected foreground color
|
- spmenu -sf color - Set the selected foreground color
|
||||||
|
|
||||||
## 4. Keybinds
|
## Keybinds
|
||||||
|
|
||||||
See `keybinds.h` for a list.
|
See `keybinds.h` for a list.
|
||||||
|
|
||||||
## 5. Modes
|
## Modes
|
||||||
|
|
||||||
One of the features that separate spmenu from dmenu is spmenu's different
|
One of the features that separate spmenu from dmenu is spmenu's different
|
||||||
modes. As of version 0.2, there are two modes. Normal mode and Insert mode.
|
modes. As of version 0.2, there are two modes. Normal mode and Insert mode.
|
||||||
|
@ -174,13 +174,13 @@ this mode, most keybinds do nothing. When you are in insert mode, you
|
||||||
filter items by typing text into the field. Once you're done
|
filter items by typing text into the field. Once you're done
|
||||||
with insert mode, you can press Escape to enter normal mode again.
|
with insert mode, you can press Escape to enter normal mode again.
|
||||||
|
|
||||||
## 6. -p option
|
## -p option
|
||||||
|
|
||||||
spmenu has a -p option, which stands for prompt. It allows you to specify
|
spmenu has a -p option, which stands for prompt. It allows you to specify
|
||||||
text to display next to the item list. It is displayed on the left side of the
|
text to display next to the item list. It is displayed on the left side of the
|
||||||
spmenu window. It should be noted that the prompt is purely visual though.
|
spmenu window. It should be noted that the prompt is purely visual though.
|
||||||
|
|
||||||
## 7. Images
|
## Images
|
||||||
|
|
||||||
spmenu supports drawing images. This image is placed on the left side of
|
spmenu supports drawing images. This image is placed on the left side of
|
||||||
the menu window. To use an image, pipe `IMG:/path/to/image` to spmenu.
|
the menu window. To use an image, pipe `IMG:/path/to/image` to spmenu.
|
||||||
|
@ -197,13 +197,46 @@ There are also a few image related arguments, such as:
|
||||||
|
|
||||||
`-is`, `-ig`, `-it`, `-ib`, `-ic`, `-itc` and `-gc`.
|
`-is`, `-ig`, `-it`, `-ib`, `-ic`, `-itc` and `-gc`.
|
||||||
|
|
||||||
## 8. Colored text
|
## Colored text
|
||||||
|
|
||||||
spmenu supports colored text through SGR sequences. This is the same colors
|
spmenu supports colored text through SGR sequences. This is the same colors
|
||||||
that you might already be using in your shell scripts. This means you can
|
that you might already be using in your shell scripts. This means you can
|
||||||
pipe practically any colored shell script straight into spmenu,
|
pipe practically any colored shell script straight into spmenu,
|
||||||
no need to filter the output or anything.
|
no need to filter the output or anything.
|
||||||
|
|
||||||
A list of SGR sequences will not be provided here, but spmenu supports most
|
For 256 color support to work, you must add to the array. See `libs/color.h`
|
||||||
color sequences. There are also a few arguments, you can override SGR
|
if you want this.
|
||||||
colors on-the-fly using the `-sgr` arguments.
|
|
||||||
|
See 'SGR sequences' for more information.
|
||||||
|
|
||||||
|
## SGR sequences
|
||||||
|
|
||||||
|
A basic supported SGR sequence looks like this: `\033[X;YZm`
|
||||||
|
|
||||||
|
Here, X specifies if you want normal or bright colors. Y specifies if you
|
||||||
|
want background or foreground. Z specifies the color number.
|
||||||
|
|
||||||
|
Foreground colors: `30` through `37`
|
||||||
|
Background colors: `40` through `47`
|
||||||
|
Reset: `0`
|
||||||
|
|
||||||
|
NOTE: `;` is a separator, and in this example it separates the
|
||||||
|
color number and normal/bright. \033 may also be written as `^]` or simply `ESC`.
|
||||||
|
|
||||||
|
spmenu supports most color sequences, although not true color by default
|
||||||
|
(unless -sgr arguments are used).
|
||||||
|
|
||||||
|
There are a few arguments, you can override SGR colors on-the-fly
|
||||||
|
using the `-sgrX` arguments. See 'Arguments' for more information.
|
||||||
|
|
||||||
|
## Configuration
|
||||||
|
|
||||||
|
spmenu has .Xresources (xrdb) support built in. It reads the xrdb (.Xresources database)
|
||||||
|
on runtime. You may disable it by passing -nxrdb, or enable it by padding -xrdb.
|
||||||
|
|
||||||
|
spmenu loads `~/.config/spmenu/spmenurc` or alternatively if you're
|
||||||
|
old fashioned, `~/.spmenurc`. This requires that `xrdb` is available on your
|
||||||
|
operating system.
|
||||||
|
|
||||||
|
You can also use wildcards (such as `*`) to achieve a global colorscheme. Programs like
|
||||||
|
`pywal` do this.
|
||||||
|
|
28
libs/argv.c
28
libs/argv.c
|
@ -2,17 +2,19 @@ void
|
||||||
readargs(int argc, char *argv[])
|
readargs(int argc, char *argv[])
|
||||||
{
|
{
|
||||||
int i = 0;
|
int i = 0;
|
||||||
|
int j = 0;
|
||||||
|
|
||||||
for (i = 1; i < argc; i++) {
|
for (j = 1; j < argc; j++) {
|
||||||
/* xrdb first as it overrides other options */
|
/* xrdb first as it overrides other options */
|
||||||
if (!strcmp(argv[i], "-xrdb")) /* xresources */
|
if (!strcmp(argv[j], "-xrdb")) { /* xresources */
|
||||||
xresources = 1;
|
xresources = 1;
|
||||||
else if (!strcmp(argv[i], "-nxrdb")) /* no xresources */
|
} else if (!strcmp(argv[j], "-nxrdb")) { /* no xresources */
|
||||||
xresources = 0;
|
xresources = 0;
|
||||||
else if (!strcmp(argv[i], "-lcfg")) /* load config */
|
} else if (!strcmp(argv[j], "-lcfg")) { /* load config */
|
||||||
loadconfig = 1;
|
loadconfig = 1;
|
||||||
else if (!strcmp(argv[i], "-ncfg")) /* don't load config */
|
} else if (!strcmp(argv[j], "-ncfg")) { /* don't load config */
|
||||||
loadconfig = 0;
|
loadconfig = 0;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (xresources) {
|
if (xresources) {
|
||||||
|
@ -136,10 +138,18 @@ readargs(int argc, char *argv[])
|
||||||
indentitems = 0;
|
indentitems = 0;
|
||||||
} else if (i + 1 == argc) {
|
} else if (i + 1 == argc) {
|
||||||
int arg = i;
|
int arg = i;
|
||||||
|
int pr = 1;
|
||||||
|
|
||||||
if (arg != 1)
|
if (strcmp(argv[i-1], "-xrdb")
|
||||||
|
|| strcmp(argv[i-1], "-nxrdb")
|
||||||
|
|| strcmp(argv[i-1], "-lcfg")
|
||||||
|
|| strcmp(argv[i-1], "-ncfg")
|
||||||
|
)
|
||||||
|
pr = 0;
|
||||||
|
|
||||||
|
if (arg != 1 && pr)
|
||||||
fprintf(stderr, "spmenu: The '%s' option requires an argument.\n", argv[i-1]);
|
fprintf(stderr, "spmenu: The '%s' option requires an argument.\n", argv[i-1]);
|
||||||
else
|
else if (pr)
|
||||||
fprintf(stderr, "spmenu: Invalid argument: '%s'\n", argv[i]);
|
fprintf(stderr, "spmenu: Invalid argument: '%s'\n", argv[i]);
|
||||||
|
|
||||||
/* these options take one argument */
|
/* these options take one argument */
|
||||||
|
|
|
@ -156,6 +156,14 @@ match(void)
|
||||||
matchend = substrend;
|
matchend = substrend;
|
||||||
}
|
}
|
||||||
curr = sel = matches;
|
curr = sel = matches;
|
||||||
|
|
||||||
|
for (i = 0; i < preselected; i++) {
|
||||||
|
if (sel && sel->right && (sel = sel->right) == next) {
|
||||||
|
curr = next;
|
||||||
|
calcoffsets();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
calcoffsets();
|
calcoffsets();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
61
spmenu.1
61
spmenu.1
|
@ -1,4 +1,4 @@
|
||||||
.\" Automatically generated by Pandoc 3.0.1
|
.\" Automatically generated by Pandoc 3.1
|
||||||
.\"
|
.\"
|
||||||
.\" Define V font for inline verbatim, using C font in formats
|
.\" Define V font for inline verbatim, using C font in formats
|
||||||
.\" that render this, and otherwise B font.
|
.\" that render this, and otherwise B font.
|
||||||
|
@ -17,7 +17,7 @@
|
||||||
.TH "spmenu" "1" "" "0.2.2" "dynamic menu"
|
.TH "spmenu" "1" "" "0.2.2" "dynamic menu"
|
||||||
.hy
|
.hy
|
||||||
.SH spmenu
|
.SH spmenu
|
||||||
.SS 1. What is spmenu?
|
.SS What is spmenu?
|
||||||
.PP
|
.PP
|
||||||
spmenu is a program for X11 that reads standard input and allows the
|
spmenu is a program for X11 that reads standard input and allows the
|
||||||
user to select items separated by a newline.
|
user to select items separated by a newline.
|
||||||
|
@ -30,7 +30,7 @@ configuration, and more.
|
||||||
.PP
|
.PP
|
||||||
Most of these features can be disabled during compile time by editing
|
Most of these features can be disabled during compile time by editing
|
||||||
\f[V]toggle.mk\f[R].
|
\f[V]toggle.mk\f[R].
|
||||||
.SS 2. Usage
|
.SS Usage
|
||||||
.PP
|
.PP
|
||||||
On runtime, spmenu reads from standard input (stdin).
|
On runtime, spmenu reads from standard input (stdin).
|
||||||
spmenu items are separated by a newline (\f[V]\[rs]n\f[R]).
|
spmenu items are separated by a newline (\f[V]\[rs]n\f[R]).
|
||||||
|
@ -46,7 +46,7 @@ This can be used in shell scripts to create interactive menus.
|
||||||
On top of this, you can specify arguments to change the behavior of
|
On top of this, you can specify arguments to change the behavior of
|
||||||
spmenu.
|
spmenu.
|
||||||
See a list below for a list.
|
See a list below for a list.
|
||||||
.SS 3. Arguments
|
.SS Arguments
|
||||||
.IP \[bu] 2
|
.IP \[bu] 2
|
||||||
spmenu -l line - Set line count to stdin
|
spmenu -l line - Set line count to stdin
|
||||||
.IP \[bu] 2
|
.IP \[bu] 2
|
||||||
|
@ -298,10 +298,10 @@ spmenu -nf color - Set the normal foreground color
|
||||||
spmenu -sb color - Set the selected background color
|
spmenu -sb color - Set the selected background color
|
||||||
.IP \[bu] 2
|
.IP \[bu] 2
|
||||||
spmenu -sf color - Set the selected foreground color
|
spmenu -sf color - Set the selected foreground color
|
||||||
.SS 4. Keybinds
|
.SS Keybinds
|
||||||
.PP
|
.PP
|
||||||
See \f[V]keybinds.h\f[R] for a list.
|
See \f[V]keybinds.h\f[R] for a list.
|
||||||
.SS 5. Modes
|
.SS Modes
|
||||||
.PP
|
.PP
|
||||||
One of the features that separate spmenu from dmenu is spmenu\[cq]s
|
One of the features that separate spmenu from dmenu is spmenu\[cq]s
|
||||||
different modes.
|
different modes.
|
||||||
|
@ -322,13 +322,13 @@ When you are in insert mode, you filter items by typing text into the
|
||||||
field.
|
field.
|
||||||
Once you\[cq]re done with insert mode, you can press Escape to enter
|
Once you\[cq]re done with insert mode, you can press Escape to enter
|
||||||
normal mode again.
|
normal mode again.
|
||||||
.SS 6. -p option
|
.SS -p option
|
||||||
.PP
|
.PP
|
||||||
spmenu has a -p option, which stands for prompt.
|
spmenu has a -p option, which stands for prompt.
|
||||||
It allows you to specify text to display next to the item list.
|
It allows you to specify text to display next to the item list.
|
||||||
It is displayed on the left side of the spmenu window.
|
It is displayed on the left side of the spmenu window.
|
||||||
It should be noted that the prompt is purely visual though.
|
It should be noted that the prompt is purely visual though.
|
||||||
.SS 7. Images
|
.SS Images
|
||||||
.PP
|
.PP
|
||||||
spmenu supports drawing images.
|
spmenu supports drawing images.
|
||||||
This image is placed on the left side of the menu window.
|
This image is placed on the left side of the menu window.
|
||||||
|
@ -348,7 +348,7 @@ There are also a few image related arguments, such as:
|
||||||
.PP
|
.PP
|
||||||
\f[V]-is\f[R], \f[V]-ig\f[R], \f[V]-it\f[R], \f[V]-ib\f[R],
|
\f[V]-is\f[R], \f[V]-ig\f[R], \f[V]-it\f[R], \f[V]-ib\f[R],
|
||||||
\f[V]-ic\f[R], \f[V]-itc\f[R] and \f[V]-gc\f[R].
|
\f[V]-ic\f[R], \f[V]-itc\f[R] and \f[V]-gc\f[R].
|
||||||
.SS 8. Colored text
|
.SS Colored text
|
||||||
.PP
|
.PP
|
||||||
spmenu supports colored text through SGR sequences.
|
spmenu supports colored text through SGR sequences.
|
||||||
This is the same colors that you might already be using in your shell
|
This is the same colors that you might already be using in your shell
|
||||||
|
@ -356,7 +356,42 @@ scripts.
|
||||||
This means you can pipe practically any colored shell script straight
|
This means you can pipe practically any colored shell script straight
|
||||||
into spmenu, no need to filter the output or anything.
|
into spmenu, no need to filter the output or anything.
|
||||||
.PP
|
.PP
|
||||||
A list of SGR sequences will not be provided here, but spmenu supports
|
For 256 color support to work, you must add to the array.
|
||||||
most color sequences.
|
See \f[V]libs/color.h\f[R] if you want this.
|
||||||
There are also a few arguments, you can override SGR colors on-the-fly
|
.PP
|
||||||
using the \f[V]-sgr\f[R] arguments.
|
See `SGR sequences' for more information.
|
||||||
|
.SS SGR sequences
|
||||||
|
.PP
|
||||||
|
A basic supported SGR sequence looks like this: \f[V]\[rs]033[X;YZm\f[R]
|
||||||
|
.PP
|
||||||
|
Here, X specifies if you want normal or bright colors.
|
||||||
|
Y specifies if you want background or foreground.
|
||||||
|
Z specifies the color number.
|
||||||
|
.PP
|
||||||
|
Foreground colors: \f[V]30\f[R] through \f[V]37\f[R] Background colors:
|
||||||
|
\f[V]40\f[R] through \f[V]47\f[R] Reset: \f[V]0\f[R]
|
||||||
|
.PP
|
||||||
|
NOTE: \f[V];\f[R] is a separator, and in this example it separates the
|
||||||
|
color number and normal/bright.
|
||||||
|
\[rs]033 may also be written as \f[V]\[ha]]\f[R] or simply
|
||||||
|
\f[V]ESC\f[R].
|
||||||
|
.PP
|
||||||
|
spmenu supports most color sequences, although not true color by default
|
||||||
|
(unless -sgr arguments are used).
|
||||||
|
.PP
|
||||||
|
There are a few arguments, you can override SGR colors on-the-fly using
|
||||||
|
the \f[V]-sgrX\f[R] arguments.
|
||||||
|
See `Arguments' for more information.
|
||||||
|
.SS Configuration
|
||||||
|
.PP
|
||||||
|
spmenu has .Xresources (xrdb) support built in.
|
||||||
|
It reads the xrdb (.Xresources database) on runtime.
|
||||||
|
You may disable it by passing -nxrdb, or enable it by padding -xrdb.
|
||||||
|
.PP
|
||||||
|
spmenu loads \f[V]\[ti]/.config/spmenu/spmenurc\f[R] or alternatively if
|
||||||
|
you\[cq]re old fashioned, \f[V]\[ti]/.spmenurc\f[R].
|
||||||
|
This requires that \f[V]xrdb\f[R] is available on your operating system.
|
||||||
|
.PP
|
||||||
|
You can also use wildcards (such as \f[V]*\f[R]) to achieve a global
|
||||||
|
colorscheme.
|
||||||
|
Programs like \f[V]pywal\f[R] do this.
|
||||||
|
|
Loading…
Reference in a new issue