Skip to content

Commit

Permalink
Merge pull request #112 from pimoroni/patch-pi4-rotate-error-handling
Browse files Browse the repository at this point in the history
Improve hyperpixel4-rotate
  • Loading branch information
Gadgetoid authored May 20, 2021
2 parents 8b71cf1 + 415840b commit 327fd87
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion dist/hyperpixel4-rotate
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ function set_matrix {

function set_display {
printf "Rotating display\n";
xrandr --output DSI-1 --rotate $1
sudo python2 - <<EOF
import os
import stat
Expand All @@ -38,8 +37,23 @@ print("Saving display settings to {}".format(file))
open(file, 'w').write(data)
os.chmod(file, stat.S_IRWXU)
EOF
if [ $? -eq 0 ]; then
xrandr --output DSI-1 --rotate $1
return 0
fi

printf "Failed to set display orientation. Make sure you're running Raspberry Pi OS desktop on a Pi 4.\n"
exit 0
}

printf "This rotate utility only works with the Raspberry Pi OS desktop version.\n"

if [ "$DISPLAY" == "" ]; then
printf "You need to set a DISPLAY variable.\n";
printf "Try: DISPLAY=:0.0 hyperpixel4-rotate <orientation>\n"
exit 0
fi

if [ "$ORIENTATION" == "right" ]; then
set_display $ORIENTATION
set_matrix 0 1 0 -1 0 1
Expand Down

0 comments on commit 327fd87

Please sign in to comment.