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

screeninfo: is broken on X11 #186978

Closed
sersorrel opened this issue Aug 16, 2022 · 2 comments · Fixed by #188197
Closed

screeninfo: is broken on X11 #186978

sersorrel opened this issue Aug 16, 2022 · 2 comments · Fixed by #188197
Labels
0.kind: bug Something is broken

Comments

@sersorrel
Copy link
Contributor

Describe the bug

remarkable-mouse doesn't work for me, exiting with the following traceback:

Traceback (most recent call last):
  File "/nix/store/f72ayjpqd585h98xn4dmy9lbj28ghql4-remarkable-mouse-7.0.1/bin/.remarkable-mouse-wrapped", line 9, in <module>
    sys.exit(main())
  File "/nix/store/f72ayjpqd585h98xn4dmy9lbj28ghql4-remarkable-mouse-7.0.1/lib/python3.9/site-packages/remarkable_mouse/remarkable_mouse.py", line 150, in main
    read_tablet(
  File "/nix/store/f72ayjpqd585h98xn4dmy9lbj28ghql4-remarkable-mouse-7.0.1/lib/python3.9/site-packages/remarkable_mouse/pynput.py", line 34, in read_tablet
    monitor = get_monitor(region, monitor_num, orientation)
  File "/nix/store/f72ayjpqd585h98xn4dmy9lbj28ghql4-remarkable-mouse-7.0.1/lib/python3.9/site-packages/remarkable_mouse/common.py", line 33, in get_monitor
    monitor = get_monitors()[monitor_num]
  File "/nix/store/z7651900fmyk3r0dz9il559sq3hn8lyl-screeninfo-0.8/lib/python3.9/site-packages/screeninfo/screeninfo.py", line 32, in get_monitors
    raise ScreenInfoError("No enumerators available")
screeninfo.common.ScreenInfoError: No enumerators available

Digging through github issues led me to https://github.com/rr-/screeninfo/issues/48, and the following traceback:

$ python -m screeninfo xrandr
Traceback (most recent call last):
  File "/nix/store/xpwwghl72bb7f48m51amvqiv1l25pa01-python3-3.9.13/lib/python3.9/runpy.py", line 197, in _run_module_as_main
    return _run_code(code, main_globals, None,
  File "/nix/store/xpwwghl72bb7f48m51amvqiv1l25pa01-python3-3.9.13/lib/python3.9/runpy.py", line 87, in _run_code
    exec(code, run_globals)
  File "/nix/store/z7651900fmyk3r0dz9il559sq3hn8lyl-screeninfo-0.8/lib/python3.9/site-packages/screeninfo/__main__.py", line 23, in <module>
    main()
  File "/nix/store/z7651900fmyk3r0dz9il559sq3hn8lyl-screeninfo-0.8/lib/python3.9/site-packages/screeninfo/__main__.py", line 18, in main
    for monitor in get_monitors(args.enumerator):
  File "/nix/store/z7651900fmyk3r0dz9il559sq3hn8lyl-screeninfo-0.8/lib/python3.9/site-packages/screeninfo/screeninfo.py", line 21, in get_monitors
    return list(ENUMERATOR_MAP[Enumerator(name)].enumerate_monitors())
  File "/nix/store/z7651900fmyk3r0dz9il559sq3hn8lyl-screeninfo-0.8/lib/python3.9/site-packages/screeninfo/enumerators/xrandr.py", line 65, in enumerate_monitors
    xlib = load_library("X11")
  File "/nix/store/z7651900fmyk3r0dz9il559sq3hn8lyl-screeninfo-0.8/lib/python3.9/site-packages/screeninfo/util.py", line 10, in load_library
    raise ScreenInfoError("Could not load " + name)
screeninfo.common.ScreenInfoError: Could not load X11

I guess this is a problem with screeninfo's packaging, but I'm unsure what exactly the issue is, or how to fix it; maybe related to #7307?

Steps To Reproduce

  1. nix-shell -p python3Packages.screeninfo 'python3.withPackages (p: with p; [ screeninfo ])' --command "python -m screeninfo xrandr"

Expected behavior

screeninfo (and, by extension, remarkable-mouse) should work.

Notify maintainers

@NickHu

Metadata

$ nix-shell -p nix-info --run "nix-info -m"
 - system: `"x86_64-linux"`
 - host os: `Linux 5.15.59, NixOS, 22.05 (Quokka), 22.05.20220810.e4c9d95`
 - multi-user?: `yes`
 - sandbox: `yes`
 - version: `nix-env (Nix) 2.8.1`
 - channels(ash): `""`
 - channels(root): `""`
 - nixpkgs: `/etc/nixpkgs/channels/nixpkgs`
@sersorrel sersorrel added the 0.kind: bug Something is broken label Aug 16, 2022
@raphaelr
Copy link
Contributor

As far as I know there is no infrastructure in place that lets find_library("X11") (in util.py) work correctly, since it has no knowledge about the Nix store or the buildInputs of screeninfo.

There used to be a substituteInPlace call which replaced all find_library calls with store paths, but it was removed in e9120ab. I think the two load_library related substitutions need to be added back in (compare with nextcord, which contains comparable code).

@sersorrel
Copy link
Contributor Author

Replacing find_library() calls seems sensible, I will try to make a PR.

A workaround for now (e.g. for remarkable-mouse users) is to set $LD_LIBRARY_PATH to ${xorg.libX11}/lib:${xorg.libXinerama}/lib:${xorg.libXrandr}/lib, but that probably isn't usable within the library itself.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
0.kind: bug Something is broken
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants