hardware:t4220:screen-rotate
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revision | |||
hardware:t4220:screen-rotate [2021/04/29 09:16] – [Manually rotation screen] tormec | hardware:t4220:screen-rotate [2023/05/28 16:37] (current) – external edit 127.0.0.1 | ||
---|---|---|---|
Line 1: | Line 1: | ||
+ | ====== Manually rotation screen ====== | ||
+ | |||
+ | The following procedures allow to rotate the screen by means of two different methods: | ||
+ | - choose of the orientation, | ||
+ | - clockwise rotation at intervals of 90°. | ||
+ | |||
+ | <WRAP important> | ||
+ | **Important: | ||
+ | |||
+ | However, when the monitor is rotated in the portrait format, this resolution is no longer supported and it's necessary to come down at 1024x768 px. | ||
+ | </ | ||
+ | |||
+ | |||
+ | ===== Packages required ===== | ||
+ | |||
+ | From Synaptic, install the packages:: | ||
+ | |||
+ | * '' | ||
+ | * '' | ||
+ | |||
+ | After that, restart the PC. | ||
+ | |||
+ | |||
+ | ===== Get pointing system name ===== | ||
+ | |||
+ | So that pointing systems, also called '' | ||
+ | |||
+ | To list them, give the command: | ||
+ | |||
+ | <code bash> | ||
+ | xinput | ||
+ | </ | ||
+ | |||
+ | |||
+ | ===== Script for rotate the monitor ===== | ||
+ | |||
+ | Save in ''/ | ||
+ | |||
+ | <code python gui.py> | ||
+ | # | ||
+ | |||
+ | import tkinter as tk | ||
+ | import rotate | ||
+ | |||
+ | |||
+ | class App(tk.Frame, | ||
+ | def __init__(self, | ||
+ | """ | ||
+ | Initialize the class. | ||
+ | """ | ||
+ | tk.Frame.__init__(self, | ||
+ | self.grid() | ||
+ | self.createWidgets() | ||
+ | self.color_std = tk.Button.cget(self, | ||
+ | self.status(self.color_std) | ||
+ | |||
+ | def createWidgets(self): | ||
+ | """ | ||
+ | Create the buttons to choose the direction. | ||
+ | """ | ||
+ | self.button_n = tk.Button(self) | ||
+ | self.button_n[" | ||
+ | self.button_n[" | ||
+ | self.button_n.grid(row=1, | ||
+ | |||
+ | self.button_l = tk.Button(self) | ||
+ | self.button_l[" | ||
+ | self.button_l[" | ||
+ | self.button_l.grid(row=2, | ||
+ | |||
+ | self.button_r = tk.Button(self) | ||
+ | self.button_r[" | ||
+ | self.button_r[" | ||
+ | self.button_r.grid(row=3, | ||
+ | |||
+ | self.button_i = tk.Button(self) | ||
+ | self.button_i[" | ||
+ | self.button_i[" | ||
+ | self.button_i.grid(row=4, | ||
+ | |||
+ | def status(self, | ||
+ | """ | ||
+ | Depending on the current direction, highlight the relative button. | ||
+ | """ | ||
+ | cur_dir = rotate.get_direction() | ||
+ | if (cur_dir == " | ||
+ | self.button_n[" | ||
+ | self.button_l[" | ||
+ | self.button_r[" | ||
+ | self.button_i[" | ||
+ | elif (cur_dir == " | ||
+ | self.button_n[" | ||
+ | self.button_l[" | ||
+ | self.button_r[" | ||
+ | self.button_i[" | ||
+ | elif (cur_dir == " | ||
+ | self.button_n[" | ||
+ | self.button_l[" | ||
+ | self.button_r[" | ||
+ | self.button_i[" | ||
+ | elif (cur_dir == " | ||
+ | self.button_n[" | ||
+ | self.button_l[" | ||
+ | self.button_r[" | ||
+ | self.button_i[" | ||
+ | |||
+ | def call_normal(self): | ||
+ | """ | ||
+ | Invoke the methods that rotate the screen to normal. | ||
+ | """ | ||
+ | cur_dir = rotate.get_direction() | ||
+ | new_dir = " | ||
+ | rotate.choose(cur_dir, | ||
+ | self.status(self.color_std) | ||
+ | |||
+ | def call_left(self): | ||
+ | """ | ||
+ | Invoke the methods that rotate the screen to left. | ||
+ | """ | ||
+ | cur_dir = rotate.get_direction() | ||
+ | new_dir = " | ||
+ | rotate.choose(cur_dir, | ||
+ | self.status(self.color_std) | ||
+ | |||
+ | def call_right(self): | ||
+ | """ | ||
+ | Invoke the methods that rotate the screen to right. | ||
+ | """ | ||
+ | cur_dir = rotate.get_direction() | ||
+ | new_dir = " | ||
+ | rotate.choose(cur_dir, | ||
+ | self.status(self.color_std) | ||
+ | |||
+ | def call_inverted(self): | ||
+ | """ | ||
+ | Invoke the methods that rotate the screen to upside-down. | ||
+ | """ | ||
+ | cur_dir = rotate.get_direction() | ||
+ | new_dir = " | ||
+ | rotate.choose(cur_dir, | ||
+ | self.status(self.color_std) | ||
+ | |||
+ | |||
+ | if __name__ == ' | ||
+ | root = tk.Tk() | ||
+ | rotate = rotate.Rotate() | ||
+ | app = App(master=root) | ||
+ | app.master.title("" | ||
+ | app.mainloop() | ||
+ | |||
+ | </ | ||
+ | # | ||
+ | |||
+ | import subprocess | ||
+ | import re | ||
+ | |||
+ | |||
+ | STYLUS = " | ||
+ | TOUCH = " | ||
+ | RES_1 = " | ||
+ | RES_2 = " | ||
+ | CMT_N = [" | ||
+ | CMT_L = [" | ||
+ | CMT_R = [" | ||
+ | CMT_I = [" | ||
+ | |||
+ | |||
+ | class Rotate(object): | ||
+ | |||
+ | def get_direction(self): | ||
+ | """ | ||
+ | Extract the actual direction of the screen. | ||
+ | |||
+ | executing the bash command: | ||
+ | xrandr | grep ' connected' | ||
+ | we get a line of the form: | ||
+ | "LVDS1 connected 1400x1050+0+0 < | ||
+ | (normal left inverted right x axis y axis) | ||
+ | 0mm x 0mm" | ||
+ | where: | ||
+ | < | ||
+ | but if: | ||
+ | < | ||
+ | the screen is in " | ||
+ | |||
+ | OUTPUT | ||
+ | cur_dir: (str) the name of the current direction among | ||
+ | " | ||
+ | """ | ||
+ | line = subprocess.check_output(" | ||
+ | | ||
+ | |||
+ | p = re.compile(r' | ||
+ | m = p.search(str(line)) | ||
+ | |||
+ | if m: | ||
+ | cur_dir = str(m.group()) | ||
+ | else: | ||
+ | cur_dir = " | ||
+ | |||
+ | return cur_dir | ||
+ | |||
+ | def choose(self, | ||
+ | """ | ||
+ | Depending on the current direction and the new direction, call the | ||
+ | appropriate function which sets the new direction of the screen. | ||
+ | |||
+ | INPUT | ||
+ | cur_dir: (str) the name of the current direction among | ||
+ | " | ||
+ | new_dir: (str) the name of the new direction among | ||
+ | " | ||
+ | """ | ||
+ | if (cur_dir == " | ||
+ | if (new_dir == " | ||
+ | self.set_left() | ||
+ | elif (new_dir == " | ||
+ | self.set_right() | ||
+ | elif (new_dir == " | ||
+ | self.set_inverted() | ||
+ | if (cur_dir == " | ||
+ | if (new_dir == " | ||
+ | self.set_normal() | ||
+ | elif (new_dir == " | ||
+ | self.set_right() | ||
+ | elif (new_dir == " | ||
+ | self.set_inverted() | ||
+ | elif (cur_dir == " | ||
+ | if (new_dir == " | ||
+ | self.set_normal() | ||
+ | elif (new_dir == " | ||
+ | self.set_left() | ||
+ | elif (new_dir == " | ||
+ | self.set_inverted() | ||
+ | elif (cur_dir == " | ||
+ | if (new_dir == " | ||
+ | self.set_normal() | ||
+ | elif (new_dir == " | ||
+ | self.set_left() | ||
+ | elif (new_dir == " | ||
+ | self.set_right() | ||
+ | |||
+ | def set_normal(self): | ||
+ | """ | ||
+ | Rotate the screen to normal. | ||
+ | """ | ||
+ | subprocess.call([" | ||
+ | subprocess.call([" | ||
+ | subprocess.call([" | ||
+ | subprocess.call([" | ||
+ | " | ||
+ | |||
+ | def set_left(self): | ||
+ | """ | ||
+ | Rotate the screen to left. | ||
+ | |||
+ | In this direction, the screen can support only 1024x768 resolution. | ||
+ | """ | ||
+ | subprocess.call([" | ||
+ | subprocess.call([" | ||
+ | subprocess.call([" | ||
+ | subprocess.call([" | ||
+ | " | ||
+ | |||
+ | def set_right(self): | ||
+ | """ | ||
+ | Rotate the screen to right. | ||
+ | |||
+ | In this direction, the screen can support only 1024x768 resolution. | ||
+ | """ | ||
+ | subprocess.call([" | ||
+ | subprocess.call([" | ||
+ | subprocess.call([" | ||
+ | subprocess.call([" | ||
+ | " | ||
+ | |||
+ | def set_inverted(self): | ||
+ | """ | ||
+ | Rotate the screen upside-down. | ||
+ | """ | ||
+ | subprocess.call([" | ||
+ | subprocess.call([" | ||
+ | subprocess.call([" | ||
+ | subprocess.call([" | ||
+ | " | ||
+ | |||
+ | def bezel_button(self): | ||
+ | """ | ||
+ | Depending on the current direction, perform rotation in counter | ||
+ | clock wise in the followin order: | ||
+ | left | ||
+ | inverted | ||
+ | right | ||
+ | normal | ||
+ | """ | ||
+ | cur_dir = self.get_direction() | ||
+ | if (cur_dir == " | ||
+ | self.set_left() | ||
+ | elif (cur_dir == " | ||
+ | self.set_inverted() | ||
+ | elif (cur_dir == " | ||
+ | self.set_right() | ||
+ | elif (cur_dir == " | ||
+ | self.set_normal() | ||
+ | |||
+ | |||
+ | if __name__ == ' | ||
+ | rotate = Rotate() | ||
+ | rotate.bezel_button() | ||
+ | |||
+ | </ | ||
+ | |||
+ | |||
+ | ===== Connect the script to a panel button ===== | ||
+ | |||
+ | Add a launcher in the panel as follows: | ||
+ | |||
+ | ^ Command | '' | ||
+ | ^ Working Directory | ''/ | ||
+ | |||
+ | |||
+ | ===== Connect the script to a bezel button ===== | ||
+ | |||
+ | Bezel buttons are those ones around the monitor frame. Hereafter the steps to associate an action to a given bezel button using its '' | ||
+ | |||
+ | - Run the command <code bash> | ||
+ | xev | ||
+ | </ | ||
+ | - Hit the button to use for the monitor rotation and write down its '' | ||
+ | < | ||
+ | {{ hardware: | ||
+ | < | ||
+ | Bezel button choosen for the monitor rotation and relative output of the command '' | ||
+ | </ | ||
+ | </ | ||
+ | - Edit the file ''/ | ||
+ | // key < | ||
+ | key < | ||
+ | </ | ||
+ | key < | ||
+ | // key < | ||
+ | // key < | ||
+ | </ | ||
+ | - Eventually clean the cache in ''/ | ||
+ | - In '' | ||
+ | ^ Shortcut | '' | ||
+ | ^ Command | '' | ||
+ | </ | ||
+ | |||
+ | |||
+ | ===== Links ===== | ||
+ | |||
+ | - The original guide: [[http:// | ||
+ | - List of symbolic codes: [[http:// | ||
+ | |||
hardware/t4220/screen-rotate.txt · Last modified: 2023/05/28 16:37 by 127.0.0.1