surface-tools/surface-tools-20180914git-autorotate-python3.patch

45 lines
1.7 KiB
Diff
Raw Permalink Normal View History

diff -Nru surface-tools-20180914git/autorotate/autorotate surface-tools-20180914git.patched/autorotate/autorotate
--- surface-tools-20180914git/autorotate/autorotate 2021-07-24 19:55:05.572617055 +0200
+++ surface-tools-20180914git.patched/autorotate/autorotate 2021-07-24 19:52:10.136395281 +0200
@@ -1,4 +1,4 @@
-#!/usr/bin/python
+#!/usr/bin/python3
#####CONFIGURATION#####
#sensorname="accel_3d"
@@ -55,7 +55,6 @@
val = val * scale / 9.8
else:
# Microsoft Surface (unsupported)
- print 1 << 16
if val & (1 << (16-1)) != 0:
val = val - (1 << 16)
return val
@@ -108,7 +107,7 @@
def checkRotation():
device = pyudev.Device.from_path(context, path)
- scale = float(device.attributes.__getitem__("in_accel_scale"))
+ scale = float(device.attributes.get("in_accel_scale"))
accelX = twos_comp(device.attributes.asint("in_accel_x_raw"), scale)
accelY = twos_comp(device.attributes.asint("in_accel_y_raw"), scale)
accelZ = twos_comp(device.attributes.asint("in_accel_z_raw"), scale)
@@ -131,7 +130,7 @@
"""Find which output to rotate, and get its current rotation"""
# Cache the xrandr info as we'll use it several times
-XRANDR_INFO = run_shell_cmd('xrandr --verbose')
+XRANDR_INFO = run_shell_cmd('xrandr --verbose').decode('utf-8')
# Find the display we are interested to move (= the laptop panel)
POSSIBLE_OUTPUT = [ "DSI1", "DSI-1", "eDP1", "LVDS", "LVDS1" ]
@@ -145,7 +144,7 @@
break
# Cache the xinput info
-XINPUT_INFO = run_shell_cmd('xinput --list --name-only')
+XINPUT_INFO = run_shell_cmd('xinput --list --name-only').decode('utf-8')
# Find the display we are interested to move (= the laptop panel)
POSSIBLE_OUTPUT = [ "CHPN0001:00" ]