From 99d97ddf8cdfbf6abdc247d8036d596a65602060 Mon Sep 17 00:00:00 2001 From: Ayush Agarwal Date: Fri, 18 Feb 2022 22:09:50 +0530 Subject: fix: rofi and wofi need individual variables since rofi and wofi support configuring themselves with config files, which is the sensible thing to do, we'll need to store their config option in separate variables to avoid conflict scenarios with the options of other dmenu backends rather than using `eval`, I've used parameter transformations in bash to expand possible variables provided in the config file. however, to avoid expanding and accepting arbitrary input, i'll use a regex to filter unwanted data --- tessen | 24 ++++++++++-------------- 1 file changed, 10 insertions(+), 14 deletions(-) diff --git a/tessen b/tessen index f12e1d5..9eaf515 100755 --- a/tessen +++ b/tessen @@ -13,7 +13,7 @@ set +x # GLOBAL VARIABLES readonly tsn_version="2.0.0" declare pass_backend dmenu_backend tsn_action tsn_config -declare -a dmenu_backend_opts tmp_opts +declare -a dmenu_backend_opts tmp_rofi_opts tmp_wofi_opts declare tsn_userkey tsn_urlkey tsn_autokey tsn_delay tsn_web_browser # show both actions, 'autotype' and 'copy', to choose from by default tsn_action="default" @@ -736,19 +736,15 @@ parse_config() { validate_dmenu_backend "$val" elif [[ $key == "action" ]]; then validate_action "$val" - elif [[ $key == "rofi_config_file" ]] && [[ $dmenu_backend == "rofi" ]]; then - validate_dmenu_backend rofi - dmenu_backend_opts+=("-config $val") - tmp_opts+=("-config $val") - elif [[ $key == "wofi_config_file" ]] && [[ $dmenu_backend == "wofi" ]]; then - dmenu_backend_opts+=("-c $val") - tmp_opts+=("-c $val") - elif [[ $key == "wofi_style_file" ]] && [[ $dmenu_backend == "wofi" ]]; then - dmenu_backend_opts+=("-s $val") - tmp_opts+=("-s $val") - elif [[ $key == "wofi_color_file" ]] && [[ $dmenu_backend == "wofi" ]]; then - dmenu_backend_opts+=("-C $val") - tmp_opts+=("-C $val") + readonly tsn_action + elif [[ $key == "rofi_config_file" ]] && [[ -f ${val@P} ]]; then + tmp_rofi_opts+=("-config" "${val@P}") + elif [[ $key == "wofi_config_file" ]] && [[ -f ${val@P} ]]; then + tmp_wofi_opts+=("-c" "${val@P}") + elif [[ $key == "wofi_style_file" ]] && [[ -f ${val@P} ]]; then + tmp_wofi_opts+=("-s" "${val@P}") + elif [[ $key == "wofi_color_file" ]] && [[ -f ${val@P} ]]; then + tmp_wofi_opts+=("-C" "${val@P}") elif [[ $key == "userkey" ]]; then tsn_userkey="$val" elif [[ $key == "urlkey" ]]; then -- cgit v1.2.3