Closed yochananmarqos closed 3 years ago
What did you run for this to happen? Is it from the build process for PKGBUILD or from running sudo python3 keyboard-color-switcher.py
? What is the hardware as well?
@ahoneybun it seems like it is unable to import Gtk
because it doesn't have Container
?
It's just odd that I haven't seen it on my system (oryp4). I'll boot in to my Manjaro to test.
I'm working on a PKGBUILD with a Polkit policy which worked earlier today. I also tried running sudo python keyboard-color-switcher.py
directly from the repo as well. This is on my Serval WS.
I can't recreate it since my other system is a galp3-b
which doesn't have the backlights.
I wonder if it is because python
was used instead of python3
?
Arch Linux tends to use bleeding edge software and disregard older versions. There could be a breaking change in the version used by @yochananmarqos. It will need more investigation.
You are using the latest version of Manjaro with Gnome @yochananmarqos? Any special repository or using unstable repositories from Manjaro?
@ahoneybun On Arch, python
is Python 3.
On Ubuntu, it's the other way around: python
is Python 2.
I'm using the Manjaro unstable branch which syncs with Arch stable multiple times a day.
@JeffLabonte can you help me disable the laptop_model check so I can launch the application?
@yochananmarqos can you share your pacman.conf file for the unstable branch?
There was just a stable update today, you'll have the same software versions just about.
See here for switching branches: https://wiki.manjaro.org/index.php/Switching_Branches
@ahoneybun in the file keyboard_backlight.py
in folder kcc_cli
, you can change self.laptop_model
at line 25 for string.
You can set oryp4 if you have 3 backlight path and oryp6 if you have one. Also, you can comment out line 23 in this case since it won't be used.
@yochananmarqos I'm trying to set up Manjaro on my oryp4 but I don't have the /sys/class/leds path and I can't use the key combos.
@ahoneybun Install system76-oled
from the AUR. I have all the driver packages installed, so I'm not sure if any others are required.
local/system76-acpi-dkms 1.0.2+1+g0bc966c-1
This provides the system76_acpi in-tree driver for systems missing it.
local/system76-dkms 1.0.12-2
On newer System76 laptops, this driver controls some of the hotkeys and allows for custom
fan control.
local/system76-driver 20.04.27-1
Universal driver for System76 computers
local/system76-firmware-daemon 1.0.23-2
System76 CLI tool for installing firmware updates and systemd service that exposes a DBUS API for handling firmware updates
local/system76-io-dkms 1.0.1-1
This DKMS driver controls System76 IO devices
local/system76-oled 0.1.4-1
Control brightness on System76 OLED displays
local/system76-power 1.1.15-1
System76 Power Management
It looks like it works now! I'll test the AUR package now.
Looks like it built for me but when I tried to run it I get this:
/opt/keyboard-color-switcher/keyboard-color-switcher.py:7: PyGIWarning: Gtk was imported without specifying a version first. Use gi.require_version('Gtk', '3.0') before import to ensure that the right version gets loaded.
from gi.repository import Gtk, Gio
Traceback (most recent call last):
File "/opt/keyboard-color-switcher/keyboard-color-switcher.py", line 9, in
I updated my PKGBUILD to install to site-packages
instead and included the folders:
/usr/lib/python3.9/site-packages/keyboard-color-switcher
├── kcc
└── kcc_cli
└── keyboard-color-switcher.py
The error output is the same. What am I missing? Does kcc_cli
need to be in a separate site-packages
folder, kcc_cli.keyboard_backlight
? I tried that, but it made no difference.
I tried this as well:
/usr/lib/python3.9/site-packages/kcc
/usr/lib/python3.9/site-packages/kcc_cli
/usr/lib/python3.9/site-packages/keyboard-color-switcher
└── keyboard-color-switcher.py
I did a git pull then built the package again and it works for me.
Hmm... I had gtk4
installed for testing and just removed it.
/usr/lib/python3.9/site-packages/keyboard-color-switcher/keyboard-color-switcher.py:7: PyGIWarning: Gtk was imported without specifying a version first. Use gi.require_version('Gtk', '3.0') before import to ensure that the right version gets loaded.
from gi.repository import Gtk, Gio
Traceback (most recent call last):
File "/usr/lib/python3.9/site-packages/keyboard-color-switcher/keyboard-color-switcher.py", line 110, in <module>
win = MainWindow()
File "/usr/lib/python3.9/site-packages/keyboard-color-switcher/keyboard-color-switcher.py", line 27, in __init__
self.keyboard_backlight = KeyboardBacklight()
File "/usr/lib/python3.9/site-packages/keyboard-color-switcher/kcc_cli/keyboard_backlight.py", line 30, in __init__
f"{laptop_model} is not supported by this script"
NameError: name 'laptop_model' is not defined
It looks like it isn't detecting this model as supported. What version of the Serval is this? I think only the serw12 is in the program right now.
Yes, it's the serw12.
❯ sudo dmidecode -s system-product-name
Serval WS
❯ sudo dmidecode -s system-version
serw12
I'm not sure how @JeffLabonte set it to detect models and if it is using a database to do that. It has to somewhere.
Oh I see it!
serw12 is missing. I added 'serw12': FOUR_BACKLIGHT_PATH,
and now...
/usr/lib/python3.9/site-packages/keyboard-color-switcher/keyboard-color-switcher.py:7: PyGIWarning: Gtk was imported without specifying a version first. Use gi.require_version('Gtk', '3.0') before import to ensure that the right version gets loaded.
from gi.repository import Gtk, Gio
Traceback (most recent call last):
File "/usr/lib/python3.9/site-packages/keyboard-color-switcher/keyboard-color-switcher.py", line 110, in <module>
win = MainWindow()
File "/usr/lib/python3.9/site-packages/keyboard-color-switcher/keyboard-color-switcher.py", line 29, in __init__
Gtk.Window.__init__(self)
File "/usr/lib/python3.9/site-packages/gi/overrides/Gtk.py", line 515, in __init__
raise RuntimeError(
RuntimeError: Gtk couldn't be initialized. Use Gtk.init_check() if you want to handle this case
Can you share this output?
cat /sys/class/leds/
❯ ls /sys/class/leds
input30::capslock input30::numlock input4::numlock system76::airplane
input30::compose input30::scrolllock input4::scrolllock system76::kbd_backlight
input30::kana input4::capslock phy0-led
❯ ls /sys/class/leds/system76::kbd_backlight
brightness color_center color_left device power trigger
brightness_hw_changed color_extra color_right max_brightness subsystem uevent
Only changing color_left
does anything.
I added the following here:
import gi
gi.require_version('Gtk', '3.0') # <--
from gi.repository import Gtk, Gio
This works now, however running GUI applications as root isn't really the greatest idea in the world.
sudo /usr/lib/python3.9/site-packages/keyboard-color-switcher/keyboard-color-switcher.py
Well, so much for the Polkit policy. For some reason that was causing an issue:
❯ pkexec /usr/lib/python3.9/site-packages/keyboard-color-switcher/keyboard-color-switcher.py
Unable to init server: Could not connect: Connection refused
Unable to init server: Could not connect: Connection refused
Traceback (most recent call last):
File "/usr/lib/python3.9/site-packages/keyboard-color-switcher/keyboard-color-switcher.py", line 111, in <module>
win = MainWindow()
File "/usr/lib/python3.9/site-packages/keyboard-color-switcher/keyboard-color-switcher.py", line 30, in __init__
Gtk.Window.__init__(self)
File "/usr/lib/python3.9/site-packages/gi/overrides/Gtk.py", line 515, in __init__
raise RuntimeError(
RuntimeError: Gtk couldn't be initialized. Use Gtk.init_check() if you want to handle this case.
PKGBUILD is updated to use gksu
instead.
It looks better with that prompt though I don't know if that works in Wayland or not though that's another task to deal with later I think.
With zensu
(provides gksu
) you can use spacefm
, kdialog
, yad
or zenity
for the prompt. It will look for them in that order. I have yad
installed as a dependency for something else, so it's using that for me.
With pkexec
, it uses the system dialog (or whatever it's called) just like when systemctl enable some.service
is used, for instance.
@JeffLabonte so it sounds like color_extra
is for the backlight on the front of some systems like the serw11
and serw12
.
Using zensu certainly works for what we need!
I don't think system76-oled
is really needed tbh.
it sounds like color_extra is for the backlight on the front of some systems like the serw11 and serw12.
You mean on the lid? That color doesn't change. color_left
is the whole keyboard, the others don't do anything.
Using zensu certainly works for what we need!
It's not ideal, but it'll work for now.
I don't think system76-oled is really needed tbh.
But you said...
I don't have the /sys/class/leds path and I can't use the key combos.
What did you install that exposed the path, then? You'll need system76-dkms
for the hotkeys.
I didn't have the system76-dkms package when I installed the oled package. Then I installed dkms then rebooted and the path was there.
I'm sorry for the extra messages I believe we are getting off course to fix your issue. I'm a bit worried about these messages as well:
Unable to init server: Could not connect: Connection refused Unable to init server: Could not connect: Connection refused
Are you using Xorg or Wayland?
I believe we are getting off course to fix your issue
It's already fixed, see above. Once #10 is merged and the gi.require_version('Gtk', '3.0')
is added, anyway.
Unable to init server: Could not connect: Connection refused Unable to init server: Could not connect: Connection refused
That was from pkexec
, don't worry about that.
Are you using Xorg or Wayland?
Xorg because NVIDIA.
Merge #11 and we're golden!
Is the main issue fixed as well?
See: #12. Actually, don't merge that yet. I'll see what else I can add to it.
If you mean the issues with using the Polkit policy, no. Still the same output as above.
Alright so I recreated it on my system though I can run the application just fine like this:
keyboard-color-switcher
Right, so can I. Effectively, the issue is solved.
Part of the issue was not declaring the GTK version. Since I also had Gtk 4 installed, it threw it off.
The other part of the issue was using the Polkit policy which I've put on hold for now. I'll figure that out later.
I'll keep looking into it when I can unless @JeffLabonte has any ideas. There don't seem to be a ton of reports of the behavior.
Well, no. Not many people would have Gtk 4 installed yet, for one. Either way, that's solved now.
I don't have GTK 4 installed as far as I know of.
No, you wouldn't as nothing stable requires it yet. I was testing new software.
Well the oddness is that I can recreate the issue without GTK 4.
You can? After #11 was merged, it doesn't matter what other versions of Gtk are installed.
After today's unstable branch updates including gtk3
3.24.25, I now cannot reproduce the issue with the Polikit policy. My PKGBUILD is updated to install it again.
I haven't run it today with the recent changes.
It sounds like this issue has been fixed correct? I can run it like this with no issue:
sudo /usr/lib/python3.9/site-packages/keyboard-color-switcher/keyboard-color-switcher.py
If you installed it via my PKGBUILD, don't run it like that. The whole idea was to use pkexec
. Just run keyboard-color-switcher
.
@yochananmarqos @ahoneybun I will consider the issue fixed and close this issue! 😄
I just tried it from the 1.0 tag:
Serval WS Manjaro GNOME
gtk3
3.24.24python
3.9.1python-gobject
3.38.0