Skip to content

Instantly share code, notes, and snippets.

@sebbekarlsson
Created October 11, 2018 06:34
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sebbekarlsson/d4a30e758a6590d4b1d25c77426eb8f6 to your computer and use it in GitHub Desktop.
Save sebbekarlsson/d4a30e758a6590d4b1d25c77426eb8f6 to your computer and use it in GitHub Desktop.
Asking questions in bash
question_state=0
function ask() {
read -p "$1" -n 1 -r
echo
if [[ $REPLY =~ ^[Yy]$ ]]
then
question_state=1
fi
}
function reset() {
question_state=0
}
ask "Set your left screen relative to the right? "
if [[ $question_state == 1 ]]
then
xrandr --output DP-2-1 --left-of DP-1-3
fi
reset
ask "Rotate your left screen? "
if [[ $question_state == 1 ]]
then
xrandr --output DP-2-1 --rotate right
fi
reset
ask "Set your right screen mode to 1920x1080? "
if [[ $question_state == 1 ]]
then
xrandr --output DP-1-3 --mode 1920x1080
fi
reset
ask "Set your left screen mode to 2560x1440? "
if [[ $question_state == 1 ]]
then
xrandr --output DP-2-1 --mode 2560x1440
fi
reset
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment