From 692c41e4b877298994be521a133b7f445509124d Mon Sep 17 00:00:00 2001 From: speedie Date: Mon, 1 May 2023 22:20:06 +0200 Subject: [PATCH] code quality improvements --- spmenuify | 19 ++++++++----------- 1 file changed, 8 insertions(+), 11 deletions(-) diff --git a/spmenuify b/spmenuify index 0a26f5b..97a8723 100755 --- a/spmenuify +++ b/spmenuify @@ -19,8 +19,6 @@ # along with this program. If not, see . -RUNLAUNCHER="${RUNLAUNCHER:-spmenu}" -RUNLAUNCHER_ARGS="${RUNLAUNCHER_ARGS:- --lines 40 --columns 1}" THEME_DIR="${THEME_DIR:-$HOME/.config/spmenu/themes}" print_list() { @@ -66,22 +64,21 @@ list_files() { } install_theme() { - [ "$(printf "Yes\nNo\n" | ${RUNLAUNCHER} ${RUNLAUNCHER_ARGS} --prompt "Install theme ${output}?")" != "Yes" ] && main + [ "$(printf "Yes\nNo\n" | spmenu --lines 40 --columns 1 --prompt "Install theme ${output}?" --no-allow-typing --hide-mode --hide-input --hide-match-count --hide-left-arrow --hide-right-arrow --hide-image --hide-highlighting --hide-caps --normal)" != "Yes" ] && main - snotif() { + [ -f "$THEME_DIR/$output" ] && cp -f "$THEME_DIR/$output" "$HOME/.config/spmenu/theme.conf" && \ command -v notify-send > /dev/null && notify-send "Installed" "Installed theme $output" - } - - [ -f "$THEME_DIR/$output" ] && cp -f "$THEME_DIR/$output" "$HOME/.config/spmenu/theme.conf" && snotif } preview() { - output="$(print_theme_list | ${RUNLAUNCHER} ${RUNLAUNCHER_ARGS} | sed -e 's/\x1b\[[0-9;]*m//g')" + output="$(print_theme_list | spmenu --lines 40 --columns 1 --prompt "Select:" --hide-mode --hide-caps --hide-match-count --hide-left-arrow --hide-right-arrow --hide-image --hide-highlighting --normal | sed -e 's/\x1b\[[0-9;]*m//g')" [ -f "$HOME/.config/spmenu/theme.conf" ] && cp "$HOME/.config/spmenu/theme.conf" "/tmp/theme.conf" [ -f "$THEME_DIR/$output" ] && cp -f "$THEME_DIR/$output" "$HOME/.config/spmenu/theme.conf" printf "\033[0;31mItem 1\n\033[0;32mItem 2\n\033[0;33mItem 3\n\033[0;34mItem 4\n\033[0;35mItem 5\n\033[0;36mItem 6\n\033[0;37mItem 7\n\033[0;38mItem 8\n\033[1;31mItem 9\n\033[1;32mItem 10\n\033[1;33mItem 11\n\033[1;34mItem 12\n\033[1;35mItem 13\n\033[1;36mItem 14\n\033[1;37mItem 15\n\033[1;38mItem 16\n\ -\033[0;41mItem 1\n\033[0;42mItem 2\n\033[0;43mItem 3\n\033[0;44mItem 4\n\033[0;45mItem 5\n\033[0;46mItem 6\n\033[0;47mItem 7\n\033[0;48mItem 8\n\033[1;41mItem 9\n\033[1;42mItem 10\n\033[1;43mItem 11\n\033[1;44mItem 12\n\033[1;45mItem 13\n\033[1;46mItem 14\n\033[1;47mItem 15\n\033[1;48mItem 16\n" | ${RUNLAUNCHER} ${RUNLAUNCHER_ARGS} - [ -f "/tmp/theme.conf" ] && mv "/tmp/theme.conf" "$HOME/.config/spmenu/theme.conf" || rm -f "$HOME/.config/spmenu/theme.conf" +\033[0;41mItem 1\n\033[0;42mItem 2\n\033[0;43mItem 3\n\033[0;44mItem 4\n\033[0;45mItem 5\n\033[0;46mItem 6\n\033[0;47mItem 7\n\033[0;48mItem 8\n\033[1;41mItem 9\n\033[1;42mItem 10\n\033[1;43mItem 11\n\033[1;44mItem 12\n\033[1;45mItem 13\n\033[1;46mItem 14\n\033[1;47mItem 15\n\033[1;48mItem 16\n" | spmenu --lines 40 --columns 1 --prompt "Preview" --no-allow-typing + if [ -f "/tmp/theme.conf" ]; then + mv "/tmp/theme.conf" "$HOME/.config/spmenu/theme.conf" || rm -f "$HOME/.config/spmenu/theme.conf" + fi main } @@ -89,7 +86,7 @@ preview() { main() { check_spmenu_ver mkdir -p "$HOME/.config/spmenu/" - output="$(print_list | ${RUNLAUNCHER} ${RUNLAUNCHER_ARGS} | sed -e 's/\x1b\[[0-9;]*m//g')" + output="$(print_list | spmenu --lines 40 --columns 1 --prompt "Select:" --hide-mode --hide-caps --hide-match-count --hide-left-arrow --hide-right-arrow --hide-image --hide-highlighting | sed -e 's/\x1b\[[0-9;]*m//g')" case "$output" in "Install") list_files ;;