-- set the path to the downloaded displayplacer executable
set displayplacer_path to "/Users/Shared/displayplacer"
-- get unique displayplacer ID
set displayplacer_id_command to displayplacer_path & " list | awk '/Persistent screen id: /{print $4}'"
set displayplacer_id to (do shell script displayplacer_id_command) as string
-- example for a 4K screen in HiDPI mode "looks like 1080p" (scaling:on)
-- rotate 90° counter clockwise
set displayplacer_rotate90_command to displayplacer_path & " \"id:" & displayplacer_id & " res:1920x1080 hz:60 color_depth:8 scaling:on origin:(0,0) degree:90\""
try
do shell script displayplacer_rotate90_command
end try
-- wait 5 seconds
delay 5
-- restore rotation to 0°
set displayplacer_rotate0_command to displayplacer_path & " \"id:" & displayplacer_id & " res:1920x1080 hz:60 color_depth:8 scaling:on origin:(0,0) degree:0\""
try
do shell script displayplacer_rotate0_command
end try