1

I have a custom keyboard layout that I want to install like this:

$sudo apt install my-custom-kbd-layout

Is this possible with Debian?

Because I started writing some python script to automate the manual steps, but maybe I'm over complicating things. Is there a better way?

Edit: removed code

aliopi
  • 163
  • This looks like a code-review question. – Stan Strum Jan 03 '18 at 17:43
  • The code is for reference here, not for reviewing. – aliopi Jan 04 '18 at 12:15
  • 1
    I don’t know much about package control, but If guess you could do 2 things, assuming it is not the code that is the problem. 1) push this to an official/unofficial repository (make sure it is added to the repo list) and download it with apt, or 2) since it is Python, maybe you can reserve a PIP package specifically for this. – Stan Strum Jan 04 '18 at 16:27
  • I'm not sure if my approach is appropriate at all, because here https://unix.stackexchange.com/questions/55933/create-and-set-custom-keyboard-layout?rq=1 they use setxkbmap to add the keyboard layout at runtime as an "addon" instead of modifying the system files manually as I do. But using setxkbmap may be too difficult for a beginner and I don't want to make installing this keyboard layout difficult. I want to script the installation and make it as easy as installing a package. I don't care if it's a package or not but this looks easiest to me, for now. – aliopi Jan 04 '18 at 16:32
  • I believe it is quite easy from the start, as (at least Ubuntu does, I think Debian follows suit) you are queried of what keyboard to use via arrow keys or mouse. Otherwise, you may be able to make a shell script that DOES modify settings for the wanted keyboard layout. While I see this as making the code less legible for beginning users, I don’t believe it’ll be a problem. I’d take this to a private convo, but I’m on mobile right now. – Stan Strum Jan 04 '18 at 16:43
  • Forget the code please, it's just here for people to understand what I'm trying to do. The users (or "beginners" as I called them) should not see any code, they should just run apt install my-kbd-layout and it will be there. Or maybe I should use setxkbmap or another approach if somebody knows better. Your 1) "push to repo" is a possibility. But the Debian people would have to accept it. And modifying system files might be bad. I should ask this on a Debian mailing list maybe, but I thought I would ask here before. – aliopi Jan 04 '18 at 17:12
  • 1
    I'd recommend you see how the package keyboards-rg does it (apt-get source keyboards-rg) and copy it. – angus Jan 05 '18 at 06:26
  • Thank you @angus, if you would write this as an answer I'll accept it. I will try to copy this package and adapt to my needs, and see how far I can go with it. – aliopi Jan 05 '18 at 10:02
  • 1
    possible, yes. beginner friendly, no. ... i went into a brief discussion of one possible solution on a similar question on askubuntu. you might not want to submit your customizations to the official package, but could use that to make your own patch for a local build of xkb-data that includes your changes. – quixotic Jan 09 '18 at 04:40

1 Answers1

4

Package keyboards-rg provides several keyboard layouts aimed at Eastern European users. By examining its source (retrieve it with apt-get source keyboards-rg) you can see what files you need to provide, what to put in the debian/ directory, etc.

angus
  • 12,321
  • 3
  • 45
  • 40
  • I'll put the url to source in case someone else is interested https://packages.debian.org/stretch/keyboards-rg – aliopi Jan 05 '18 at 17:33
  • For other people who want to make a keyboard package, I found this excellent answer here https://superuser.com/a/1168603, which confirms what I hoped would not be. Because I use Gnome, I can't avoid editing the evdev.lst and evdev.xml files. Why is this a problem? Because system updates will overwrite my change. The other problem is that I have to write a script to insert the snippets for my custom keyboard at the right place, without deleting other custom edits or breaking something. Very complicated, I was hoping a "plugin" style architecture was possible. – aliopi Jan 08 '18 at 10:36
  • There is another problem with the setxkbmap aproach, it completely overrides my Gnome settings. So if I have de activated in Gnome and then do setxkbmap xy, xy will be active in every window or terminal but Gnome still shows de as active. Switching keyboards in Gnome with Win + Space I can see the keyboard symbols switching but actually nothing happens; I expected it would override the setxkbmap xy command. – aliopi Jan 08 '18 at 10:56
  • @aliopi Once you manage to do it, please write a better answer and assign it to you. It'll be an asset for the site. – angus Jan 08 '18 at 16:18
  • I think this task is too difficult for my experience level with Debian / Linux. But I gathered a lot of information with this question, so many thanks to everyone and apologies. – aliopi Jan 08 '18 at 16:47
  • 1
    @aliopi the answer you link mentions disabling gnome's settings daemon if you prefer the setxkbmap approach. you do need to understand setxkbmap needs all the layouts you want: you'll need setxkbmap -layout de,xy to get both layouts. on the other hand, if you make changes to the system files correctly you'll be able to use gnome's builtin handling. – quixotic Jan 09 '18 at 04:39