Jade Dungeon

旋转屏幕角度

旋转屏幕角度

带鱼屏无论横坚都不舒服,旋转22度显示:

旋转显示

First off, I could only get this to work in xorg - no wayland support yet.

xrandr --output HDMI-3 --transform lots of numbers here 

takes a transformation matrix thats used to position the screen. We can use that to rotate the display.

The basic syntax that we need for rotating and shifting is this

cos(x),-sin(x),shift_left,sin(x),cos(x),shift_up,0,0,1

Some examples

# these won't shift / center the display as I don't know the resolution

#-0.1
xrandr --output HDMI-3 --transform 0.999998476913288,0.00174532836589831,0,-0.00174532836589831,0.999998476913288,0,0,0,1
#1
xrandr --output HDMI-3 --transform 0.999847695156391,-0.0174524064372835,0,0.0174524064372835,0.999847695156391,0,0,0,1
#45
xrandr --output HDMI-3 --transform 0.707106781186548,-0.707106781186548,0,0.707106781186548,0.707106781186548,0,0,0,1
#22
xrandr --output HDMI-3 --transform 0.927183854566787,-0.374606593415912,0,0.374606593415912,0.927183854566787,0,0,0,1

计算公式:

function update_xrandr2(displayInput, angle, shiftX, shiftY) {
	let a =  Math.cos(angle * (Math.PI/180));
	let b = -Math.sin(angle * (Math.PI/180));
	let d =  Math.sin(angle * (Math.PI/180));
	let e =  Math.cos(angle * (Math.PI/180));
	return `xrandr --output ${displayInput} --transform ${a.toPrecision(5)},${b.toPrecision(5)},${shiftX},${d.toPrecision(5)},${e.toPrecision(5)},${shiftY},0,0,1`;
}