平板电脑
本文汇总了在平板电脑上运行 Arch Linux 的信息。这些说明包含关于如何在此类设备上正确使用触摸键盘、触控笔、触控笔旋转和屏幕旋转的信息。
触控笔
- 要手动配置样式设备(尽管不建议这样做),请参阅 Linux Wacom Project Wiki。
- 如果在安装 xf86-input-wacom 后,您的键盘在 X 中停止正常工作,请注释掉
/usr/share/X11/xorg.conf.d/70-wacom.conf
中所有不必要的条目,并将结果文件放入/etc/xorg.conf.d/70-wacom.conf
。
屏幕键盘
请参阅 List of applications/Utilities#屏幕键盘。
使用 GNOME
根据您的设备,当您点击文本输入字段时,默认的 GNOME 屏幕键盘将自动工作。如果您的设备上“平板模式”检测不起作用(mutter 问题),您可能需要自定义Gnome 设置 > 辅助功能。
启用屏幕键盘 将使其在文本输入字段获得焦点时始终显示。
始终显示辅助功能菜单 将允许您根据需要手动启用或禁用此功能。
旋转
屏幕旋转
启用 Xserver 选项
除非您运行的是非常旧的 Xserver,否则旋转功能(包含在 xrandr 中)默认情况下应已启用。 如果未启用,您可以通过将以下选项添加到 xorg.conf 文件的 Screen 部分来启用 xrandr。
Option "RandRRotation" "on"
保存文件并重启 xserver 以使更改生效。
使用 xrandr
最简单的方法是使用
xrandr -o 1 #portrait mode xrandr -o 0 #back to normal
或类似地
xrandr -o left #portrait mode xrandr -o normal #back to normal
在某些驱动程序上,使用 xrandr -o 1
或 xrandr -o left
旋转屏幕会搞砸 dpi:字体变得无法阅读。 xrandr -o
选项相当旧。 使用 --rotate
可以解决问题,但我们需要首先指定 --output
选项。 使用 xrandr
识别所需的设备,然后键入类似如下内容
xrandr --output eDP --rotate left
触控笔旋转
使用 xsetwacom
如果尚未完成,并且类似于 绘图板,获得触摸面板输入也旋转的一种方法是 安装 xf86-input-wacom Xorg 驱动程序,就像上面建议的那样。 完成后,有各种命令可用于操作和管理触摸面板的输入。
要将触控笔输入设置为纵向模式
$ xsetwacom set stylus Rotate cw
返回横向模式
$ xsetwacom set stylus Rotate none
如果找不到设备“stylus”,请使用
$ xsetwacom list devices
获取设备列表。
例如
xsetwacom set "Wacom Co.,Ltd. Pen and multitouch sensor Pen stylus" Rotate cw
来源:https://xournal.sourceforge.net/manual.html
如果您仍然无法更改旋转,您可以尝试使用 xinput。
使用 xinput
您也可以使用 xinput 来旋转触控笔,就像旋转触摸屏一样。
要将触控笔输入设置为纵向模式
xinput set-prop <Name of Stylus|Touch Screen> --type=float "Coordinate Transformation Matrix" 0 -1 1 1 0 0 0 0 1
返回横向模式
xinput set-prop <Name of Stylus|Touch Screen> --type=float "Coordinate Transformation Matrix" 0 0 0 0 0 0 0 0 0
如果在使用“xinput list”时,您的触控笔仅被列为键盘,这些是我的结果
$ xinput list
⎡ Virtual core pointer id=2 [master pointer (3)] ⎜ ↳ SynPS/2 Synaptics TouchPad id=14 [slave pointer (2)] ⎣ Virtual core keyboard id=3 [master keyboard (2)] ↳ Virtual core XTEST keyboard id=5 [slave keyboard (3)] ↳ ELAN0732:00 04F3:272A Pen id=11 [slave keyboard (3)] #My Pen
您可以尝试用笔触摸屏幕
$ xinput list
⎡ Virtual core pointer id=2 [master pointer (3)] ⎜ ↳ SynPS/2 Synaptics TouchPad id=14 [slave pointer (2)] ⎜ ↳ ELAN0732:00 04F3:272A Pen Pen (0) id=17 [slave pointer (2)] #My Pen Pointer ⎣ Virtual core keyboard id=3 [master keyboard (2)] ↳ Virtual core XTEST keyboard id=5 [slave keyboard (3)] ↳ ELAN0732:00 04F3:272A Pen id=11 [slave keyboard (3)] #My Pen Keyboard
使用现在列出的指针,命令应该按预期工作,旋转触控笔。
这在我的 HP Envy x360 上有效。
Xfce:触控笔和屏幕旋转
以下脚本将在每次执行时将显示器顺时针旋转 90 度。 它还将旋转 Wacom 指针,以便触控笔仍然可以工作。
rotate.sh
#!/bin/bash case $(xfconf-query -c pointers -p /Wacom_ISDv4_90_Pen_stylus/Properties/Wacom_Rotation) in 2) # Currently top is rotated left, we should set it normal (0°) xrandr -o 0 xfconf-query -c pointers -p /Wacom_ISDv4_90_Pen_stylus/Properties/Wacom_Rotation -s 0 xfconf-query -c xsettings -p /Xft/RGBA -s rgb ;; 0) # Screen is not rotated, we should rotate it right (90°) xrandr -o 3 xfconf-query -c pointers -p /Wacom_ISDv4_90_Pen_stylus/Properties/Wacom_Rotation -s 1 xfconf-query -c xsettings -p /Xft/RGBA -s vbgr ;; 1) # Top of screen is rotated right, we should invert it (180°) xrandr -o 2 xfconf-query -c pointers -p /Wacom_ISDv4_90_Pen_stylus/Properties/Wacom_Rotation -s 3 xfconf-query -c xsettings -p /Xft/RGBA -s bgr ;; 3) # Screen is inverted, we should rotate it left (270°) xrandr -o 1 xfconf-query -c pointers -p /Wacom_ISDv4_90_Pen_stylus/Properties/Wacom_Rotation -s 2 xfconf-query -c xsettings -p /Xft/RGBA -s vrgb ;; *) echo "Unknown result from 'xfconf-query -c pointers -p /Wacom_ISDv4_90_Pen_stylus/Properties/Wacom_Rotation'" >&2 exit 1 ;; esac
保存文件并使其成为可执行文件。
您可以在桌面或面板上创建它的链接,或者将其链接到键盘快捷键或平板电脑上的特殊按钮。
自动旋转
使用 xrandr + xinput
开发了以下 python 脚本以自动旋转屏幕和触摸屏。 此外,它还禁用了倒置、右侧和左侧方向的触摸板,并支持自动检测加速度计、触摸屏和触摸板设备。
它适用于加速度计通过工业 I/O 子系统 /sys/bus/iio/devices/iio:deviceX
通信的设备,其中 X 是设备的编号。 通常,有必要更改以下参数 dpath、devicename 和 touchpad。
请参阅 rotate.py 或 C 版本的脚本,旨在减少一些系统开销:2in1screen.c。
您将需要替换您实际的触摸设备名称并重新编译。 重新编译的说明位于第 1 行。 您可以将其放在 exec 行之前的 .xinitrc
中
.xinitrc
#!/bin/sh # xrandr --dpi 180 xrdb -merge ~/.Xresources ~/bin/2in1screen & exec i3
请注意,github 上还有许多其他旋转脚本,包括
- https://github.com/freundTech/surface-tools/tree/master/autorotate
- https://github.com/andrewrembrandt/surface-autorotate2
使用 GNOME
请参阅 iio-sensor-proxy。 安装 iio-sensor-proxy 软件包,git 版本 iio-sensor-proxy-gitAUR 可用。
如果您想要旋转,但遇到 GNOME 以错误的方式自动调整亮度的问题,那么您可以使用这些命令来禁用它。
对于当前用户,也可以通过电源管理 GUI 完成
$ dbus-launch gsettings set org.gnome.settings-daemon.plugins.power ambient-enabled false
对于 GDM,无法通过 GUI 完成,以 gdm 用户身份运行
[gdm]$ dbus-launch gsettings set org.gnome.settings-daemon.plugins.power ambient-enabled false
在默认的 Wayland 模式下,GNOME 屏幕旋转在某些不报告屏幕翻转内核事件 (SW_TABLET_MODE
) 的笔记本电脑上已损坏,因此 GNOME 不会启用某些平板电脑功能:GitLab 上有相关讨论。 安装 gnome-shell-extension-screen-autorotateAUR 扩展程序,以便在有触摸屏时始终假定为平板模式。
或者,使用 X11 模式,您可以从登录屏幕中选择该模式。
使用 KDE 模块
- 从 Plasma 5.25+ 开始,Plasma Wayland 会话不需要 kded-rotation-gitAUR。
- kded_rotation 处于早期开发阶段,并且有点 hacky。 请谨慎使用。
安装 iio-sensor-proxy 或 iio-sensor-proxy-gitAUR 和 kded-rotation-gitAUR,然后重启您的 Plasma 会话。 屏幕旋转现在应该可以正常工作了。
对于自动触摸屏旋转,编辑 /usr/bin/orientation-helper
脚本,更改硬编码的输入设备名称以匹配您拥有的设备名称(从 xinput list
的输出中选择)。
使用 rot8
安装 rot8-gitAUR 并为 Wayland 执行 rot8
,或为 X11 执行 rot8 --touchscreen TOUCHSCREEN
。 这通过使用 exec rot8
与 i3 或 sway 很好地集成。
要仅在启用平板模式时启动 rot8,您可以使用 acpid 并修改 /etc/acpi/handler.sh
中的处理程序,以在触发 tabletmode 事件时执行 rot8
(您可以通过调用 acpi_listen
并翻转显示器来触发事件来获得正确的事件)。
/etc/acpi/handler.sh
... video/tabletmode) case "$3" in 0000008A) #echo 'tablet mode' case "$4" in 00000001) DISPLAY=:0 rot8 --touchscreen TOUCHSCREEN & logger 'tablet mode enabled' ;; 00000000) killall rot8 DISPLAY=:0 xrandr --output eDP-1 --rotate normal rmmod wacom modprobe wacom logger 'tablet mode disabled' ;; *) logger "ACPI action undefined: $4" ;; esac ;; *) logger "ACPI action undefined: $3" esac ;; ...
rot8 将自动检测方向并旋转现代 Linux 桌面屏幕和输入设备。 有关其他配置,请参阅 [1]。
平板模式
您可以使用 linuxflip-gitAUR 或 detect-tablet-mode-gitAUR 来配置笔记本电脑和平板电脑模式(例如,启用/禁用键盘/触摸板/轨迹点,启动/关闭屏幕键盘等)
如果未检测到传感器,则可以使用 tablet-modeAUR 手动触发。
桌面环境 / 窗口管理器
i3
对于屏幕空间有限的平板电脑,使用像 i3 这样的平铺窗口管理器非常有意义。 虽然乍一看这可能看起来违反直觉 – 想想看:Android、iOS 和 Windows 10 的平板电脑模式都使用平铺窗口管理器。 因此,i3 是运行 Arch 的平板电脑的绝佳窗口管理器。 问题在于 i3 旨在与键盘一起使用,而无需鼠标,因此没有内置触摸控件。 在大多数情况下,用户需要构建自己的控件,尽管可以通过触摸手势(请参阅 #技巧和窍门)或通过在状态栏或面板中添加触摸按钮控件来实现。 polybar 状态栏的用户可以尝试 i3touchmenu。
Xfce
Xfce 在平板电脑上运行良好。 但是,当 xfce-screensaver 锁定时,默认情况下无法显示屏幕键盘。 可以通过转到 设置 > 屏幕保护程序 > 锁定屏幕
并启用 屏幕键盘
选项来启用它。 您还需要添加显示您选择的键盘所需的命令。 例如,使用 onboard 输入此命令:onboard -e
技巧和窍门
Easystroke
Easystroke 是一款手势识别应用程序,可识别各种输入设备的手势,包括笔触控笔、鼠标和触摸。 手势可用于启动程序、输入文本、模拟按钮和按键以及滚动。 Easystroke 在 AUR 中可用:easystroke-gitAUR。
Easystroke 现在已无人维护,作者建议使用 mouse-actions 代替 mouse-actions-cli-binAUR 和 mouse-actions-gui-binAUR。
检查笔电池
请参阅:Laptop#电池状态
在笔下启动 CellWriter
Easystroke 的一个有用的应用是使用它在鼠标指针正下方启动 CellWriter。
#!/bin/bash # Original author: mr_deimos (ubuntuforums.org). February 14, 2010 # Many bugs fixed and improvements made by Ben Wong. October 20, 2010 # This script toggles the cellwriter letter recognizer window. # If a cellwriter window is visible, it will be hidden. # If cellwriter is not already running, this will create a new process. # If coordinates are specified, the window pops up at those coordinates. # If coordinates are not specified, the window is toggled, but not moved. # Implementation Note: this script is trickier than it should be # because cellwriter does two stupid things. First, it has no # --get-state option, so we can't tell if it is hidden or not. Second, # both the notification area applet and the actual program window have # the same window name in X, which means we can't simply use xwininfo # to find out if it is showing or not. # # (Of course, we wouldn't have to be doing this crazy script at all, # if cellwriter had a --toggle-window option to toggle showing the # keyboard, but that's another rant...) # # To work around the problem, we'll assume that if the window we got # information about from xwininfo is smaller than 100 pixels wide, it # must be an icon in the notification area. This may be the wrong # assumption, but, oh well... if [[ "$1" == "-v" || "$1" == "--verbose" ]]; then verbose=echo shift else verbose=: fi if [[ "$1" && -z "$2" || "$1" == "-h" || "$1" == "--help" ]] ; then cat >&2 <<EOF $(basename $0): Toggle showing the cellwriter window, optionally moving it." Usage: $(basename $0) [x y]" Where x and y are the desired position of the cellwriter window." If x and y are omitted, the window is not moved." EOF exit 1 fi if [[ "$1" && "$2" ]]; then x=$[$1-20] # Offset slightly so cursor will be in window y=$[$2-30] [ $x -lt 0 ] && x=0 # Minimum value is zero [ $y -lt 0 ] && y=0 fi if ! xwininfo -root >/dev/null; then echo "$(basename $0): Error: Could not connect to your X server." >&2 exit 1 fi # Try to obtain CellWriter's window id. # We can't use "xwininfo -name" b/c that might find the notification icon. OLDIFS="$IFS" IFS=$'\n' for line in $(xwininfo -root -tree | grep CellWriter); do line=0x${line#*0x} # Just to get rid of white space before 0x. $verbose -en "Checking: $line\t" if [[ $line =~ (0x[A-Fa-f0-9]+).*\)\ *([0-9]+)x([0-9]+) ]]; then id=${BASH_REMATCH[1]} width=${BASH_REMATCH[2]} height=${BASH_REMATCH[3]} if [[ $width -gt 100 ]]; then $verbose "looks good." CW_WIN_ID=$id break; else $verbose "too small, ignoring." fi else echo "BUG: The xwininfo regular expression in $0 is broken." >&2 fi done IFS="$OLDIFS" #Check if Cellwriter's window is visible if [ "$CW_WIN_ID" ] ; then CW_MAP_STATE=`xwininfo -id "$CW_WIN_ID"|grep "Map State"|cut -f 2 -d :` else $verbose "Can't find cellwriter window, checking for a running process..." if ! pgrep -x cellwriter >& /dev/null; then $verbose "No cellwriter process running, starting a new one." if [[ "$x" && "$y" ]]; then cellwriter --show-window --window-x=$x --window-y=$y & else cellwriter --show-window & fi exit 0 else $verbose "Found a process, so the window has not been created yet." $verbose "Pretending the window is UnMapped." CW_MAP_STATE=IsUnMapped fi fi $verbose "Map state: $CW_MAP_STATE" case "$CW_MAP_STATE" in *IsViewable*) # Window is currently visible. $verbose "hiding window" cellwriter --hide-window & ;; *IsUnMapped*) # Window is currently hidden or non-existent. if [[ "$x" && "$y" && "$CW_WIN_ID" ]]; then $verbose "moving window to $x $y" xdotool windowmove $CW_WIN_ID $x $y fi $verbose "showing window" cellwriter --show-window & # In bg in case cw is not already running ;; *) # This will never happen... echo "BUG: cellwriter is neither viewable nor unmapped" >&2 echo "BUG: ...which means this script, $0, is buggy." >&2 exit 1 ;; esac exit 0
将脚本另存为 cellwriter.sh,保存在 /usr/local/bin/
或 $HOME/bin
中,并使其可执行。
然后在 Easystroke 中创建一个手势,绑定到以下命令
cellwriter.sh $EASYSTROKE_X1 $EASYSTROKE_Y1
当您启动它时(使用您创建的手势),它将在您的笔下打开。
字母表的手势
您还可以使用 Easystroke 为整个字母表制作手势,从而在很大程度上取代对 CellWriter 的需求。 为了避免为大写字母制作单独的手势,您可以使用以下 脚本 来激活 shift 键。
#!/bin/bash if [ -f /tmp/shift ] then xte "keydown Shift_L" "key $1" "keyup Shift_L" rm -f /tmp/shift else xte "key $1" fi
将脚本另存为 keypress.sh,保存在 /usr/local/bin/
或 $HOME/bin
中,并使其可执行。
然后在 Easystroke 中创建一个手势,绑定到以下命令
touch /tmp/shift
这将激活 shift 键。 要激活字母键,请将您的手势绑定到以下命令
keypress.sh $LETTER
将 $LETTER
替换为所讨论字母表中的字母。
因此,当您想要输入大写字母时,请使用您的 shift 键手势,然后是字母。 如果您想要小写字母,只需使用您的字母手势即可。
Xournal & Xournal++
Xournal
Xournal 是一款使用触控笔进行笔记、草图绘制和保持日记的应用程序。 Xournal 旨在提供卓越的图形质量(亚像素分辨率)和整体功能。
您还可以使用补丁扩展 xournalAUR 的功能,以启用诸如自动保存文档和插入图像之类的功能。 有关所有可用补丁的链接,请参阅 SourceForge。 要应用补丁,请参阅 Patching packages。
Xournal++
Xournal++ (xournalpp) 是 Xournal 的后继者,目前正在开发中。 如果您想要更新版本的 Xournal,那么您可以尝试这个。 它目前稳定,几乎没有导致崩溃的错误。
GNOME 屏幕保护程序
要使用 Cellwriter 输入密码来解锁您的 gnome-screensaverAUR[链接失效:未找到软件包],首先启动 dconf-editor
$ dconf-editor
在 /org/gnome/desktop/screensaver
下,将 embedded-keyboard-command
设置为 cellwriter --xid --keyboard-only
,并选中 embedded-keyboard-enabled
复选框。
或者,您可以简单地在命令行中键入以下内容,而不是使用图形注册表编辑器
$ gsettings set org.gnome.desktop.screensaver embedded-keyboard-command "cellwriter --xid --keyboard-only" $ gsettings set org.gnome.desktop.screensaver embedded-keyboard-enabled true
GDM
您也可以将 CellWriter 与 GDM 一起使用。 首先以 root 身份使用文本编辑器打开 /etc/gdm/Init/Default
。 然后在该文件底部附近,添加以粗体显示的行,如下所示
fi cellwriter --keyboard-only & exit 0
您可以添加 --window-x
和 --window-y
以相应地调整 CellWriter 的位置。 例如
cellwriter --keyboard-only --window-x=512 --window-y=768 &
要在用户会话中启动一个功能完善的 CellWriter 实例,您可能需要终止在 gdm 上下文中以 keyboard-only 开关启动的实例。 将诸如 killall cellwriter
之类的命令添加到您新创建的文件 /etc/gdm/PostLogin/Default
中。
LightDM
将 LightDM 配置为使用 Onboard 进行触摸屏登录和解锁可能是提供屏幕键盘登录(当使用默认 GTK 欢迎程序时)的最简单选项(且稳定)。
确保已安装 onboard 和 lightdm-gtk-greeter-settings,并运行 lightdm-gtk-greeter-settings
以配置 onboard 启动。
指定 onboard -t Droid -l Phone
配置 Droid 主题并设置 Phone 布局。
Touchegg
Touchegg 是一款多点触控手势识别器。 它可以识别最多五个手指的手势(点击、拖动、捏合、旋转...)。
故障排除
Wacom 驱动程序
以下命令在故障排除中很有用
wacdump -f tpc /dev/ttyS0 xidump -l xidump -u stylus
如果 xidump 显示您的平板电脑的最大分辨率与屏幕分辨率相同,则您的 wacom 驱动程序已将您的 wacom 坐标重新缩放到 X 服务器的分辨率。 要解决此问题,请尝试使用以下命令重新编译您的 linuxwacom 驱动程序
./configure --disable-quirk-tablet-rescale
屏幕旋转支持
某些视频驱动程序不支持旋转。 要检查您的驱动程序是否支持旋转,请检查 xrandr
的输出以获取方向列表
normal left inverted right