1 (30-04-2015 22:48:14 отредактировано aloneuser)

Тема: Скрипт поворота экрана и стилуса для Linux

Для начала нужно узнать название стилуса.

Введите xinput:

ura@debian:~$ xinput
⎡ Virtual core pointer                        id=2    [master pointer  (3)]
⎜   ↳ Virtual core XTEST pointer                  id=4    [slave  pointer  (2)]
⎜   ↳ A4Tech USB Mouse                            id=9    [slave  pointer  (2)]
⎜   ↳ TPPS/2 IBM TrackPoint                       id=11    [slave  pointer  (2)]
⎜   ↳ [b]Serial Wacom Tablet stylus [/b]                 id=13    [slave  pointer  (2)]
⎜   ↳ Serial Wacom Tablet eraser                  id=14    [slave  pointer  (2)]
⎣ Virtual core keyboard                       id=3    [master keyboard (2)]
    ↳ Virtual core XTEST keyboard                 id=5    [slave  keyboard (3)]
    ↳ Power Button                                id=6    [slave  keyboard (3)]
    ↳ Video Bus                                   id=7    [slave  keyboard (3)]
    ↳ Sleep Button                                id=8    [slave  keyboard (3)]
    ↳ AT Translated Set 2 keyboard                id=10    [slave  keyboard (3)]
    ↳ ThinkPad Extra Buttons                      id=12    [slave  keyboard (3)]
ura@debian:~$

Serial Wacom Tablet stylus это мой стилус.

Теперь создадим скрипт поворота экрана:

nano rotation

#!/bin/sh

# Find the line in "xrandr -q --verbose" output that contains current screen orientation and "strip" out current orientation.

rotation="$(xrandr -q --verbose | grep 'connected' | egrep -o  '\) (normal|left|inverted|right) \(' | egrep -o '(normal|left|inverted|right)')"

# Using current screen orientation proceed to rotate screen and input devices.

case "$rotation" in
   normal)
    # rotate to the right
    xrandr -o right
    xsetwacom set "Serial Wacom Tablet stylus" rotate cw
    xinput set-prop "N-Trig MultiTouch" "Coordinate Transformation Matrix" 0 1 0 -1 0 1 0 0 1
    ;;
    right)
    # rotate to inverted
    xrandr -o inverted
     xsetwacom set "Serial Wacom Tablet stylus" rotate half
    xinput set-prop "N-Trig MultiTouch" "Coordinate Transformation Matrix" -1 0 1 0 -1 1 0 0 1
    ;;
    inverted)
    # rotate to the left
    xrandr -o left
    xsetwacom set "Serial Wacom Tablet stylus" rotate ccw
    xinput set-prop "N-Trig MultiTouch" "Coordinate Transformation Matrix" 0 -1 1 1 0 0 0 0 1
    ;;
    left)
    # rotate to normal
    xrandr -o normal
     xsetwacom set "Serial Wacom Tablet stylus" rotate none
    xinput set-prop "N-Trig MultiTouch" "Coordinate Transformation Matrix" 1 0 0 0 1 0 0 0 1
    ;;
esac

Дадим ему право на выполнение:
chmod +x rotation

В скрипте укажите название именно своего стилуса, иначе команда xsetwacom set скажет: Cannot find device '*** stylus'.

2

Re: Скрипт поворота экрана и стилуса для Linux

Спасибо!

Thumbs up Thumbs down