Skip to content

Instantly share code, notes, and snippets.

@MolarFox
Created April 3, 2024 07:30
Show Gist options
  • Select an option

  • Save MolarFox/368e1c055a782e41e71b29ad56b284dd to your computer and use it in GitHub Desktop.

Select an option

Save MolarFox/368e1c055a782e41e71b29ad56b284dd to your computer and use it in GitHub Desktop.
Toggle display orientation (for 2-in-1 without working tilt sensor)
#!/bin/bash
tgt_disp="eDP-1"
# Determine which index the orientation will be at. +1 if tgt_disp is primary (try running the edpi_state xrandr command without the cut to see why)
disp_info=$(xrandr --query --verbose | grep "$tgt_disp")
if [ $(echo "$disp_info" | cut -d ' ' -f 3) == "primary" ]
then
cut_index=6
else
cut_index=5
fi
edpi_state=$(echo "$disp_info" | cut -d ' ' -f $cut_index)
if [ "$edpi_state" != "normal" ]
then
xrandr --output eDP-1 --rotate normal
else
xrandr --output eDP-1 --rotate left
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment