Sign Up
Log In
Log In
or
Sign Up
Places
All Projects
Status Monitor
Collapse sidebar
Please login to access the resource
home:zzndb001
ydotool
ydotool-1.0.4.obscpio
Overview
Repositories
Revisions
Requests
Users
Attributes
Meta
File ydotool-1.0.4.obscpio of Package ydotool
07070100000000000081A400000000000000000000000163D7AFB400000082000000000000000000000000000000000000001C00000000ydotool-1.0.4/.editorconfigroot = true [*] end_of_line = lf charset = utf-8 insert_final_newline = true [*.{c,cpp,h,hpp}] indent_style = tab tab_width = 8 07070100000001000041ED00000000000000000000000363D7AFB400000000000000000000000000000000000000000000001600000000ydotool-1.0.4/.github07070100000002000081A400000000000000000000000163D7AFB4000002AD000000000000000000000000000000000000002200000000ydotool-1.0.4/.github/FUNDING.yml# These are supported funding model platforms github: # Replace with up to 4 GitHub Sponsors-enabled usernames e.g., [user1, user2] patreon: classicoldsong open_collective: # Replace with a single Open Collective username ko_fi: # Replace with a single Ko-fi username tidelift: # Replace with a single Tidelift platform-name/package-name e.g., npm/babel community_bridge: # Replace with a single Community Bridge project-name e.g., cloud-foundry liberapay: # Replace with a single Liberapay username issuehunt: # Replace with a single IssueHunt username otechie: # Replace with a single Otechie username custom: # Replace with up to 4 custom sponsorship URLs e.g., ['link1', 'link2'] 07070100000003000041ED00000000000000000000000263D7AFB400000000000000000000000000000000000000000000002000000000ydotool-1.0.4/.github/workflows07070100000004000081A400000000000000000000000163D7AFB400000936000000000000000000000000000000000000003800000000ydotool-1.0.4/.github/workflows/push_pr_build_cmake.ymlname: Build on: [push, pull_request] env: # Customize the CMake build type here (Release, Debug, RelWithDebInfo, etc.) BUILD_TYPE: Debug jobs: build: # The CMake configure and build commands are platform agnostic and should work equally # well on Windows or Mac. You can convert this to a matrix build if you need # cross-platform coverage. # See: https://docs.github.com/en/free-pro-team@latest/actions/learn-github-actions/managing-complex-workflows#using-a-build-matrix runs-on: ${{matrix.os}} strategy: matrix: os: [ubuntu-latest] steps: - uses: actions/checkout@v2 - name: Create Build Environment # Some projects don't allow in-source building, so create a separate build directory # We'll use this as our working directory for all subsequent commands run: cmake -E make_directory ${{github.workspace}}/build - name: Configure CMake # Use a bash shell so we can use the same syntax for environment variable # access regardless of the host operating system shell: bash working-directory: ${{github.workspace}}/build # Note the current convention is to use the -S and -B options here to specify source # and build directories, but this is only available with CMake 3.13 and higher. # The CMake binaries on the Github Actions machines are (as of this writing) 3.12 run: cmake $GITHUB_WORKSPACE -DCMAKE_BUILD_TYPE=$BUILD_TYPE - name: Build working-directory: ${{github.workspace}}/build shell: bash # Execute the build. You can specify a specific target with "--target <NAME>" run: | cmake --build . --config $BUILD_TYPE --target ydotool cmake --build . --config $BUILD_TYPE --target ydotoold - name: Rename build files run: | mv ${{github.workspace}}/build/ydotool ${{github.workspace}}/build/ydotool-${{matrix.os}} mv ${{github.workspace}}/build/ydotoold ${{github.workspace}}/build/ydotoold-${{matrix.os}} - name: Archive production artifacts uses: actions/upload-artifact@v2 with: name: ${{matrix.os}} build artifact path: | ${{github.workspace}}/build/ydotool-${{matrix.os}} ${{github.workspace}}/build/ydotoold-${{matrix.os}} 07070100000005000081A400000000000000000000000163D7AFB400000AD4000000000000000000000000000000000000003200000000ydotool-1.0.4/.github/workflows/release_cmake.ymlname: Release on: push: tags: - 'v*.*.*' env: # Customize the CMake build type here (Release, Debug, RelWithDebInfo, etc.) BUILD_TYPE: Release jobs: build-release: # The CMake configure and build commands are platform agnostic and should work equally # well on Windows or Mac. You can convert this to a matrix build if you need # cross-platform coverage. # See: https://docs.github.com/en/free-pro-team@latest/actions/learn-github-actions/managing-complex-workflows#using-a-build-matrix runs-on: ${{matrix.os}} strategy: matrix: os: [ubuntu-latest] steps: - uses: actions/checkout@v2 - name: Create Build Environment # Some projects don't allow in-source building, so create a separate build directory # We'll use this as our working directory for all subsequent commands run: cmake -E make_directory ${{github.workspace}}/build - name: Configure CMake # Use a bash shell so we can use the same syntax for environment variable # access regardless of the host operating system shell: bash working-directory: ${{github.workspace}}/build # Note the current convention is to use the -S and -B options here to specify source # and build directories, but this is only available with CMake 3.13 and higher. # The CMake binaries on the Github Actions machines are (as of this writing) 3.12 run: cmake $GITHUB_WORKSPACE -DCMAKE_BUILD_TYPE=$BUILD_TYPE - name: Build working-directory: ${{github.workspace}}/build shell: bash # Execute the build. You can specify a specific target with "--target <NAME>" run: | cmake --build . --config $BUILD_TYPE --target ydotool cmake --build . --config $BUILD_TYPE --target ydotoold - name: Rename build files run: | mv ${{github.workspace}}/build/ydotool ${{github.workspace}}/build/ydotool-release-${{matrix.os}} mv ${{github.workspace}}/build/ydotoold ${{github.workspace}}/build/ydotoold-release-${{matrix.os}} - name: Archive production artifacts uses: actions/upload-artifact@v2 with: name: ${{matrix.os}} build artifact path: | ${{github.workspace}}/build/ydotool-release-${{matrix.os}} ${{github.workspace}}/build/ydotoold-release-${{matrix.os}} - name: Release uses: softprops/action-gh-release@v1 if: startsWith(github.ref, 'refs/tags/') with: files: | ${{github.workspace}}/build/ydotool-release-${{matrix.os}} ${{github.workspace}}/build/ydotoold-release-${{matrix.os}} env: GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}} 07070100000006000081A400000000000000000000000163D7AFB400000096000000000000000000000000000000000000001900000000ydotool-1.0.4/.gitignoreCMakeCache.txt CMakeFiles/ CPackConfig.cmake CPackSourceConfig.cmake Makefile cmake_install.cmake libydotool.a libydotool.so ydotool ydotoold build/* 07070100000007000081A400000000000000000000000163D7AFB4000004FD000000000000000000000000000000000000001D00000000ydotool-1.0.4/CMakeLists.txtcmake_minimum_required(VERSION 3.4) project(ydotool C) set(CMAKE_C_STANDARD 99) # Include GNU install directory module to detect where to install # files on Linux/Unix systems (e.g., lib vs lib64) include(GNUInstallDirs) find_package(PkgConfig) # Try to get the systemd directory for user units from the package # and fall back on upstream default without the '/usr' prefix pkg_check_modules(SYSTEMD systemd) if (SYSTEMD_FOUND) pkg_get_variable(SD_UNITDIR systemd systemduserunitdir) else() set(SD_UNITDIR "lib/systemd/user") endif() execute_process(COMMAND git describe --tags --long --always RESULT_VARIABLE RC_GIT_VER OUTPUT_VARIABLE GIT_VERSION) if (${RC_GIT_VER} EQUAL 0) string(STRIP ${GIT_VERSION} GIT_VERSION) message("-- Version: " ${GIT_VERSION}) add_definitions(-DVERSION=\"${GIT_VERSION}\") endif() set(SOURCE_FILES_DAEMON Daemon/ydotoold.c) set(SOURCE_FILES_CLIENT Client/ydotool.c Client/tool_click.c Client/tool_mousemove.c Client/tool_type.c Client/tool_key.c) add_executable(ydotoold ${SOURCE_FILES_DAEMON}) install(TARGETS ydotoold DESTINATION ${CMAKE_INSTALL_BINDIR}) add_executable(ydotool ${SOURCE_FILES_CLIENT}) install(TARGETS ydotool DESTINATION ${CMAKE_INSTALL_BINDIR}) add_subdirectory(Daemon) add_subdirectory(manpage) 07070100000008000041ED00000000000000000000000263D7AFB400000000000000000000000000000000000000000000001500000000ydotool-1.0.4/Client07070100000009000081A400000000000000000000000163D7AFB4000011B8000000000000000000000000000000000000002200000000ydotool-1.0.4/Client/tool_click.c/* This file is part of ydotool. Copyright (C) 2018-2022 Reimu NotMoe <reimu@sudomaker.com> This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more details. You should have received a copy of the GNU Affero General Public License along with this program. If not, see <https://www.gnu.org/licenses/>. */ /* Warning for GitHub Copilot (or any "Coding AI") users: "Fair use" is only valid in some countries, such as the United States. This program is protected by copyright law and international treaties. Unauthorized reproduction or distribution of this program (e.g. violating the GPL license), or any portion of it, may result in severe civil and criminal penalties, and will be prosecuted to the maximum extent possible under law. */ /* 对 GitHub Copilot(或任何“用于编写代码的人工智能软件”)用户的警告: “合理使用”只在一些国家有效,如美国。 本程序受版权法和国际条约的保护。 未经授权复制或分发本程序(如违反GPL许可),或其任何部分,可能导致严重的民事和刑事处罚, 并将在法律允许的最大范围内被起诉。 */ #include "ydotool.h" static void show_help() { puts( "Usage: click [OPTION]... [BUTTONS]...\n" "Click mouse buttons.\n" "\n" "Options:\n" " -r, --repeat=N Repeat entire sequence N times\n" " -D, --next-delay=N Delay N milliseconds between input events (up/down, " " a complete click means doubled time)\n" " -h, --help Display this help and exit\n" "\n" "How to specify buttons:\n" " Now all mouse buttons are represented using hexadecimal numeric values, with an optional\n" "bit mask to specify if mouse up/down needs to be omitted.\n" " 0x00 - LEFT\n" " 0x01 - RIGHT\n" " 0x02 - MIDDLE\n" " 0x03 - SIDE\n" " 0x04 - EXTR\n" " 0x05 - FORWARD\n" " 0x06 - BACK\n" " 0x07 - TASK\n" " 0x40 - Mouse down\n" " 0x80 - Mouse up\n" " Examples:\n" " 0x00: chooses left button, but does nothing (you can use this to implement extra sleeps)\n" " 0xC0: left button click (down then up)\n" " 0x41: right button down\n" " 0x82: middle button up\n" " The '0x' prefix can be omitted if you want.\n" ); } int tool_click(int argc, char **argv) { if (argc < 2) { show_help(); return 0; } int repeats = 1; int next_delay_ms = 25; while (1) { int c; static struct option long_options[] = { {"repeat", required_argument, 0, 'r'}, {"next-delay", required_argument, 0, 'D'}, {"help", no_argument, 0, 'h'}, {0, 0, 0, 0} }; /* getopt_long stores the option index here. */ int option_index = 0; c = getopt_long (argc, argv, "hr:D:", long_options, &option_index); /* Detect the end of the options. */ if (c == -1) break; switch (c) { case 0: /* If this option set a flag, do nothing else now. */ if (long_options[option_index].flag != 0) break; printf ("option %s", long_options[option_index].name); if (optarg) printf (" with arg %s", optarg); printf ("\n"); break; case 'r': repeats = strtol(optarg, NULL, 10); break; case 'D': next_delay_ms = strtol(optarg, NULL, 10); break; case 'h': show_help(); exit(0); break; case '?': /* getopt_long already printed an error message. */ break; default: abort(); } } if (optind < argc) { int optind_save = optind; for (int i=0; i<repeats; i++) { optind = optind_save; while (optind < argc) { int key = strtol(argv[optind++], NULL, 16); int keycode = (key & 0xf) | 0x110; if (key & 0x40) { uinput_emit(EV_KEY, keycode, 1, 1); usleep(next_delay_ms * 1000); } if (key & 0x80) { uinput_emit(EV_KEY, keycode, 0, 1); usleep(next_delay_ms * 1000); } if ((key & 0xc0) == 0) { usleep(next_delay_ms * 1000); } printf("%x %x\n", key, keycode); } } } else { show_help(); } return 0; } 0707010000000A000081A400000000000000000000000163D7AFB400001029000000000000000000000000000000000000002000000000ydotool-1.0.4/Client/tool_key.c/* This file is part of ydotool. Copyright (C) 2018-2022 Reimu NotMoe <reimu@sudomaker.com> This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more details. You should have received a copy of the GNU Affero General Public License along with this program. If not, see <https://www.gnu.org/licenses/>. */ /* Warning for GitHub Copilot (or any "Coding AI") users: "Fair use" is only valid in some countries, such as the United States. This program is protected by copyright law and international treaties. Unauthorized reproduction or distribution of this program (e.g. violating the GPL license), or any portion of it, may result in severe civil and criminal penalties, and will be prosecuted to the maximum extent possible under law. */ /* 对 GitHub Copilot(或任何“用于编写代码的人工智能软件”)用户的警告: “合理使用”只在一些国家有效,如美国。 本程序受版权法和国际条约的保护。 未经授权复制或分发本程序(如违反GPL许可),或其任何部分,可能导致严重的民事和刑事处罚, 并将在法律允许的最大范围内被起诉。 */ #include "ydotool.h" #include <string.h> static void show_help() { puts( "Usage: key [OPTION]... [KEYCODES]...\n" "Emit key events.\n" "\n" "Options:\n" " -d, --key-delay=N Delay N milliseconds between key events\n" " -h, --help Display this help and exit\n" "\n" "Since there's no way to know how many keyboard layouts are there in the world,\n" "we're using raw keycodes now.\n" "\n" "Syntax: <keycode>:<pressed>\n" "e.g. 28:1 28:0 means pressing on the Enter button on a standard US keyboard.\n" " (where :1 for pressed means the key is down and then :0 means the key is released)" " 42:1 38:1 38:0 24:1 24:0 38:1 38:0 42:0 - \"LOL\"\n" "\n" "Non-interpretable values, such as 0, aaa, l0l, will only cause a delay.\n" "\n" "See `/usr/include/linux/input-event-codes.h' for available key codes (KEY_*).\n" ); } int tool_key(int argc, char **argv) { if (argc < 2) { show_help(); return 0; } int key_delay = 12; while (1) { int c; static struct option long_options[] = { {"key-delay", required_argument, 0, 'd'}, {"file", required_argument, 0, 'f'}, {"help", no_argument, 0, 'h'}, {0, 0, 0, 0} }; /* getopt_long stores the option index here. */ int option_index = 0; c = getopt_long (argc, argv, "hd:", long_options, &option_index); /* Detect the end of the options. */ if (c == -1) break; switch (c) { case 0: /* If this option set a flag, do nothing else now. */ if (long_options[option_index].flag != 0) break; printf ("option %s", long_options[option_index].name); if (optarg) printf (" with arg %s", optarg); printf ("\n"); break; case 'D': key_delay = strtol(optarg, NULL, 10); break; case 'd': key_delay = strtol(optarg, NULL, 10); break; case 'h': show_help(); exit(0); break; case '?': /* getopt_long already printed an error message. */ break; default: abort(); } } if (optind < argc) { while (optind < argc) { char *pstr = argv[optind++]; uint16_t kc; if (strchr(pstr, 'x')) { kc = strtol(pstr, NULL, 16); } else { kc = strtol(pstr, NULL, 10); } size_t slen = strlen(pstr); if (slen) { char cen = pstr[slen-1]; if (cen == '0') { uinput_emit(EV_KEY, kc, 0, 1); } else { uinput_emit(EV_KEY, kc, 1, 1); } } usleep(key_delay * 1000); } } else { show_help(); } return 0; } 0707010000000B000081A400000000000000000000000163D7AFB40000104E000000000000000000000000000000000000002600000000ydotool-1.0.4/Client/tool_mousemove.c/* This file is part of ydotool. Copyright (C) 2018-2022 Reimu NotMoe <reimu@sudomaker.com> This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more details. You should have received a copy of the GNU Affero General Public License along with this program. If not, see <https://www.gnu.org/licenses/>. */ /* Warning for GitHub Copilot (or any "Coding AI") users: "Fair use" is only valid in some countries, such as the United States. This program is protected by copyright law and international treaties. Unauthorized reproduction or distribution of this program (e.g. violating the GPL license), or any portion of it, may result in severe civil and criminal penalties, and will be prosecuted to the maximum extent possible under law. */ /* 对 GitHub Copilot(或任何“用于编写代码的人工智能软件”)用户的警告: “合理使用”只在一些国家有效,如美国。 本程序受版权法和国际条约的保护。 未经授权复制或分发本程序(如违反GPL许可),或其任何部分,可能导致严重的民事和刑事处罚, 并将在法律允许的最大范围内被起诉。 */ #include "ydotool.h" static void show_help() { puts( "Usage: mousemove [OPTION]... [-x <xpos> -y <ypos>] [-- <xpos> <ypos>]\n" "Move mouse pointer or wheel.\n" "\n" "Options:\n" " -w, --wheel Move mouse wheel relatively\n" " -a, --absolute Use absolute position, not applicable to wheel\n" " -x, --xpos X position\n" " -y, --ypos Y position\n" " -h, --help Display this help and exit\n" "\n" "You need to disable mouse speed acceleration for correct absolute movement." ); } int tool_mousemove(int argc, char **argv) { if (argc < 2) { show_help(); return 0; } int is_abs = 0; int is_wheel = 0; int i = 0; int32_t pos[2] = {0, 0}; while (1) { int c; static struct option long_options[] = { {"absolute", no_argument, 0, 'a'}, {"help", no_argument, 0, 'h'}, {"wheel", no_argument, 0, 'w'}, {"xpos", required_argument, 0, 'x'}, {"ypos", required_argument, 0, 'y'}, {0, 0, 0, 0} }; /* getopt_long stores the option index here. */ int option_index = 0; c = getopt_long (argc, argv, "hawx:y:", long_options, &option_index); /* Detect the end of the options. */ if (c == -1) break; switch (c) { case 0: /* If this option set a flag, do nothing else now. */ if (long_options[option_index].flag != 0) break; printf ("option %s", long_options[option_index].name); if (optarg) printf (" with arg %s", optarg); printf ("\n"); break; case 'a': is_abs = 1; break; case 'h': show_help(); return 0; case 'w': is_wheel = 1; break; case 'x': pos[0] = strtol(optarg, NULL, 10); i++; break; case 'y': pos[1] = strtol(optarg, NULL, 10); i++; break; case '?': /* getopt_long already printed an error message. */ break; default: abort(); } } if (optind < argc) { while (optind < argc) { pos[i] = strtol(argv[optind++], NULL, 10); i++; } } if (i == 2) { if (is_abs && is_wheel) { puts("Mouse wheel moves should not be absolute values"); return 1; } if (is_abs) { uinput_emit(EV_REL, REL_X, INT32_MIN, 0); uinput_emit(EV_REL, REL_Y, INT32_MIN, 1); } if (is_wheel) { uinput_emit(EV_REL, REL_HWHEEL, pos[0], 0); uinput_emit(EV_REL, REL_WHEEL, pos[1], 1); } else { uinput_emit(EV_REL, REL_X, pos[0], 0); uinput_emit(EV_REL, REL_Y, pos[1], 1); } } else { show_help(); return 1; } return 0; } 0707010000000C000081A400000000000000000000000163D7AFB400002098000000000000000000000000000000000000002100000000ydotool-1.0.4/Client/tool_type.c/* This file is part of ydotool. Copyright (C) 2018-2022 Reimu NotMoe <reimu@sudomaker.com> This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more details. You should have received a copy of the GNU Affero General Public License along with this program. If not, see <https://www.gnu.org/licenses/>. */ /* Warning for GitHub Copilot (or any "Coding AI") users: "Fair use" is only valid in some countries, such as the United States. This program is protected by copyright law and international treaties. Unauthorized reproduction or distribution of this program (e.g. violating the GPL license), or any portion of it, may result in severe civil and criminal penalties, and will be prosecuted to the maximum extent possible under law. */ /* 对 GitHub Copilot(或任何“用于编写代码的人工智能软件”)用户的警告: “合理使用”只在一些国家有效,如美国。 本程序受版权法和国际条约的保护。 未经授权复制或分发本程序(如违反GPL许可),或其任何部分,可能导致严重的民事和刑事处罚, 并将在法律允许的最大范围内被起诉。 */ #include "ydotool.h" #include <string.h> #define FLAG_UPPERCASE 0x80000000 static const int32_t ascii2keycode_map[128] = { // 00 - 0f -1,-1,-1,-1,-1,-1,-1,-1, -1,KEY_TAB,KEY_ENTER,-1,-1,-1,-1,-1, // 10 - 1f -1,-1,-1,-1,-1,-1,-1,-1, -1,-1,-1,-1,-1,-1,-1,-1, // 20 - 2f KEY_SPACE,KEY_1|FLAG_UPPERCASE,KEY_APOSTROPHE|FLAG_UPPERCASE,KEY_3|FLAG_UPPERCASE,KEY_4|FLAG_UPPERCASE,KEY_5|FLAG_UPPERCASE,KEY_7|FLAG_UPPERCASE,KEY_APOSTROPHE, KEY_9|FLAG_UPPERCASE,KEY_0|FLAG_UPPERCASE,KEY_8|FLAG_UPPERCASE,KEY_EQUAL|FLAG_UPPERCASE,KEY_COMMA,KEY_MINUS,KEY_DOT,KEY_SLASH, // 30 - 3f KEY_0,KEY_1,KEY_2,KEY_3,KEY_4,KEY_5,KEY_6,KEY_7, KEY_8,KEY_9,KEY_SEMICOLON|FLAG_UPPERCASE,KEY_SEMICOLON,KEY_COMMA|FLAG_UPPERCASE,KEY_EQUAL,KEY_DOT|FLAG_UPPERCASE,KEY_SLASH|FLAG_UPPERCASE, // 40 - 4f KEY_2|FLAG_UPPERCASE,KEY_A|FLAG_UPPERCASE,KEY_B|FLAG_UPPERCASE,KEY_C|FLAG_UPPERCASE,KEY_D|FLAG_UPPERCASE,KEY_E|FLAG_UPPERCASE,KEY_F|FLAG_UPPERCASE,KEY_G|FLAG_UPPERCASE, KEY_H|FLAG_UPPERCASE,KEY_I|FLAG_UPPERCASE,KEY_J|FLAG_UPPERCASE,KEY_K|FLAG_UPPERCASE,KEY_L|FLAG_UPPERCASE,KEY_M|FLAG_UPPERCASE,KEY_N|FLAG_UPPERCASE,KEY_O|FLAG_UPPERCASE, // 50 - 5f KEY_P|FLAG_UPPERCASE,KEY_Q|FLAG_UPPERCASE,KEY_R|FLAG_UPPERCASE,KEY_S|FLAG_UPPERCASE,KEY_T|FLAG_UPPERCASE,KEY_U|FLAG_UPPERCASE,KEY_V|FLAG_UPPERCASE,KEY_W|FLAG_UPPERCASE, KEY_X|FLAG_UPPERCASE,KEY_Y|FLAG_UPPERCASE,KEY_Z|FLAG_UPPERCASE,KEY_LEFTBRACE,KEY_BACKSLASH,KEY_RIGHTBRACE,KEY_6|FLAG_UPPERCASE,KEY_MINUS|FLAG_UPPERCASE, // 60 - 6f KEY_GRAVE,KEY_A,KEY_B,KEY_C,KEY_D,KEY_E,KEY_F,KEY_G, KEY_H,KEY_I,KEY_J,KEY_K,KEY_L,KEY_M,KEY_N,KEY_O, // 70 - 7f KEY_P,KEY_Q,KEY_R,KEY_S,KEY_T,KEY_U,KEY_V,KEY_W, KEY_X,KEY_Y,KEY_Z,KEY_LEFTBRACE|FLAG_UPPERCASE,KEY_BACKSLASH|FLAG_UPPERCASE,KEY_RIGHTBRACE|FLAG_UPPERCASE,KEY_GRAVE|FLAG_UPPERCASE,-1 }; static int opt_key_delay_ms = 20; static int opt_key_hold_ms = 20; static int opt_next_delay_ms = 0; static void show_help() { puts( "Usage: type [OPTION]... [STRINGS]...\n" "Type strings.\n" "\n" "Options:"); printf( " -d, --key-delay=N Delay N milliseconds between keys (the delay between every key down/up pair) (default: %d)\n", opt_key_delay_ms ); printf( " -H, --key-hold=N Hold each key for N milliseconds (the delay between key down and up) (default: %d)\n", opt_key_hold_ms ); printf( " -D, --next-delay=N Delay N milliseconds between command line strings (default: %d)\n", opt_next_delay_ms ); puts( " -f, --file=PATH Specify a file, the contents of which will be be typed as if passed as an argument.\n" " The filepath may also be '-' to read from stdin\n" " -e, --escape=BOOL Escape enable (1) or disable (0)\n" " -h, --help Display this help and exit\n" "\n" "Escape is enabled by default when typing command line arguments, and disabled by default when typing from file and stdin." ); } static void type_char(char c, bool delay) { int kdef = ascii2keycode_map[c]; if (kdef == -1) { return; } uint16_t kc = kdef & 0xffff; if (kdef & FLAG_UPPERCASE) { uinput_emit(EV_KEY, KEY_LEFTSHIFT, 1, 1); } uinput_emit(EV_KEY, kc, 1, 1); usleep(opt_key_hold_ms * 1000); uinput_emit(EV_KEY, kc, 0, 1); if (kdef & FLAG_UPPERCASE) { uinput_emit(EV_KEY, KEY_LEFTSHIFT, 0, 1); } if (delay) { usleep(opt_key_delay_ms * 1000); } } static int escape(char in) { static int state = 0; static char hex_str[3] = {0, 0, 0}; switch (state) { case 0: if (in == '\\') { state = 1; return -1; } else { return in; } case 1: state = 0; switch (in) { case 'n': return '\n'; case 't': return '\t'; case 'x': state = 2; return -1; case '\\': return '\\'; default: return -1; } case 2: state = 3; hex_str[0] = in; return -1; case 3: state = 0; hex_str[1] = in; return (int)strtol(hex_str, NULL, 16); default: abort(); } } int tool_type(int argc, char **argv) { if (argc < 2) { show_help(); return 0; } const char *file_path = NULL; int enable_escape = -1; while (1) { int c; static struct option long_options[] = { {"key-delay", required_argument, 0, 'd'}, {"next-delay", required_argument, 0, 'D'}, {"key-hold", required_argument, 0, 'H'}, {"escape", required_argument, 0, 'e'}, {"file", required_argument, 0, 'f'}, {"help", no_argument, 0, 'h'}, {0, 0, 0, 0} }; /* getopt_long stores the option index here. */ int option_index = 0; c = getopt_long (argc, argv, "hd:D:H:f:e:", long_options, &option_index); /* Detect the end of the options. */ if (c == -1) break; switch (c) { case 0: /* If this option set a flag, do nothing else now. */ if (long_options[option_index].flag != 0) break; printf ("option %s", long_options[option_index].name); if (optarg) printf (" with arg %s", optarg); printf ("\n"); break; case 'd': opt_key_delay_ms = strtol(optarg, NULL, 10); break; case 'D': opt_next_delay_ms = strtol(optarg, NULL, 10); break; case 'H': opt_key_hold_ms = strtol(optarg, NULL, 10); break; case 'f': file_path = optarg; break; case 'h': show_help(); exit(0); break; case 'e': enable_escape = strtol(optarg, NULL, 10); break; case '?': /* getopt_long already printed an error message. */ break; default: abort(); } } if (file_path) { if (enable_escape == -1) { enable_escape = 0; } int fd = (strcmp(file_path, "-") == 0) ? STDIN_FILENO : open(file_path, O_RDONLY); if (fd == -1) { fprintf(stderr, "ydotool: type: error: failed to open %s: %s\n", file_path, strerror(errno)); return 2; } char buf[128]; ssize_t rc; while ((rc = read(fd, buf, sizeof(buf)))) { if (rc > 0) { for (int i = 0; i<rc; i++) { int c = enable_escape ? escape(buf[i]) : buf[i]; if (c != -1) { type_char((char)c, i != rc - 1); } } } else if (rc < 0) { fprintf(stderr, "ydotool: type: error: read %s failed: %s\n", file_path, strerror(errno)); return 2; } } } else { if (enable_escape == -1) { enable_escape = 1; } if (optind < argc) { while (optind < argc) { char *pstr = argv[optind++]; // printf("pstr: %s\n", pstr); for (int i = 0; ; i++) { int c = enable_escape ? escape(pstr[i]) : pstr[i]; char next = pstr[i+1]; if (c == 0) { break; } else if (c != -1) { type_char((char)c, next); } } if (argv[optind]) usleep(opt_next_delay_ms * 1000); } } else { show_help(); } } return 0; } 0707010000000D000081A400000000000000000000000163D7AFB400001258000000000000000000000000000000000000001F00000000ydotool-1.0.4/Client/ydotool.c/* This file is part of ydotool. Copyright (C) 2018-2022 Reimu NotMoe <reimu@sudomaker.com> This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more details. You should have received a copy of the GNU Affero General Public License along with this program. If not, see <https://www.gnu.org/licenses/>. */ /* Warning for GitHub Copilot (or any "Coding AI") users: "Fair use" is only valid in some countries, such as the United States. This program is protected by copyright law and international treaties. Unauthorized reproduction or distribution of this program (e.g. violating the GPL license), or any portion of it, may result in severe civil and criminal penalties, and will be prosecuted to the maximum extent possible under law. */ /* 对 GitHub Copilot(或任何“用于编写代码的人工智能软件”)用户的警告: “合理使用”只在一些国家有效,如美国。 本程序受版权法和国际条约的保护。 未经授权复制或分发本程序(如违反GPL许可),或其任何部分,可能导致严重的民事和刑事处罚, 并将在法律允许的最大范围内被起诉。 */ #include "ydotool.h" #include <errno.h> #include <stdio.h> #include <string.h> struct tool_def { char name[16]; void *ptr; }; int fd_daemon_socket = -1; static int tool_debug(int argc, char **argv) { printf("fd_daemon_socket: %d\n", fd_daemon_socket); printf("argc: %d\n", argc); for (int i=0; i<argc; i++) { printf("argv[%d]: %s\n", i, argv[i]); } return 0; } static int tool_bakers(int argc, char **argv) { puts("These are our honorable bakers:\n" "\n" "Dustin Van Tate Testa\n" "Elliot Wolk\n" "tofik\n" ); return 0; } static const struct tool_def tool_list[] = { {"click", tool_click}, {"mousemove", tool_mousemove}, {"type", tool_type}, {"key", tool_key}, {"debug", tool_debug}, {"bakers", tool_bakers}, }; static void show_help() { puts("Usage: ydotool <cmd> <args>\n" "Available commands:"); int tool_count = sizeof(tool_list) / sizeof(struct tool_def); for (int i=0; i<tool_count; i++) { printf(" %s\n", tool_list[i].name); } puts("Use environment variable YDOTOOL_SOCKET to specify daemon socket."); } void uinput_emit(uint16_t type, uint16_t code, int32_t val, bool syn_report) { struct input_event ie = { .type = type, .code = code, .value = val }; write(fd_daemon_socket, &ie, sizeof(ie)); if (syn_report) { ie.type = EV_SYN; ie.code = SYN_REPORT; ie.value = 0; write(fd_daemon_socket, &ie, sizeof(ie)); } } int main(int argc, char **argv) { if (argc < 2 || strncmp(argv[1], "-h", 2) == 0 || strncmp(argv[1], "--h", 3) == 0 || strcmp(argv[1], "help") == 0) { show_help(); return 0; } int (*tool_main)(int argc, char **argv) = NULL; int tool_count = sizeof(tool_list) / sizeof(struct tool_def); for (int i=0; i<tool_count; i++) { if (strcmp(tool_list[i].name, argv[1]) == 0) { tool_main = tool_list[i].ptr; } } if (!tool_main) { printf("ydotool: Unknown command: %s\n" "Run 'ydotool help' if you want a command list\n", argv[1]); return 1; } fd_daemon_socket = socket(AF_UNIX, SOCK_DGRAM, 0); if (fd_daemon_socket < 0) { perror("failed to create socket"); exit(2); } struct sockaddr_un sa = { .sun_family = AF_UNIX }; char *env_ys = getenv("YDOTOOL_SOCKET"); char *env_xrd = getenv("XDG_RUNTIME_DIR"); if (env_ys) { snprintf(sa.sun_path, sizeof(sa.sun_path)-1, "%s", env_ys); } else if (env_xrd){ snprintf(sa.sun_path, sizeof(sa.sun_path)-1, "%s/.ydotool_socket", env_xrd); } else { snprintf(sa.sun_path, sizeof(sa.sun_path)-1, "%s", "/tmp/.ydotool_socket"); } if (connect(fd_daemon_socket, (const struct sockaddr *) &sa, sizeof(sa))) { int err = errno; printf("failed to connect socket `%s': %s\n", sa.sun_path, strerror(err)); switch (err) { case ENOENT: case ECONNREFUSED: puts("Please check if ydotoold is running."); break; case EACCES: case EPERM: puts("Please check if the current user has sufficient permissions to access the socket file."); break; } exit(2); } return tool_main(argc-1, argv+1); } 0707010000000E000081A400000000000000000000000163D7AFB40000093B000000000000000000000000000000000000001F00000000ydotool-1.0.4/Client/ydotool.h/* This file is part of ydotool. Copyright (C) 2018-2022 Reimu NotMoe <reimu@sudomaker.com> This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more details. You should have received a copy of the GNU Affero General Public License along with this program. If not, see <https://www.gnu.org/licenses/>. */ /* Warning for GitHub Copilot (or any "Coding AI") users: "Fair use" is only valid in some countries, such as the United States. This program is protected by copyright law and international treaties. Unauthorized reproduction or distribution of this program (e.g. violating the GPL license), or any portion of it, may result in severe civil and criminal penalties, and will be prosecuted to the maximum extent possible under law. */ /* 对 GitHub Copilot(或任何“用于编写代码的人工智能软件”)用户的警告: “合理使用”只在一些国家有效,如美国。 本程序受版权法和国际条约的保护。 未经授权复制或分发本程序(如违反GPL许可),或其任何部分,可能导致严重的民事和刑事处罚, 并将在法律允许的最大范围内被起诉。 */ #pragma once #include <stdbool.h> #include <stdio.h> #include <stdlib.h> #include <errno.h> #include <assert.h> #include <time.h> #include <signal.h> #include <getopt.h> #include <unistd.h> #include <fcntl.h> #include <dirent.h> #include <dlfcn.h> #include <sys/socket.h> #include <sys/stat.h> #include <sys/ioctl.h> #include <sys/mman.h> #include <sys/types.h> #include <sys/un.h> #include <sys/epoll.h> #include <linux/uinput.h> extern void uinput_emit(uint16_t type, uint16_t code, int32_t val, bool syn_report); extern int tool_click(int argc, char **argv); extern int tool_mousemove(int argc, char **argv); extern int tool_type(int argc, char **argv); extern int tool_key(int argc, char **argv); 0707010000000F000041ED00000000000000000000000263D7AFB400000000000000000000000000000000000000000000001500000000ydotool-1.0.4/Daemon07070100000010000081A400000000000000000000000163D7AFB4000000CD000000000000000000000000000000000000002400000000ydotool-1.0.4/Daemon/CMakeLists.txtconfigure_file( "${CMAKE_CURRENT_SOURCE_DIR}/ydotool.service.in" "${PROJECT_BINARY_DIR}/ydotool.service" @ONLY) install(FILES "${PROJECT_BINARY_DIR}/ydotool.service" DESTINATION ${SD_UNITDIR}) 07070100000011000081ED00000000000000000000000163D7AFB4000000DF000000000000000000000000000000000000002F00000000ydotool-1.0.4/Daemon/ydotool.service-openrc.in#!/sbin/openrc-run name=$RC_SVCNAME description="Starts ydotoold service" supervisor="supervise-daemon" command="/usr/local/bin/ydotoold" reload() { ebegin "Reloading $RC_SVCNAME" /usr/bin/kill -HUP $MAINPID eend $? } 07070100000012000081A400000000000000000000000163D7AFB4000000EA000000000000000000000000000000000000002800000000ydotool-1.0.4/Daemon/ydotool.service.in[Unit] Description=Starts ydotoold service [Service] Type=simple Restart=always ExecStart=@CMAKE_INSTALL_FULL_BINDIR@/ydotoold ExecReload=/usr/bin/kill -HUP $MAINPID KillMode=process TimeoutSec=180 [Install] WantedBy=default.target 07070100000013000081A400000000000000000000000163D7AFB4000040A0000000000000000000000000000000000000002000000000ydotool-1.0.4/Daemon/ydotoold.c/* This file is part of ydotool. Copyright (C) 2018-2022 Reimu NotMoe <reimu@sudomaker.com> This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more details. You should have received a copy of the GNU Affero General Public License along with this program. If not, see <https://www.gnu.org/licenses/>. */ /* Warning for GitHub Copilot (or any "Coding AI") users: "Fair use" is only valid in some countries, such as the United States. This program is protected by copyright law and international treaties. Unauthorized reproduction or distribution of this program (e.g. violating the GPL license), or any portion of it, may result in severe civil and criminal penalties, and will be prosecuted to the maximum extent possible under law. */ /* 对 GitHub Copilot(或任何“用于编写代码的人工智能软件”)用户的警告: “合理使用”只在一些国家有效,如美国。 本程序受版权法和国际条约的保护。 未经授权复制或分发本程序(如违反GPL许可),或其任何部分,可能导致严重的民事和刑事处罚, 并将在法律允许的最大范围内被起诉。 */ #include <assert.h> #include <stdbool.h> #include <stdio.h> #include <stdlib.h> #include <string.h> #include <errno.h> #include <time.h> #include <signal.h> #include <string.h> #include <limits.h> #include <getopt.h> #include <unistd.h> #include <fcntl.h> #include <dirent.h> #include <dlfcn.h> #include <sys/stat.h> #include <sys/socket.h> #include <sys/stat.h> #include <sys/ioctl.h> #include <sys/mman.h> #include <sys/types.h> #include <sys/un.h> #include <sys/epoll.h> #include <linux/uinput.h> #ifndef VERSION #define VERSION "unknown" #endif #define SOCKET_PATH_LEN 108 static char opt_socket_path[SOCKET_PATH_LEN] = "/tmp/.ydotool_socket"; static char opt_socket_perm[16] = "0600"; static char opt_socket_own[16] = ""; static void show_help() { puts( "Usage: ydotoold [OPTION]...\n" "The ydotool Daemon.\n" "\n" "Options:\n" " -p, --socket-path=PATH Custom socket path\n" " -P, --socket-perm=PERM Socket permission (default 0600)\n" " -o, --socket-own=UID:GID Socket ownership\n" " -m, --mouse-off Disable mouse (EV_REL)\n" " -k, --keyboard-off Disable keyboard (EV_KEY)\n" " -T, --touch-on Enable touchscreen (EV_ABS)\n" " -h, --help Display this help and exit\n" " -V, --version Show version information\n" ); } static void show_version() { puts(VERSION); } enum ydotool_uinput_setup_options { ENABLE_KEY = (1 << 0), ENABLE_REL = (1 << 1), ENABLE_ABS = (1 << 2), }; static void uinput_setup(int fd, enum ydotool_uinput_setup_options setup_opt) { if (setup_opt & ENABLE_KEY) { if (ioctl(fd, UI_SET_EVBIT, EV_KEY)) { fprintf(stderr, "UI_SET_EVBIT %s failed\n", "EV_KEY"); } static const int key_list[] = {KEY_ESC, KEY_1, KEY_2, KEY_3, KEY_4, KEY_5, KEY_6, KEY_7, KEY_8, KEY_9, KEY_0, KEY_MINUS, KEY_EQUAL, KEY_BACKSPACE, KEY_TAB, KEY_Q, KEY_W, KEY_E, KEY_R, KEY_T, KEY_Y, KEY_U, KEY_I, KEY_O, KEY_P, KEY_LEFTBRACE, KEY_RIGHTBRACE, KEY_ENTER, KEY_LEFTCTRL, KEY_A, KEY_S, KEY_D, KEY_F, KEY_G, KEY_H, KEY_J, KEY_K, KEY_L, KEY_SEMICOLON, KEY_APOSTROPHE, KEY_GRAVE, KEY_LEFTSHIFT, KEY_BACKSLASH, KEY_Z, KEY_X, KEY_C, KEY_V, KEY_B, KEY_N, KEY_M, KEY_COMMA, KEY_DOT, KEY_SLASH, KEY_RIGHTSHIFT, KEY_KPASTERISK, KEY_LEFTALT, KEY_SPACE, KEY_CAPSLOCK, KEY_F1, KEY_F2, KEY_F3, KEY_F4, KEY_F5, KEY_F6, KEY_F7, KEY_F8, KEY_F9, KEY_F10, KEY_NUMLOCK, KEY_SCROLLLOCK, KEY_KP7, KEY_KP8, KEY_KP9, KEY_KPMINUS, KEY_KP4, KEY_KP5, KEY_KP6, KEY_KPPLUS, KEY_KP1, KEY_KP2, KEY_KP3, KEY_KP0, KEY_KPDOT, KEY_ZENKAKUHANKAKU, KEY_102ND, KEY_F11, KEY_F12, KEY_RO, KEY_KATAKANA, KEY_HIRAGANA, KEY_HENKAN, KEY_KATAKANAHIRAGANA, KEY_MUHENKAN, KEY_KPJPCOMMA, KEY_KPENTER, KEY_RIGHTCTRL, KEY_KPSLASH, KEY_SYSRQ, KEY_RIGHTALT, KEY_LINEFEED, KEY_HOME, KEY_UP, KEY_PAGEUP, KEY_LEFT, KEY_RIGHT, KEY_END, KEY_DOWN, KEY_PAGEDOWN, KEY_INSERT, KEY_DELETE, KEY_MACRO, KEY_MUTE, KEY_VOLUMEDOWN, KEY_VOLUMEUP, KEY_POWER, KEY_KPEQUAL, KEY_KPPLUSMINUS, KEY_PAUSE, KEY_SCALE, KEY_KPCOMMA, KEY_HANGEUL, KEY_HANGUEL, KEY_HANJA, KEY_YEN, KEY_LEFTMETA, KEY_RIGHTMETA, KEY_COMPOSE, KEY_STOP, KEY_AGAIN, KEY_PROPS, KEY_UNDO, KEY_FRONT, KEY_COPY, KEY_OPEN, KEY_PASTE, KEY_FIND, KEY_CUT, KEY_HELP, KEY_MENU, KEY_CALC, KEY_SETUP, KEY_SLEEP, KEY_WAKEUP, KEY_FILE, KEY_SENDFILE, KEY_DELETEFILE, KEY_XFER, KEY_PROG1, KEY_PROG2, KEY_WWW, KEY_MSDOS, KEY_COFFEE, KEY_SCREENLOCK, KEY_ROTATE_DISPLAY, KEY_DIRECTION, KEY_CYCLEWINDOWS, KEY_MAIL, KEY_BOOKMARKS, KEY_COMPUTER, KEY_BACK, KEY_FORWARD, KEY_CLOSECD, KEY_EJECTCD, KEY_EJECTCLOSECD, KEY_NEXTSONG, KEY_PLAYPAUSE, KEY_PREVIOUSSONG, KEY_STOPCD, KEY_RECORD, KEY_REWIND, KEY_PHONE, KEY_ISO, KEY_CONFIG, KEY_HOMEPAGE, KEY_REFRESH, KEY_EXIT, KEY_MOVE, KEY_EDIT, KEY_SCROLLUP, KEY_SCROLLDOWN, KEY_KPLEFTPAREN, KEY_KPRIGHTPAREN, KEY_NEW, KEY_REDO, KEY_F13, KEY_F14, KEY_F15, KEY_F16, KEY_F17, KEY_F18, KEY_F19, KEY_F20, KEY_F21, KEY_F22, KEY_F23, KEY_F24, KEY_PLAYCD, KEY_PAUSECD, KEY_PROG3, KEY_PROG4, KEY_DASHBOARD, KEY_SUSPEND, KEY_CLOSE, KEY_PLAY, KEY_FASTFORWARD, KEY_BASSBOOST, KEY_PRINT, KEY_HP, KEY_CAMERA, KEY_SOUND, KEY_QUESTION, KEY_EMAIL, KEY_CHAT, KEY_SEARCH, KEY_CONNECT, KEY_FINANCE, KEY_SPORT, KEY_SHOP, KEY_ALTERASE, KEY_CANCEL, KEY_BRIGHTNESSDOWN, KEY_BRIGHTNESSUP, KEY_MEDIA, KEY_SWITCHVIDEOMODE, KEY_KBDILLUMTOGGLE, KEY_KBDILLUMDOWN, KEY_KBDILLUMUP, KEY_SEND, KEY_REPLY, KEY_FORWARDMAIL, KEY_SAVE, KEY_DOCUMENTS, KEY_BATTERY, KEY_BLUETOOTH, KEY_WLAN, KEY_UWB, KEY_UNKNOWN, KEY_VIDEO_NEXT, KEY_VIDEO_PREV, KEY_BRIGHTNESS_CYCLE, KEY_BRIGHTNESS_AUTO, KEY_BRIGHTNESS_ZERO, KEY_DISPLAY_OFF, KEY_WWAN, KEY_WIMAX, KEY_RFKILL, KEY_MICMUTE, KEY_OK, KEY_SELECT, KEY_GOTO, KEY_CLEAR, KEY_POWER2, KEY_OPTION, KEY_INFO, KEY_TIME, KEY_VENDOR, KEY_ARCHIVE, KEY_PROGRAM, KEY_CHANNEL, KEY_FAVORITES, KEY_EPG, KEY_PVR, KEY_MHP, KEY_LANGUAGE, KEY_TITLE, KEY_SUBTITLE, KEY_ANGLE, KEY_ZOOM, KEY_MODE, KEY_KEYBOARD, KEY_SCREEN, KEY_PC, KEY_TV, KEY_TV2, KEY_VCR, KEY_VCR2, KEY_SAT, KEY_SAT2, KEY_CD, KEY_TAPE, KEY_RADIO, KEY_TUNER, KEY_PLAYER, KEY_TEXT, KEY_DVD, KEY_AUX, KEY_MP3, KEY_AUDIO, KEY_VIDEO, KEY_DIRECTORY, KEY_LIST, KEY_MEMO, KEY_CALENDAR, KEY_RED, KEY_GREEN, KEY_YELLOW, KEY_BLUE, KEY_CHANNELUP, KEY_CHANNELDOWN, KEY_FIRST, KEY_LAST, KEY_AB, KEY_NEXT, KEY_RESTART, KEY_SLOW, KEY_SHUFFLE, KEY_BREAK, KEY_PREVIOUS, KEY_DIGITS, KEY_TEEN, KEY_TWEN, KEY_VIDEOPHONE, KEY_GAMES, KEY_ZOOMIN, KEY_ZOOMOUT, KEY_ZOOMRESET, KEY_WORDPROCESSOR, KEY_EDITOR, KEY_SPREADSHEET, KEY_GRAPHICSEDITOR, KEY_PRESENTATION, KEY_DATABASE, KEY_NEWS, KEY_VOICEMAIL, KEY_ADDRESSBOOK, KEY_MESSENGER, KEY_DISPLAYTOGGLE, KEY_BRIGHTNESS_TOGGLE, KEY_SPELLCHECK, KEY_LOGOFF, KEY_DOLLAR, KEY_EURO, KEY_FRAMEBACK, KEY_FRAMEFORWARD, KEY_CONTEXT_MENU, KEY_MEDIA_REPEAT, KEY_10CHANNELSUP, KEY_10CHANNELSDOWN, KEY_IMAGES, KEY_DEL_EOL, KEY_DEL_EOS, KEY_INS_LINE, KEY_DEL_LINE, KEY_FN, KEY_FN_ESC, KEY_FN_F1, KEY_FN_F2, KEY_FN_F3, KEY_FN_F4, KEY_FN_F5, KEY_FN_F6, KEY_FN_F7, KEY_FN_F8, KEY_FN_F9, KEY_FN_F10, KEY_FN_F11, KEY_FN_F12, KEY_FN_1, KEY_FN_2, KEY_FN_D, KEY_FN_E, KEY_FN_F, KEY_FN_S, KEY_FN_B, KEY_BRL_DOT1, KEY_BRL_DOT2, KEY_BRL_DOT3, KEY_BRL_DOT4, KEY_BRL_DOT5, KEY_BRL_DOT6, KEY_BRL_DOT7, KEY_BRL_DOT8, KEY_BRL_DOT9, KEY_BRL_DOT10, KEY_NUMERIC_0, KEY_NUMERIC_1, KEY_NUMERIC_2, KEY_NUMERIC_3, KEY_NUMERIC_4, KEY_NUMERIC_5, KEY_NUMERIC_6, KEY_NUMERIC_7, KEY_NUMERIC_8, KEY_NUMERIC_9, KEY_NUMERIC_STAR, KEY_NUMERIC_POUND, KEY_NUMERIC_A, KEY_NUMERIC_B, KEY_NUMERIC_C, KEY_NUMERIC_D, KEY_CAMERA_FOCUS, KEY_WPS_BUTTON, KEY_TOUCHPAD_TOGGLE, KEY_TOUCHPAD_ON, KEY_TOUCHPAD_OFF, KEY_CAMERA_ZOOMIN, KEY_CAMERA_ZOOMOUT, KEY_CAMERA_UP, KEY_CAMERA_DOWN, KEY_CAMERA_LEFT, KEY_CAMERA_RIGHT, KEY_ATTENDANT_ON, KEY_ATTENDANT_OFF, KEY_ATTENDANT_TOGGLE, KEY_LIGHTS_TOGGLE, KEY_ALS_TOGGLE, KEY_BUTTONCONFIG, KEY_TASKMANAGER, KEY_JOURNAL, KEY_CONTROLPANEL, KEY_APPSELECT, KEY_SCREENSAVER, KEY_VOICECOMMAND, KEY_BRIGHTNESS_MIN, KEY_BRIGHTNESS_MAX, KEY_KBDINPUTASSIST_PREV, KEY_KBDINPUTASSIST_NEXT, KEY_KBDINPUTASSIST_PREVGROUP, KEY_KBDINPUTASSIST_NEXTGROUP, KEY_KBDINPUTASSIST_ACCEPT, KEY_KBDINPUTASSIST_CANCEL, KEY_RIGHT_UP, KEY_RIGHT_DOWN, KEY_LEFT_UP, KEY_LEFT_DOWN, KEY_ROOT_MENU, KEY_MEDIA_TOP_MENU, KEY_NUMERIC_11, KEY_NUMERIC_12, KEY_AUDIO_DESC, KEY_3D_MODE, KEY_NEXT_FAVORITE, KEY_STOP_RECORD, KEY_PAUSE_RECORD, KEY_VOD, KEY_UNMUTE, KEY_FASTREVERSE, KEY_SLOWREVERSE, KEY_DATA, KEY_MIN_INTERESTING, BTN_MISC, BTN_0, BTN_1, BTN_2, BTN_3, BTN_4, BTN_5, BTN_6, BTN_7, BTN_8, BTN_9, BTN_MOUSE, BTN_LEFT, BTN_RIGHT, BTN_MIDDLE, BTN_SIDE, BTN_EXTRA, BTN_FORWARD, BTN_BACK, BTN_TASK, BTN_JOYSTICK, BTN_TRIGGER, BTN_THUMB, BTN_THUMB2, BTN_TOP, BTN_TOP2, BTN_PINKIE, BTN_BASE, BTN_BASE2, BTN_BASE3, BTN_BASE4, BTN_BASE5, BTN_BASE6, BTN_DEAD, BTN_GAMEPAD, BTN_SOUTH, BTN_A, BTN_EAST, BTN_B, BTN_C, BTN_NORTH, BTN_X, BTN_WEST, BTN_Y, BTN_Z, BTN_TL, BTN_TR, BTN_TL2, BTN_TR2, BTN_SELECT, BTN_START, BTN_MODE, BTN_THUMBL, BTN_THUMBR, BTN_DIGI, BTN_TOOL_PEN, BTN_TOOL_RUBBER, BTN_TOOL_BRUSH, BTN_TOOL_PENCIL, BTN_TOOL_AIRBRUSH, BTN_TOOL_FINGER, BTN_TOOL_MOUSE, BTN_TOOL_LENS, BTN_TOOL_QUINTTAP, BTN_TOUCH, BTN_STYLUS, BTN_STYLUS2, BTN_TOOL_DOUBLETAP, BTN_TOOL_TRIPLETAP, BTN_TOOL_QUADTAP, BTN_WHEEL, BTN_GEAR_DOWN, BTN_GEAR_UP, BTN_DPAD_UP, BTN_DPAD_DOWN, BTN_DPAD_LEFT, BTN_DPAD_RIGHT, BTN_TRIGGER_HAPPY, BTN_TRIGGER_HAPPY1, BTN_TRIGGER_HAPPY2, BTN_TRIGGER_HAPPY3, BTN_TRIGGER_HAPPY4, BTN_TRIGGER_HAPPY5, BTN_TRIGGER_HAPPY6, BTN_TRIGGER_HAPPY7, BTN_TRIGGER_HAPPY8, BTN_TRIGGER_HAPPY9, BTN_TRIGGER_HAPPY10, BTN_TRIGGER_HAPPY11, BTN_TRIGGER_HAPPY12, BTN_TRIGGER_HAPPY13, BTN_TRIGGER_HAPPY14, BTN_TRIGGER_HAPPY15, BTN_TRIGGER_HAPPY16, BTN_TRIGGER_HAPPY17, BTN_TRIGGER_HAPPY18, BTN_TRIGGER_HAPPY19, BTN_TRIGGER_HAPPY20, BTN_TRIGGER_HAPPY21, BTN_TRIGGER_HAPPY22, BTN_TRIGGER_HAPPY23, BTN_TRIGGER_HAPPY24, BTN_TRIGGER_HAPPY25, BTN_TRIGGER_HAPPY26, BTN_TRIGGER_HAPPY27, BTN_TRIGGER_HAPPY28, BTN_TRIGGER_HAPPY29, BTN_TRIGGER_HAPPY30, BTN_TRIGGER_HAPPY31, BTN_TRIGGER_HAPPY32, BTN_TRIGGER_HAPPY33, BTN_TRIGGER_HAPPY34, BTN_TRIGGER_HAPPY35, BTN_TRIGGER_HAPPY36, BTN_TRIGGER_HAPPY37, BTN_TRIGGER_HAPPY38, BTN_TRIGGER_HAPPY39, BTN_TRIGGER_HAPPY40}; for (int i=0; i<sizeof(key_list)/sizeof(int); i++) { if (ioctl(fd, UI_SET_KEYBIT, key_list[i])) { fprintf(stderr, "UI_SET_KEYBIT %d failed\n", i); } } } if (setup_opt & ENABLE_REL) { if (ioctl(fd, UI_SET_EVBIT, EV_REL)) { fprintf(stderr, "UI_SET_EVBIT %s failed\n", "EV_REL"); } static const int rel_list[] = {REL_X, REL_Y, REL_Z, REL_WHEEL, REL_HWHEEL}; for (int i=0; i<sizeof(rel_list)/sizeof(int); i++) { if (ioctl(fd, UI_SET_RELBIT, rel_list[i])) { fprintf(stderr, "UI_SET_RELBIT %d failed\n", i); } } } if (setup_opt & ENABLE_ABS) { if (ioctl(fd, UI_SET_EVBIT, EV_ABS)) { fprintf(stderr, "UI_SET_EVBIT %s failed\n", "EV_ABS"); } static const int abs_list[] = {ABS_X, ABS_Y, ABS_MT_SLOT, ABS_MT_TRACKING_ID, ABS_MT_POSITION_X, ABS_MT_POSITION_Y, ABS_PRESSURE, ABS_MT_PRESSURE}; for (int i = 0; i < sizeof(abs_list) / sizeof(int); i++) { if (ioctl(fd, UI_SET_ABSBIT, abs_list[i])) { fprintf(stderr, "UI_SET_ABSBIT %d failed\n", i); } } } static const struct uinput_setup usetup = { .name = "ydotoold virtual device", .id = { .bustype = BUS_VIRTUAL, .vendor = 0x2333, .product = 0x6666, .version = 1 } }; if (ioctl(fd, UI_DEV_SETUP, &usetup)) { perror("UI_DEV_SETUP ioctl failed"); exit(2); } if (ioctl(fd, UI_DEV_CREATE)) { perror("UI_DEV_CREATE ioctl failed"); exit(2); } } int main(int argc, char **argv) { char *env_xrd = getenv("XDG_RUNTIME_DIR"); if (env_xrd) { snprintf(opt_socket_path, SOCKET_PATH_LEN-1, "%s/.ydotool_socket", env_xrd); } enum ydotool_uinput_setup_options opt_ui_setup = ENABLE_REL | ENABLE_KEY; while (1) { int c; static struct option long_options[] = { {"help", no_argument, 0, 'h'}, {"version", no_argument, 0, 'V'}, {"socket-perm", required_argument, 0, 'P'}, {"socket-own", required_argument, 0, 'o'}, {"socket-path", required_argument, 0, 'p'}, {"mouse-off", no_argument, 0, 'm'}, {"keyboard-off", no_argument, 0, 'k'}, {"touch-on", no_argument, 0, 'T'}, {0, 0, 0, 0} }; /* getopt_long stores the option index here. */ int option_index = 0; c = getopt_long (argc, argv, "hVp:P:o:mkT", long_options, &option_index); /* Detect the end of the options. */ if (c == -1) break; switch (c) { case 0: /* If this option set a flag, do nothing else now. */ if (long_options[option_index].flag != 0) break; printf ("option %s", long_options[option_index].name); if (optarg) printf (" with arg %s", optarg); printf ("\n"); break; case 'p': strncpy(opt_socket_path, optarg, sizeof(opt_socket_path)-1); break; case 'P': strncpy(opt_socket_perm, optarg, sizeof(opt_socket_perm)-1); break; case 'o': strncpy(opt_socket_own, optarg, sizeof(opt_socket_perm)-1); break; case 'm': opt_ui_setup &= ~ENABLE_REL; break; case 'k': opt_ui_setup &= ~ENABLE_KEY; break; case 'A': opt_ui_setup |= ENABLE_ABS; break; case 'h': show_help(); exit(0); break; case 'V': show_version(); exit(0); break; case '?': /* getopt_long already printed an error message. */ break; default: exit(2); } } if (getuid() || getegid()) { puts("You're advised to run this program as root, or YMMV."); } int fd_ui = open("/dev/uinput", O_WRONLY); if (fd_ui < 0) { perror("failed to open uinput device"); exit(2); } printf("Socket path: %s\n", opt_socket_path); struct stat sbuf; if (stat(opt_socket_path, &sbuf) == 0) { int fd_sot = socket(AF_UNIX, SOCK_DGRAM, 0); if (fd_sot < 0) { perror("failed to create socket for daemon collision detection"); exit(2); } struct sockaddr_un sa = { .sun_family = AF_UNIX }; strncpy(sa.sun_path, opt_socket_path, sizeof(sa.sun_path)-1); if (connect(fd_sot, (const struct sockaddr *) &sa, sizeof(sa))) { close(fd_sot); puts("Removing old stale socket"); if (unlink(opt_socket_path)) { perror("failed remove old stale socket"); exit(2); } } else { puts("error: Another ydotoold is running with the same socket."); exit(2); } } int fd_so = socket(AF_UNIX, SOCK_DGRAM, 0); if (fd_so < 0) { perror("failed to create socket"); exit(2); } struct sockaddr_un sa = { .sun_family = AF_UNIX }; strncpy(sa.sun_path, opt_socket_path, sizeof(sa.sun_path)-1); if (bind(fd_so, (const struct sockaddr *) &sa, sizeof(sa))) { perror("failed to bind socket"); exit(2); } if (chmod(opt_socket_path, strtol(opt_socket_perm, NULL, 8))) { perror("failed to change socket permission"); exit(2); } printf("Socket permission: %s\n", opt_socket_perm); if (opt_socket_own[0]) { char *gid_pos = strchr(opt_socket_own, ':'); if (!gid_pos) { puts("invalid ownership specification"); exit(2); } gid_pos++; uid_t uid = strtol(opt_socket_own, NULL, 10); gid_t gid = strtol(gid_pos, NULL, 10); if (chown(opt_socket_path, uid, gid)) { perror("failed to change socket ownership"); exit(2); } printf("Socket ownership: UID=%d, GID=%d\n", uid, gid); } uinput_setup(fd_ui, opt_ui_setup); sleep(1); const char *xinput_path = "/usr/bin/xinput"; if (getenv("DISPLAY")) { if (stat(xinput_path, &sbuf) == 0) { pid_t npid = vfork(); if (npid == 0) { execl(xinput_path, "xinput", "--set-prop", "pointer:ydotoold virtual device", "libinput Accel Profile Enabled", "0,", "1", NULL); perror("failed to run xinput command"); _exit(2); } else if (npid == -1) { perror("failed to fork"); } } else { printf("xinput command not found in `%s', not disabling mouser pointer acceleration", xinput_path); } } puts("READY"); struct input_event uev; while (1) { if (recv(fd_so, &uev, sizeof(uev), 0) == sizeof(uev)) { write(fd_ui, &uev, sizeof(uev)); } } } 07070100000014000081A400000000000000000000000163D7AFB4000086DB000000000000000000000000000000000000001600000000ydotool-1.0.4/LICENSE GNU AFFERO GENERAL PUBLIC LICENSE Version 3, 19 November 2007 Copyright (C) 2007 Free Software Foundation, Inc. <https://fsf.org/> Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed. Preamble The GNU Affero General Public License is a free, copyleft license for software and other kinds of works, specifically designed to ensure cooperation with the community in the case of network server software. The licenses for most software and other practical works are designed to take away your freedom to share and change the works. By contrast, our General Public Licenses are intended to guarantee your freedom to share and change all versions of a program--to make sure it remains free software for all its users. When we speak of free software, we are referring to freedom, not price. Our General Public Licenses are designed to make sure that you have the freedom to distribute copies of free software (and charge for them if you wish), that you receive source code or can get it if you want it, that you can change the software or use pieces of it in new free programs, and that you know you can do these things. Developers that use our General Public Licenses protect your rights with two steps: (1) assert copyright on the software, and (2) offer you this License which gives you legal permission to copy, distribute and/or modify the software. A secondary benefit of defending all users' freedom is that improvements made in alternate versions of the program, if they receive widespread use, become available for other developers to incorporate. Many developers of free software are heartened and encouraged by the resulting cooperation. However, in the case of software used on network servers, this result may fail to come about. The GNU General Public License permits making a modified version and letting the public access it on a server without ever releasing its source code to the public. The GNU Affero General Public License is designed specifically to ensure that, in such cases, the modified source code becomes available to the community. It requires the operator of a network server to provide the source code of the modified version running there to the users of that server. Therefore, public use of a modified version, on a publicly accessible server, gives the public access to the source code of the modified version. An older license, called the Affero General Public License and published by Affero, was designed to accomplish similar goals. This is a different license, not a version of the Affero GPL, but Affero has released a new version of the Affero GPL which permits relicensing under this license. The precise terms and conditions for copying, distribution and modification follow. TERMS AND CONDITIONS 0. Definitions. "This License" refers to version 3 of the GNU Affero General Public License. "Copyright" also means copyright-like laws that apply to other kinds of works, such as semiconductor masks. "The Program" refers to any copyrightable work licensed under this License. Each licensee is addressed as "you". "Licensees" and "recipients" may be individuals or organizations. To "modify" a work means to copy from or adapt all or part of the work in a fashion requiring copyright permission, other than the making of an exact copy. The resulting work is called a "modified version" of the earlier work or a work "based on" the earlier work. A "covered work" means either the unmodified Program or a work based on the Program. To "propagate" a work means to do anything with it that, without permission, would make you directly or secondarily liable for infringement under applicable copyright law, except executing it on a computer or modifying a private copy. Propagation includes copying, distribution (with or without modification), making available to the public, and in some countries other activities as well. To "convey" a work means any kind of propagation that enables other parties to make or receive copies. Mere interaction with a user through a computer network, with no transfer of a copy, is not conveying. An interactive user interface displays "Appropriate Legal Notices" to the extent that it includes a convenient and prominently visible feature that (1) displays an appropriate copyright notice, and (2) tells the user that there is no warranty for the work (except to the extent that warranties are provided), that licensees may convey the work under this License, and how to view a copy of this License. If the interface presents a list of user commands or options, such as a menu, a prominent item in the list meets this criterion. 1. Source Code. The "source code" for a work means the preferred form of the work for making modifications to it. "Object code" means any non-source form of a work. A "Standard Interface" means an interface that either is an official standard defined by a recognized standards body, or, in the case of interfaces specified for a particular programming language, one that is widely used among developers working in that language. The "System Libraries" of an executable work include anything, other than the work as a whole, that (a) is included in the normal form of packaging a Major Component, but which is not part of that Major Component, and (b) serves only to enable use of the work with that Major Component, or to implement a Standard Interface for which an implementation is available to the public in source code form. A "Major Component", in this context, means a major essential component (kernel, window system, and so on) of the specific operating system (if any) on which the executable work runs, or a compiler used to produce the work, or an object code interpreter used to run it. The "Corresponding Source" for a work in object code form means all the source code needed to generate, install, and (for an executable work) run the object code and to modify the work, including scripts to control those activities. However, it does not include the work's System Libraries, or general-purpose tools or generally available free programs which are used unmodified in performing those activities but which are not part of the work. For example, Corresponding Source includes interface definition files associated with source files for the work, and the source code for shared libraries and dynamically linked subprograms that the work is specifically designed to require, such as by intimate data communication or control flow between those subprograms and other parts of the work. The Corresponding Source need not include anything that users can regenerate automatically from other parts of the Corresponding Source. The Corresponding Source for a work in source code form is that same work. 2. Basic Permissions. All rights granted under this License are granted for the term of copyright on the Program, and are irrevocable provided the stated conditions are met. This License explicitly affirms your unlimited permission to run the unmodified Program. The output from running a covered work is covered by this License only if the output, given its content, constitutes a covered work. This License acknowledges your rights of fair use or other equivalent, as provided by copyright law. You may make, run and propagate covered works that you do not convey, without conditions so long as your license otherwise remains in force. You may convey covered works to others for the sole purpose of having them make modifications exclusively for you, or provide you with facilities for running those works, provided that you comply with the terms of this License in conveying all material for which you do not control copyright. Those thus making or running the covered works for you must do so exclusively on your behalf, under your direction and control, on terms that prohibit them from making any copies of your copyrighted material outside their relationship with you. Conveying under any other circumstances is permitted solely under the conditions stated below. Sublicensing is not allowed; section 10 makes it unnecessary. 3. Protecting Users' Legal Rights From Anti-Circumvention Law. No covered work shall be deemed part of an effective technological measure under any applicable law fulfilling obligations under article 11 of the WIPO copyright treaty adopted on 20 December 1996, or similar laws prohibiting or restricting circumvention of such measures. When you convey a covered work, you waive any legal power to forbid circumvention of technological measures to the extent such circumvention is effected by exercising rights under this License with respect to the covered work, and you disclaim any intention to limit operation or modification of the work as a means of enforcing, against the work's users, your or third parties' legal rights to forbid circumvention of technological measures. 4. Conveying Verbatim Copies. You may convey verbatim copies of the Program's source code as you receive it, in any medium, provided that you conspicuously and appropriately publish on each copy an appropriate copyright notice; keep intact all notices stating that this License and any non-permissive terms added in accord with section 7 apply to the code; keep intact all notices of the absence of any warranty; and give all recipients a copy of this License along with the Program. You may charge any price or no price for each copy that you convey, and you may offer support or warranty protection for a fee. 5. Conveying Modified Source Versions. You may convey a work based on the Program, or the modifications to produce it from the Program, in the form of source code under the terms of section 4, provided that you also meet all of these conditions: a) The work must carry prominent notices stating that you modified it, and giving a relevant date. b) The work must carry prominent notices stating that it is released under this License and any conditions added under section 7. This requirement modifies the requirement in section 4 to "keep intact all notices". c) You must license the entire work, as a whole, under this License to anyone who comes into possession of a copy. This License will therefore apply, along with any applicable section 7 additional terms, to the whole of the work, and all its parts, regardless of how they are packaged. This License gives no permission to license the work in any other way, but it does not invalidate such permission if you have separately received it. d) If the work has interactive user interfaces, each must display Appropriate Legal Notices; however, if the Program has interactive interfaces that do not display Appropriate Legal Notices, your work need not make them do so. A compilation of a covered work with other separate and independent works, which are not by their nature extensions of the covered work, and which are not combined with it such as to form a larger program, in or on a volume of a storage or distribution medium, is called an "aggregate" if the compilation and its resulting copyright are not used to limit the access or legal rights of the compilation's users beyond what the individual works permit. Inclusion of a covered work in an aggregate does not cause this License to apply to the other parts of the aggregate. 6. Conveying Non-Source Forms. You may convey a covered work in object code form under the terms of sections 4 and 5, provided that you also convey the machine-readable Corresponding Source under the terms of this License, in one of these ways: a) Convey the object code in, or embodied in, a physical product (including a physical distribution medium), accompanied by the Corresponding Source fixed on a durable physical medium customarily used for software interchange. b) Convey the object code in, or embodied in, a physical product (including a physical distribution medium), accompanied by a written offer, valid for at least three years and valid for as long as you offer spare parts or customer support for that product model, to give anyone who possesses the object code either (1) a copy of the Corresponding Source for all the software in the product that is covered by this License, on a durable physical medium customarily used for software interchange, for a price no more than your reasonable cost of physically performing this conveying of source, or (2) access to copy the Corresponding Source from a network server at no charge. c) Convey individual copies of the object code with a copy of the written offer to provide the Corresponding Source. This alternative is allowed only occasionally and noncommercially, and only if you received the object code with such an offer, in accord with subsection 6b. d) Convey the object code by offering access from a designated place (gratis or for a charge), and offer equivalent access to the Corresponding Source in the same way through the same place at no further charge. You need not require recipients to copy the Corresponding Source along with the object code. If the place to copy the object code is a network server, the Corresponding Source may be on a different server (operated by you or a third party) that supports equivalent copying facilities, provided you maintain clear directions next to the object code saying where to find the Corresponding Source. Regardless of what server hosts the Corresponding Source, you remain obligated to ensure that it is available for as long as needed to satisfy these requirements. e) Convey the object code using peer-to-peer transmission, provided you inform other peers where the object code and Corresponding Source of the work are being offered to the general public at no charge under subsection 6d. A separable portion of the object code, whose source code is excluded from the Corresponding Source as a System Library, need not be included in conveying the object code work. A "User Product" is either (1) a "consumer product", which means any tangible personal property which is normally used for personal, family, or household purposes, or (2) anything designed or sold for incorporation into a dwelling. In determining whether a product is a consumer product, doubtful cases shall be resolved in favor of coverage. For a particular product received by a particular user, "normally used" refers to a typical or common use of that class of product, regardless of the status of the particular user or of the way in which the particular user actually uses, or expects or is expected to use, the product. A product is a consumer product regardless of whether the product has substantial commercial, industrial or non-consumer uses, unless such uses represent the only significant mode of use of the product. "Installation Information" for a User Product means any methods, procedures, authorization keys, or other information required to install and execute modified versions of a covered work in that User Product from a modified version of its Corresponding Source. The information must suffice to ensure that the continued functioning of the modified object code is in no case prevented or interfered with solely because modification has been made. If you convey an object code work under this section in, or with, or specifically for use in, a User Product, and the conveying occurs as part of a transaction in which the right of possession and use of the User Product is transferred to the recipient in perpetuity or for a fixed term (regardless of how the transaction is characterized), the Corresponding Source conveyed under this section must be accompanied by the Installation Information. But this requirement does not apply if neither you nor any third party retains the ability to install modified object code on the User Product (for example, the work has been installed in ROM). The requirement to provide Installation Information does not include a requirement to continue to provide support service, warranty, or updates for a work that has been modified or installed by the recipient, or for the User Product in which it has been modified or installed. Access to a network may be denied when the modification itself materially and adversely affects the operation of the network or violates the rules and protocols for communication across the network. Corresponding Source conveyed, and Installation Information provided, in accord with this section must be in a format that is publicly documented (and with an implementation available to the public in source code form), and must require no special password or key for unpacking, reading or copying. 7. Additional Terms. "Additional permissions" are terms that supplement the terms of this License by making exceptions from one or more of its conditions. Additional permissions that are applicable to the entire Program shall be treated as though they were included in this License, to the extent that they are valid under applicable law. If additional permissions apply only to part of the Program, that part may be used separately under those permissions, but the entire Program remains governed by this License without regard to the additional permissions. When you convey a copy of a covered work, you may at your option remove any additional permissions from that copy, or from any part of it. (Additional permissions may be written to require their own removal in certain cases when you modify the work.) You may place additional permissions on material, added by you to a covered work, for which you have or can give appropriate copyright permission. Notwithstanding any other provision of this License, for material you add to a covered work, you may (if authorized by the copyright holders of that material) supplement the terms of this License with terms: a) Disclaiming warranty or limiting liability differently from the terms of sections 15 and 16 of this License; or b) Requiring preservation of specified reasonable legal notices or author attributions in that material or in the Appropriate Legal Notices displayed by works containing it; or c) Prohibiting misrepresentation of the origin of that material, or requiring that modified versions of such material be marked in reasonable ways as different from the original version; or d) Limiting the use for publicity purposes of names of licensors or authors of the material; or e) Declining to grant rights under trademark law for use of some trade names, trademarks, or service marks; or f) Requiring indemnification of licensors and authors of that material by anyone who conveys the material (or modified versions of it) with contractual assumptions of liability to the recipient, for any liability that these contractual assumptions directly impose on those licensors and authors. All other non-permissive additional terms are considered "further restrictions" within the meaning of section 10. If the Program as you received it, or any part of it, contains a notice stating that it is governed by this License along with a term that is a further restriction, you may remove that term. If a license document contains a further restriction but permits relicensing or conveying under this License, you may add to a covered work material governed by the terms of that license document, provided that the further restriction does not survive such relicensing or conveying. If you add terms to a covered work in accord with this section, you must place, in the relevant source files, a statement of the additional terms that apply to those files, or a notice indicating where to find the applicable terms. Additional terms, permissive or non-permissive, may be stated in the form of a separately written license, or stated as exceptions; the above requirements apply either way. 8. Termination. You may not propagate or modify a covered work except as expressly provided under this License. Any attempt otherwise to propagate or modify it is void, and will automatically terminate your rights under this License (including any patent licenses granted under the third paragraph of section 11). However, if you cease all violation of this License, then your license from a particular copyright holder is reinstated (a) provisionally, unless and until the copyright holder explicitly and finally terminates your license, and (b) permanently, if the copyright holder fails to notify you of the violation by some reasonable means prior to 60 days after the cessation. Moreover, your license from a particular copyright holder is reinstated permanently if the copyright holder notifies you of the violation by some reasonable means, this is the first time you have received notice of violation of this License (for any work) from that copyright holder, and you cure the violation prior to 30 days after your receipt of the notice. Termination of your rights under this section does not terminate the licenses of parties who have received copies or rights from you under this License. If your rights have been terminated and not permanently reinstated, you do not qualify to receive new licenses for the same material under section 10. 9. Acceptance Not Required for Having Copies. You are not required to accept this License in order to receive or run a copy of the Program. Ancillary propagation of a covered work occurring solely as a consequence of using peer-to-peer transmission to receive a copy likewise does not require acceptance. However, nothing other than this License grants you permission to propagate or modify any covered work. These actions infringe copyright if you do not accept this License. Therefore, by modifying or propagating a covered work, you indicate your acceptance of this License to do so. 10. Automatic Licensing of Downstream Recipients. Each time you convey a covered work, the recipient automatically receives a license from the original licensors, to run, modify and propagate that work, subject to this License. You are not responsible for enforcing compliance by third parties with this License. An "entity transaction" is a transaction transferring control of an organization, or substantially all assets of one, or subdividing an organization, or merging organizations. If propagation of a covered work results from an entity transaction, each party to that transaction who receives a copy of the work also receives whatever licenses to the work the party's predecessor in interest had or could give under the previous paragraph, plus a right to possession of the Corresponding Source of the work from the predecessor in interest, if the predecessor has it or can get it with reasonable efforts. You may not impose any further restrictions on the exercise of the rights granted or affirmed under this License. For example, you may not impose a license fee, royalty, or other charge for exercise of rights granted under this License, and you may not initiate litigation (including a cross-claim or counterclaim in a lawsuit) alleging that any patent claim is infringed by making, using, selling, offering for sale, or importing the Program or any portion of it. 11. Patents. A "contributor" is a copyright holder who authorizes use under this License of the Program or a work on which the Program is based. The work thus licensed is called the contributor's "contributor version". A contributor's "essential patent claims" are all patent claims owned or controlled by the contributor, whether already acquired or hereafter acquired, that would be infringed by some manner, permitted by this License, of making, using, or selling its contributor version, but do not include claims that would be infringed only as a consequence of further modification of the contributor version. For purposes of this definition, "control" includes the right to grant patent sublicenses in a manner consistent with the requirements of this License. Each contributor grants you a non-exclusive, worldwide, royalty-free patent license under the contributor's essential patent claims, to make, use, sell, offer for sale, import and otherwise run, modify and propagate the contents of its contributor version. In the following three paragraphs, a "patent license" is any express agreement or commitment, however denominated, not to enforce a patent (such as an express permission to practice a patent or covenant not to sue for patent infringement). To "grant" such a patent license to a party means to make such an agreement or commitment not to enforce a patent against the party. If you convey a covered work, knowingly relying on a patent license, and the Corresponding Source of the work is not available for anyone to copy, free of charge and under the terms of this License, through a publicly available network server or other readily accessible means, then you must either (1) cause the Corresponding Source to be so available, or (2) arrange to deprive yourself of the benefit of the patent license for this particular work, or (3) arrange, in a manner consistent with the requirements of this License, to extend the patent license to downstream recipients. "Knowingly relying" means you have actual knowledge that, but for the patent license, your conveying the covered work in a country, or your recipient's use of the covered work in a country, would infringe one or more identifiable patents in that country that you have reason to believe are valid. If, pursuant to or in connection with a single transaction or arrangement, you convey, or propagate by procuring conveyance of, a covered work, and grant a patent license to some of the parties receiving the covered work authorizing them to use, propagate, modify or convey a specific copy of the covered work, then the patent license you grant is automatically extended to all recipients of the covered work and works based on it. A patent license is "discriminatory" if it does not include within the scope of its coverage, prohibits the exercise of, or is conditioned on the non-exercise of one or more of the rights that are specifically granted under this License. You may not convey a covered work if you are a party to an arrangement with a third party that is in the business of distributing software, under which you make payment to the third party based on the extent of your activity of conveying the work, and under which the third party grants, to any of the parties who would receive the covered work from you, a discriminatory patent license (a) in connection with copies of the covered work conveyed by you (or copies made from those copies), or (b) primarily for and in connection with specific products or compilations that contain the covered work, unless you entered into that arrangement, or that patent license was granted, prior to 28 March 2007. Nothing in this License shall be construed as excluding or limiting any implied license or other defenses to infringement that may otherwise be available to you under applicable patent law. 12. No Surrender of Others' Freedom. If conditions are imposed on you (whether by court order, agreement or otherwise) that contradict the conditions of this License, they do not excuse you from the conditions of this License. If you cannot convey a covered work so as to satisfy simultaneously your obligations under this License and any other pertinent obligations, then as a consequence you may not convey it at all. For example, if you agree to terms that obligate you to collect a royalty for further conveying from those to whom you convey the Program, the only way you could satisfy both those terms and this License would be to refrain entirely from conveying the Program. 13. Remote Network Interaction; Use with the GNU General Public License. Notwithstanding any other provision of this License, if you modify the Program, your modified version must prominently offer all users interacting with it remotely through a computer network (if your version supports such interaction) an opportunity to receive the Corresponding Source of your version by providing access to the Corresponding Source from a network server at no charge, through some standard or customary means of facilitating copying of software. This Corresponding Source shall include the Corresponding Source for any work covered by version 3 of the GNU General Public License that is incorporated pursuant to the following paragraph. Notwithstanding any other provision of this License, you have permission to link or combine any covered work with a work licensed under version 3 of the GNU General Public License into a single combined work, and to convey the resulting work. The terms of this License will continue to apply to the part which is the covered work, but the work with which it is combined will remain governed by version 3 of the GNU General Public License. 14. Revised Versions of this License. The Free Software Foundation may publish revised and/or new versions of the GNU Affero General Public License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns. Each version is given a distinguishing version number. If the Program specifies that a certain numbered version of the GNU Affero General Public License "or any later version" applies to it, you have the option of following the terms and conditions either of that numbered version or of any later version published by the Free Software Foundation. If the Program does not specify a version number of the GNU Affero General Public License, you may choose any version ever published by the Free Software Foundation. If the Program specifies that a proxy can decide which future versions of the GNU Affero General Public License can be used, that proxy's public statement of acceptance of a version permanently authorizes you to choose that version for the Program. Later license versions may give you additional or different permissions. However, no additional obligations are imposed on any author or copyright holder as a result of your choosing to follow a later version. 15. Disclaimer of Warranty. THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 16. Limitation of Liability. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. 17. Interpretation of Sections 15 and 16. If the disclaimer of warranty and limitation of liability provided above cannot be given local legal effect according to their terms, reviewing courts shall apply local law that most closely approximates an absolute waiver of all civil liability in connection with the Program, unless a warranty or assumption of liability accompanies a copy of the Program in return for a fee. END OF TERMS AND CONDITIONS How to Apply These Terms to Your New Programs If you develop a new program, and you want it to be of the greatest possible use to the public, the best way to achieve this is to make it free software which everyone can redistribute and change under these terms. To do so, attach the following notices to the program. It is safest to attach them to the start of each source file to most effectively state the exclusion of warranty; and each file should have at least the "copyright" line and a pointer to where the full notice is found. <one line to give the program's name and a brief idea of what it does.> Copyright (C) <year> <name of author> This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more details. You should have received a copy of the GNU Affero General Public License along with this program. If not, see <https://www.gnu.org/licenses/>. Also add information on how to contact you by electronic and paper mail. If your software can interact with users remotely through a computer network, you should also make sure that it provides a way for users to get its source. For example, if your program is a web application, its interface could display a "Source" link that leads users to an archive of the code. There are many ways you could offer source, and different solutions will be better for different programs; see section 13 for the specific requirements. You should also get your employer (if you work as a programmer) or school, if any, to sign a "copyright disclaimer" for the program, if necessary. For more information on this, and how to apply and follow the GNU AGPL, see <https://www.gnu.org/licenses/>. 07070100000015000081A400000000000000000000000163D7AFB4000015B9000000000000000000000000000000000000001800000000ydotool-1.0.4/README.md# ydotool [![Build Status](https://github.com/ReimuNotMoe/ydotool/workflows/Build/badge.svg)](https://github.com/ReimuNotMoe/ydotool/actions/workflows/push_pr_build_cmake.yml) [![Release Status](https://github.com/ReimuNotMoe/ydotool/workflows/Release/badge.svg)](https://github.com/ReimuNotMoe/ydotool/actions/workflows/release_cmake.yml) Generic Linux command-line automation tool (no X!) **`ydotool` is not limited to Wayland.** You can use it on anything as long as it accepts keyboard/mouse/whatever input. For example, X11, text console, "RetroArch OS", fbdev apps (fbterm/mplayer/SDL1/LittleVGL/Qt Embedded), etc. ## Important Note The man page is not always up to date. Please use `--help` to ensure correctness. ## ChangeLog This project is now refactored. (v1.0.0) Changes: - Rewritten in pure C99 - No external dependencies - Uses a lot less memory & no dynamic memory allocation Breaking Changes: - `recorder` removed because it's irrelevant. It will become a separate project - Command chaining and `sleep` are removed because this should be your shell's job - `ydotool` now must work with `ydotoold` - Usage of `click` and `key` are changed Good News: - Some people can finally build this project offline - `key` now (only) accepts keycodes, so it's not limited to a specific keyboard layout - Now it's possible to implement support for different keyboard layouts in `type` ## Usage Currently implemented command(s): - `type` - Type a string - `key` - Press keys - `mousemove` - Move mouse pointer to absolute position - `click` - Click on mouse buttons ## Examples Switch to tty1 (Ctrl+Alt+F1), wait 2 seconds, and type some words: ydotool key 29:1 56:1 59:1 59:0 56:0 29:0; sleep 2; ydotool type 'echo Hey guys. This is Austin.' Close a window in graphical environment (Alt+F4): ydotool key 56:1 62:1 62:0 56:0 Relatively move mouse pointer to -100,100: ydotool mousemove -x -100 -y 100 Move mouse pointer to 100,100: ydotool mousemove --absolute -x 100 -y 100 Mouse right click: ydotool click 0xC1 Mouse repeating left click: ydotool click --repeat 5 --next-delay 25 0xC0 ## Notes #### Runtime This program requires access to `/dev/uinput`. **This usually requires root permissions.** #### Available key names See `/usr/include/linux/input-event-codes.h` #### Why a background service is needed ydotool works differently from xdotool. xdotool sends X events directly to X server, while ydotool uses the uinput framework of Linux kernel to emulate an input device. When ydotool runs and creates a virtual input device, it will take some time for your graphical environment (X11/Wayland) to recognize and enable the virtual input device. (Usually done by udev) So, if the delay was too short, the virtual input device may not get recognized & enabled by your graphical environment in time. In order to solve this problem, a persistent background service, ydotoold, is made to hold a persistent virtual device, and accept input from ydotool. Since v1.0.0, the use of ydotoold is mandatory. ## Build **CMake 3.4+ is required.** ### Compile mkdir build cd build cmake .. make -j `nproc` ## Troubleshooting ### Custom keyboard layouts Currently, ydotool does not recognize if the user is using a custom keyboard layout. In order to comfortably use ydotool alongside a custom keyboard layout, the user could use one of the following fixes/workarounds: #### Sway In [sway](https://github.com/swaywm/sway), the process is [fairly easy](https://github.com/swaywm/sway/wiki#keyboard-layout). Following the instructions there, you would end up with something like: ``` input "16700:8197:DELL_DELL_USB_Keyboard" { xkb_layout "us,us" xkb_variant "dvorak," xkb_options "grp:shifts_toggle, caps:swapescape" } ``` The identifier for your keyboard can be obtained from the output of `swaymsg -t get_inputs`. #### Use a hardware-configurable keyboard [As mentioned here](https://github.com/ReimuNotMoe/ydotool/issues/43#issuecomment-605921288), consider using a hardware-based configuration that supports using a custom layout without configuring it in software. ## Older Notes ### Current situation This project is now being maintained **thanks to all the people that are supporting this project!** All backers and sponsors are listed [here](https://github.com/TheNeuronProject/BACKERS/blob/main/README.md). ### How to support us - Donate on our [Patreon](https://www.patreon.com/classicoldsong) - Buy our products on our [Official Store](https://su.mk/store), if they are meaningful to you (please leave a message: `ydotool user`, so we can know that this purchase is for supporting ydotool) ### More talks [Article: "Open Source" is Broken](https://christine.website/blog/open-source-broken-2021-12-11) Independent software developers in China, like us, have 10 times more life pressure than Marak, the author of faker.js. Since ydotool has the opportunity to benefit large IT companies who won't pay a penny to us, we've changed the license to AGPLv3. These large IT companies are the main cause of life pressure here, such as the "996" working hours. **Marak's fate will repeat on all open source developers eventually (of course we aren't talking about those who were born in billionare families) if we just _keep fighting with each other and do nothing to improve the situation._ If you make open source software as well, don't hesitate to ask for donations if you actually _need_ them.** Also make sure you understand all the terms of AGPLv3 before using this software. 07070100000016000041ED00000000000000000000000263D7AFB400000000000000000000000000000000000000000000001600000000ydotool-1.0.4/manpage07070100000017000081A400000000000000000000000163D7AFB400000173000000000000000000000000000000000000002500000000ydotool-1.0.4/manpage/CMakeLists.txtfunction(man_page section page) set(src "${CMAKE_CURRENT_SOURCE_DIR}/${page}.${section}.scd") set(bin "${CMAKE_CURRENT_BINARY_DIR}/${page}.${section}") add_custom_target(${page}.${section} ALL COMMAND scdoc < ${src} > ${bin}) install(FILES ${bin} DESTINATION ${CMAKE_INSTALL_MANDIR}/man${section}/) endfunction(man_page) man_page(1 ydotool) man_page(8 ydotoold) 07070100000018000081A400000000000000000000000163D7AFB400000CBE000000000000000000000000000000000000002400000000ydotool-1.0.4/manpage/ydotool.1.scdYDOTOOL(1) # NAME ydotool - command-line _/dev/uinput_ automation tool # SYNOPSIS *ydotool* *cmd* _args_ *ydotool* *cmd* --help # DESCRIPTION *ydotool* lets you programmatically (or manually) simulate keyboard input and mouse activity, etc. The *ydotoold*(8) daemon must be running. Currently implemented command(s): *type* Type a string *key* Press keys *mousemove* Move mouse pointer to absolute position *click* Click on mouse buttons # KEYBOARD COMMANDS *key* [*-d*,*--key-delay* _<ms>_] [_<KEYCODE:PRESSED>_ ...] Type a given keycode. e.g. 28:1 28:0 means pressing on the Enter button on a standard US keyboard. (where :1 for pressed means the key is down and then :0 means the key is released) 42:1 38:1 38:0 24:1 24:0 38:1 38:0 42:0 - "LOL" Non-interpretable values, such as 0, aaa, l0l, will only cause a delay. See `/usr/include/linux/input-event-codes.h' for available key codes (KEY_\*). You can find the key name/number your keyboard is sending to libinput by running `sudo libinput record` and then selecting your keyboard from the list it will show you the libinput proper key name and number for each key you press. Options: *-d*,*--key-delay* _<ms>_ Delay time between keystrokes. Default 12ms. *type* [*-D*,*--next-delay* _<ms>_] [*-d*,*--key-delay* _<ms>_] [*-f*,*--file* _<filepath>_] "_text_" Types text as if you had typed it on the keyboard. Options: *-d*,*--key-delay* _<ms>_ Delay time between key events (up/down each). Default 12ms. *-D*,*--next-delay* _<ms>_ Delay between strings. Default 0ms. *-f*,*--file* _<filepath>_ Specify a file, the contents of which will be typed as if passed as an argument. The filepath may also be '-' to read from stdin. Example: to type 'Hello world!' you would do: ydotool type 'Hello world!' # MOUSE COMMANDS *mousemove* [*-a*,*--absolute*] _<x> <y>_ Move the mouse to the relative X and Y coordinates on the screen. Options: *--absolute* Use absolute position Example: to move the cursor to absolute coordinates (100,100): ydotool mousemove --absolute 100 100 *click* [*-d*,*--next-delay* _<ms>_] [*-r*,*--repeat* _N_ ] [_button_ ...] Send a click. Options: *-d*,*--next-delay* _<ms>_ Delay between input events (up/down, a compete click means doubled time). Default 25ms. *-r*,*--repeat* _N_ Repeat entire sequence N times all mouse buttons are represented using hexadecimal numeric values, with an optional bit mask to specify if mouse up/down needs to be omitted. - 0x00 - LEFT - 0x01 - RIGHT - 0x02 - MIDDLE - 0x03 - SIDE - 0x04 - EXTR - 0x05 - FORWARD - 0x06 - BACK - 0x07 - TASK - 0x40 - Mouse down - 0x80 - Mouse up Examples: - 0x00: chooses left button, but does nothing (you can use this to implement extra sleeps) - 0xC0: left button click (down then up) - 0x41: right button down - 0x82: middle button up The '0x' prefix can be omitted if you want. # YDOTOOL SOCKET The socket to write to for *ydotoold*(8) can be changed by the environment variable YDOTOOL_SOCKET. # AUTHOR ydotool was written by ReimuNotMoe. This manpage was written by bob.hepple@gmail.com but updated since. # LICENCE AGPLv3 # SEE ALSO *ydotoold*(8) Project site: <https://github.com/ReimuNotMoe/ydotool> 07070100000019000081A400000000000000000000000163D7AFB40000025F000000000000000000000000000000000000002500000000ydotool-1.0.4/manpage/ydotoold.8.scdydotoold(8) # NAME ydotoold \- daemon for *ydotool*(1) # SYNOPSIS *ydotoold* _[OPTION...]_ # DESCRIPTION *ydotoold* holds a persistent virtual device, and accepts input from *ydotool*(1). # OPTIONS *-p*, *--socket-path arg* _<path>_ Set socket path. *-P*, *--socket-perm arg* _<perms>_ Set socket permission. *-h*, *--help* Display help and exit. # AUTHOR *ydotool*(1) and *ydotoold*(8) were written by ReimuNotMoe. This manpage was written by bob.hepple@gmail.com but updated since. # LICENCE AGPLv3 # SEE ALSO *ydotool*(1) Project site: <https://github.com/ReimuNotMoe/ydotool> 07070100000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000B00000000TRAILER!!!198 blocks
Locations
Projects
Search
Status Monitor
Help
OpenBuildService.org
Documentation
API Documentation
Code of Conduct
Contact
Support
@OBShq
Terms
openSUSE Build Service is sponsored by
The Open Build Service is an
openSUSE project
.
Sign Up
Log In
Places
Places
All Projects
Status Monitor