2010/07/19

Скрипт для изменения ориентации экрана (Lenovo Thinkpad X200t)

Забинден у меня на кнопочку, меняет ориентацию экрана (а также стилуса и тачскрина) по часовой стрелке при каждом нажатии. По идее должен подходить ко всем планшетным ноутам. Единственное, что может потребоваться изменить - это имена устройств, которые можно узнать командой xsetwacom --list dev.

#!/bin/bash

function set_normal {
xrandr -o normal
xsetwacom set cursor Rotate none
xsetwacom set touch Rotate none
xsetwacom set eraser Rotate none
orientation="normal"
}

function set_right {
xrandr -o right
xsetwacom set cursor Rotate cw
xsetwacom set touch Rotate cw
xsetwacom set eraser Rotate cw
orientation="right"
}

function set_left {
xrandr -o left
xsetwacom set cursor Rotate ccw
xsetwacom set touch Rotate ccw
xsetwacom set eraser Rotate ccw
orientation="left"
}

function set_inverted {
xrandr -o inverted
xsetwacom set cursor Rotate half
xsetwacom set touch Rotate half
xsetwacom set eraser Rotate half
orientation="inverted"
}

orientation="$(xrandr --query --verbose | grep 'LVDS1 connected' | awk '{print $5}')"

if [ "$orientation" = "normal" ]; then
        set_right
elif [ "$orientation" = "right" ]; then
        set_inverted
elif [ "$orientation" = "inverted" ]; then
        set_left
elif [ "$orientation" = "left" ]; then
        set_normal
fi

No comments:

Post a Comment