[scripts] fix: displayselect
fix default config + refactor code
This commit is contained in:
parent
5b158166db
commit
cacfe657a7
@ -39,11 +39,23 @@ twoscreen() { # If multi-monitor is selected and there are two screens.
|
|||||||
secondary=$(echo "$screens" | grep -v -w "$primary")
|
secondary=$(echo "$screens" | grep -v -w "$primary")
|
||||||
direction=$(printf "left\\nright" | dmenu -i -p "What side of $primary should $secondary be on?")
|
direction=$(printf "left\\nright" | dmenu -i -p "What side of $primary should $secondary be on?")
|
||||||
rotation=$(printf "normal\\nleft\\nright" | dmenu -i -p "Rotate $secondary?")
|
rotation=$(printf "normal\\nleft\\nright" | dmenu -i -p "Rotate $secondary?")
|
||||||
xrandr --output "$primary" --auto --scale 1.0x1.0 \
|
setup
|
||||||
--output "$secondary" --"$direction"-of "$primary" --auto
|
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
default() {
|
||||||
|
primary=$(echo "$allposs" | grep -w "connected primary" | awk '{printf $1}')
|
||||||
|
secondary=$(echo "$screens" | grep -v -w "$primary")
|
||||||
|
direction="left"
|
||||||
|
rotation="normal"
|
||||||
|
setup
|
||||||
|
}
|
||||||
|
|
||||||
|
setup() {
|
||||||
|
xrandr --output "$primary" --auto --scale 1.0x1.0 \
|
||||||
|
--output "$secondary" --"$direction"-of "$primary" --auto
|
||||||
|
}
|
||||||
|
|
||||||
morescreen() { # If multi-monitor is selected and there are more than two screens.
|
morescreen() { # If multi-monitor is selected and there are more than two screens.
|
||||||
primary=$(echo "$screens" | dmenu -i -p "Select primary display:")
|
primary=$(echo "$screens" | dmenu -i -p "Select primary display:")
|
||||||
secondary=$(echo "$screens" | grep -v -w "$primary" | dmenu -i -p "Select secondary display:")
|
secondary=$(echo "$screens" | grep -v -w "$primary" | dmenu -i -p "Select secondary display:")
|
||||||
@ -66,8 +78,9 @@ allposs=$(xrandr -q | grep -w "connected")
|
|||||||
screens=$(echo "$allposs" | awk '{print $1}')
|
screens=$(echo "$allposs" | awk '{print $1}')
|
||||||
|
|
||||||
# Get user choice including multi-monitor and manual selection:
|
# Get user choice including multi-monitor and manual selection:
|
||||||
chosen=$(printf "multi-monitor\\n%s\\nmanual selection" "$screens" | dmenu -i -p "Select display arangement:") &&
|
chosen=$(printf "default\\n\\nmulti-monitor\\n%s\\nmanual selection" "$screens" | dmenu -i -p "Select display arangement:") &&
|
||||||
case "$chosen" in
|
case "$chosen" in
|
||||||
|
"default") default ;;
|
||||||
"manual selection") arandr ; exit ;;
|
"manual selection") arandr ; exit ;;
|
||||||
"multi-monitor") multimon ;;
|
"multi-monitor") multimon ;;
|
||||||
*) xrandr --output "$chosen" --auto --scale 1.0x1.0 $(echo "$allposs" | grep -v "$chosen" | awk '{print "--output", $1, "--off"}' | tr '\n' ' ') ;;
|
*) xrandr --output "$chosen" --auto --scale 1.0x1.0 $(echo "$allposs" | grep -v "$chosen" | awk '{print "--output", $1, "--off"}' | tr '\n' ' ') ;;
|
||||||
|
Reference in New Issue
Block a user