Commit 1fb8f8a5 authored by Jay Ta'ala's avatar Jay Ta'ala
Browse files

Update addresolution script so that even if creating/adding resolution fails...

Update addresolution script so that even if creating/adding resolution fails (i.e. might already be defined) then ask to switch to res anyway.
parent a269820d
...@@ -13,7 +13,26 @@ addRes() { ...@@ -13,7 +13,26 @@ addRes() {
} }
switchRes() { switchRes() {
xrandr --output "$DEVICE" --mode "$WIDTH"x"$HEIGHT"_"$REFRESH".00
while true; do
read -p "$1" yn
case $yn in
[Yy]* ) xrandr --output "$DEVICE" --mode "$WIDTH"x"$HEIGHT"_"$REFRESH".00 || {
echo -e "\nERROR switching resolution with \"xrandr\"\n"
return 1
}; break;;
[Nn]* ) break;;
* ) echo "Please type \"y\" or \"n\"";;
esac
done
}
switchResAnyway() {
switchRes "Adding resolution failed. Try to switch to this resolution anyway? (y/n) "
}
switchResNow() {
switchRes "Switch to this resolution now? (y/n) "
} }
# check arguments # check arguments
...@@ -49,25 +68,15 @@ REFRESH=$4 ...@@ -49,25 +68,15 @@ REFRESH=$4
createRes || { createRes || {
echo -e "\nERROR creating resolution with \"cvt\"\n" echo -e "\nERROR creating resolution with \"cvt\"\n"
switchResAnyway
exit 1 exit 1
} }
addRes || { addRes || {
echo -e "\nERROR adding resolution with \"xrandr\"\n" echo -e "\nERROR adding resolution with \"xrandr\"\n"
switchResAnyway
exit 1 exit 1
} }
echo -e "\n" switchResNow
while true; do
read -p "Do you want to switch to this resolution now? (y/n) " yn
case $yn in
[Yy]* ) switchRes || {
echo -e "\nERROR switching resolution with \"xrandr\"\n"
return 1
}; break;;
[Nn]* ) break;;
* ) echo "Please type \"y\" or \"n\"";;
esac
done
exit 0 exit 0
\ No newline at end of file
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment