Commit Graph

148 Commits

Author SHA1 Message Date
Nick Price 9bbe552c0a
solaar: require pyudev only where it is used, and support FreeBSD
pyudev binds libudev and only the Linux HID backend imports it:
base.py selects hidapi/udev_impl on Linux and hidapi/hidapi_impl
everywhere else. But gtk.py demanded pyudev on every OS other than macOS
and Windows and exited if it was missing, and setup.py listed it with no
environment marker at all -- so on FreeBSD Solaar refused to start over a
module the backend it had already chosen never touches.

Gate the check on Linux, mark the dependency accordingly, and stop
installing the udev rules on platforms that have no udev. FreeBSD uses
devd and its own devfs rules for the same job.
2026-08-01 11:29:46 -07:00
Ken Sanislo d8422d78d1 Add per-key RGB color painter and replace MAP_CHOICE color validator
Replace the per-key dropdown UI (MapChoiceControl) with a Cairo-rendered
keyboard canvas where users can paint colors directly onto keys.

Editor (lib/solaar/ui/perkey/):
  - Cairo DrawingArea renders cells from a Layout dataclass; bound cells
    take their painted color, unset cells show a diagonal hash whose base
    color matches the device's rgb_zone_* setting.
  - Tools: brush, drag-rectangle, flood-fill (4-adjacent, Paint-style),
    and a directional gradient (line A->B projected across the matrix
    with cells past the endpoints clamped to the endpoint colors).
  - GradientSwatch is the single source of truth for the gradient's two
    colors; the canvas reads from it on each gradient stroke.
  - Palette: GTK ColorButton plus an unset toggle that paints the
    "no change" sentinel (-1).
  - PerKeyEditorDialog auto-sizes from the canvas's size_request, so a
    104-key keyboard opens wide and a 8-LED mouse opens compact.
  - Editor consumes only a narrow PerKeyColorSink protocol; never imports
    from lib/logitech_receiver, preserving the FE/BE seam.
  - Per-device palette state (active + previous color) persists via the
    existing persister under a _palette: prefixed key.

Layouts:
  - ANSI 104-key full-size and TKL keyboard layouts.
  - G502 X family mouse layout (zones 1-8 -> labels A-H).
  - Generic registry: register_layout(feature, matcher, layout). A
    _name_contains() helper builds case-insensitive substring matchers
    against device codename / name. Unknown devices fall back to a flat
    strip of all reported zones.

Validator (open value space):
  - New Range dataclass and MapRangeValidator extending Validator
    directly (kind=MAP_CHOICE for dispatch compatibility). Replaces the
    ChoicesMapValidator on PerKeyLighting -- the named-color universe
    (COLORSPLUS) was rejecting any picker color outside its ~20 entries.
    Other MAP_CHOICE settings are untouched.

Integration:
  - Setting base gains an editor_class string attribute. config_panel's
    _create_sbox resolves it via importlib before the kind dispatch, so
    PerKeyLighting routes to the new editor without a new Kind value.
  - CLI gains a hex/dec parser for open-value MAP_CHOICE settings:
      solaar config <dev> per-key-lighting A 0xFF00FF
  - Diversion rule editor skips Range-valued MAP_CHOICE settings'
    value-selector instead of crashing on the open value space.
  - pycairo declared in install_requires; transitively present on most
    systems but now explicit for pip-from-source installs.

Tests in test_setting_templates.py updated for the new validator.
2026-05-10 17:52:55 -04:00
Br1an67 8cea17fc46 Use console_scripts entry point for pipx compatibility
Replace scripts=glob("bin/*") with entry_points console_scripts
to make solaar installable via pipx. pipx requires packages to
define console_scripts entry points to detect command-line apps.
2026-03-07 07:17:54 -05:00
Dominik 'Rathann' Mierzejewski d95068c3f5 make typing-extensions dependency mandatory
It's imported unconditionally in:
lib/solaar/ui/about/presenter.py:19
lib/logitech_receiver/hidpp10.py:22
lib/logitech_receiver/hidpp20.py:35

Fixes 469c04f (committed as part of #2428).
2025-01-10 17:00:03 -05:00
MattHag 46366b2430 Fix warnings from automatic code inspections
Warnings found by automatic code inspection and partially tackled
- Drop distuitls inf favour of setuptools
- Replace deprecated pyudev.Device.from_device_number
- Remove unnecessary brackets
- Avoid access to private variables etc.
- Shadows built-in name
- Line length >120 characters
- Not a module level variable
- Simplify clause
and more
2024-10-11 07:42:38 -04:00
MattHag 26667afea4 Simplify setup with pathlib 2024-10-08 14:35:16 -04:00
MattHag f40a5cc7a9
Clean up setup.py (#2536)
- Indent description
- Remove commented code

Related #2273
2024-06-29 15:23:38 -04:00
MattHag 104556e7a3 Automatically detect packages in /lib
Automate handling of internal packages.
2024-06-02 10:42:57 -04:00
Matthias Hagmann 675cd6ee34 Add typing_extensions dependency 2024-05-22 21:14:41 -04:00
MattHag b321167304
Drop support for end-of-life Python 3.7
* Drop support for end-of-life Python 3.7

* Remove handling of code for Python 3.7 and older
2024-05-11 11:48:32 -04:00
Peter F. Patel-Schneider a5a0d7e80e dist: add included hid_parser to packages installed 2024-04-20 14:06:41 -04:00
Matthias Hagmann cc7194fe3d Extend Ubuntu dependencies for GitHub CI
Related #1097
2024-03-10 09:20:39 -04:00
Matthias Hagmann a29f2b8614 tests: Add hidpp10 tests
Related #1097
2024-03-02 10:56:41 -05:00
Peter F. Patel-Schneider 6805a57b94 hid: copy newer version of hid_parser into Solaar codebase 2024-02-26 14:19:16 -05:00
Peter F. Patel-Schneider 069f96fe48 hidapi: make hid_parser optional, but add it to setup 2024-02-23 13:30:52 -05:00
Matthias Hagmann 7774569971 Apply ruff format
Run ruff auto formatting using:
ruff format .

Related #2295
2024-02-20 15:41:10 -05:00
Matthias Hagmann fb6285606d Introduce ruff formatter and linter
Replace yapf, isort and flake8 with much faster ruff formatter. Remove
conflicting rule and switch to double quotes for strings.

Install:
pip install ."[dev]"
pre-commit install

Run pre-commit hooks:
pre-commit run -a

Related #2295
2024-02-20 15:41:10 -05:00
MattHag afdfcb0d2c
tests: Show pytest coverage in GitHub CI tests
Related #1097
2024-02-18 07:40:09 -05:00
Peter F. Patel-Schneider d1c899d6da solaar: improve imports and guard Gtk, etc imports with correct version
solaar: move imports to top of files

solaar: move more imports to top of files

solaar: guard Gtk, etc imports with correct version
2024-02-18 06:21:35 -05:00
Peter F. Patel-Schneider a3ff536c90 dist: correctly find light icons 2024-02-15 10:42:26 -05:00
Peter F. Patel-Schneider 8facd0cf68 dist: rename light icons and install them in correct place 2024-02-15 08:51:36 -05:00
MattHag b516b12920
Setup macOS tests using GitHub action (#2284)
Related #1244
2024-02-14 13:40:25 -05:00
Matthias Hagmann 3eebd4b4b0 tests: Introduce tests with pytest
Relates #1097
2024-02-10 13:58:20 -05:00
MattHag 87658fb189
logging: Simplify logger instantiation
* logging: Simplify logger instantiation

Relates #2254

* logging: Remove aliases

Relates #2254

* logging: Replace deprecated warn with warning

Related #2254

* logging: Fix mistake

Related #2257
2024-02-10 13:55:27 -05:00
Peter F. Patel-Schneider c8fc6990b5 device: remove dependency on webcolors 2024-02-09 13:45:41 -05:00
Peter F. Patel-Schneider 73d091c86f ui: add UI for LED Zone control 2024-02-09 08:36:36 -05:00
markopy 29ff35d553
Partial support for macOS and Windows (#1971)
* Add support for macOS via hidapi

* Style fixes

* Ignore keyboard and mouse input devices

* Don't require pyudev on mac and windows

* Fix debug log format error

* More logging for failed hidpp checks

* Don't try to load hid_darwin_set_open_exclusive on windows

* Bring back button for rule editor since some rules will work

---------

Co-authored-by: markopy <(none)>
Co-authored-by: Peter F. Patel-Schneider <pfpschneider@gmail.com>
2023-11-28 16:25:17 -05:00
Peter F. Patel-Schneider 5ca1790cb8 ui: better handling and installation of icons 2023-11-19 12:06:04 -05:00
psykose cf71736920 dist: install .rules to correct place by default
these only have meaning when they end up in a directory scanned by udev,
so $prefix/lib/udev/rules.d will be correct when installed to /usr. this
changes it from /usr/share/solaar/udev-rules.d which is ignored. it does
not affect installing as a user (e.g. pip install --user)
2023-10-21 15:19:51 -04:00
Swapnil Devesh 91f1894e8b
Add support for process condition under wayland using solaar-gnome-extension (#2101)
* Add support for process condition under wayland using solaar-gnome-extension

* Fix typo

* Improvements

* Rename dbus extension

* Final fixes

* Fix style checks

* More styling fixes

* More fixes

* More fixes

---------

Co-authored-by: Peter F. Patel-Schneider <pfpschneider@gmail.com>
2023-07-26 06:53:57 -04:00
Peter F. Patel-Schneider f4b25b2594 dist: get Ubuntu version from dpkg-parsechangelog 2022-11-28 11:42:05 -05:00
Peter F. Patel-Schneider 4a9319a4c0 dist: get Ubuntu version from dpkg-parsechangelog 2022-11-28 11:27:07 -05:00
Peter F. Patel-Schneider c2b4d5a8c8 dist: get Ubuntu version from dpkg-parsechangelog 2022-11-28 06:25:43 -05:00
Peter F. Patel-Schneider 4e6f59c2ad dist: get Ubuntu version from dpkg-parsechangelog 2022-11-27 09:41:02 -05:00
Peter F. Patel-Schneider 9b868c8869 dist: get Ubuntu version from dpkg-parsechangelog 2022-11-27 00:02:37 -05:00
Peter F. Patel-Schneider b73030a0f1 dist: get Ubuntu version from dpkg-parsechangelog 2022-11-26 12:26:05 -05:00
Peter F. Patel-Schneider a6461d6a6e dist: print Ubuntu PPA environment 2022-11-25 05:25:43 -05:00
Peter F. Patel-Schneider 0547b1895a dist: get commit from Ubuntu PPA directory name if no git information 2022-11-24 12:48:19 -05:00
Peter F. Patel-Schneider 8765089d43 dist: use separate data files for version and commit information 2022-11-23 14:05:03 -05:00
Peter F. Patel-Schneider b5b6152e06 dist: use git describe to get git version information 2022-11-20 19:04:31 -05:00
Peter F. Patel-Schneider 49c7e5cc44 dist: add 8-character commit hash to version information 2022-11-19 16:15:13 -05:00
Peter F. Patel-Schneider 0a2f57f51a dist: get release in setup.py by reading lib/solaar/__init__.py 2022-11-19 11:03:32 -05:00
Peter F. Patel-Schneider e15b58fdaa install: remove unnecessary dependency on typing_extensions 2022-11-05 10:47:35 -04:00
Peter F. Patel-Schneider a14a89781e release 1.1.7 2022-11-03 07:22:00 -04:00
Peter F. Patel-Schneider e699209370 install: add depdendency on typing_extensions 2022-11-03 07:22:00 -04:00
Peter F. Patel-Schneider f539ac064e release 1.1.7rc2 2022-10-30 12:17:00 -04:00
Peter F. Patel-Schneider 6bbf83a293 release 1.1.7rc1 2022-10-26 21:09:30 -04:00
Peter F. Patel-Schneider 8d0795af53 solaar: make hid-parser an optional dependency 2022-10-25 10:51:23 -04:00
Peter F. Patel-Schneider 9ce0fd7060 release 1.1.6 2022-10-24 19:58:39 -04:00
Peter F. Patel-Schneider b67a6030a4 1.1.6rc4 2022-10-13 16:38:38 -04:00