some improvements to documentation and spmenu_run

This commit is contained in:
speedie 2023-03-24 15:58:36 +01:00
parent ca52c5986e
commit ca7cd97e08
3 changed files with 54 additions and 14 deletions

View file

@ -407,6 +407,7 @@ dmenu compatibility can be achieved using these arguments:
`-sb color`
: Set the selected background color
`-sf color`
: Set the selected foreground color
@ -457,6 +458,8 @@ There are also a few image related arguments, such as:
`-is`, `-ig`, `-it`, `-ib`, `-ic`, `-itc` and `-gc`.
NOTE: Vector images (such as .svg) can be displayed too.
Colored text
============
@ -501,8 +504,21 @@ 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.
You can also use wildcards (such as `*`) to achieve a global colorscheme.
Programs like `pywal` do this to apply universal colorschemes.
Run launcher
============
spmenu includes a shell script called spmenu_run. It lists executable programs in $PATH and displays them to the user in a list. Not only that but it shows recently run programs first in the list.
spmenu_run will interpret any arguments as spmenu arguments and pass them to spmenu. Therefore `spmenu_run --prompt 'Run:'` will set the prompt to `Run:`. While it is similar to dmenu_run (and achieves the same goal), this version has some extra features.
The selected option is piped to /bin/sh (by default). Unlike dmenu_run, spmenu_run has some cool features. For example:
- Prepending `#` will spawn it in a terminal instead of just a shell.
- Prepending `magnet ` will open a magnet link in $TORRENT
- Prepending `www` will open a page in $BROWSER
License
=======

View file

@ -1,11 +1,4 @@
#!/bin/sh
[ ! -f "$HOME/.config/spmenu/spmenu_run.conf" ] && \
mkdir -p "$HOME/.config/spmenu"; \
touch "$HOME/.config/spmenu/spmenu_run.conf"
[ -f "$HOME/.config/spmenu/spmenu_run.conf" ] && \
"$HOME/.config/spmenu/spmenu_run.conf"
[ -z "$TERMINAL" ] && TERMINAL="st -e"
[ -z "$BROWSER" ] && BROWSER="xdg-open"
[ -z "$TORRENT" ] && TORRENT="qbittorrent"
@ -17,12 +10,15 @@ path() { echo "$PATH" | tr ':' '\n' | uniq | sed 's#$#/#' | xargs ls -lu --time-
parse() {
dout="$(path | sed "s/\&/\&/g" | spmenu -im -H "$HISTORY" "$@")"
# parse
[ "$(printf '%c' "$dout")" = "#" ] && RUN_ARG="$TERMINAL"
[ "$(printf "$dout" | awk '{ print $1 }')" = "magnet" ] && "$TORRENT" "$(printf "$dout" | sed "s/magnet //")" && return
[ "$(printf "$dout" | awk '{ print $1 }')" = "www" ] && "$BROWSER" "$(printf "$dout" | sed "s/www //")" && return
[ "$(printf "$dout" | awk '{ print $1 }')" = "magnet" ] && "$TORRENT" "$(printf "$dout" | sed "s/magnet //")"
[ "$(printf "$dout" | awk '{ print $1 }')" = "www" ] && "$BROWSER" "$(printf "$dout" | sed "s/www //")"
# terminal
[ "$RUN_ARG" != "$TERMINAL" ] && printf "%s" "$dout" | sed "s/#//g" | ${SHELL:-"/bin/sh"} & return
[ -z "$RUN_ARG" ] && \
printf "%s" "$dout" | sed "s/#//g" | ${SHELL:-"/bin/sh"} &
[ "$RUN_ARG" = "$TERMINAL" ] && $TERMINAL -e "$(printf "%s" "$dout" | sed "s/#//g")"; return
}

View file

@ -427,7 +427,9 @@ Set the normal background color
Set the normal foreground color
.TP
\f[V]-sb color\f[R]
Set the selected background color \f[V]-sf color\f[R]
Set the selected background color
.TP
\f[V]-sf color\f[R]
Set the selected foreground color
.SH Keybinds
.PP
@ -479,6 +481,8 @@ There are also a few image related arguments, such as:
.PP
\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].
.PP
NOTE: Vector images (such as .svg) can be displayed too.
.SH Colored text
.PP
spmenu supports colored text through SGR sequences.
@ -525,7 +529,31 @@ 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.
Programs like \f[V]pywal\f[R] do this to apply universal colorschemes.
.SH Run launcher
.PP
spmenu includes a shell script called spmenu_run.
It lists executable programs in $PATH and displays them to the user in a
list.
Not only that but it shows recently run programs first in the list.
.PP
spmenu_run will interpret any arguments as spmenu arguments and pass
them to spmenu.
Therefore \f[V]spmenu_run --prompt \[aq]Run:\[aq]\f[R] will set the
prompt to \f[V]Run:\f[R].
While it is similar to dmenu_run (and achieves the same goal), this
version has some extra features.
.PP
The selected option is piped to /bin/sh (by default).
Unlike dmenu_run, spmenu_run has some cool features.
For example:
.IP \[bu] 2
Prepending \f[V]#\f[R] will spawn it in a terminal instead of just a
shell.
.IP \[bu] 2
Prepending \f[V]magnet\f[R] will open a magnet link in $TORRENT
.IP \[bu] 2
Prepending \f[V]www\f[R] will open a page in $BROWSER
.SH License
.PP
spmenu is licensed under the MIT license.