Merge pull request 'Pretext: Add -pt argument, add pretext to spmenu_run' (#18) from pretext into master

Reviewed-on: #18
This commit is contained in:
Jacob 2023-07-24 14:51:28 +00:00
commit ec7ec23374
4 changed files with 36 additions and 1 deletions

View file

@ -106,6 +106,9 @@ in the config files.
`-p, --prompt text` `-p, --prompt text`
: Set spmenu prompt text to text : Set spmenu prompt text to text
`-pt, --pretext text`
: Set spmenu pretext to text
`-It, --input text` `-It, --input text`
: Set initial input text to text : Set initial input text to text

View file

@ -352,6 +352,8 @@ void readargs(int argc, char *argv[]) {
menuwidth = atoi(argv[++i]); menuwidth = atoi(argv[++i]);
else if (!strcmp(argv[i], "-p") || (!strcmp(argv[i], "--prompt"))) // adds prompt to left of input field else if (!strcmp(argv[i], "-p") || (!strcmp(argv[i], "--prompt"))) // adds prompt to left of input field
prompt = argv[++i]; prompt = argv[++i];
else if (!strcmp(argv[i], "-pt") || (!strcmp(argv[i], "--pretext"))) // adds pretext
pretext = argv[++i];
else if (!strcmp(argv[i], "-It") || (!strcmp(argv[i], "--input"))) // specify initial text else if (!strcmp(argv[i], "-It") || (!strcmp(argv[i], "--input"))) // specify initial text
input = argv[++i]; input = argv[++i];
else if (!strcmp(argv[i], "-fn") || (!strcmp(argv[i], "--font"))) // font or font set else if (!strcmp(argv[i], "-fn") || (!strcmp(argv[i], "--font"))) // font or font set
@ -623,6 +625,7 @@ void usage(int status) {
"spmenu -P, --password Hide characters\n" "spmenu -P, --password Hide characters\n"
"spmenu -nP, --no-password Don't hide characters\n" "spmenu -nP, --no-password Don't hide characters\n"
"spmenu -p, --prompt <text> Set spmenu prompt text to <text>\n" "spmenu -p, --prompt <text> Set spmenu prompt text to <text>\n"
"spmenu -pt, --pretext <text> Set spmenu pretext to <text>\n"
"spmenu -It, --input <text> Set initial input text to <text>\n" "spmenu -It, --input <text> Set initial input text to <text>\n"
"spmenu -ip, --indent Indent items to prompt width\n" "spmenu -ip, --indent Indent items to prompt width\n"
"spmenu -nip, --no-indent Don't indent items to prompt width\n" "spmenu -nip, --no-indent Don't indent items to prompt width\n"

View file

@ -53,6 +53,12 @@ RUNLAUNCHER_DESKTOP_ARGS=""
RUNLAUNCHER_FM_ARGS="--lines 40 --columns 2" RUNLAUNCHER_FM_ARGS="--lines 40 --columns 2"
RUNLAUNCHER_HELP_ARGS="" RUNLAUNCHER_HELP_ARGS=""
RUNLAUNCHER_RUN_PRETEXT="Type in keywords to search for a program.."
RUNLAUNCHER_BM_PRETEXT="Type in keywords to search for a bookmark.."
RUNLAUNCHER_DESKTOP_PRETEXT="Type in keywords to search for a program.."
RUNLAUNCHER_FM_PRETEXT="Type in keywords to search for a file or directory.."
RUNLAUNCHER_HELP_PRETEXT=""
DESKTOP_DIR="${DESKTOP_DIR:-${DESTDIR}${PREFIX}/share/applications ${HOME}/.local/share/applications}" DESKTOP_DIR="${DESKTOP_DIR:-${DESTDIR}${PREFIX}/share/applications ${HOME}/.local/share/applications}"
ICON_DIR="${ICON_DIR:-${DESTDIR}${PREFIX}/share/icons/hicolor ${HOME}/.local/share/icons/hicolor ${DESTDIR}${PREFIX}/share/pixmaps}" ICON_DIR="${ICON_DIR:-${DESTDIR}${PREFIX}/share/icons/hicolor ${HOME}/.local/share/icons/hicolor ${DESTDIR}${PREFIX}/share/pixmaps}"
IMAGE="${IMAGE:-true}" IMAGE="${IMAGE:-true}"
@ -211,6 +217,13 @@ RUNLAUNCHER_FM_ARGS="${RUNLAUCNHER_FM_ARGS}" # Extra arguments passed to \$RUNLA
RUNLAUNCHER_HELP_ARGS="${RUNLAUNCHER_HELP_ARGS}" # Extra arguments passed to \$RUNLAUNCHER when using the help RUNLAUNCHER_HELP_ARGS="${RUNLAUNCHER_HELP_ARGS}" # Extra arguments passed to \$RUNLAUNCHER when using the help
DMENU_COMPAT="$DMENU_COMPAT" # Enable dmenu compatibility (true/false) DMENU_COMPAT="$DMENU_COMPAT" # Enable dmenu compatibility (true/false)
# Pretext
RUNLAUNCHER_RUN_PRETEXT="$RUNLAUNCHER_RUN_PRETEXT" # Text to display when no input text
RUNLAUNCHER_BM_PRETEXT="$RUNLAUNCHER_BM_PRETEXT" # Text to display when no input text
RUNLAUNCHER_DESKTOP_PRETEXT="$RUNLAUNCHER_DESKTOP_PRETEXT" # Text to display when no input text
RUNLAUNCHER_FM_PRETEXT="$RUNLAUNCHER_FM_PRETEXT" # Text to display when no input text
RUNLAUNCHER_HELP_PRETEXT="$RUNLAUNCHER_HELP_PRETEXT" # Text to display when no input text
# Sorting # Sorting
SORT_BY_NUMBER="$SORT_BY_NUMBER" # Sort by numbers SORT_BY_NUMBER="$SORT_BY_NUMBER" # Sort by numbers
SORT_IN_REVERSE="$SORT_IN_REVERSE" # Sort in reverse SORT_IN_REVERSE="$SORT_IN_REVERSE" # Sort in reverse
@ -379,7 +392,7 @@ main() {
RUNLAUNCHER_FM_ARGS="--insert --lines 20 --columns 1 $HIST_ARG $RUNLAUNCHER_FM_ARGS $MARGS" RUNLAUNCHER_FM_ARGS="--insert --lines 20 --columns 1 $HIST_ARG $RUNLAUNCHER_FM_ARGS $MARGS"
RUNLAUNCHER_RUN_ARGS="--insert $HIST_ARG $RUNLAUNCHER_RUN_ARGS $MARGS" RUNLAUNCHER_RUN_ARGS="--insert $HIST_ARG $RUNLAUNCHER_RUN_ARGS $MARGS"
RUNLAUNCHER_BM_ARGS="--insert $HIST_ARG --prompt Bookmarks $RUNLAUNCHER_BM_ARGS $MARGS" RUNLAUNCHER_BM_ARGS="--insert $HIST_ARG --prompt Bookmarks $RUNLAUNCHER_BM_ARGS $MARGS"
RUNLAUNCHER_DESKTOP_ARGS="--sgr1 $DESCRIPTION_COLOR --sgr2 $COMMENT_COLOR --lines 20 --columns 1 --image-size 100 --image-gaps 20 --display-icons $RUNLAUNCHER_DESKTOP_ARGS $MARGS" RUNLAUNCHER_DESKTOP_ARGS="--insert --sgr1 $DESCRIPTION_COLOR --sgr2 $COMMENT_COLOR --lines 20 --columns 1 --image-size 100 --image-gaps 20 --display-icons $RUNLAUNCHER_DESKTOP_ARGS $MARGS"
RUNLAUNCHER_HELP_ARGS="--insert $HIST_ARG $RUNLAUNCHER_HELP_ARGS $MARGS" RUNLAUNCHER_HELP_ARGS="--insert $HIST_ARG $RUNLAUNCHER_HELP_ARGS $MARGS"
# dmenu compatibility # dmenu compatibility
@ -411,6 +424,19 @@ main() {
read -ra desktopdir <<< "${DESKTOP_DIR}" read -ra desktopdir <<< "${DESKTOP_DIR}"
read -ra icondir <<< "${ICON_DIR}" read -ra icondir <<< "${ICON_DIR}"
if [ "$DMENU_COMPAT" = "false" ]; then
rl_desktop+=("--pretext")
rl_fm+=("--pretext")
rl_run+=("--pretext")
rl_help+=("--pretext")
rl_bm+=("--pretext")
rl_desktop+=("$RUNLAUNCHER_DESKTOP_PRETEXT")
rl_fm+=("$RUNLAUNCHER_FM_PRETEXT")
rl_run+=("$RUNLAUNCHER_RUN_PRETEXT")
rl_help+=("$RUNLAUNCHER_HELP_PRETEXT")
rl_bm+=("$RUNLAUNCHER_BM_PRETEXT")
fi
# $PATH listing # $PATH listing
case "$function" in case "$function" in
"run") "run")

View file

@ -133,6 +133,9 @@ Don\[cq]t hide characters
\f[V]-p, --prompt text\f[R] \f[V]-p, --prompt text\f[R]
Set spmenu prompt text to text Set spmenu prompt text to text
.TP .TP
\f[V]-pt, --pretext text\f[R]
Set spmenu pretext to text
.TP
\f[V]-It, --input text\f[R] \f[V]-It, --input text\f[R]
Set initial input text to text Set initial input text to text
.TP .TP