Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

polychromatic: init at 0.7.3 #82609

Closed
wants to merge 310 commits into from
Closed

Conversation

evanjs
Copy link
Member

@evanjs evanjs commented Mar 14, 2020

Notes regarding branch selection

- use dev-1.0.0 branch
- the 1.0.0 branch uses meson instead of a plain Makefile and I found it much easier to create an expression for this version of the repository
- according to this comment, it assumes a PR from openrazer is merged.

This PR now targets the v0.7.3 branch

Related:

#82269 - Init OpenRGB
#90691 - openrgb: init at 0.2

Current issues (OUTDATED)

polychromatic-controller errors
Unable to get device states for Razer Huntsman Elite
Traceback (most recent call last):
  File ’/nix/store/9hsbcqi59nqqwgv0v4nvxgmkpabi97hn-polychromatic-unstable-2020-03-10/lib/python3.7/site-packages/polychromatic/backends/openrazer.py’, line 283, in get_device
    effect = str(zone_to_device[zone].effect)
AttributeError: ’RazerFX’ object has no attribute ’effect’

This probably indicates a bug, wrong OpenRazer version or improperly specified Chroma device:
Razer Huntsman Elite (0226:1532)
polychromatic-tray-applet errors
/nix/store/9hsbcqi59nqqwgv0v4nvxgmkpabi97hn-polychromatic-unstable-2020-03-10/bin/..polychromatic-tray-applet-wrapped-wrapped:183: DeprecationWarning: Gtk.StatusIcon.set_name is deprecated
  self.indicator.set_name("polychromatic-tray-applet")
/nix/store/9hsbcqi59nqqwgv0v4nvxgmkpabi97hn-polychromatic-unstable-2020-03-10/bin/..polychromatic-tray-applet-wrapped-wrapped:184: DeprecationWarning: Gtk.StatusIcon.set_from_file is deprecated
  self.indicator.set_from_file(self._get_tray_icon())
/nix/store/9hsbcqi59nqqwgv0v4nvxgmkpabi97hn-polychromatic-unstable-2020-03-10/bin/..polychromatic-tray-applet-wrapped-wrapped:185: DeprecationWarning: Gtk.StatusIcon.set_visible is deprecated
  self.indicator.set_visible(True)
Unable to get device states for Razer Huntsman Elite
Traceback (most recent call last):
  File ’/nix/store/9hsbcqi59nqqwgv0v4nvxgmkpabi97hn-polychromatic-unstable-2020-03-10/lib/python3.7/site-packages/polychromatic/backends/openrazer.py’, line 283, in get_device
    effect = str(zone_to_device[zone].effect)
AttributeError: ’RazerFX’ object has no attribute ’effect’

This probably indicates a bug, wrong OpenRazer version or improperly specified Chroma device:
Razer Huntsman Elite (0226:1532)
/nix/store/9hsbcqi59nqqwgv0v4nvxgmkpabi97hn-polychromatic-unstable-2020-03-10/bin/..polychromatic-tray-applet-wrapped-wrapped:129: DeprecationWarning: Gtk.ImageMenuItem.set_image is deprecated
  item.set_image(img)            # GTK3: Deprecated, no replacement!
Traceback (most recent call last):
  File "/nix/store/9hsbcqi59nqqwgv0v4nvxgmkpabi97hn-polychromatic-unstable-2020-03-10/bin/..polychromatic-tray-applet-wrapped-wrapped", line 862, in <module>
    indicator.setup()
  File "/nix/store/9hsbcqi59nqqwgv0v4nvxgmkpabi97hn-polychromatic-unstable-2020-03-10/bin/..polychromatic-tray-applet-wrapped-wrapped", line 194, in setup
    self.build_indicator()
  File "/nix/store/9hsbcqi59nqqwgv0v4nvxgmkpabi97hn-polychromatic-unstable-2020-03-10/bin/..polychromatic-tray-applet-wrapped-wrapped", line 274, in build_indicator
    root.append(self.build_device_submenu(device, details)[0])
  File "/nix/store/9hsbcqi59nqqwgv0v4nvxgmkpabi97hn-polychromatic-unstable-2020-03-10/bin/..polychromatic-tray-applet-wrapped-wrapped", line 357, in build_device_submenu
    submenu[1].append(self._create_effect_submenu(details, zone)[0])
  File "/nix/store/9hsbcqi59nqqwgv0v4nvxgmkpabi97hn-polychromatic-unstable-2020-03-10/bin/..polychromatic-tray-applet-wrapped-wrapped", line 486, in _create_effect_submenu
    if "random" in starlight_options:
NameError: name 'starlight_options' is not defined

I tried using the master branch for openrazer, but encountered the same issues.
Interestingly, I found mention in the source for features that require OpenRazer 2.8.0+ (here).

I am not sure if this is a typo or referring to the current master branch.

Additionally, this is what happens if no ~/.config/polychromatic/custom_icons directory is found when polychromatic-controller is launched

Missing directory error

Exception in thread Thread-1:
Traceback (most recent call last):
  File "/nix/store/xb1mp0f16lv23rwhfdc1665v5r20jfmm-python3-3.7.6/lib/python3.7/threading.py", line 926, in _bootstrap_inner
    self.run()
  File "/nix/store/xb1mp0f16lv23rwhfdc1665v5r20jfmm-python3-3.7.6/lib/python3.7/threading.py", line 870, in run
    self._target(*self._args, **self._kwargs)
  File "/nix/store/9hsbcqi59nqqwgv0v4nvxgmkpabi97hn-polychromatic-unstable-2020-03-10/bin/..polychromatic-controller-wrapped-wrapped", line 342, in start_app
    self.controller.initalise_app(self.version, self.versions, args.tab)
  File "/nix/store/9hsbcqi59nqqwgv0v4nvxgmkpabi97hn-polychromatic-unstable-2020-03-10/lib/python3.7/site-packages/polychromatic/controller.py", line 110, in initalise_app
    self.send_view_variable("CUSTOM_ICONS", pref.get_custom_icons())
  File "/nix/store/9hsbcqi59nqqwgv0v4nvxgmkpabi97hn-polychromatic-unstable-2020-03-10/lib/python3.7/site-packages/polychromatic/preferences.py", line 371, in get_custom_icons
    return os.listdir(path.custom_icons)
FileNotFoundError: [Errno 2] No such file or directory: '/home/evanjs/.config/polychromatic/custom_icons'

Current Functionality

As it stands, brightness for connected devices can be changed, but you cannot switch between tabs, and much of the application is inaccessible.

Motivation for this change

Polychromatic provides a graphical interface to manage Razer devices using Openrazer

Things done
  • Tested using sandboxing (nix.useSandbox on NixOS, or option sandbox in nix.conf on non-NixOS linux)
  • Built on platform(s)
    • NixOS
    • macOS
    • other Linux distributions
  • Tested via one or more NixOS test(s) if existing and applicable for the change (look inside nixos/tests)
  • Tested compilation of all pkgs that depend on this change using nix-shell -p nixpkgs-review --run "nixpkgs-review wip"
  • Tested execution of all binary files (usually in ./result/bin/)
  • Determined the impact on package closure size (by running nix path-info -S before and after)
  • Ensured that relevant documentation is up to date
  • Fits CONTRIBUTING.md.

cc @adisbladis @worldofpeace

@evanjs evanjs changed the title polychromatic: init at unstable-2020-03-10 [WIP] - polychromatic: init at unstable-2020-03-10 Mar 14, 2020
pkgs/applications/misc/polychromatic/default.nix Outdated Show resolved Hide resolved
pkgs/top-level/all-packages.nix Outdated Show resolved Hide resolved
@evanjs
Copy link
Member Author

evanjs commented Mar 14, 2020

Ah, looks like we're blocked on openrazer/openrazer#888 being merged, as mentioned here.

@evanjs evanjs changed the title [WIP] - polychromatic: init at unstable-2020-03-10 WIP - polychromatic: init at unstable-2020-03-10 Mar 14, 2020
@symphorien
Copy link
Member

symphorien commented Mar 14, 2020

The derivation lacks meta.

@cawilliamson
Copy link
Member

Would love to see this merged ASAP - really missing the functionality.

@evanjs
Copy link
Member Author

evanjs commented Jun 2, 2020

For @cawilliamson and others that need something in the meantime, please check out Razer Genie (#84812), which was recently merged.

@evanjs evanjs marked this pull request as draft June 2, 2020 16:38
@evanjs evanjs changed the title WIP - polychromatic: init at unstable-2020-03-10 polychromatic: init at unstable-2020-03-10 Jun 2, 2020
@evanjs
Copy link
Member Author

evanjs commented Aug 19, 2020

The development status of Polychromatic is provided via the roadmap if anyone is interested.

I will be keeping an eye on this and investigate the amount of effort required to get 1.0.0 packaged once it is made available in a non-alpha state.

@lah7
Copy link

lah7 commented Dec 21, 2020

Developer of the Polychromatic app here - just thought I'd let you know:

At time of writing:

  • Consider this codebase alpha quality, with a version string of v0.6.0, but may work better then v0.3.12 for certain types of hardware.
  • Bugs expected, since extensive testing on many distros/environments hasn't started.
  • Has one feature regression from v0.3.12 (custom effect editor), but this should be restored soon.

@stale
Copy link

stale bot commented Jun 20, 2021

I marked this as stale due to inactivity. → More info

@stale stale bot added the 2.status: stale https://github.com/NixOS/nixpkgs/blob/master/.github/STALE-BOT.md label Jun 20, 2021
@lah7
Copy link

lah7 commented Aug 9, 2021

Just a note - this software released a new stable v0.7.0 version. The dependencies might want looking over with its docs.

@stale stale bot removed the 2.status: stale https://github.com/NixOS/nixpkgs/blob/master/.github/STALE-BOT.md label Aug 9, 2021
@evanjs evanjs changed the title polychromatic: init at unstable-2020-03-10 polychromatic: init at v0.7.0 Aug 14, 2021
@evanjs
Copy link
Member Author

evanjs commented Aug 14, 2021

This PR now targets v0.7.0, and builds without errors, but e.g. the controller fails to run.

I am not sure which callPackage variant I should be using/package set I should be importing (qt5, pythonPackages, etc.).

I am also unsure how the application should be wrapped, as the controller depends on QT5, while the tray applet requires libappindicator-gtk3, and so on.

@leifhelm
Copy link
Contributor

I have the following in my config:

default.nix
{ lib
, stdenv
, fetchFromGitHub
, buildPythonPackage
, meson
, sassc
, which
, ninja
, wrapQtAppsHook
, intltool
, requests
, pyqt5
, pyqtwebengine
, colorama
, colour
, setproctitle
, imagemagick
, openrazer
}:

buildPythonPackage rec {
  pname = "polychromatic";
  version = "0.7.2";

  format = "other";

  src = fetchFromGitHub {
    owner = "polychromatic";
    repo = "polychromatic";
    rev = "v${version}";
    sha256 = "109p89d56qp0pybhrwx9n7xzj5jg74pihh4ic5c6nzjbyjkc9xjn";
  };

  patches = [
    ./data_dir.patch
  ];

  nativeBuildInputs = [
    wrapQtAppsHook
    meson
    ninja
    sassc
    which
  ];

  preConfigure = "patchShebangs .";

  propagatedBuildInputs = [
    colour
    colorama
    setproctitle
    requests
    pyqt5
    pyqtwebengine
    openrazer
  ];

  buildInputs = [
    intltool
    imagemagick
  ];
  makeWrapperArgs = [
    "\${qtWrapperArgs[@]}"
  ];
}
overlay (`callPackage`)
{
  polychromatic = super.python3Packages.callPackage ./polychromatic {
    inherit (super) meson sassc which;
    inherit (super.libsForQt5) wrapQtAppsHook;
  };
}
data_dir.patch
diff --git a/pylib/common.py b/pylib/common.py
index 7bbda38..8fb8963 100755
--- a/pylib/common.py
+++ b/pylib/common.py
@@ -108,8 +108,8 @@ class Paths(object):
         """
         module_path = __file__
 
-        if os.path.exists(os.path.join(os.path.dirname(module_path), "../data/img/")):
-            return os.path.abspath(os.path.join(os.path.dirname(module_path), "../data/"))
+        if os.path.exists(os.path.join(os.path.dirname(module_path), "../../../../share/polychromatic/img/")):
+            return os.path.abspath(os.path.join(os.path.dirname(module_path), "../../../../share/polychromatic"))
 
         for directory in ["/usr/local/share/polychromatic", "/usr/share/polychromatic"]:
             if os.path.exists(directory):

I do not care about the tray so it probably does not work. I hope this helps

pkgs/applications/misc/polychromatic/default.nix Outdated Show resolved Hide resolved
pkgs/applications/misc/polychromatic/default.nix Outdated Show resolved Hide resolved
pkgs/applications/misc/polychromatic/default.nix Outdated Show resolved Hide resolved
pkgs/top-level/all-packages.nix Outdated Show resolved Hide resolved
pkgs/applications/misc/polychromatic/default.nix Outdated Show resolved Hide resolved
@leifhelm
Copy link
Contributor

Adding wrapGAppsHook to nativeBuildInputs and libappindicator-gtk3 to propagatedBuildInputs does seem to work for the tray

@piegamesde
Copy link
Member

It looks like something went wrong while rebasing. Given that you can't un-ping people on GitHub, I'm going to close this now to prevent further spamming. Please open a new PR, and ping previous reviewers in there.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet