Created
October 22, 2025 05:49
-
-
Save CFM880/911c274e611ca8692f9b8a77fef99f59 to your computer and use it in GitHub Desktop.
https://github.com/CalcProgrammer1/TouchpadEmulator/ 修改启动脚本,没有启动TouchpadEmulator,获取合适的方向后启动TouchpadEmulator ,已启动,kill TouchpadEmulator
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #! /bin/bash | |
| if [ "$1" = "--autostart" ] ; then | |
| mkdir -p ~/.config/autostart | |
| AUTOSTART="" | |
| AUTOSTART+="[Desktop Entry]\r\n" | |
| AUTOSTART+="Type=Application\r\n" | |
| AUTOSTART+="Name=Touchpad Emulator Autostart\r\n" | |
| AUTOSTART+="Exec=sh -c \"LaunchTouchpadEmulator.sh --start-disabled --force-autorotation\"\r\n" | |
| AUTOSTART+="Icon=TouchpadEmulator\r\n" | |
| echo -e $AUTOSTART > ~/.config/autostart/TouchpadEmulator-Autostart.desktop | |
| echo "Autostart enabled, TouchpadEmulator will start automatically on login." | |
| exit | |
| fi | |
| # If TouchpadEmulator is already running, kill it and exit (we assume user wanted to stop it) | |
| if ps -e | grep "[T]ouchpadEmulato"; then | |
| echo "TouchpadEmulator is running; killing existing process(es)." | |
| killall TouchpadEmulator || true | |
| exit 0 | |
| fi | |
| # If access is not already available, load the uinput module and enable user access | |
| # to input devices and uinput. This requires root permission, so use pkexec to show | |
| # a graphical root prompt. | |
| if ( ! [ -e /dev/uinput ] ) || \ | |
| ( ! [ -w /dev/uinput ] ) || \ | |
| ( ! [ -r /dev/input/event0 ] ) then | |
| pkexec bash -c "chmod 666 /dev/input/*; modprobe uinput; chmod 777 /dev/uinput" | |
| fi | |
| # Determine rotation from xrandr for primary display | |
| # Mapping: normal -> 0, left -> 90, inverted -> 180, right -> 270 | |
| ROTATION_ANGLE="0" | |
| if command -v xrandr >/dev/null 2>&1; then | |
| line=$(xrandr --query | awk '/ primary / {print; exit}') | |
| if [ -z "$line" ]; then | |
| line=$(xrandr --query | awk '/ connected/ {print; exit}') | |
| fi | |
| echo "$line" | |
| if echo "$line" | grep -q " left (normal"; then | |
| ROTATION_ANGLE=270 | |
| elif echo "$line" | grep -q " inverted (normal"; then | |
| ROTATION_ANGLE=180 | |
| elif echo "$line" | grep -q " right (normal"; then | |
| ROTATION_ANGLE=90 | |
| else | |
| ROTATION_ANGLE=0 | |
| fi | |
| fi | |
| export TOUCHPAD_ROTATION="$ROTATION_ANGLE" | |
| # If user didn't already supply a --rotation-override argument, append it | |
| if ! printf "%s\n" "$@" | grep -q -- "--rotation-override"; then | |
| TouchpadEmulator --rotation-override "$ROTATION_ANGLE" "$@" | |
| else | |
| TouchpadEmulator "$@" | |
| fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment