Skip to content

Commit

Permalink
Merge pull request sezanzeb#641 from sezanzeb/beta
Browse files Browse the repository at this point in the history
Merge `beta` into `main`
  • Loading branch information
sezanzeb authored Mar 2, 2023
2 parents 115fb78 + b325598 commit d5ec038
Show file tree
Hide file tree
Showing 173 changed files with 27,630 additions and 12,584 deletions.
9 changes: 9 additions & 0 deletions .coveragerc
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,12 @@ debug = multiproc
omit =
# not used currently due to problems
/usr/lib/python3.9/site-packages/inputremapper/ipc/socket.py

[report]
exclude_lines =
pragma: no cover

# Don't complain about abstract methods, they aren't run:
@(abc\.)?abstractmethod
# Don't cover Protocol classes
class .*\(.*Protocol.*\):
4 changes: 2 additions & 2 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ jobs:
if: github.event_name == 'push' || github.event.pull_request.head.repo.full_name != github.repository
strategy:
matrix:
python-version: ["3.10"]
python-version: ["3.11"]
steps:
- uses: actions/checkout@v2
- name: Set up Python ${{ matrix.python-version }}
Expand All @@ -21,5 +21,5 @@ jobs:
pip install black
- name: Analysing the code with black --check --diff
run: |
black --version
black --check --diff ./inputremapper ./tests
4 changes: 2 additions & 2 deletions .github/workflows/reviewdog.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ["3.10"]
python-version: ["3.11"]

steps:
- uses: actions/checkout@v2
Expand All @@ -26,7 +26,7 @@ jobs:
shell: bash
run: |
scripts/ci-install-deps.sh
pip install flake8 pylint mypy black
pip install flake8 pylint mypy black types-pkg_resources
- name: Set env for PR
if: github.event_name == 'pull_request'
shell: bash
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ jobs:
if: github.event_name == 'push' || github.event.pull_request.head.repo.full_name != github.repository
strategy:
matrix:
python-version: ["3.7", "3.10"] # min and max supported versions?
python-version: ["3.7", "3.11"] # min and max supported versions?
steps:
- uses: actions/checkout@v2
- name: Set up Python ${{ matrix.python-version }}
Expand Down
8 changes: 6 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@ inputremapper/commit_hash.py
*.glade~
*.glade#
.idea
*.png~
*.png~*
*.orig

# Byte-compiled / optimized / DLL files
__pycache__/
Expand All @@ -21,7 +22,7 @@ dist/
downloads/
eggs/
.eggs/
lib/
/lib/
lib64/
parts/
sdist/
Expand Down Expand Up @@ -58,6 +59,9 @@ coverage.xml
.hypothesis/
.pytest_cache/

# pyreverse graphs
*.dot

# Translations
*.mo

Expand Down
7 changes: 7 additions & 0 deletions .mypy.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@

[mypy]
plugins = pydantic.mypy

# ignore the missing evdev stubs
[mypy-evdev.*]
ignore_missing_imports = True
3 changes: 2 additions & 1 deletion .pylintrc
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@

max-line-length=88 # black

extension-pkg-whitelist=evdev
extension-pkg-whitelist=evdev, pydantic
load-plugins=pylint_pydantic

disable=
# that is the standard way to import GTK afaik
Expand Down
3 changes: 2 additions & 1 deletion .run/All Tests.run.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<component name="ProjectRunConfigurationManager">
<configuration default="false" name="All Tests" type="tests" factoryName="Autodetect">
<configuration default="false" name="All Tests" type="tests" factoryName="Unittests">
<module name="input-remapper" />
<option name="INTERPRETER_OPTIONS" value="" />
<option name="PARENT_ENVS" value="true" />
Expand All @@ -8,6 +8,7 @@
<option name="IS_MODULE_SDK" value="true" />
<option name="ADD_CONTENT_ROOTS" value="true" />
<option name="ADD_SOURCE_ROOTS" value="true" />
<option name="_new_pattern" value="&quot;&quot;" />
<option name="_new_additionalArguments" value="&quot;&quot;" />
<option name="_new_target" value="&quot;$PROJECT_DIR$/tests&quot;" />
<option name="_new_targetType" value="&quot;PATH&quot;" />
Expand Down
17 changes: 17 additions & 0 deletions .run/Only Integration Tests.run.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<component name="ProjectRunConfigurationManager">
<configuration default="false" name="Only Integration Tests" type="tests" factoryName="Unittests">
<module name="input-remapper" />
<option name="INTERPRETER_OPTIONS" value="" />
<option name="PARENT_ENVS" value="true" />
<option name="SDK_HOME" value="" />
<option name="WORKING_DIRECTORY" value="$PROJECT_DIR$/tests" />
<option name="IS_MODULE_SDK" value="true" />
<option name="ADD_CONTENT_ROOTS" value="true" />
<option name="ADD_SOURCE_ROOTS" value="true" />
<option name="_new_pattern" value="&quot;&quot;" />
<option name="_new_additionalArguments" value="&quot;&quot;" />
<option name="_new_target" value="&quot;$PROJECT_DIR$/tests/integration&quot;" />
<option name="_new_targetType" value="&quot;PATH&quot;" />
<method v="2" />
</configuration>
</component>
17 changes: 17 additions & 0 deletions .run/Only Unit Tests.run.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<component name="ProjectRunConfigurationManager">
<configuration default="false" name="Only Unit Tests" type="tests" factoryName="Unittests">
<module name="input-remapper" />
<option name="INTERPRETER_OPTIONS" value="" />
<option name="PARENT_ENVS" value="true" />
<option name="SDK_HOME" value="" />
<option name="WORKING_DIRECTORY" value="$PROJECT_DIR$/tests" />
<option name="IS_MODULE_SDK" value="true" />
<option name="ADD_CONTENT_ROOTS" value="true" />
<option name="ADD_SOURCE_ROOTS" value="true" />
<option name="_new_pattern" value="&quot;&quot;" />
<option name="_new_additionalArguments" value="&quot;&quot;" />
<option name="_new_target" value="&quot;$PROJECT_DIR$/tests/unit&quot;" />
<option name="_new_targetType" value="&quot;PATH&quot;" />
<method v="2" />
</configuration>
</component>
2 changes: 1 addition & 1 deletion DEBIAN/control
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
Package: input-remapper
Version: 1.5.0
Version: 2.0.0-rc
Architecture: all
Maintainer: Sezanzeb <proxima@sezanzeb.de>
Depends: build-essential, libpython3-dev, libdbus-1-dev, python3, python3-setuptools, python3-evdev, python3-pydbus, python3-gi, gettext, python3-cairo, libgtk-3-0, libgtksourceview-4-dev, python3-pydantic
Expand Down
2 changes: 1 addition & 1 deletion DEBIAN/copyright
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
Files: *
Copyright: 2021 sezanzeb
Copyright: 2023 Sezanzeb
License: GPL-3+
51 changes: 27 additions & 24 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,24 +2,29 @@

<h1 align="center">Input Remapper</h1>

<p align="center"><b>Formerly Key Mapper</b></p>

<p align="center">
An easy to use tool to change the mapping of your input device buttons.<br/>
Supports mice, keyboards, gamepads, X11, Wayland, combined buttons and programmable macros.<br/>
Allows mapping non-keyboard events (click, joystick, wheel) to keys of keyboard devices.
An easy to use tool to change the behaviour of your input devices.<br/>
Supports X11, Wayland, combinations, programmable macros, joysticks, wheels,<br/>
triggers, keys, mouse-movements and more. Maps any input to any other input.
</p>

<p align="center"><a href="readme/usage.md">Usage</a> - <a href="readme/macros.md">Macros</a> - <a href="#installation">Installation</a> - <a href="readme/development.md">Development</a> - <a href="#screenshots">Screenshots</a> - <a href="readme/examples.md">Examples</a></p>
<p align="center"><a href="readme/usage.md">Usage</a> - <a href="readme/macros.md">Macros</a> - <a href="#installation">Installation</a> - <a href="readme/development.md">Development</a> - <a href="readme/examples.md">Examples</a></p>

<p align="center"><img src="readme/pylint.svg"/> <img src="readme/coverage.svg"/></p>


<p align="center">
<img src="readme/screenshot.png" width="48%"/>
&#160;
<img src="readme/screenshot_2.png" width="48%"/>
</p>

## Installation

##### Manjaro/Arch

```bash
pacaur -S input-remapper-git
yay -S input-remapper-git
```

##### Ubuntu/Debian
Expand All @@ -31,18 +36,22 @@ or install the latest changes via:
sudo apt install git python3-setuptools gettext
git clone https://github.com/sezanzeb/input-remapper.git
cd input-remapper && ./scripts/build.sh
sudo apt install ./dist/input-remapper-1.5.0.deb
sudo apt install -f ./dist/input-remapper-2.0.0-rc.deb
```

input-remapper is now part of [Debian Unstable](https://packages.debian.org/sid/input-remapper)
and of [Ubuntu](https://packages.ubuntu.com/jammy/input-remapper)
input-remapper is available in [Debian](https://tracker.debian.org/pkg/input-remapper)
and [Ubuntu](https://packages.ubuntu.com/jammy/input-remapper)

##### Manual

Dependencies: `python3-evdev` ≥1.3.0, `gtksourceview4`, `python3-devel`, `python3-pydantic`, `python3-pydbus`

Python packages need to be installed globally for the service to be able to import them. Don't use `--user`

Conda can cause problems due to changed python paths and versions.

If it doesn't seem to install, you can also try `sudo python3 setup.py install`

```bash
sudo pip install evdev -U # If newest version not in distros repo
sudo pip uninstall key-mapper # In case the old package is still installed
Expand All @@ -51,20 +60,14 @@ sudo systemctl enable input-remapper
sudo systemctl restart input-remapper
```

If it doesn't seem to install, you can also try `sudo python3 setup.py install`
## Migrating beta configs to version 2

##### Beta
By default, Input Remapper will not migrate configurations from the beta.
If you want to use those you will need to copy them manually.

The `beta` branch contains features that still require work, but that are ready for testing. It uses a different
config path, so your presets won't break. `input-remapper-beta-git` can be installed from the AUR. If you are
facing problems, please open up an [issue](https://github.com/sezanzeb/input-remapper/issues).

## Screenshots

<p align="center">
<img src="readme/screenshot.png"/>
</p>
```bash
rm ~/.config/input-remapper-2 -r
cp ~/.config/input-remapper/beta_1.6.0-beta ~/.config/input-remapper-2 -r
```

<p align="center">
<img src="readme/screenshot_2.png"/>
</p>
Then start input-remapper
21 changes: 12 additions & 9 deletions bin/input-remapper-control
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/usr/bin/python3
# -*- coding: utf-8 -*-
# input-remapper - GUI for device specific keyboard mappings
# Copyright (C) 2022 sezanzeb <proxima@sezanzeb.de>
# Copyright (C) 2023 sezanzeb <proxima@sezanzeb.de>
#
# This file is part of input-remapper.
#
Expand Down Expand Up @@ -43,7 +43,7 @@ HELLO = 'hello'

# internal stuff that the gui uses
START_DAEMON = 'start-daemon'
HELPER = 'helper'
START_READER_SERVICE = 'start-reader-service'


def run(cmd):
Expand All @@ -56,7 +56,7 @@ def run(cmd):

COMMANDS = [AUTOLOAD, START, STOP, HELLO, STOP_ALL]

INTERNALS = [START_DAEMON, HELPER]
INTERNALS = [START_DAEMON, START_READER_SERVICE]


def utils(options):
Expand All @@ -73,7 +73,7 @@ def utils(options):


def communicate(options, daemon):
"""Commands that require a running daemon"""
"""Commands that require a running daemon."""
# import stuff late to make sure the correct log level is applied
# before anything is logged
from inputremapper.groups import groups
Expand Down Expand Up @@ -166,15 +166,16 @@ def internals(options):
"""
debug = ' -d' if options.debug else ''

if options.command == HELPER:
cmd = f'input-remapper-helper{debug}'
if options.command == START_READER_SERVICE:
cmd = f'input-remapper-reader-service{debug}'
elif options.command == START_DAEMON:
cmd = f'input-remapper-service --hide-info{debug}'
else:
return

# daemonize
cmd = f'{cmd} &'
logger.debug(f'Running `{cmd}`')
os.system(cmd)


Expand Down Expand Up @@ -202,14 +203,16 @@ def _systemd_finished():

def boot_finished():
"""Check if booting is completed."""
# Get as much information as needed to really safely determine if booting up is complete.
# Get as much information as needed to really safely determine if booting up is
# complete.
# - `who` returns an empty list on some system for security purposes
# - something might be broken and might make systemd_analyze fail:
# Bootup is not yet finished (org.freedesktop.systemd1.Manager.FinishTimestampMonotonic=0).
# Bootup is not yet finished
# (org.freedesktop.systemd1.Manager.FinishTimestampMonotonic=0).
# Please try again later.
# Hint: Use 'systemctl list-jobs' to see active jobs
if _systemd_finished():
logger.debug('Booting finished')
logger.debug('System is booted')
return True

if _num_logged_in_users() > 0:
Expand Down
Loading

0 comments on commit d5ec038

Please sign in to comment.