summaryrefslogtreecommitdiff
path: root/tessen
diff options
context:
space:
mode:
authorAyush Agarwal <ayush@fastmail.in>2022-01-16 18:47:55 +0530
committerAyush Agarwal <ayush@fastmail.in>2022-01-16 21:15:35 +0530
commitedea7a802c93b1347a28b26efe8687b2fa38a9ca (patch)
treedb18f9c5bf153b382b1cf2d55e933f979711fd48 /tessen
parentfc86aa3c27efecc56cb0ac7a5b042d9c4459f0cd (diff)
refactor: change the setup_backend function
A few extraneous `{}` were removed from variable names, `=` was replaced with `==` because we're using bash and the former is more confusing, and other cosmetic changes.
Diffstat (limited to 'tessen')
-rwxr-xr-xtessen29
1 files changed, 15 insertions, 14 deletions
diff --git a/tessen b/tessen
index 6bd04e9..1e08a19 100755
--- a/tessen
+++ b/tessen
@@ -338,27 +338,28 @@ is_installed() {
}
setup_backend() {
- local backend="${1}"
+ local backend="$1"
local backend_opts="${backend#* }"
backend="${backend%% *}"
- if ! is_installed "${backend}"; then
- _die "'${backend}' not installed"
+
+ if ! is_installed "$backend"; then
+ _die "'$backend' is not installed"
fi
- if [[ "${backend_opts}" = "${backend}" ]]; then
- backend_opts="$(get_defaults "${backend}")"
+ if [[ "$backend_opts" == "$backend" ]]; then
+ backend_opts="$(get_default_opts "$backend")"
+ if [[ -z "$backend_opts" ]]; then
+ printf "%s\n" "unable to determine any dmenu options for '$backend'" >&2
+ fi
fi
- mapfile -t -d' ' backend_opts < <(printf "%s" "${backend_opts}")
- readonly tsn_backend="${backend}"
- readonly tsn_backend_opts=("${backend_opts[@]}")
-}
-get_defaults() {
- if [[ "$(type -t "defaults_${1}")" = "function" ]]; then
- "defaults_${1}"
+ readonly tsn_backend="$backend"
+
+ if [[ -n "$backend_opts" ]]; then
+ mapfile -t -d ' ' backend_opts < <(printf "%s" "$backend_opts")
+ readonly -a tsn_backend_opts=("${backend_opts[@]}")
else
- printf ""
+ readonly -a tsn_backend_opts=()
fi
- return 0
}
get_default_opts() {