From 660c4e53fd60644ab3a0ff4b4c9a289d4e5c6ed8 Mon Sep 17 00:00:00 2001 From: speedie Date: Tue, 4 Apr 2023 23:57:47 +0200 Subject: [PATCH] some minor changes to spmenu_profile --- scripts/spmenu_profile | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/scripts/spmenu_profile b/scripts/spmenu_profile index a718d60..a264df0 100755 --- a/scripts/spmenu_profile +++ b/scripts/spmenu_profile @@ -5,7 +5,16 @@ CONFDIR="${XDG_CONFIG_HOME:-$HOME/.config}" PREFIX="${PREFIX:-/usr}" load_profile() { - [ -f "${CONFDIR}/spmenu/.profile" ] && PROFILE="$(cat "${CONFDIR}/spmenu/.profile")" + [ -f "${CONFDIR}/spmenu/.profile" ] && [ "$(cat "${CONFDIR}/spmenu/.profile")" = "NONE" ] && NONE=true + + if [ "$NONE" = "true" ]; then + xrdb -remove spmenu* + return + fi + + [ -f "${CONFDIR}/spmenu/.profile" ] && \ + PROFILE="$(cat "${CONFDIR}/spmenu/.profile")" + [ -f "$HOME/.spmenurc" ] && xrdb -override "$HOME/.spmenurc" # legacy config [ -n "$PROFILE" ] && xrdb -override "$PROFILE" } @@ -39,7 +48,8 @@ check() { case "$sel" in "Add") add_profile ;; "Remove") remove_profile ;; - "Default") printf "%s/.config/spmenu/spmenurc\n" "$HOME" > "${CONFDIR}/spmenu/.profile" && set_profile ;; + "Default") printf "${CONFDIR}/spmenu/spmenurc\n" > "${CONFDIR}/spmenu/.profile" && set_profile ;; + "None") printf "NONE\n" > "${CONFDIR}/spmenu/.profile" ;; "") exit 0 ;; *) profile="$sel" && write_profile && set_profile ;; esac @@ -57,7 +67,7 @@ list_profiles() { profiles="$(find "${CONFDIR}/spmenu/profiles" -type f)" profilec="$(find "${CONFDIR}/spmenu/profiles" -type f | wc -l)" - [ "$1" != "noopts" ] && [ -f "${CONFDIR}/spmenu/.profile" ] && printf "\033[1;33m%s\n" "Current profile: $(basename "$(cat "${CONFDIR}/spmenu/.profile")")" | sed "s/spmenurc/Default/g" + [ "$1" != "noopts" ] && [ -f "${CONFDIR}/spmenu/.profile" ] && printf "\033[1;33m%s\n" "Current profile: $(basename "$(cat "${CONFDIR}/spmenu/.profile")")" | sed "s/spmenurc/Default/g; s/NONE/None/g" for i in $(seq "$profilec"); do curprofile="$(basename "$(printf "%s" "$profiles" | sed "${i}q;d")")" @@ -68,7 +78,7 @@ list_profiles() { } list_ex_options() { - printf "‎\nDefault\nAdd\nRemove\n" + printf "‎\nNone\nDefault\nAdd\nRemove\n" } main() {