Some config file code cleanup
This commit is contained in:
parent
69d5ae6950
commit
d750f3a78a
|
@ -15,7 +15,7 @@ PLAYER="${PLAYER:-mpv}"
|
|||
GENERIC="${GENERIC:-$TERMINAL -e $EDITOR}"
|
||||
WEB_GREP="${WEB_GREP:-http:|https:|www[.]}"
|
||||
MAGNET_GREP="${MAGNET_GREP:-magnet:?}"
|
||||
HISTORY="${HISTORY:-${XDG_CACHE_HOME:-$HOME/.cache/}/spmenu_run.hist}"
|
||||
HISTORY="${HISTORY:-${XDG_CACHE_HOME:-$HOME/.cache/}/spmenu/spmenu_run.hist}"
|
||||
RUNLAUNCHER="${RUNLAUNCHER:-spmenu}"
|
||||
PREFIX="${PREFIX:-/usr}"
|
||||
DESTDIR="${DESTDIR:-}"
|
||||
|
@ -36,21 +36,27 @@ DESCRIPTION_COLOR="${DESCRIPTION_COLOR:-#999888}"
|
|||
DMENU_COMPAT="${DMENU_COMPAT:-false}"
|
||||
AUTOREFRESH="${AUTOREFRESH:-true}"
|
||||
MULTISELECT="${MULTISELECT:-true}"
|
||||
BOOKMARK_FILE="${BOOKMARK_FILE:-${XDG_CACHE_HOME:-$HOME/.cache/}/spmenu_run.bookmarks}"
|
||||
BOOKMARK_FILE="${BOOKMARK_FILE:-${XDG_CACHE_HOME:-$HOME/.cache/}/spmenu/spmenu_run.bookmarks}"
|
||||
BOOKMARK_PROMPT="${BOOKMARK_PROMPT:-Bookmarks}"
|
||||
PRINT_LOGS_STDERR="${PRINT_LOGS_STDERR:-true}"
|
||||
|
||||
RUNLAUNCHER_RUN_ARGS=""
|
||||
RUNLAUNCHER_BM_ARGS=""
|
||||
RUNLAUNCHER_DESKTOP_ARGS=""
|
||||
RUNLAUNCHER_FM_ARGS="--lines 40 --columns 2"
|
||||
RUNLAUNCHER_HELP_ARGS=""
|
||||
|
||||
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}"
|
||||
IMAGE="${IMAGE:-true}"
|
||||
LOGFILE="${LOGFILE:-/tmp/spmenu_run.log}"
|
||||
|
||||
TITLEFILE="${TITLEFILE:-${XDG_CACHE_HOME:-$HOME/.cache}/.title}"
|
||||
EXECFILE="${EXECFILE:-${XDG_CACHE_HOME:-$HOME/.cache}/.exec}"
|
||||
ICONFILE="${ICONFILE:-${XDG_CACHE_HOME:-$HOME/.cache}/.icon}"
|
||||
DESCFILE="${DESCFILE:-${XDG_CACHE_HOME:-$HOME/.cache}/.desc}"
|
||||
FILEFILE="${FILEFILE:-${XDG_CACHE_HOME:-$HOME/.cache}/.file}"
|
||||
TERMFILE="${TERMFILE:-${XDG_CACHE_HOME:-$HOME/.cache}/.term}"
|
||||
TITLEFILE="${TITLEFILE:-${XDG_CACHE_HOME:-$HOME/.cache}/spmenu/.desktop_title}"
|
||||
EXECFILE="${EXECFILE:-${XDG_CACHE_HOME:-$HOME/.cache}/spmenu/.desktop_exec}"
|
||||
ICONFILE="${ICONFILE:-${XDG_CACHE_HOME:-$HOME/.cache}/spmenu/.desktop_icon}"
|
||||
DESCFILE="${DESCFILE:-${XDG_CACHE_HOME:-$HOME/.cache}/spmenu/.desktop_desc}"
|
||||
FILEFILE="${FILEFILE:-${XDG_CACHE_HOME:-$HOME/.cache}/spmenu/.desktop_file}"
|
||||
TERMFILE="${TERMFILE:-${XDG_CACHE_HOME:-$HOME/.cache}/spmenu/.desktop_term}"
|
||||
|
||||
# arrays containing entries
|
||||
declare -a it_title
|
||||
|
@ -75,18 +81,21 @@ declare -a uniq_args
|
|||
declare -a desktopdir
|
||||
declare -a icondir
|
||||
|
||||
fail_mac() {
|
||||
[ -f "/usr/local/share/spmenu/allowusageonmac" ] && return
|
||||
cat << EOF
|
||||
spmenu_run does not support macOS due to the outdated Bash version.
|
||||
See https://spmenu.speedie.site/Using+spmenu+on+macOS for more information.
|
||||
|
||||
If you wish to ignore this warning anyway, touch /usr/local/share/spmenu/allowusageonmac.
|
||||
EOF
|
||||
exit 1
|
||||
prepare_dirs() {
|
||||
mkdir -p \
|
||||
"$(dirname "$TITLEFILE")" \
|
||||
"$(dirname "$EXECFILE")" \
|
||||
"$(dirname "$ICONFILE")" \
|
||||
"$(dirname "$DESCFILE")" \
|
||||
"$(dirname "$FILEFILE")" \
|
||||
"$(dirname "$TERMFILE")" \
|
||||
"$(dirname "$LOGFILE")" \
|
||||
"$(dirname "$HISTORY")" \
|
||||
"$(dirname "$BOOKMARK_FILE")"
|
||||
}
|
||||
|
||||
check() {
|
||||
prepare_dirs
|
||||
[ ! -d "$CONFDIR/spmenu/run" ] && mkdir -p "$CONFDIR/spmenu/run"
|
||||
if [ ! -f "$CONFDIR/spmenu/run/.first_run" ]; then
|
||||
print_help
|
||||
|
@ -235,54 +244,55 @@ PDF_READER="\${PDF_READER:-zathura}" # PDF reader, for file management
|
|||
EDITOR="\${EDITOR:-nvim}" # Editor, used to open documents
|
||||
PLAYER="\${PLAYER:-mpv}" # Player, used to play audio/video
|
||||
GENERIC="\${GENERIC:-\$TERMINAL -e \$EDITOR}" # Generic, used to open unknown files
|
||||
WEB_GREP="http:|https:|www[.]" # Needs to be in grep -E syntax
|
||||
MAGNET_GREP="magnet:?" # Needs to be in grep -E syntax
|
||||
HISTORY="\${XDG_CACHE_HOME:-\$HOME/.cache/}/spmenu_run.hist" # History file, spmenu (meaning your user) must have permission to read and write to it.
|
||||
BOOKMARK_FILE="\${BOOKMARK_FILE:-\${XDG_CACHE_HOME:-\$HOME/.cache/}/spmenu_run.bookmarks}" # Bookmark file, spmenu_run must have permission to read and write to it.
|
||||
BOOKMARK_PROMPT="Bookmarks" # Bookmark prompt (-p)
|
||||
WEB_GREP="$WEB_GREP" # Needs to be in grep -E syntax
|
||||
MAGNET_GREP="$MAGNET_GREP" # Needs to be in grep -E syntax
|
||||
HISTORY="\${XDG_CACHE_HOME:-\$HOME/.cache/}/spmenu/spmenu_run.hist" # History file, spmenu (meaning your user) must have permission to read and write to it.
|
||||
BOOKMARK_FILE="\${BOOKMARK_FILE:-\${XDG_CACHE_HOME:-\$HOME/.cache/}/spmenu/spmenu_run.bookmarks}" # Bookmark file, spmenu_run must have permission to read and write to it.
|
||||
BOOKMARK_PROMPT="$BOOKMARK_PROMPT" # Bookmark prompt (-p)
|
||||
|
||||
# Run launcher argument options
|
||||
RUNLAUNCHER="\${RUNLAUNCHER:-spmenu}" # Run launcher to use
|
||||
RUNLAUNCHER_RUN_ARGS="" # Extra arguments passed to \$RUNLAUNCHER when using the run launcher
|
||||
RUNLAUNCHER_BM_ARGS="" # Extra arguments passed to \$RUNLAUNCHER when using the bookmark menu
|
||||
RUNLAUNCHER_DESKTOP_ARGS="" # Extra rguments passed to \$RUNLAUNCHER when using the .desktop launcher
|
||||
RUNLAUNCHER_FM_ARGS="--lines 40 --columns 2" # Extra arguments passed to \$RUNLAUNCHER when using the file manager
|
||||
RUNLAUNCHER_HELP_ARGS="" # Extra arguments passed to \$RUNLAUNCHER when using the help
|
||||
DMENU_COMPAT="false" # Enable dmenu compatibility (true/false)
|
||||
RUNLAUNCHER_RUN_ARGS="$RUNLAUNCHER_RUN_ARGS" # Extra arguments passed to \$RUNLAUNCHER when using the run launcher
|
||||
RUNLAUNCHER_BM_ARGS="$RUNLAUNCHER_BM_ARGS" # Extra arguments passed to \$RUNLAUNCHER when using the bookmark menu
|
||||
RUNLAUNCHER_DESKTOP_ARGS="$RUNLAUNCHER_DESKTOP_ARGS" # Extra rguments passed to \$RUNLAUNCHER when using the .desktop launcher
|
||||
RUNLAUNCHER_FM_ARGS="${RUNLAUCNHER_FM_ARGS}" # Extra arguments passed to \$RUNLAUNCHER when using the file manager
|
||||
RUNLAUNCHER_HELP_ARGS="${RUNLAUNCHER_HELP_ARGS}" # Extra arguments passed to \$RUNLAUNCHER when using the help
|
||||
DMENU_COMPAT="$DMENU_COMPAT" # Enable dmenu compatibility (true/false)
|
||||
|
||||
# Sorting
|
||||
SORT_BY_NUMBER="true" # Sort by numbers
|
||||
SORT_IN_REVERSE="true" # Sort in reverse
|
||||
SORT_BY_RECENT="false" # Sort by recent
|
||||
SORT_ARGS="" # Extra arguments passed to the sort command.
|
||||
SORT_BY_NUMBER="$SORT_BY_NUMBER" # Sort by numbers
|
||||
SORT_IN_REVERSE="$SORT_IN_REVERSE" # Sort in reverse
|
||||
SORT_BY_RECENT="$SORT_BY_RECENT" # Sort by recent
|
||||
SORT_ARGS="$SORT_ARGS" # Extra arguments passed to the sort command.
|
||||
|
||||
# Keywords
|
||||
HIDDEN_KEYWORDS="spmenu" # Keywords that will be ignored, needs to be in grep -vE syntax.
|
||||
KEYWORDS="" # Keywords that will be matched, needs to be in grep -E syntax.
|
||||
HIDDEN_KEYWORDS="$HIDDEN_KEYWORDS" # Keywords that will be ignored, needs to be in grep -vE syntax.
|
||||
KEYWORDS="$KEYWORDS" # Keywords that will be matched, needs to be in grep -E syntax.
|
||||
|
||||
# Miscellanious
|
||||
STDOUT="false" # Print to stdout and exit (true/false)
|
||||
DISPLAY_DUPLICATES="false" # Display duplicates or not
|
||||
DEFAULT_FEATURE="run" # spmenu_run default feature (run/fm/desktop/help)
|
||||
HELP_COLOR="#FFFF00"
|
||||
STDOUT="$STDOUT" # Print to stdout and exit (true/false)
|
||||
DISPLAY_DUPLICATES="$DISPLAY_DUPLICATES" # Display duplicates or not
|
||||
DEFAULT_FEATURE="$DEFAULT_FEATURE" # spmenu_run default feature (run/fm/desktop/help)
|
||||
HELP_COLOR="$HELP_COLOR"
|
||||
|
||||
# .desktop entry options
|
||||
DESKTOP_DIR="\${DESTDIR}\${PREFIX}/share/applications \${HOME}/.local/share/applications" # Directories for .desktop entries
|
||||
ICON_DIR="\${DESTDIR}\${PREFIX}/share/icons/hicolor \${HOME}/.local/share/icons/hicolor \${DESTDIR}\${PREFIX}/share/pixmaps" # Directories for icons defined in the entries
|
||||
DESKTOP_DIR="$DESKTOP_DIR" # Directories for .desktop entries
|
||||
ICON_DIR="$ICON_DIR" # Directories for icons defined in the entries
|
||||
HIDDEN_ENTRY_KEYWORDS="\$HIDDEN_KEYWORDS" # Keywords that will be ignored, needs to be in grep -vE syntax.
|
||||
ENTRY_KEYWORDS="\$KEYWORDS" # Keywords that will be matched, needs to be in grep -E syntax.
|
||||
AUTOREFRESH="true" # Refresh (clear) cache if there are more entries available than cached. May cause cache to be cleared every time in some cases. (true/false)
|
||||
MULTISELECT="true" # Allow handling multiple items, if set to false only the first line/selected item will be used.
|
||||
IMAGE="true" # Display images (true/false)
|
||||
DISPLAY_DESCRIPTION="true" # Display description (true/false)"
|
||||
DESCRIPTION_COLOR="#999888" # Description text color
|
||||
LOGFILE="/tmp/spmenu_run.log" # Log file
|
||||
PRINT_LOGS_STDERR="true" # Print information (such as logs) to stderr (true/false)
|
||||
TITLEFILE="\${TITLEFILE:-\${XDG_CACHE_HOME:-\$HOME/.cache}/.title}" # File containing the different titles to display.
|
||||
DESCFILE="\${DESCFILE:-\${XDG_CACHE_HOME:-\$HOME/.cache}/.desc}" # File containing the description to display
|
||||
EXECFILE="\${EXECFILE:-\${XDG_CACHE_HOME:-\$HOME/.cache}/.exec}" # File containing the different executables to run.
|
||||
ICONFILE="\${ICONFILE:-\${XDG_CACHE_HOME:-\$HOME/.cache}/.icon}" # File containing the paths to the icons to display.
|
||||
FILEFILE="\${FILEFILE:-\${XDG_CACHE_HOME:-\$HOME/.cache}/.file}" # File containing the path to the .desktop entries.
|
||||
AUTOREFRESH="$AUTOREFRESH" # Refresh (clear) cache if there are more entries available than cached. May cause cache to be cleared every time in some cases. (true/false)
|
||||
MULTISELECT="$MULTISELECT" # Allow handling multiple items, if set to false only the first line/selected item will be used.
|
||||
IMAGE="$IMAGE" # Display images (true/false)
|
||||
DISPLAY_DESCRIPTION="$DISPLAY_DESCRIPTION" # Display description (true/false)"
|
||||
DESCRIPTION_COLOR="$DESCRIPTION_COLOR" # Description text color
|
||||
LOGFILE="$LOGFILE" # Log file
|
||||
PRINT_LOGS_STDERR="$PRINT_LOGS_STDERR" # Print information (such as logs) to stderr (true/false)
|
||||
TITLEFILE="\${XDG_CACHE_HOME:-\$HOME/.cache}/spmenu/.desktop_title" # File containing the different titles to display.
|
||||
DESCFILE="\${XDG_CACHE_HOME:-\$HOME/.cache}/spmenu/.desktop_desc" # File containing the description to display
|
||||
EXECFILE="\${XDG_CACHE_HOME:-\$HOME/.cache}/spmenu/.desktop_exec" # File containing the different executables to run.
|
||||
ICONFILE="\${XDG_CACHE_HOME:-\$HOME/.cache}/spmenu/.desktop_icon" # File containing the paths to the icons to display.
|
||||
FILEFILE="\${XDG_CACHE_HOME:-\$HOME/.cache}/spmenu/.desktop_file" # File containing the path to the .desktop entries.
|
||||
TERMFILE="\${XDG_CACHE_HOME:-\$HOME/.cache}/spmenu/.desktop_term" # File containing the path to the terminal data
|
||||
|
||||
# File management
|
||||
DEFAULT_DIRECTORY="\$(pwd)" # Directory to start -fm if none is specified.
|
||||
|
@ -730,7 +740,6 @@ clear_cache() {
|
|||
}
|
||||
|
||||
main() {
|
||||
[ -d "/System/Library/Extensions" ] && fail_mac
|
||||
rm -f "$LOGFILE"
|
||||
print_config
|
||||
read_args "$@"
|
||||
|
|
Loading…
Reference in a new issue