master #1

Merged
Lucas-mother3 merged 5 commits from speedie/spmenu:master into master 2023-09-10 01:37:34 +02:00
8 changed files with 42 additions and 26 deletions

View file

@ -182,3 +182,5 @@ Before contributing, please see [this article](https://spmenu.speedie.site/Contr
spmenu has [a wiki](https://spmenu.speedie.site) for more extensive spmenu has [a wiki](https://spmenu.speedie.site) for more extensive
documentation. Contributions to the wiki are appreciated, and documentation. Contributions to the wiki are appreciated, and
can be done through [the Git repository](https://git.speedie.site/speedie/spmenu-wiki). can be done through [the Git repository](https://git.speedie.site/speedie/spmenu-wiki).
If you need help, you can also check out [my Matrix space](https://matrix.speedie.site).

View file

@ -52,6 +52,11 @@ cache (useful if you just installed/uninstalled a program) run `spmenu_run -cc`.
**NOTE: By default it will hide any entries matching `spmenu` (for convenience) **NOTE: By default it will hide any entries matching `spmenu` (for convenience)
but you can unhide these if you wish through the configuration file.** but you can unhide these if you wish through the configuration file.**
Flatpaks are also functional, provided they use valid .desktop entries. You
can use Flatpaks with spmenu_run by passing `-d`. $DESKTOP_DIR and
$ICON_DIR must contain Flatpak paths though. If you have a new config,
these variables should be defined properly already.
## Bookmarking ## Bookmarking
spmenu_run provides bookmarking entries or just general text if preferred. To spmenu_run provides bookmarking entries or just general text if preferred. To

13
scripts/spmenu_desktop Normal file → Executable file
View file

@ -67,7 +67,7 @@ print_desktop_list() {
[ "$PRINT_LOGS_STDERR" = "true" ] && printf "spmenu_run: Updating .desktop entries.\n" >> /dev/stderr [ "$PRINT_LOGS_STDERR" = "true" ] && printf "spmenu_run: Updating .desktop entries.\n" >> /dev/stderr
icons="$(find "${icondir[@]}" -type f 2>/dev/null)" icons="$(find -L "${icondir[@]}" -type f 2>/dev/null)"
[ -z "$entry" ] && entry="$(find -L "${desktopdir[@]}" -type f -name '*.desktop' 2>/dev/null)" [ -z "$entry" ] && entry="$(find -L "${desktopdir[@]}" -type f -name '*.desktop' 2>/dev/null)"
[ -z "$entry_c" ] && entry_c="$(printf "%s\n" "$entry" | grep -c "")" [ -z "$entry_c" ] && entry_c="$(printf "%s\n" "$entry" | grep -c "")"
@ -143,13 +143,20 @@ print_desktop_list() {
mapfile -t it_only < "$ONLYFILE" mapfile -t it_only < "$ONLYFILE"
mapfile -t it_comment < "$COMMENTFILE" mapfile -t it_comment < "$COMMENTFILE"
d_print_array d_print_array | \
sort -k 2 "${sort_args[@]}" | \
uniq "${uniq_args[@]}" | \
grep -vE "$HIDDEN_ENTRY_KEYWORDS" | \
grep -E "$ENTRY_KEYWORDS"
fi fi
} }
d_print_array() { d_print_array() {
command -v print_array > /dev/null && print_array && return command -v print_array > /dev/null && print_array && return
printf "SORT_ARGS: %s\n" "${sort_args[*]}" >> "$LOGFILE"
printf "UNIQ_ARGS: %s\n" "${uniq_args[*]}" >> "$LOGFILE"
for i in "${!it_title[@]}"; do for i in "${!it_title[@]}"; do
[ "$RESPECT_ONLYSHOWIN" != "false" ] && [ "${it_only[i]}" != "false" ] && continue [ "$RESPECT_ONLYSHOWIN" != "false" ] && [ "${it_only[i]}" != "false" ] && continue
[ "$RESPECT_NODISPLAY" != "false" ] && [ "${it_display[i]}" != "true" ] && continue [ "$RESPECT_NODISPLAY" != "false" ] && [ "${it_display[i]}" != "true" ] && continue
@ -214,7 +221,7 @@ print_desktop_menu() {
HIDDEN_ENTRY_KEYWORDS="${HIDDEN_ENTRY_KEYWORDS:-NULL_ENTRY}" HIDDEN_ENTRY_KEYWORDS="${HIDDEN_ENTRY_KEYWORDS:-NULL_ENTRY}"
print_desktop_list "" | uniq "${uniq_args[@]}" | sort "${sort_args[@]}" | grep -vE "$HIDDEN_ENTRY_KEYWORDS" | grep -E "$ENTRY_KEYWORDS" | $RUNLAUNCHER "${rl_desktop[@]}" > /tmp/spmenu_out print_desktop_list "" | $RUNLAUNCHER "${rl_desktop[@]}" > /tmp/spmenu_out
while read -r menusel; do while read -r menusel; do
[ "$menusel" = "?" ] && print_desktop_help && print_desktop_menu [ "$menusel" = "?" ] && print_desktop_help && print_desktop_menu

View file

@ -5,31 +5,20 @@
# See LICENSE file for copyright and license details. # See LICENSE file for copyright and license details.
path() { path() {
[ "$SORT_BY_NUMBER" != "false" ] && NUMBERSORTARG="-n"
[ "$SORT_IN_REVERSE" != "false" ] && REVERSESORTARG="-r"
SORT_ARGS="$NUMBERSORTARG $REVERSESORTARG $SORT_ARGS"
read -ra uniq_args <<< "${UNIQ_ARGS}"
read -ra sort_args <<< "${SORT_ARGS}"
HIDDEN_KEYWORDS="${HIDDEN_KEYWORDS:-NULL_ENTRY}" HIDDEN_KEYWORDS="${HIDDEN_KEYWORDS:-NULL_ENTRY}"
print_menu() { print_menu() {
print() { print() {
compgen -c | \ compgen -c | \
grep -vE "$HIDDEN_KEYWORDS" | \ grep -vE "$HIDDEN_KEYWORDS" | \
grep -E "$KEYWORDS" grep -E "$KEYWORDS"
[ "$DISPLAY_BOOKMARKS" != "false" ] && bookmark_path [ "$DISPLAY_BOOKMARKS" != "false" ] && bookmark_path
}
if [ "$SORT_BY_RECENT" != "false" ]; then
print | sort "${sort_args[@]}" | cut -d' ' -f 2 2>&1
else
print | sort "${sort_args[@]}" | cut -d' ' -f 2 2>&1
fi
} }
print | sort "${sort_args[@]}" | cut -d' ' -f 2 2>&1
}
# uniq # uniq
if [ "$DISPLAY_DUPLICATES" != "false" ]; then if [ "$DISPLAY_DUPLICATES" != "false" ]; then
print_menu print_menu

11
scripts/spmenu_run Normal file → Executable file
View file

@ -20,8 +20,8 @@ RUNLAUNCHER="${RUNLAUNCHER:-spmenu}"
PREFIX="${PREFIX:-/usr}" PREFIX="${PREFIX:-/usr}"
DESTDIR="${DESTDIR:-}" DESTDIR="${DESTDIR:-}"
STDOUT="${STDOUT:-false}" STDOUT="${STDOUT:-false}"
SORT_BY_NUMBER="${SORT_BY_NUMBER:-true}" SORT_BY_NUMBER="${SORT_BY_NUMBER:-false}"
SORT_IN_REVERSE="${SORT_IN_REVERSE:-true}" SORT_IN_REVERSE="${SORT_IN_REVERSE:-false}"
SORT_BY_RECENT="${SORT_BY_RECENT:-false}" SORT_BY_RECENT="${SORT_BY_RECENT:-false}"
SORT_ARGS="${SORT_ARGS:-}" SORT_ARGS="${SORT_ARGS:-}"
UNIQ_ARGS="${UNIQ_ARGS:-}" UNIQ_ARGS="${UNIQ_ARGS:-}"
@ -435,6 +435,13 @@ main() {
rl_bm+=("$RUNLAUNCHER_BM_PRETEXT") rl_bm+=("$RUNLAUNCHER_BM_PRETEXT")
fi fi
[ "$SORT_BY_NUMBER" != "false" ] && NUMBERSORTARG="-n"
[ "$SORT_IN_REVERSE" != "false" ] && REVERSESORTARG="-r"
SORT_ARGS="$NUMBERSORTARG $REVERSESORTARG $SORT_ARGS"
read -ra uniq_args <<< "${UNIQ_ARGS}"
read -ra sort_args <<< "${SORT_ARGS}"
# $PATH listing # $PATH listing
case "$function" in case "$function" in
"run") "run")

View file

@ -1,5 +1,5 @@
'\" t '\" t
.\" Automatically generated by Pandoc 3.1.2 .\" Automatically generated by Pandoc 3.1.6
.\" .\"
.\" 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.

View file

@ -1,4 +1,4 @@
.\" Automatically generated by Pandoc 3.1.2 .\" Automatically generated by Pandoc 3.1.6
.\" .\"
.\" 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.
@ -77,6 +77,12 @@ run \f[V]spmenu_run -cc\f[R].
\f[B]NOTE: By default it will hide any entries matching \f[B]NOTE: By default it will hide any entries matching
\f[VB]spmenu\f[B] (for convenience) but you can unhide these if you wish \f[VB]spmenu\f[B] (for convenience) but you can unhide these if you wish
through the configuration file.\f[R] through the configuration file.\f[R]
.PP
Flatpaks are also functional, provided they use valid .desktop entries.
You can use Flatpaks with spmenu_run by passing \f[V]-d\f[R].
$DESKTOP_DIR and $ICON_DIR must contain Flatpak paths though.
If you have a new config, these variables should be defined properly
already.
.SS Bookmarking .SS Bookmarking
.PP .PP
spmenu_run provides bookmarking entries or just general text if spmenu_run provides bookmarking entries or just general text if

View file

@ -1,4 +1,4 @@
.\" Automatically generated by Pandoc 3.1.2 .\" Automatically generated by Pandoc 3.1.6
.\" .\"
.\" 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.