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

[FEAT] Configuration for keybinds/controls. #257

Open
CabalCrow opened this issue Oct 7, 2024 · 24 comments
Open

[FEAT] Configuration for keybinds/controls. #257

CabalCrow opened this issue Oct 7, 2024 · 24 comments

Comments

@CabalCrow
Copy link
Contributor

Is your feature request related to a problem? Please describe.

I'm using a non-qwerty keyboard, so I generally use a custom keybinds for vim like keys.

Describe the solution you'd like

Being able to rebind every or most controls via the config file.

@s-n-g
Copy link
Collaborator

s-n-g commented Oct 8, 2024

Hi @CabalCrow

This is something that was requested in the past...
The thing is, the way the code was structured from the early days of the project, it would be very hard to implement such a request

I will look into it again, but i'm not that optimistic about it...

@s-n-g
Copy link
Collaborator

s-n-g commented Oct 8, 2024

Do you have a definition for the keyboard you are using?
I am interested in the ASCII codes it produces

@CabalCrow
Copy link
Contributor Author

Dunno, what you mean by definition. It is a dvorak keyboard, in case you mean that.

@s-n-g
Copy link
Collaborator

s-n-g commented Oct 8, 2024

Yes, that's what I mean :)

I have the Wikipedia page https://en.wikipedia.org/wiki/Dvorak_keyboard_layout as a reference.
I see there are many variants, some of which can produce "non-standard" characters, like "É" for example.

Can you present a couple of examples of the custom keybinds for vim like keys you would like to use with pyradio?
I am trying to understand the differences to the standard keybinds, and more specifically the potential use of "non-standard" characters

@CabalCrow
Copy link
Contributor Author

CabalCrow commented Oct 8, 2024 via email

@s-n-g
Copy link
Collaborator

s-n-g commented Oct 8, 2024

ok, I see
I have started the process of making pyradio's keybindings configurable, it will take a while though.
Would you be available to test the result; 4 eyes are always better than 2 :) ?

@CabalCrow
Copy link
Contributor Author

CabalCrow commented Oct 8, 2024 via email

@s-n-g
Copy link
Collaborator

s-n-g commented Oct 8, 2024

ok, I will get back to you when I have something that's working

@s-n-g
Copy link
Collaborator

s-n-g commented Oct 13, 2024

ok, so here it is, here's what I have up to now...
Almost all shortcuts can be customized (well, the interface is missing, but all key codes are in `keyboard.py)

I have changed the key definitions for you, here's the differences

image

Please do consult the help screens. see a mockup of the main screen showing the changes there
keyboard

Now, this is how you install this update:

Go to https://github.com/s-n-g/pyradio/tree/devel click on "Code" ans "Download ZIP"
You will get a file: pyradio-devel
Unzip it and

cd pyradio-devel
./devel/build_install_pyradio

@s-n-g
Copy link
Collaborator

s-n-g commented Oct 13, 2024

I forgot to post the configuration file :)

To install it, execute pyradio, press "\o" and press Enter to open the "Data Directory".
Then copy/save the following file in that directory
Finally, restart pyradio

keyboard.json

@CabalCrow
Copy link
Contributor Author

CabalCrow commented Oct 13, 2024 via email

@s-n-g
Copy link
Collaborator

s-n-g commented Oct 13, 2024

Can you post your system info?
And the output of ./devel/build_install_pyradio?
Also pipx --vestion

I also use pipx and I do not have to use the pipx command directly...

Anyhow, have you tried it?
Any problems / suggestions?

@CabalCrow
Copy link
Contributor Author

CabalCrow commented Oct 13, 2024 via email

@s-n-g
Copy link
Collaborator

s-n-g commented Oct 13, 2024

If I try and run it afterwards it would crash because of the lack of modules so in order to make it work I need to use the pipx inject command.

Try his one:

./devel/build_install_pyradio -i

What do you want specifically for system info?
I meant what distro are you on....
But that's irrelevant right now

As for the actual changes, I'm trying it right now. It seems to work, and I will try changing the keys around. I assume only the given keys in the json file could be changed?

The full list of keys are in keyboard.py

find ~/.local/pipx/venvs/pyradio -name keyboard.py

Just be careful not to create duplicate key definitions

@s-n-g
Copy link
Collaborator

s-n-g commented Oct 13, 2024

Manually editing keyboard.py would require some knowledge of python and curses under python

For example, this line

    'del':                      ord('x'),               # delete an item

means that "x" will be del (a shorthand used by the program internally to represent the DEL key)

And this one

    'gr':                       curses.ascii.BEL,       # open groups window - default: ^G

that Ctrl-G will open the groups window

curses_ascii_dict in the file defines all Ctrl combinations used by python

And this one

    'F9':                       curses.KEY_F9,          # Windows Show EXE location

that F9 will show the EXE location on Windows

So, it is easy to either make a mistake and get a crash, or get duplicate key definitions, so keep a backup of keyboard.py before editing

@CabalCrow
Copy link
Contributor Author

With -i it works properly. Here the output in case it is important

Looking for pipx ... 1.6.0
  installed package pyradio 0.9.3.11, installed using Python 3.12.7
  These apps are now globally available
    - pyradio
    - pyradio-client
done! ✨ 🌟 ✨
  injected package dnspython into venv pyradio
done! ✨ 🌟 ✨
  injected package netifaces into venv pyradio
done! ✨ 🌟 ✨
  injected package psutil into venv pyradio
done! ✨ 🌟 ✨
  injected package python-dateutil into venv pyradio
done! ✨ 🌟 ✨
  injected package requests into venv pyradio
done! ✨ 🌟 ✨
  injected package rich into venv pyradio
done! ✨ 🌟 ✨
Installing Desktop file ...   

Other than that, I tried changing some keys (only via the json file), and everything seems to be working great so far - thanks a lot! I will keep using this version for now and tell you if I encounter any issues.

@s-n-g
Copy link
Collaborator

s-n-g commented Oct 13, 2024

Great!
I will just start creating the interface for it; editing the file manually is a no go 😉

@CabalCrow
Copy link
Contributor Author

Will there still be a input configuration file in the config folder? I tend to configure via text files.

@s-n-g
Copy link
Collaborator

s-n-g commented Oct 13, 2024

No, the default configuration will be in keyboard.py (hardcoded), only user changes will be in the json file.
You may be perfectly capable to edit the file directly, but most people will not be :)
That's why some kind of interface is needed

@s-n-g
Copy link
Collaborator

s-n-g commented Oct 13, 2024

So, if you make any changes in keyboard.py, I will help you to "pass" them to the json file before the final release of it all (before updating and overwriting keyboard.py)

@CabalCrow
Copy link
Contributor Author

I didn't saw use to edit the keyboard.py directly, since the json file seems to work great. I guess the only use case could be disabling a key or trying to have multiple keys mapped to a single function?

@s-n-g
Copy link
Collaborator

s-n-g commented Oct 13, 2024

As long as you just use in the json file the same keys used in keyboard.py, you should be ok, you should not be editing keyboard.py

I guess the only use case could be disabling a key

No, don't do that; the program will probably crash if you try to disable a key (delete the key: value pair)

or trying to have multiple keys mapped to a single function?

That would not work either, the last key definition will be used

@s-n-g
Copy link
Collaborator

s-n-g commented Oct 17, 2024

All changes released in 0.9.3.11.1

There are a lot of changes there, please keep reporting keybindings issues here 😉

@s-n-g
Copy link
Collaborator

s-n-g commented Dec 5, 2024

A configuration window has been added in version 0.9.3.11.2

Please do try it out and report any bug you may find
Do keep a backup of your current keyboard.json file (residing in the data dir)

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

No branches or pull requests

2 participants