Created
October 11, 2018 06:34
-
-
Save sebbekarlsson/d4a30e758a6590d4b1d25c77426eb8f6 to your computer and use it in GitHub Desktop.
Asking questions in bash
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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