Skip to content

Instantly share code, notes, and snippets.

@hansen033
Last active May 9, 2024 12:17
Show Gist options
  • Save hansen033/009dabc40981d9dba9021ae17d8f23cc to your computer and use it in GitHub Desktop.
Save hansen033/009dabc40981d9dba9021ae17d8f23cc to your computer and use it in GitHub Desktop.
import rotatescreen # pip install rotate-screen
# ANSI escape code
class terco:
BL = '\033[0m' # Black
RD = '\033[91m' # Bright Red
BM = '\033[95m' # Bright Magenta
def print_displays_info(displays):
print(f'There are {terco.RD}{len(displays)}{terco.BL} available displays:')
for i in range(0, len(displays)):
print('Display' + terco.BM, i, terco.BL)
print(' Orientation:', displays[i].current_orientation)
print(' Primary:', {'True' if displays[i].is_primary else 'False'})
print(' Info:', displays[i].info)
print(' Device:', displays[i].device)
print(' Description:', displays[i].device_description)
print()
# Select display to rotate
displays = rotatescreen.get_displays()
selected_display = 0
if len(displays) > 1:
print_displays_info(displays)
selected_display = int(input(terco.BM + 'Select: ' + terco.BL))
# Decide where to rotate to
current_position = displays[selected_display].current_orientation
new_orientation = 90 if current_position == 0 else 0
displays[selected_display].rotate_to(new_orientation)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment