pyradio icon indicating copy to clipboard operation
pyradio copied to clipboard

[FEAT] Configuration for keybinds/controls.

Open CabalCrow opened this issue 1 year ago • 24 comments

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.

CabalCrow avatar Oct 07 '24 17:10 CabalCrow

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 avatar Oct 08 '24 07:10 s-n-g

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

s-n-g avatar Oct 08 '24 13:10 s-n-g

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

CabalCrow avatar Oct 08 '24 14:10 CabalCrow

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

s-n-g avatar Oct 08 '24 14:10 s-n-g

The common thing is I rebind the jkhl keys to htns so that they are still on the home row like it is with jkhl on qwerty. The only difference really is that I use n as right and s as left (which would be the opposite in jkhl).

On 24/10/08 07:28AM, Spiros Georgaras wrote:

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

-- Reply to this email directly or view it on GitHub: https://github.com/coderholic/pyradio/issues/257#issuecomment-2400013020 You are receiving this because you were mentioned.

Message ID: @.***>

CabalCrow avatar Oct 08 '24 14:10 CabalCrow

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 :) ?

s-n-g avatar Oct 08 '24 14:10 s-n-g

Yeah sure! Thanks for doing this!

On 24/10/08 07:41AM, Spiros Georgaras wrote:

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 :) ?

-- Reply to this email directly or view it on GitHub: https://github.com/coderholic/pyradio/issues/257#issuecomment-2400048123 You are receiving this because you were mentioned.

Message ID: @.***>

CabalCrow avatar Oct 08 '24 14:10 CabalCrow

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

s-n-g avatar Oct 08 '24 14:10 s-n-g

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 avatar Oct 13 '24 14:10 s-n-g

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

s-n-g avatar Oct 13 '24 15:10 s-n-g

Got it installed and running. Albeit I had to run: pipx inject pyradio -r requirements_pipx.txt Probably can/should be added to the install script - I'm not sure.

On 24/10/13 07:58AM, Spiros Georgaras wrote:

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

-- Reply to this email directly or view it on GitHub: https://github.com/coderholic/pyradio/issues/257#issuecomment-2409011024 You are receiving this because you were mentioned.

Message ID: @.***>

CabalCrow avatar Oct 13 '24 15:10 CabalCrow

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?

s-n-g avatar Oct 13 '24 15:10 s-n-g

Output of the build script:

./devel/build_install_pyradio 
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! ✨ 🌟 ✨
Installing Desktop file ...  

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.

What do you want specifically for system info?

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?

On 24/10/13 08:15AM, Spiros Georgaras wrote:

Can you post your system info? And the output of ./devel/build_install_pyradio?

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

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

-- Reply to this email directly or view it on GitHub: https://github.com/coderholic/pyradio/issues/257#issuecomment-2409017107 You are receiving this because you were mentioned.

Message ID: @.***>

CabalCrow avatar Oct 13 '24 15:10 CabalCrow

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 avatar Oct 13 '24 15:10 s-n-g

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

s-n-g avatar Oct 13 '24 15:10 s-n-g

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.

CabalCrow avatar Oct 13 '24 15:10 CabalCrow

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

s-n-g avatar Oct 13 '24 15:10 s-n-g

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

CabalCrow avatar Oct 13 '24 15:10 CabalCrow

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 avatar Oct 13 '24 15:10 s-n-g

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)

s-n-g avatar Oct 13 '24 15:10 s-n-g

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?

CabalCrow avatar Oct 13 '24 16:10 CabalCrow

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 avatar Oct 13 '24 16:10 s-n-g

All changes released in 0.9.3.11.1

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

s-n-g avatar Oct 17 '24 17:10 s-n-g

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)

s-n-g avatar Dec 05 '24 11:12 s-n-g

This is fully functional for a couple of releases now

s-n-g avatar Oct 23 '25 09:10 s-n-g