Ultrabooks, tablets en zelfs klassieke monitors kunnen gekanteld worden. Sommige toepassingen ogen namelijk beter op een monitor in landschap stand (breed en minder hoog) en andere op een monitor in portret stand (hoog en minder breed). Zo kijk je naar films op een monitor in landschap stand en lees je een e-boek in portret stand. Het blijft me zelfs verwonderen dat in kantoren je bijna nergens monitors in portret stand ziet, hoewel tekstverwerking meestal met pagina's in staand formaat gebruikt wordt (klassieke A4 pagina's).
Toepassingen als arandr, het bij de lichtgewicht LXDE grafische omgeving ingebouwde lxrandr en het in KDE ingebouwde kscreen zorgen voor de muis bediende methode om de scherminhoud naargelang de stand van de monitor te kantelen. In KDE start je Kicker > Systeeminstellingen, waarna je de module Scherm en monitor start. In de categorie Instellingen van het scherm kan je met behulp van een klik op de knop met de cirkelvormige pijl de scherminhoud draaien. Eénmaal de gekozen draaiing ingesteld, pas je ze toe door op de knop Toepassen te klikken.
Je hebt dan echter een probleem met de muis, die beweegt de muiswijzer nog steeds alsof de scherminhoud niet gedraaid is, wat erg vervelend is.
Alle hierboven genoemde grafische programma's gebruiken op de achtergrond de opdracht xrandr om de scherminhoud effectief te draaien.
Eerst en vooral gaan we wat informatie opvragen:
dany@linux-nlfy:~> xrandr -q --verbose
Screen 0: minimum 320 x 200, current 1920 x 1080, maximum 32767 x 32767
eDP1 connected 1920x1080+0+0 (0x4a) normal (normal left inverted right x axis y axis) 276mm x 156mm
Identifier: 0x43
Timestamp: 3521985
Subpixel: unknown
Gamma: 1.0:1.0:1.0
Brightness: 1.0
Clones:
CRTC: 0
CRTCs: 0 1 2
Transform: 1.000000 0.000000 0.000000
0.000000 1.000000 0.000000
0.000000 0.000000 1.000000
filter:
EDID:
00ffffffffffff0030e4140400000000
00170104951c107802b5459959579127
1f505400000001010101010101010101
010101010101163680ba70380f403020
3500149c1000001a0000000000000000
00000000000000000000000000fe004c
4720446973706c61790a2020000000fe
004c503132355746322d5350423100c4
BACKLIGHT: 60
range: (0, 100)
Backlight: 60
range: (0, 100)
scaling mode: Full aspect
supported: None, Full, Center, Full aspect
Broadcast RGB: Automatic
supported: Automatic, Full, Limited 16:235
audio: auto
supported: force-dvi, off, auto, on
1920x1080 (0x4a) 138.5MHz +HSync -VSync *current +preferred
h: width 1920 start 1968 end 2000 total 2106 skew 0 clock 65.7KHz
v: height 1080 start 1083 end 1088 total 1095 clock 60.0Hz
1400x1050 (0xb1) 122.0MHz +HSync +VSync
h: width 1400 start 1488 end 1640 total 1880 skew 0 clock 64.9KHz
v: height 1050 start 1052 end 1064 total 1082 clock 60.0Hz
1280x1024 (0xb2) 108.0MHz +HSync +VSync
h: width 1280 start 1328 end 1440 total 1688 skew 0 clock 64.0KHz
v: height 1024 start 1025 end 1028 total 1066 clock 60.0Hz
1280x960 (0xb3) 108.0MHz +HSync +VSync
h: width 1280 start 1376 end 1488 total 1800 skew 0 clock 60.0KHz
v: height 960 start 961 end 964 total 1000 clock 60.0Hz
1024x768 (0xb4) 65.0MHz -HSync -VSync
h: width 1024 start 1048 end 1184 total 1344 skew 0 clock 48.4KHz
v: height 768 start 771 end 777 total 806 clock 60.0Hz
800x600 (0xb5) 40.0MHz +HSync +VSync
h: width 800 start 840 end 968 total 1056 skew 0 clock 37.9KHz
v: height 600 start 601 end 605 total 628 clock 60.3Hz
800x600 (0xb6) 36.0MHz +HSync +VSync
h: width 800 start 824 end 896 total 1024 skew 0 clock 35.2KHz
v: height 600 start 601 end 603 total 625 clock 56.2Hz
640x480 (0xb7) 25.2MHz -HSync -VSync
h: width 640 start 656 end 752 total 800 skew 0 clock 31.5KHz
v: height 480 start 490 end 492 total 525 clock 59.9Hz
DP1 disconnected (normal left inverted right x axis y axis)
Identifier: 0x44
Timestamp: 3521985
Subpixel: unknown
Clones: HDMI1
CRTCs: 0 1 2
Transform: 1.000000 0.000000 0.000000
0.000000 1.000000 0.000000
0.000000 0.000000 1.000000
filter:
Broadcast RGB: Automatic
supported: Automatic, Full, Limited 16:235
audio: auto
supported: force-dvi, off, auto, on
HDMI1 disconnected (normal left inverted right x axis y axis)
Identifier: 0x45
Timestamp: 3521985
Subpixel: unknown
Clones: DP1
CRTCs: 0 1 2
Transform: 1.000000 0.000000 0.000000
0.000000 1.000000 0.000000
0.000000 0.000000 1.000000
filter:
Broadcast RGB: Automatic
supported: Automatic, Full, Limited 16:235
audio: auto
supported: force-dvi, off, auto, on
DP2 disconnected (normal left inverted right x axis y axis)
Identifier: 0x46
Timestamp: 3521985
Subpixel: unknown
Clones: HDMI2
CRTCs: 0 1 2
Transform: 1.000000 0.000000 0.000000
0.000000 1.000000 0.000000
0.000000 0.000000 1.000000
filter:
Broadcast RGB: Automatic
supported: Automatic, Full, Limited 16:235
audio: auto
supported: force-dvi, off, auto, on
HDMI2 disconnected (normal left inverted right x axis y axis)
Identifier: 0x47
Timestamp: 3521985
Subpixel: unknown
Clones: DP2
CRTCs: 0 1 2
Transform: 1.000000 0.000000 0.000000
0.000000 1.000000 0.000000
0.000000 0.000000 1.000000
filter:
Broadcast RGB: Automatic
supported: Automatic, Full, Limited 16:235
audio: auto
supported: force-dvi, off, auto, on
VIRTUAL1 disconnected (normal left inverted right x axis y axis)
Identifier: 0x48
Timestamp: 3521985
Subpixel: no subpixels
Clones:
CRTCs: 3
Transform: 1.000000 0.000000 0.000000
0.000000 1.000000 0.000000
0.000000 0.000000 1.000000
filter:
Uit bovenstaande uitvoer kan je afleiden dat het in de ultrabook ingebouwde scherm eDP1 is aangesloten (connected) en in de normale (normal) stand staat (standaard oriëntatie). Deze informatie kan je afzonderen door deze te filteren, handig voor het gebruik in een script (zie verder).
dany@linux-nlfy:~> xrandr -q --verbose | grep 'connected' | egrep -o '\) (normal|left|inverted|right) \(' | egrep -o '(normal|left|inverted|right)'
normal
Om de scherminhoud effectief te draaien, gebruik je de opdrachten xrandr -o left
, xrandr -o inverted
, xrandr -o right
en xrandr -o normal
om de scherminhoud respectievelijk 90°, 180°, 270° en 0° te draaien.
Deze laatste opdracht gebruik je om de standaard oriëntatie te herstellen.
Om de werking van de invoerapparaten aan te passen, heb je extra software nodig. Installeer het pakket xinput met de opdracht:
dany@linux-nlfy:~> sudo zypper install xinput
Daarna kan je een lijst met de verschillende invoerapparaten opvragen met de opdracht:
dany@linux-nlfy:~> xinput --list
Virtual core pointer id=2 [master pointer (3)]
⎜ ↳ Virtual core XTEST pointer id=4 [slave pointer (2)]
⎜ ↳ ELAN Touchscreen id=9 [slave pointer (2)]
⎜ ↳ Wacom ISDv4 EC Pen stylus id=11 [slave pointer (2)]
⎜ ↳ SynPS/2 Synaptics TouchPad id=13 [slave pointer (2)]
⎜ ↳ Wacom ISDv4 EC Pen eraser id=15 [slave pointer (2)]
⎜ ↳ TPPS/2 IBM TrackPoint id=16 [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)]
↳ Power Button id=8 [slave keyboard (3)]
↳ Integrated Camera id=10 [slave keyboard (3)]
↳ AT Translated Set 2 keyboard id=12 [slave keyboard (3)]
↳ ThinkPad Extra Buttons id=14 [slave keyboard (3)]
Uit de uitvoer blijkt dat er verschillende invoerapparaten de muiswijzer sturen. Laat ons beginnen met het touchpad.
Om de eigenschappen (instellingen) van het touchpad op te vragen, gebruik je de volgende opdracht:
dany@linux-nlfy:~> xinput --list-props "SynPS/2 Synaptics TouchPad"
Device 'SynPS/2 Synaptics TouchPad':
Device Enabled (134): 1
Coordinate Transformation Matrix (136): 1.000000, 0.000000, 0.000000, 0.000000, 1.000000, 0.000000, 0.000000, 0.000000, 1.000000
Device Accel Profile (268): 1
Device Accel Constant Deceleration (269): 2.500000
Device Accel Adaptive Deceleration (270): 1.000000
Device Accel Velocity Scaling (271): 12.500000
Synaptics Edges (314): 1768, 5414, 1638, 4466
Synaptics Finger (315): 25, 30, 0
Synaptics Tap Time (316): 180
Synaptics Tap Move (317): 235
Synaptics Tap Durations (318): 180, 180, 100
Synaptics ClickPad (319): 1
Synaptics Middle Button Timeout (320): 0
Synaptics Two-Finger Pressure (321): 282
Synaptics Two-Finger Width (322): 7
Synaptics Scrolling Distance (323): 107, 0
Synaptics Edge Scrolling (324): 0, 0, 0
Synaptics Two-Finger Scrolling (325): 1, 0
Synaptics Move Speed (326): 1.000000, 1.750000, 0.037293, 0.000000
Synaptics Off (327): 0
Synaptics Locked Drags (328): 0
Synaptics Locked Drags Timeout (329): 5000
Synaptics Tap Action (330): 0, 0, 0, 0, 1, 3, 2
Synaptics Click Action (331): 1, 3, 2
Synaptics Circular Scrolling (332): 0
Synaptics Circular Scrolling Distance (333): 0.100000
Synaptics Circular Scrolling Trigger (334): 0
Synaptics Palm Detection (335): 0
Synaptics Palm Dimensions (336): 10, 200
Synaptics Coasting Speed (337): 20.000000, 50.000000
Synaptics Pressure Motion (338): 30, 160
Synaptics Pressure Motion Factor (339): 1.000000, 1.000000
Synaptics Grab Event Device (340): 1
Synaptics Gestures (341): 1
Synaptics Capabilities (342): 1, 0, 0, 1, 1, 1, 1
Synaptics Pad Resolution (343): 55, 53
Synaptics Area (344): 0, 0, 0, 0
Synaptics Soft Button Areas (345): 3591, 0, 4104, 0, 0, 0, 0, 0
Synaptics Noise Cancellation (346): 8, 8
Device Product ID (255): 2, 7
Device Node (256): "/dev/input/event4"
Voor ons is de eigenschap Coordinate Transformation Matrix van belang. Deze eigenschap is een matrix met standaard de volgende waarden:
⎡ 1 0 0 ⎤ ⎜ 0 1 0 ⎥ ⎣ 0 0 1 ⎦
Bij een touchpad positie op coördinaat 400, 197 wordt de scherm positie als volgt berekend:
⎡ 1 0 0 ⎤ ⎡ 400 ⎤ ⎡ 400 ⎤ ⎜ 0 1 0 ⎥ · ⎜ 197 ⎥ = ⎜ 197 ⎥ ⎣ 0 0 1 ⎦ ⎣ 1 ⎦ ⎣ 1 ⎦
Met andere woorden zonder verandering worden de touchpad coördinaten aan het scherm doorgegeven. Bij een geroteerd scherm moeten de touchpad coördinaten echter een andere positie aan het scherm doorgeven, de scherminhoud is namelijk gedraaid, maar het touchpad behoud dezelfde oriëntatie.
Voor een naar links geroteerd scherm (90° gedraaid), hebben we de volgende matrix nodig:
⎡ 0 -1 1 ⎤ ⎜ 1 0 0 ⎥ ⎣ 0 0 1 ⎦
Voor een scherm op zijn kop (180°):
⎡ -1 0 1 ⎤ ⎜ 0 -1 1 ⎥ ⎣ 0 0 1 ⎦
En voor een naar rechts geroteerd scherm (270°):
⎡ 0 1 0 ⎤ ⎜ -1 0 1 ⎥ ⎣ 0 0 1 ⎦
De volgende opdrachten zorgen bij een respectievelijk 90°, 180°, 270° en 0° geroteerd scherm voor een correcte muiswijzer beweging bij het werken met het touchpad:
xinput --set-prop "SynPS/2 Synaptics TouchPad" "Coordinate Transformation Matrix" 0 -1 1 1 0 0 0 0 1
xinput --set-prop "SynPS/2 Synaptics TouchPad" "Coordinate Transformation Matrix" -1 0 1 0 -1 1 0 0 1
xinput --set-prop "SynPS/2 Synaptics TouchPad" "Coordinate Transformation Matrix" 0 1 0 -1 0 1 0 0 1
xinput --set-prop "SynPS/2 Synaptics TouchPad" "Coordinate Transformation Matrix" 1 0 0 0 1 0 0 0 1
Passen we dezelfde methode toe voor het touchscreen, dan bekomen we de volgende opdrachten:
xinput --set-prop "ELAN Touchscreen" "Coordinate Transformation Matrix" 0 -1 1 1 0 0 0 0 1
xinput --set-prop "ELAN Touchscreen" "Coordinate Transformation Matrix" -1 0 1 0 -1 1 0 0 1
xinput --set-prop "ELAN Touchscreen" "Coordinate Transformation Matrix" 0 1 0 -1 0 1 0 0 1
xinput --set-prop "ELAN Touchscreen" "Coordinate Transformation Matrix" 1 0 0 0 1 0 0 0 1
De hier gebruikte pen heeft meer dan één apparaat, namelijk stylus en eraser, vandaar twee opdrachten per stand. Voor de stylus:
xinput --set-prop "Wacom ISDv4 EC Pen stylus" "Coordinate Transformation Matrix" 0 -1 1 1 0 0 0 0 1
xinput --set-prop "Wacom ISDv4 EC Pen stylus" "Coordinate Transformation Matrix" -1 0 1 0 -1 1 0 0 1
xinput --set-prop "Wacom ISDv4 EC Pen stylus" "Coordinate Transformation Matrix" 0 1 0 -1 0 1 0 0 1
xinput --set-prop "Wacom ISDv4 EC Pen stylus" "Coordinate Transformation Matrix" 1 0 0 0 1 0 0 0 1
Voor de eraser:
xinput --set-prop "Wacom ISDv4 EC Pen eraser" "Coordinate Transformation Matrix" 0 -1 1 1 0 0 0 0 1
xinput --set-prop "Wacom ISDv4 EC Pen eraser" "Coordinate Transformation Matrix" -1 0 1 0 -1 1 0 0 1
xinput --set-prop "Wacom ISDv4 EC Pen eraser" "Coordinate Transformation Matrix" 0 1 0 -1 0 1 0 0 1
xinput --set-prop "Wacom ISDv4 EC Pen eraser" "Coordinate Transformation Matrix" 1 0 0 0 1 0 0 0 1
Deze methode kan verder gebruikt worden voor elk invoerapparaat. Het hierboven gevonden trackpoint komt hiervoor in aanmerking en een eventueel aangesloten muis. Het trackpoint gebruik ik nooit en ook een muis sluit ik nooit op mijn ultrabook aan. Vandaar dat ik deze niet aanpas bij het roteren van het scherm.
De bovenstaande opdrachten kan je nu samenbrengen tot een handig script waarmee je de rotatie in een oogwenk kunt uitvoeren:
#!/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 left
xrandr -o left
xinput --set-prop "SynPS/2 Synaptics TouchPad" "Coordinate Transformation Matrix" 0 -1 1 1 0 0 0 0 1
xinput --set-prop "ELAN Touchscreen" "Coordinate Transformation Matrix" 0 -1 1 1 0 0 0 0 1
xinput --set-prop "Wacom ISDv4 EC Pen stylus" "Coordinate Transformation Matrix" 0 -1 1 1 0 0 0 0 1
xinput --set-prop "Wacom ISDv4 EC Pen eraser" "Coordinate Transformation Matrix" 0 -1 1 1 0 0 0 0 1
;;
left)
# rotate to inverted
xrandr -o inverted
xinput --set-prop "SynPS/2 Synaptics TouchPad" "Coordinate Transformation Matrix" -1 0 1 0 -1 1 0 0 1
xinput --set-prop "ELAN Touchscreen" "Coordinate Transformation Matrix" -1 0 1 0 -1 1 0 0 1
xinput --set-prop "Wacom ISDv4 EC Pen stylus" "Coordinate Transformation Matrix" -1 0 1 0 -1 1 0 0 1
xinput --set-prop "Wacom ISDv4 EC Pen eraser" "Coordinate Transformation Matrix" -1 0 1 0 -1 1 0 0 1
;;
inverted)
# rotate to the right
xrandr -o right
xinput --set-prop "SynPS/2 Synaptics TouchPad" "Coordinate Transformation Matrix" 0 1 0 -1 0 1 0 0 1
xinput --set-prop "ELAN Touchscreen" "Coordinate Transformation Matrix" 0 1 0 -1 0 1 0 0 1
xinput --set-prop "Wacom ISDv4 EC Pen stylus" "Coordinate Transformation Matrix" 0 1 0 -1 0 1 0 0 1
xinput --set-prop "Wacom ISDv4 EC Pen eraser" "Coordinate Transformation Matrix" 0 1 0 -1 0 1 0 0 1
;;
right)
# rotate to normal
xrandr -o normal
xinput --set-prop "SynPS/2 Synaptics TouchPad" "Coordinate Transformation Matrix" 1 0 0 0 1 0 0 0 1
xinput --set-prop "ELAN Touchscreen" "Coordinate Transformation Matrix" 1 0 0 0 1 0 0 0 1
xinput --set-prop "Wacom ISDv4 EC Pen stylus" "Coordinate Transformation Matrix" 1 0 0 0 1 0 0 0 1
xinput --set-prop "Wacom ISDv4 EC Pen eraser" "Coordinate Transformation Matrix" 1 0 0 0 1 0 0 0 1
;;
esac
Sla dit script op (bijvoorbeeld in de bin map van de persoonlijke map). Om het scherm naar de volgende stand te roteren, voer je de volgende opdracht uit:
dany@linux-nlfy:~> sh $HOME/bin/rotate.sh
Nog beter wordt het als je het script bij het indrukken van een knop (toets) kunt laten uitvoeren.
Dit kan met behulp van het pakket xbindkeys (installeren via de site http://software.opensuse.org.
Met de opdracht xbindkeys -mk
kan je door het drukken op een toets (of -combinatie) bepalen welke codes het besturingssysteem doorkrijgt.
Zo bleek mijn ultrabook op de zijkant een knopje te hebben die in KDE toch niet gebruikt wordt.
dany@linux-nlfy:~> xbindkeys -mk
Press combination of keys or/and click under the window.
You can use one of the two lines after "NoCommand"
in $HOME/.xbindkeysrc to bind a key.
--- Press "q" to stop. ---
"(Scheme function)"
m:0x50 + c:32
Mod2+Mod4 + o
"(Scheme function)"
m:0x50 + c:133
Mod2+Mod4 + Super_L
"(Scheme function)"
m:0x10 + c:38
Mod2 + q
Na het aanmaken van een configuratiebestand voor xbindkeys:
dany@linux-nlfy:~>echo -e "\"sh $HOME/bin/rotate.sh\"" > $HOME/.xbindkeysrc
dany@linux-nlfy:~>echo " Mod2+Mod4 + o" >> $HOME/.xbindkeysrc
En het starten van xbindkeys:
dany@linux-nlfy:~> xbindkeys
Wordt bij elke druk op de betreffende knop het scherm gedraaid. xbindkeys afsluiten, doe je met de opdracht:
dany@linux-nlfy:~> killall xbindkeys
Als alles naar behoren werkt, kan je xbindkeys automatisch starten bij het starten van KDE met behulp van de opdracht:
dany@linux-nlfy:~> ln -s /usr/bin/xbindkeys $HOME/.kde4/Autostart/
Sommige ultrabooks, tablets, enz. produceren een toetscode bij het kantelen van het toestel, mits wat aanpassingen van het script en het xbindkeys configuratiebestand moet het mogelijk zijn de scherminhoud te draaien bij het draaien van het toestel. Veel geluk ermee