1
0
mirror of https://github.com/kmein/niveum synced 2026-03-16 10:11:08 +01:00
Files
niveum/configs/keyboard/default.nix

143 lines
4.4 KiB
Nix
Raw Normal View History

2022-03-10 21:52:12 +01:00
{
2025-12-25 18:23:27 +01:00
config,
2022-03-10 21:52:12 +01:00
pkgs,
lib,
...
2025-07-08 20:56:40 +02:00
}:
let
2024-10-27 15:45:18 +01:00
2022-03-10 21:52:12 +01:00
commaSep = builtins.concatStringsSep ",";
2025-07-08 20:56:40 +02:00
xkbOptions = [
"compose:caps"
"terminate:ctrl_alt_bksp"
"grp:ctrls_toggle"
];
languages = {
2025-07-08 20:56:40 +02:00
deutsch = {
code = "de";
variant = "T3";
};
greek = {
code = "gr";
variant = "polytonic";
};
russian = {
code = "ru";
variant = "phonetic";
};
arabic = {
code = "ara";
variant = "buckwalter";
2025-12-25 14:35:28 +01:00
};
coptic = ./coptic;
avestan = ./avestan;
gothic = ./gothic;
2025-07-08 20:56:40 +02:00
farsi = {
code = "ir";
variant = "qwerty";
};
syriac = {
code = "sy";
variant = "syc_phonetic";
};
sanskrit = {
code = "in";
variant = "san-kagapa";
};
gujarati = {
code = "in";
variant = "guj-kagapa";
};
urdu = {
code = "in";
variant = "urd-phonetic";
};
hebrew = {
code = "il";
variant = "phonetic";
};
};
2024-06-20 15:05:40 +02:00
defaultLanguage = languages.deutsch;
2025-07-08 20:56:40 +02:00
in
{
2024-06-03 07:27:01 +02:00
services.libinput.enable = true;
2022-04-25 11:34:07 +02:00
# man 7 xkeyboard-config
2019-04-19 03:11:51 +02:00
services.xserver = {
2025-12-25 18:23:27 +01:00
exportConfiguration = lib.mkForce true; # link /usr/share/X11 properly
2024-06-20 15:05:40 +02:00
xkb.layout = defaultLanguage.code;
2022-04-25 11:52:27 +02:00
# T3: https://upload.wikimedia.org/wikipedia/commons/a/a9/German-Keyboard-Layout-T3-Version1-large.png
# buckwalter: http://www.qamus.org/transliteration.htm
2024-06-20 15:05:40 +02:00
xkb.variant = defaultLanguage.variant;
2024-06-03 07:27:01 +02:00
xkb.options = commaSep xkbOptions;
2025-12-25 18:23:27 +01:00
xkb.extraLayouts = {
coptic = {
languages = [ "cop" ];
description = "Coptic is the latest stage of the Egyptian language and was used by Egyptian Christians. The Coptic script is based on the Greek alphabet with some letters borrowed from Demotic Egyptian.";
symbolsFile = ./coptic;
};
avestan = {
languages = [ "ave" ];
description = "Avestan is an ancient Iranian language known primarily from its use in the sacred texts of Zoroastrianism, the Avesta. It is an Indo-Iranian language that was spoken in ancient Persia.";
symbolsFile = ./avestan;
};
gothic = {
languages = [ "got" ];
description = "Gothic is an extinct East Germanic language that was spoken by the Goths. It is known primarily from the Codex Argenteus, a 6th-century manuscript containing a translation of the Bible into Gothic.";
symbolsFile = ./gothic;
};
farsi = {
languages = [ "fas" ];
description = "Farsi, also known as Persian, is an Indo-Iranian language spoken primarily in Iran, Afghanistan (where it is known as Dari), and Tajikistan (where it is called Tajik). It has a rich literary tradition and is written in a modified Arabic script.";
symbolsFile = ./farsi;
};
};
2019-04-19 03:11:51 +02:00
};
2024-02-25 22:18:57 +01:00
environment.etc."x11-locale".source = toString pkgs.xorg.libX11 + "share/X11/locale";
2025-07-08 20:56:40 +02:00
home-manager.users.me = {
2025-12-25 18:23:27 +01:00
home.file = {
".XCompose".source = ./XCompose;
};
2025-07-08 20:56:40 +02:00
};
console.keyMap = "de";
2020-05-31 18:24:15 +02:00
2025-07-08 20:56:40 +02:00
environment.systemPackages = lib.mapAttrsToList (
language: settings:
2024-06-20 15:05:40 +02:00
let
code = if settings ? "code" then settings.code else language;
variant = if settings ? "variant" then settings.variant else "";
in
2025-07-08 20:56:40 +02:00
pkgs.writers.writeDashBin "kb-${language}" ''
2026-01-04 14:30:06 +01:00
if [ -n "$SWAYSOCK" ]; then
2025-07-08 20:56:40 +02:00
swaymsg -s $SWAYSOCK 'input * xkb_layout "${defaultLanguage.code},${code}"'
swaymsg -s $SWAYSOCK 'input * xkb_variant "${defaultLanguage.variant},${variant}"'
swaymsg -s $SWAYSOCK 'input * xkb_options "${lib.concatStringsSep "," xkbOptions}"'
2026-01-04 14:30:06 +01:00
elif [ -n "$HYPRLAND_INSTANCE_SIGNATURE" ]; then
hyprctl keyword input:kb_layout "${defaultLanguage.code},${code}"
hyprctl keyword input:kb_variant "${defaultLanguage.variant},${variant}"
elif [ -n "$DISPLAY" ]; then
${pkgs.xorg.setxkbmap}/bin/setxkbmap ${defaultLanguage.code},${code} ${defaultLanguage.variant},${variant} ${
toString (map (option: "-option ${option}") xkbOptions)
}
2025-07-08 20:56:40 +02:00
fi
''
2025-12-25 18:23:27 +01:00
) (languages // config.services.xserver.xkb.extraLayouts);
2020-05-31 18:24:15 +02:00
# improve held key rate
2022-03-10 21:52:12 +01:00
services.xserver.displayManager.sessionCommands = "${pkgs.xorg.xset}/bin/xset r rate 300 50";
2022-04-25 11:38:10 +02:00
systemd.user.services.gxkb = {
2025-07-08 20:56:40 +02:00
wantedBy = [ "graphical-session.target" ];
2022-04-25 11:38:10 +02:00
serviceConfig = {
SyslogIdentifier = "gxkb";
ExecStart = "${pkgs.gxkb}/bin/gxkb";
Restart = "always";
RestartSec = "15s";
StartLimitBurst = 0;
};
};
2019-04-19 03:11:51 +02:00
}