I have tried a long time ago to make package for a custom keyboard layout. Here the option i could find at that time:
Modify original layout (ex:
/usr/share/X11/xkb/symbols/us)Issues:
- It got overwritten on
xkb-dataupdate. Package name may differ from distribution to another. - Bad idea to create a debian package that overwrites another package file.
- It got overwritten on
Add new layout with different name
xylike in this postIssues:
- Same issues of previous method but with layout declaration file:
/usr/share/X11/xkb/rules/evdev.xmlthat need to be modified. AFAIK, Xorg server does not support dynamic loading for new layouts.
- Same issues of previous method but with layout declaration file:
The above methods relay on XIM (Standard X input method), a legacy system. I would recommend using a modern input method that support plug-ins (modular design) like IBus or SCIM.
I didn't try that but I expect ibus-table is the easiest way to go like as explain in this post. The added file could be packaged and installed separately like most IBus engines & layouts, IBus take care to loading them.
Update:
Well, this answer on AskUbuntu mentions a cleaner way to modify the upstream package. Here are the minimum instructions to rebuild the package
Enable the source code for repository
Download build dependencies
sudo apt build-dep xkb-dataDownload the source
mkdir sandbox cd sandbox apt source xkb-dataCreate new quilt patch following Ubuntu packaging guide
cd xkeyboard-config*/ quilt new username_custom_layout.diff quilt add symbols/usMake your needed modification on
symbols/usthenquilt refreshBuild the unsigned source & binary package
debuild -us -uc