I have this script:
#!/bin/bash
declare -a arr
arr+=(
[mirror]="xrandr --output hdmi-1 --same-as edp-1"
[extend]="xrandr --output hdmi-1 --auto"
)
screen=hdmi-1
chosen=$(echo -e ${!arr[@]}| dmenu -fn monospace-14)
[ "$chosen" != "" ] || exit
But when I run this, mirror and extend are the same item.
Is there a way to get this into two separate items?
To print multiple items you do this:
echo -e "first\nsecond\nthird" | dmenu
I used an associative array because then I only need to write the options once, and adding options is very easy (just append the list).
bashorsh? Your code explicitly usesshbut the question is taggedbash. Please clarify. n. b. I'm pretty sureshdoes not have associative arrays.declare -A(upper case) for an associative array (as opposed todeclare -afor an indexed array)?