alexriss / keyboard-layout-converter

A simple python script to convert a Windows .klc keyboard layout to a Linux .xkb file
GNU General Public License v3.0
50 stars 7 forks source link

Difficulties for a Linux newbie (Ubuntu) #3

Open CodeGrepicious opened 2 years ago

CodeGrepicious commented 2 years ago

image I am having issues running the script, I am also not sure if I got the naming correct or if you also somehow have to include the directory in it (see the attached screenshot) I also have no idea what it means that you have to merge the files

CodeGrepicious commented 2 years ago

I realized I probably need to name the subfolders (or directories I guess they are called) correctly, so I did that, but when I try to run the script it does not work with "python" image image

CodeGrepicious commented 2 years ago

and when I try without the directories above (and with python3) I get the error "name "klcfile) is not defined" image

alexriss commented 2 years ago

running it with python3 seems to be fine on your system. the filename should be in quotes, i.e. input.close("...klc"). (Replace the "...klc" with your filename, but keep the quotes)

CodeGrepicious commented 2 years ago

Edit: new error textiowrapper takes no arguments

Am I not naming the .xkb file correctly? i just want to get the xkb file now I don't care where it goes or what it is called image image

CodeGrepicious commented 2 years ago

I also tried with a slash before, the apostrophes also don't make a difference image

alexriss commented 2 years ago

oh sorry, I didn't look properly. this line should not be changed. just these two (you see the quotes?):

output = open(r"US - international - custom - nodeadkeys - greek.xkb","w")
input = open(r"US - international - custom - nodeadkeys - greek.klc", encoding="utf-16")
CodeGrepicious commented 2 years ago

So you should not have close, but open? And what does the r mean? That is what I meant! It would be really helpful to have an example of what to input like let's say a file in the Downloads directory input.close(Home/daniel/Downloads/NorUltiNov2021.klc) output.close(Home/daniel/Downloads/NorUltiLinuxNov2021.xkb)

CodeGrepicious commented 2 years ago

edit: I see what you mean, it is the one where output is over input. image I'm still getting an error maybe the r should not be there? output = open(r"Home/daniel/Downloads/NorUlti10LinuxNov2021.xkb","w") input = open(r"Home/daniel/Downloads/NorUlti10Nov2021.klc", encoding="utf-16")

alexriss commented 2 years ago

r is raw string. I dont think there will be much difference in most cases.

You see it says "no such file or directory", which means that your file path is wrong, you need to figure this out. If I were to guess it would be /home/daniel... (with the first slash, also upper/lowercase matters)

CodeGrepicious commented 2 years ago

well first off, do I leave the international - custom text in the front ? output = open(r"US - international - custom - nodeadkeys - NorUlti10Nov2021ctl.xkb","w") input = open(r"US - international - custom - nodeadkeys - NorUlti10Nov2021.klc", encoding="utf-16")

and do I need to state the directories if I have the .klc file in the same directory as the convert_to_xkb.py script?

CodeGrepicious commented 2 years ago

Now I am getting this error image edit: this is with the correct directories :

alexriss commented 2 years ago

remove it - just the filename. Same directory is good.

CodeGrepicious commented 2 years ago

that's what I am confused about, remove what exactly? do I not need this? /home/daniel ``

r is raw string. I dont think there will be much difference in most cases.

You see it says "no such file or directory", which means that your file path is wrong, you need to figure this out. If I were to guess it would be /home/daniel... (with the first slash, also upper/lowercase matters)

alexriss commented 2 years ago

put the path of your file inside the quotes (nothing else), leave everything outside the quotes.

CodeGrepicious commented 2 years ago

This worked, turned out the problem was that home was home with small letters and not capital letters. to whoever's reading this, remember to check the properties of your .klc file to get the proper file path! image

CodeGrepicious commented 2 years ago

Now I have the .xkb file (finally! :)) I tried looking at the sites you linked to in the README document, but I couldn't find any specific instructions as to what "merging" you were talking about. I can't seem to just add the lines of codes to the bottom as I don't have the permissions to do so image Two of the links referred to in the readme doc seem to not be working. I found this page https://rlog.rgtti.com/2014/05/01/how-to-modify-a-keyboard-layout-in-linux/ But here I also don't understand if this merging is something you do in the terminal. I don't understand these two last steps I tried reading through Karol's blog too https://karols.github.io/blog/2013/11/18/creating-custom-keyboard-layouts-for-linux/ Though I have the same issue there, I don't get where I am supposed to paste the generated xkb code, or how to merge it image

CodeGrepicious commented 2 years ago

I've been trying to figure it out and I've watched some videos and read some posts, but it's still unclear to me how you actually edit the

layout definitions are in the /usr/share/X11/xkb/symbols directory,

layout metadata are in the /usr/share/X11/xkb/rules/evdev.xml file.

and how you actually add the converted .xkb data into an existing layout. No matter what directory I go into I don't have the permission to change the keyboard layout code it seems.

CodeGrepicious commented 2 years ago

To whoever's reading this; the answer is to edit the file as root. The easiest way is using the terminal: navigate to /usr/share/X11/xkb/symbols and edit the file from command line.

If you don't know any conmand line editors, your best bet is nano: use sudo nano us (if you want to edit the us file)