// Keyboard layouts for Sweden.

default partial alphanumeric_keys
xkb_symbols "basic" {
    include "latin(type2)"
    include "se(se)"
};

partial alphanumeric_keys
xkb_symbols "se" {

    name[Group1]="Swedish";

    key <TLDE>	{[   section,    onehalf,    paragraph, threequarters]};
    key <AE05>	{[         5,    percent,     EuroSign,     permille ]};
    key <AE06>	{[         6,  ampersand,          yen,      radical ]};
    key <AE11>	{[      plus,   question,    backslash, questiondown ]};
    key <AE12>	{[dead_acute, dead_grave,    plusminus,      notsign ]};

    key <AD01>	{[         q,          Q,  Greek_omega,  Greek_OMEGA ]};
    key <AD02>	{[         w,          W,  Greek_sigma,  Greek_SIGMA ]};
    key <AD04>	{[         r,          R,   registered,    trademark ]};
    key <AD10>	{[         p,          P,     Greek_pi,     Greek_PI ]};

    key <AC08>	{[         k,          K,          kra,       dagger ]};
    key <AC10>	{[odiaeresis, Odiaeresis,       oslash,       Oslash ]};
    key <AC11>	{[adiaeresis, Adiaeresis,           ae,           AE ]};
    key <BKSL>	{[apostrophe,   asterisk,        acute,     multiply ]};

    key <LSGT>  {[      less,     greater,         bar,    brokenbar ]};
    key <AB03>	{[         c,          C,    copyright,       U1F12F ]}; // 🄯  (copyleft)
    key <AB09>	{[    period,      colon, periodcentered,   ellipsis ]};

    key <SPCE>	{[     space,      space,        space, nobreakspace ]};

    include "kpdl(comma)"

    include "level3(ralt_switch)"
};

// The basic Swedish layout but without any dead symbols.
partial alphanumeric_keys
xkb_symbols "nodeadkeys" {

    include "latin(type2)"
    include "latin(type2_nodeadkeys)"
    include "se(se)"

    name[Group1]="Swedish (no dead keys)";

    key <AE12>	{[     acute,      grave,    plusminus,      notsign ]};
};

// A Dvorak layout for Swedish.
partial alphanumeric_keys
xkb_symbols "dvorak" {

    include "se(basic)"

    name[Group1]="Swedish (Dvorak)";

    key <AD01> {[     aring,      Aring,    backslash               ]};
    key <AD02> {[ adiaeresis, Adiaeresis,  braceleft,   bracketleft ]};
    key <AD03> {[ odiaeresis, Odiaeresis,  braceright, bracketright ]};
    key <AD04> {[         p,          P,        thorn,        THORN ]};
    key <AD05> {[         y,          Y,    leftarrow,          yen ]};
    key <AD06> {[         f,          F,      dstroke,  ordfeminine ]};
    key <AD07> {[         g,          G,          eng,          ENG ]};
    key <AD08> {[         c,          C,    copyright,    copyright ]};
    key <AD09> {[         r,          R,   registered,   registered ]};
    key <AD10> {[         l,          L,      lstroke,      Lstroke ]};
    key <AD11> {[     comma,  semicolon, dead_cedilla,  dead_ogonek ]};
    key <AD12> {[ dead_diaeresis, dead_circumflex, dead_tilde, asciicircum ]};

    key <AC01> {[         a,          A,           ae,           AE ]};
    key <AC02> {[         o,          O,           oe,           OE ]};
    key <AC03> {[         e,          E,     EuroSign,         cent ]};
    key <AC04> {[         u,          U,    downarrow,      uparrow ]};
    key <AC05> {[         i,          I,   rightarrow,     idotless ]};
    key <AC06> {[         d,          D,          eth,          ETH ]};
    key <AC07> {[         h,          H,      hstroke,      Hstroke ]};
    key <AC08> {[         t,          T,       tslash,       Tslash ]};
    key <AC09> {[         n,          N ]};
    key <AC10> {[         s,          S,       ssharp,      section ]};
    key <AC11> {[     minus, underscore, dead_belowdot, dead_abovedot ]};

    key <AB01> {[    period,   colon, periodcentered, dead_abovedot ]};
    key <AB02> {[         q,          Q,           at,  Greek_OMEGA ]};
    key <AB03> {[         j,          J ]};
    key <AB04> {[         k,          K,          kra,    ampersand ]};
    key <AB05> {[         x,          X, guillemotright,    greater ]};
    key <AB06> {[         b,          B, rightdoublequotemark, apostrophe ]};
    key <AB07> {[         m,          M,           mu,    masculine ]};
    key <AB08> {[         w,          W,      lstroke,      Lstroke ]};
    key <AB09> {[         v,          V, leftdoublequotemark, grave ]};
    key <AB10> {[         z,          Z, guillemotleft,        less ]};
};

// A phonetic layout for typing Russian on a Swedish keyboard.
// Originally by Ivan Popov <pin@konvalo.org>, 2005.
partial alphanumeric_keys
xkb_symbols "rus" {

    include "se(basic)"

    name[Group1]="Russian (Sweden, phonetic)";

    key.type[group1]="ALPHABETIC";

    key <TLDE>	{[ Cyrillic_io, Cyrillic_IO ]};
    key <AE12>	{[ Cyrillic_hardsign, Cyrillic_HARDSIGN ]};

    key <AD01>	{[ Cyrillic_ya, Cyrillic_YA ]};
    key <AD02>	{[ Cyrillic_ve, Cyrillic_VE ]};
    key <AD03>	{[ Cyrillic_ie, Cyrillic_IE ]};
    key <AD04>	{[ Cyrillic_er, Cyrillic_ER ]};
    key <AD05>	{[ Cyrillic_te, Cyrillic_TE ]};
    key <AD06>	{[ Cyrillic_yeru, Cyrillic_YERU ]};
    key <AD07>	{[ Cyrillic_u, Cyrillic_U ]};
    key <AD08>	{[ Cyrillic_i, Cyrillic_I ]};
    key <AD09>	{[ Cyrillic_o, Cyrillic_O ]};
    key <AD10>	{[ Cyrillic_pe, Cyrillic_PE ]};
    key <AD11>	{[ Cyrillic_e, Cyrillic_E ]};

    key <AC01>	{[ Cyrillic_a, Cyrillic_A ]};
    key <AC02>	{[ Cyrillic_es, Cyrillic_ES ]};
    key <AC03>	{[ Cyrillic_de, Cyrillic_DE ]};
    key <AC04>	{[ Cyrillic_ef, Cyrillic_EF ]};
    key <AC05>	{[ Cyrillic_ghe, Cyrillic_GHE ]};
    key <AC06>	{[ Cyrillic_ha, Cyrillic_HA ]};
    key <AC07>	{[ Cyrillic_shorti, Cyrillic_SHORTI ]};
    key <AC08>	{[ Cyrillic_ka, Cyrillic_KA ]};
    key <AC09>	{[ Cyrillic_el, Cyrillic_EL ]};
    key <AC10>	{[ Cyrillic_sha, Cyrillic_SHA ]};
    key <AC11>	{[ Cyrillic_shcha, Cyrillic_SHCHA ]};
    key <BKSL>	{[ Cyrillic_yu, Cyrillic_YU ]};

    key <LSGT>	{[ Cyrillic_che, Cyrillic_CHE ]};
    key <AB01>	{[ Cyrillic_ze, Cyrillic_ZE ]};
    key <AB02>	{[ Cyrillic_softsign, Cyrillic_SOFTSIGN ]};
    key <AB03>	{[ Cyrillic_tse, Cyrillic_TSE ]};
    key <AB04>	{[ Cyrillic_zhe, Cyrillic_ZHE ]};
    key <AB05>	{[ Cyrillic_be, Cyrillic_BE ]};
    key <AB06>	{[ Cyrillic_en, Cyrillic_EN ]};
    key <AB07>	{[ Cyrillic_em, Cyrillic_EM ]};
};

xkb_symbols "smi" {
    include "fi(smi)"
    name[Group1]= "Northern Saami (Sweden)";
};

partial alphanumeric_keys
xkb_symbols "mac" {

    include "latin"

    name[Group1]= "Swedish (Macintosh)";

    key <TLDE>	{[    section,      degree ]};
    key <AE01>	{[          1,      exclam,      copyright, exclamdown ]};
    key <AE02>	{[          2,    quotedbl,             at,  oneeighth ]};
    key <AE03>	{[          3,  numbersign,       sterling,        yen ]};
    key <AE04>	{[          4,    currency,         dollar,       cent ]};
    key <AE06>	{[          6,   ampersand ]};
    key <AE07>	{[          7,       slash,            bar,  backslash ]};
    key <AE08>	{[          8,   parenleft,    bracketleft,  braceleft ]};
    key <AE09>	{[          9,  parenright,   bracketright, braceright ]};
    key <AE10>	{[          0,       equal ]};
    key <AE11>	{[       plus,    question ]};
    key <AE12>	{[      acute,       grave ]};

    key <AD03>	{[          e,           E,       EuroSign,       cent ]};
    key <AD11>	{[      aring,       Aring ]};
    key <AD12>	{[  diaeresis, asciicircum,     asciitilde             ]};

    key <AC10>	{[ odiaeresis,  Odiaeresis,         oslash,     Oslash ]};
    key <AC11>	{[ adiaeresis,  Adiaeresis,             ae,         AE ]};
    key <BKSL>	{[ apostrophe,    asterisk,             at             ]};

    key <AB08>	{[      comma,   semicolon ]};
    key <AB09>	{[     period,       colon ]};
    key <AB10>	{[      minus,  underscore ]};

    include "kpdl(comma)"
    include "level3(ralt_switch)"
};

// This version of Dvorak follows the Danish and Norwegian style,
// hoping for a Scandinavian standard to evolve.
partial alphanumeric_keys
xkb_symbols "svdvorak" {

   include "se(basic)"

   name[Group1]="Swedish (Svdvorak)";

   key <AD01> {[ aring, Aring, braceleft ]};
   key <AD02> {[ comma, semicolon, bracketleft ]};
   key <AD03> {[ period, colon, bracketright ]};
   key <AD04> {[ p, P, braceright ]};
   key <AD05> {[ y, Y ]};
   key <AD06> {[ f, F ]};
   key <AD07> {[ g, G ]};
   key <AD08> {[ c, C ]};
   key <AD09> {[ r, R ]};
   key <AD10> {[ l, L ]};
   key <AD11> {[ apostrophe, asterisk ]};

   key <AC01> {[ a, A ]};
   key <AC02> {[ o, O, parenleft ]};
   key <AC03> {[ e, E, parenright ]};
   key <AC04> {[ u, U ]};
   key <AC05> {[ i, I ]};
   key <AC06> {[ d, D ]};
   key <AC07> {[ h, H ]};
   key <AC08> {[ t, T ]};
   key <AC09> {[ n, N ]};
   key <AC10> {[ s, S, ssharp, U1E9E ]};
   key <AC11> {[ minus, underscore ]};
   key <BKSL> {[ less, greater, bar ]};

   key <LSGT> {[ odiaeresis, Odiaeresis ]};
   key <AB01> {[ adiaeresis, Adiaeresis ]};
   key <AB02> {[ q, Q ]};
   key <AB03> {[ j, J ]};
   key <AB04> {[ k, K ]};
   key <AB05> {[ x, X ]};
   key <AB06> {[ b, B ]};
   key <AB07> {[ m, M ]};
   key <AB08> {[ w, W ]};
   key <AB09> {[ v, V ]};
   key <AB10> {[ z, Z ]};
};

// A layout for Swedish Sign Language (“Svenskt teckenspråk”).
// Originally by: Saašha Metsärantala <saasha@acc.umu.se>
//
// A sans-serif font is available at
// http://www.acc.umu.se/home/saasha/typsnitt/swl_sans.ttf
partial alphanumeric_keys
xkb_symbols "swl" {

  include "se(basic)"

  name[Group1]="Swedish Sign Language";

  key <AE01>  {[ U10c953, U10c936, U10c988, U10c962 ]};
  key <AE02>  {[ U10c954, U10c957, U10c97d, U10c963 ]};
  key <AE03>  {[ U10c934, U10c937, U10c97e, U10c983 ]};
  key <AE04>  {[ U10c955, U10c958, U10c98a, U10c984 ]};
  key <AE05>  {[ U10c935, U10c938, U10c97f, U10c966 ]};
  key <AE06>  {[ U10c956, U10c959, U10c980, U10c967 ]};
  key <AE07>  {[ U10c960, U10c969, U10c982, U10c96a ]};
  key <AE08>  {[ U10c97c, U10c90b, U10c989, U10c964 ]};
  key <AE09>  {[ U10c97b, U10c90a, U10c98b, U10c965 ]};
  key <AE10>  {[ U10c974, U10c909, U10c98c, U10c968 ]};

  key <AD01>  {[ U10c96c, U10c92a, U10c900, U10c9a1 ]};
  key <AD02>  {[ U10c971, U10c930, U10c903, U10c99e ]};
  key <AD03>  {[ U10c987, U10c947, U10c90c, U10c96d ]};
  key <AD04>  {[ U10c986, U10c92c, U10c91b, U10c993 ]};
  key <AD05>  {[ U10c939, U10c94a, U10c911, U10c995 ]};
  key <AD06>  {[ U10c952, U10c943, U10c912, U10c99b ]};
  key <AD07>  {[ U10c978, U10c977, U10c95e, U10c9a3 ]};
  key <AD08>  {[ U10c951, U10c931, U10c91e, U10c997 ]};
  key <AD09>  {[ U10c90e, U10c946, U10c906, U10c9a0 ]};
  key <AD10>  {[ U10c91f, U10c961, U10c91c,    none ]};
  key <AD11>  {[ U10c93d, U10c92f, U10c902,    none ]};

  key <AC01>  {[ U10c973, U10c924, U10c93c, U10c9a4 ]};
  key <AC02>  {[ U10c972, U10c945, U10c91a, U10c99c ]};
  key <AC03>  {[ U10c979, U10c929, U10c916, U10c999 ]};
  key <AC04>  {[ U10c976, U10c975, U10c917, U10c994 ]};
  key <AC05>  {[ U10c95a, U10c926, U10c918, U10c996 ]};
  key <AC06>  {[ U10c96f, U10c932, U10c915, U10c998 ]};
  key <AC07>  {[ U10c942, U10c922, U10c913, U10c9a2 ]};
  key <AC08>  {[ U10c985, U10c94e, U10c914, U10c97a ]};
  key <AC09>  {[ U10c928, U10c948, U10c919, U10c9a5 ]};
  key <AC10>  {[ U10c970, U10c92b, U10c905, U10c991 ]};
  key <AC11>  {[ U10c92e, U10c944, U10c904,    none ]};

  key <AB01>  {[ U10c925, U10c95f, U10c940, U10c99a ]};
  key <AB02>  {[ U10c96b, U10c933, U10c920, U10c98e ]};
  key <AB03>  {[ U10c949, U10c94b, U10c921, U10c99f ]};
  key <AB04>  {[ U10c923, U10c92d, U10c95c, U10c96e ]};
  key <AB05>  {[ U10c93b, U10c927, U10c908, U10c9a6 ]};
  key <AB06>  {[ U10c93a, U10c94c, U10c93e, U10c9a7 ]};
  key <AB07>  {[ U10c95b, U10c93f, U10c907, U10c992 ]};
};

// For typing Swedish on a basic US keyboard, putting Å Ö Ä
// on the upper levels of the corresponding Swedish keys.
partial alphanumeric_keys
xkb_symbols "us" {

    include "us"

    name[Group1]="Swedish (US)";

    key <AD11> {[ any, any,  aring,      Aring      ]};
    key <AC10> {[ any, any,  odiaeresis, Odiaeresis ]};
    key <AC11> {[ any, any,  adiaeresis, Adiaeresis ]};

    include "level3(ralt_switch)"
};


// EXTRAS:

partial alphanumeric_keys
	xkb_symbols "sun_type6" {
	include "sun_vndr/se(sun_type6)"
};

partial alphanumeric_keys
xkb_symbols "dvorak_a5" {

	include "se(basic)"

	name[Group1]="Swedish (Dvorak A5)";

	key <AE12> {[ dead_acute, dead_grave, plusminus,           none ]};

	key <AD01> {[ aring,      Aring,      braceleft,           none ]};
	key <AD02> {[ adiaeresis, Adiaeresis, braceright,          none ]};
	key <AD03> {[ odiaeresis, Odiaeresis, bracketleft,         none ]};
	key <AD04> {[ p,          P,          bracketright,        none ]};
	key <AD05> {[ y,          Y,          dollar,              none ]};
	key <AD06> {[ f,          F,          quotedbl,            none ]};
	key <AD07> {[ g,          G,          question,            none ]};
	key <AD08> {[ c,          C,          ampersand,           none ]};
	key <AD09> {[ r,          R,          less,                none ]};
	key <AD10> {[ l,          L,          greater,             none ]};
	key <AD11> {[ comma,      semicolon,  dead_cedilla,        none ]};
	key <AD12> {[ dead_diaeresis, dead_circumflex, dead_tilde, asciicircum ]};

	key <AC01> {[ a,          A,          semicolon,           none ]};
	key <AC02> {[ o,          O,          slash,               none ]};
	key <AC03> {[ e,          E,          parenleft,           none ]};
	key <AC04> {[ u,          U,          parenright,          none ]};
	key <AC05> {[ i,          I,          bar,                 none ]};
	key <AC06> {[ d,          D,          numbersign,          none ]};
	key <AC07> {[ h,          H,          asciicircum,         none ]};
	key <AC08> {[ t,          T,          numbersign,          none ]};
	key <AC09> {[ n,          N,          quotedbl,            none ]};
	key <AC10> {[ s,          S,          asciitilde,          none ]};
	key <AC11> {[ minus,      underscore, grave,               none ]};

	key <AB01> {[ period,     colon,      colon,               none ]};
	key <AB02> {[ q,          Q,          equal,               none ]};
	key <AB03> {[ j,          J,          at,                  none ]};
	key <AB04> {[ k,          K,          exclam,              none ]};
	key <AB05> {[ x,          X,          backslash,           none ]};
	key <AB06> {[ b,          B,          percent,             none ]};
	key <AB07> {[ m,          M,          grave,               none ]};
	key <AB08> {[ w,          W,          lstroke,             none ]};
	key <AB09> {[ v,          V,          leftdoublequotemark, none ]};
	key <AB10> {[ z,          Z,          guillemotleft,       none ]};

	key <BKSL> {[ apostrophe, asterisk,   asterisk,            none ]};
};

partial alphanumeric_keys
xkb_symbols "ovd" {

    // Adds combining ogonek (U0328) to the basic Swedish layout to facilitate
    // typing of Ą ą Ę ę Į į Ų ų Y̨ y̨ Ą̊ ą̊.
    // The character replaces <dead_diaeresis> which is considered dispensable
    // since ä and ö have their own keys. <dead_diaeresis> is still available
    // via <AltGr> + Å.

    include "se(basic)"

    name[Group1]="Elfdalian (Sweden, with combining ogonek)";

    key <AD12> {[ U0328,  dead_circumflex,  dead_tilde,  dead_caron ]};
};

// us_dvorak
// Author Thomas Lundqvist http://tlundqvist.org/sv_dvorak/

partial alphanumeric_keys
xkb_symbols "us_dvorak" {
  include "us(dvorak-intl)"
  name[Group1]="Swedish (Dvorak, intl.)";

  key <TLDE> {[ apostrophe,  asciitilde,           grave,      dead_tilde ]};
  key <AE02> {[          2,    quotedbl,              at                  ]};
  key <AE06> {[          6, asciicircum, dead_circumflex                  ]};
  key <AD01> {[      aring,       Aring,      dead_acute                  ]};
  key <AC11> {[      minus,  underscore,             bar,     dead_macron ]};
  key <AB01> {[ adiaeresis,  Adiaeresis,      dead_grave,     dead_ogonek ]};
  key <LSGT> {[ odiaeresis,  Odiaeresis,  dead_diaeresis,   dead_belowdot ]};
  key <BKSL> {[  semicolon,       colon,       backslash                  ]};

  include "kpdl(comma)"
  include "level3(ralt_switch)"
};
