monitor-setup: Put redundant arguments in fzf_args

# Conflicts:
#	.local/bin/monitor-setup
This commit is contained in:
2022-10-07 05:49:36 +02:00
parent cfec9334ef
commit 9e477ff5a4

View File

@@ -6,6 +6,8 @@
command -v xrandr &>/dev/null || exit 1 command -v xrandr &>/dev/null || exit 1
command -v fzf &>/dev/null || exit 1 command -v fzf &>/dev/null || exit 1
fzf_args=( --cycle --select-1 --exit-0 --header )
xrandr_q="$(xrandr -q)" xrandr_q="$(xrandr -q)"
# Get outputs currently in use as regex matching either one (e.g. `HDMI-0|DP-0`) # Get outputs currently in use as regex matching either one (e.g. `HDMI-0|DP-0`)
@@ -29,7 +31,7 @@ formatted="$(<<<"$xrandr_q" \
# Select all outputs to-use # Select all outputs to-use
selected=( $(<<<"$formatted" \ selected=( $(<<<"$formatted" \
fzf -m --cycle --header "Select outputs" | # select fzf -m "${fzf_args[@]}" "Select outputs" | # select
cut -d' ' -f1 # only output name cut -d' ' -f1 # only output name
) ) ) )
# Abort if nothing was selected # Abort if nothing was selected
@@ -48,7 +50,7 @@ non_selected=( $(<<<"$xrandr_q" \
# Choose primary # Choose primary
primary="$(<<<"$formatted" \ primary="$(<<<"$formatted" \
grep -E "$selected_regex" | # use formatted for more information grep -E "$selected_regex" | # use formatted for more information
fzf --cycle --select-1 --header "Select primary" | fzf "${fzf_args[@]}" "Select primary" |
cut -d' ' -f1 # name only cut -d' ' -f1 # name only
)" )"
[[ $primary ]] || exit 1 [[ $primary ]] || exit 1
@@ -73,7 +75,7 @@ for out in "${selected[@]}"; do
} }
}" }"
)" )"
res="$(<<<"$all_res" fzf --cycle --header "Select resolution for $out")" res="$(<<<"$all_res" fzf "${fzf_args[@]}" "Select resolution for $out")"
[[ $res ]] || exit 1 [[ $res ]] || exit 1
xrandr_cmd+=(--mode "$res") xrandr_cmd+=(--mode "$res")
@@ -94,7 +96,7 @@ for out in "${selected[@]}"; do
} }
}" }"
)" )"
rate="$(<<<"$rates" fzf --cycle --header "Select refresh rate for $out")" rate="$(<<<"$rates" fzf "${fzf_args[@]}" "Select refresh rate for $out")"
[[ $rate ]] || exit 1 [[ $rate ]] || exit 1
rate="${rate%%[*+]*}" # remove current and preferred mode indicator rate="${rate%%[*+]*}" # remove current and preferred mode indicator
xrandr_cmd+=(--rate "$rate") xrandr_cmd+=(--rate "$rate")