erjiang / huion-keys

Linux program to create custom bindings for Huion tablet hotkeys
GNU General Public License v3.0
13 stars 4 forks source link

Config folder location and question about start up. #13

Closed Rodgers13 closed 3 years ago

Rodgers13 commented 3 years ago

First off, WOW thanks for taking the time to write this program! I have found a Huion-keys config file in two locations in two different config folders. One in /home/ and another in /root/. The one in /root/ is the one to edit correct? Also, is there a way I can have this launch at startup and run in the background or minimized to the system tray? I'm a Linux noob so sorry if the answers to these questions are self evident. Thanks again for taking the time.

Oh and I'm running kubuntu if that makes any difference

erjiang commented 3 years ago

I'm not 100% sure what files you are referring to, but the first time you run the program, it should say that it automatically generated a config file for you, for example at /home/rodgers13/.config/huion_keys.conf. If you open that file up with your favorite text editor, the top of the file should say:

# use one line for each button you want to configure
# buttons that aren't in this file will be ignored by this program
...

That's the file you want to edit to change what keys go with what tablet buttons.

As for starting it up automatically, yes you can, but you should first make sure you can run it without sudo and it works. There's a udev config file that you can create (step 7 of the readme) to tell Linux that you should have permission to talk to the tablet.

Then, KDE should have some kind of "Startup Applications" or "Application Autostart" settings screen. In that settings screen, you'd put the same command that you would use to start the program. E.g. python /home/rodgers13/huion-keys/huion_keys.py

Unfortunately there's no tray icon feature right now so there's no way to see whether it's running or not (other than trying out the buttons). Might be a neat thing to have in the future, so if you have strong opinions on that, you can create a feature request.

Hope you get some use out of this!

Rodgers13 commented 3 years ago

This is interesting. When I edit the "huion_keys.conf" in for example /home/rodgers13/.config/ "huion_keys.py" doesn't produce results matching my edits. It continues to have the keys function as with the original content of the "huion_keys.conf", ignoring my edits.

When I checked the /root/.config/huion_keys.conf I found it still had the original settings from when the file was first created. I then edited that "huion_keys.conf", found in /root/.config/. After that, the program worked like a charm. So it appears that the "huion_keys.conf" found in /home/rodgers13/.config/ is being ignored in favor of the one found in /root/.config/

Is "huion_keys.conf" even supposed to be created with a version of it in the /root/.config/ directory? Or is this some sort of kde/Ubuntu black magic?

erjiang commented 3 years ago

Are you running it as root? (i.e. with sudo?) That would explain why it's using the root user's home directory, and /root/.config/huion_keys.conf. If it works it works, but generally the fewer things you run as root, the more secure your computer is.

Rodgers13 commented 3 years ago

Ah yes. I was running as sudo, so then it uses the file in root. Makes sense. Running it without sudo would be preferable, a more secure system is always better. It's one of the reasons I switched to Linux.

I followed step 7 by entering 'python huion_keys.py > /etc/udev/rules.d/50-huion-tablet.rules' as root, it wouldn’t give me permissions through sudo to do so. This is what I got: File "huion_keys.py", line 8, in from _xdo_cffi import ffi, lib ImportError: No module named _xdo_cffi

I then ran 'python3 huion_keys.py > /etc/udev/rules.d/50-huion-tablet.rules' and got nothing in the output. No return to command prompt. It just hoped one line down. I then checked up on the file ‘50-huion-tablet.rules’. Opening it with a text editor gave me a blank document. Is there a variable in the example command for udev rules that is unique to each system? For example your tablet seems to be hidraw3 where mine is hidraw0, in regards to the chmod command.

Worst case scenario, I use chmod if my lack of knowledge or kubuntu setup keeps me from using the udev rules. Chmod editing of permissions is temporary, needing to be enacted at each startup. Which could be done by the process you described for start up programs/commands/functions, correct?

Thanks again for the replies and your patience. Like I said im a noob to linux and im trying to learn as much as I can as I go along trying to fine tune my system for illustration and animation.

erjiang commented 3 years ago

I then ran 'python3 huion_keys.py > /etc/udev/rules.d/50-huion-tablet.rules' and got nothing in the output.

Oops, that's a mistake in the readme instructions. It should be python3 huion_keys.py --rules > /etc/udev/rules.d/50-huion-tablet.rules or you can copy the contents from here:

# Kamvas Pro (2019)
KERNEL=="hidraw*", ATTRS{idVendor}=="256c", ATTRS{idProduct}=="006e", MODE="0660", TAG+="uaccess"
# Q620M
KERNEL=="hidraw*", ATTRS{idVendor}=="256c", ATTRS{idProduct}=="006d", MODE="0660", TAG+="uaccess"

Putting that in /etc/udev/rules.d/50-huion-tablet.rules should tell Linux to give the current user access to the tablet. The file should be owned by root. You should only need to do this once, and it does not depend on what number your tablet is assigned.

Rodgers13 commented 3 years ago

Hot damn! Worked like a charm, after the reboot. Thanks for clearing that up. You mentioned submitting a feature request, where do I do that? Just in this section tagged with 'Feature request'?

Thanks again for all the help! The 'mode' switching will definitely come in handy.

erjiang commented 3 years ago

You mentioned submitting a feature request, where do I do that? Just in this section tagged with 'Feature request'?

Yes, create a new issue and describe whatever it is that you're wanting.