about summary refs log tree commit diff stats
path: root/src/command/cmd_ac.h
Commit message (Expand)AuthorAgeFilesLines
* Apply coding styleMichael Vetter2020-07-071-14/+14
* Revert "Apply coding style"Michael Vetter2020-07-071-15/+15
* Apply coding styleMichael Vetter2020-07-071-15/+15
* Add vim modelineMichael Vetter2019-11-131-0/+1
* Update copyright to include 2019Michael Vetter2019-01-221-1/+1
* Update copyrightJames Booth2018-01-211-1/+1
* Allow previous autocompletion with shift tabJames Booth2017-04-011-2/+2
* Update CopyrightJames Booth2017-01-281-1/+1
* Allow filepath autocompletion in pluginsJames Booth2016-10-101-0/+2
* Minor code tidy cmd_ac.hJames Booth2016-10-061-6/+3
* Make header defines consistentJames Booth2016-07-241-2/+2
* Update GPL link in headersJames Booth2016-07-241-1/+1
* Plugin unload remove cmd_acs and close windowJames Booth2016-07-051-0/+1
* Revert "WIP - Unload plugin commands"James Booth2016-06-301-1/+0
* WIP - Unload plugin commandsJames Booth2016-06-291-0/+1
* Fix command headersJames Booth2016-05-231-1/+6
* Rename command sourcesJames Booth2016-05-221-0/+57
ckground-color: #fff0f0 } /* Comment.Special */ .highlight .gd { color: #000000; background-color: #ffdddd } /* Generic.Deleted */ .highlight .ge { font-style: italic } /* Generic.Emph */ .highlight .ges { font-weight: bold; font-style: italic } /* Generic.EmphStrong */ .highlight .gr { color: #aa0000 } /* Generic.Error */ .highlight .gh { color: #333333 } /* Generic.Heading */ .highlight .gi { color: #000000; background-color: #ddffdd } /* Generic.Inserted */ .highlight .go { color: #888888 } /* Generic.Output */ .highlight .gp { color: #555555 } /* Generic.Prompt */ .highlight .gs { font-weight: bold } /* Generic.Strong */ .highlight .gu { color: #666666 } /* Generic.Subheading */ .highlight .gt { color: #aa0000 } /* Generic.Traceback */ .highlight .kc { color: #008800; font-weight: bold } /* Keyword.Constant */ .highlight .kd { color: #008800; font-weight: bold } /* Keyword.Declaration */ .highlight .kn { color: #008800; font-weight: bold } /* Keyword.Namespace */ .highlight .kp { color: #008800 } /* Keyword.Pseudo */ .highlight .kr { color: #008800; font-weight: bold } /* Keyword.Reserved */ .highlight .kt { color: #888888; font-weight: bold } /* Keyword.Type */ .highlight .m { color: #0000DD; font-weight: bold } /* Literal.Number */ .highlight .s { color: #dd2200; background-color: #fff0f0 } /* Literal.String */ .highlight .na { color: #336699 } /* Name.Attribute */ .highlight .nb { color: #003388 } /* Name.Builtin */ .highlight .nc { color: #bb0066; font-weight: bold } /* Name.Class */ .highlight .no { color: #003366; font-weight: bold } /* Name.Constant */ .highlight .nd { color: #555555 } /* Name.Decorator */ .highlight .ne { color: #bb0066; font-weight: bold } /* Name.Exception */ .highlight .nf { color: #0066bb; font-weight: bold } /* Name.Function */ .highlight .nl { color: #336699; font-style: italic } /* Name.Label */ .highlight .nn { color: #bb0066; font-weight: bold } /* Name.Namespace */ .highlight .py { color: #336699; font-weight: bold } /* Name.Property */ .highlight .nt { color: #bb0066; font-weight: bold } /* Name.Tag */ .highlight .nv { color: #336699 } /* Name.Variable */ .highlight .ow { color: #008800 } /* Operator.Word */ .highlight .w { color: #bbbbbb } /* Text.Whitespace */ .highlight .mb { color: #0000DD; font-weight: bold } /* Literal.Number.Bin */ .highlight .mf { color: #0000DD; font-weight: bold } /* Literal.Number.Float */ .highlight .mh { color: #0000DD; font-weight: bold } /* Literal.Number.Hex */ .highlight .mi { color: #0000DD; font-weight: bold } /* Literal.Number.Integer */ .highlight .mo { color: #0000DD; font-weight: bold } /* Literal.Number.Oct */ .highlight .sa { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Affix */ .highlight .sb { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Backtick */ .highlight .sc { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Char */ .highlight .dl { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Delimiter */ .highlight .sd { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Doc */ .highlight .s2 { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Double */ .highlight .se { color: #0044dd; background-color: #fff0f0 } /* Literal.String.Escape */ .highlight .sh { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Heredoc */ .highlight .si { color: #3333bb; background-color: #fff0f0 } /* Literal.String.Interpol */ .highlight .sx { color: #22bb22; background-color: #f0fff0 } /* Literal.String.Other */ .highlight .sr { color: #008800; background-color: #fff0ff } /* Literal.String.Regex */ .highlight .s1 { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Single */ .highlight .ss { color: #aa6600; background-color: #fff0f0 } /* Literal.String.Symbol */ .highlight .bp { color: #003388 } /* Name.Builtin.Pseudo */ .highlight .fm { color: #0066bb; font-weight: bold } /* Name.Function.Magic */ .highlight .vc { color: #336699 } /* Name.Variable.Class */ .highlight .vg { color: #dd7700 } /* Name.Variable.Global */ .highlight .vi { color: #3333bb } /* Name.Variable.Instance */ .highlight .vm { color: #336699 } /* Name.Variable.Magic */ .highlight .il { color: #0000DD; font-weight: bold } /* Literal.Number.Integer.Long */
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="en">
	<head>
		<title>Sway keysym</title>
		<link rel="stylesheet" href="/plain.css" />
		<link rel="shortcut icon" href="/favicon.ico" type="image/x-icon" />
		<meta charset="utf-8" />
	</head>
	<body>
		<h1>Sway keysym</h1>
		<p>Article ID: 21</p>
		<p>
		Under the <a href="https://swaywm.org/">Sway</a> Wayland compositor, we could set set <code>xkb_layout</code> and <code>xkb_options</code> for keyboards in order to do weird key mapping related things. Many people use <code>caps:ctrl_modifier</code> and <code>caps:escape</code> in <code>xkb_options</code> (see <a href="https://man.openbsd.org/xkeyboard-config">xkeyboard-config(7)</a> for other options) to make Caps Lock function as an extra Ctrl or Esc key.
		</p>
		<p>
		If all you want to do is do a relatively common modification like that, chances are that <code>xkb_variant</code> and <code>xkb_options</code> already has what you want, and you should just set that.
		</p>
		<hr />
		<p>
		But if what you want isn't covered in the standard XKB files, hear my story. I personally wanted Caps Lock to function as an additional Shift key, which isn't covered in <code>xkb_options</code>. (<code>caps:shift</code> doesn't differ much from normal Caps Lock, make it confusingly documented and doesn't make the Caps Lock function as an extra Shift.)
		</p>
		<p>
		On X11, I would simply use <code>xmodmap -e "keysym Caps_Lock = Shift_L"</code>. Now my Caps Lock functions as an extra Left Shift. Works just alright.
		</p>
		<p>
		But now that I switched to Wayland, Sway in particular, <code>xmodmap</code> for X11 isn't going to work. What I ended up doing was the following:
		</p>
		<p>
		<b><code>$HOME/.xkb/symbols/gbcustom</code></b>
		</p>
<pre>default partial alphanumeric_keys
xkb_symbols "basic" { // leave "basic" in-tact unless you know what you're doing
    include "gb" // or whatever base layout you use, most likely "us"
    name[Group1] = "English (UK) Customized";
    key &lt;CAPS&gt; { [ Shift_L, Shift_L, Shift_L, Shift_L ] };
};</pre>
		<p>
		Note that here, the ``<code>key</code>'' lines are in the form <code>key &lt;X&gt; { [ A, B, C, D ] } ;</code>, where ``<code>X</code>'' is the keycode symbolic name of the physical key you want to press. In my case, it is <code>CAPS</code>. Check <code>/usr/share/X11/xkb/symbols/pc</code> and <code>/usr/share/X11/xkb/symbols/latin</code>, or the relevant files for your keyboard configuration, to look up the keycode symbolic name from the name you're used to. (Looking up <code>Shift_L</code> in <code>symbols/pc</code> gets you to <code>LFSH</code>, which is what you would use in place of ``<code>X</code>''. <code>A</code> is triggered when <code>X</code> is pressed alone, <code>B</code> when it's pressd with Shift, <code>C</code> with AltGr, and <code>D</code> with both AltGr and Shift.
		</p>
		<p>
		<b><code>$HOME/.config/sway/config</code></b>
		</p>
<pre>input "1:1:AT_Translated_Set_2_keyboard" {
    xkb_layout "gbcustom"
}</pre>
		<p>
		Of course, replace ``<code>1:1:AT_Translated_Set_2_keyboard</code>'' with your actual keyboard identifier listed in <code>swaymsg -t get_inputs</code>. And reload Sway.
		</p>
		<p>
		There might be better ways to do so, but I've got this to work. For these unusual setups, it is a bit complicated and not as straightforward as adding a <code>xmondmap</code> line to <code>.xinitrc</code>. Hopefully things would get better as Wayland matures.
		</p>
		<p>
		<a href="https://github.com/swaywm/sway/issues/4250">This GitHub issue</a> and <a href="https://www.city17.xyz/keychron/#xkb-here-be-dragons">jman's article on this</a> were extremely helpful. Thanks to <a href="https://sr.ht/~brocellous">brocellous</a> for pointing out the solution involving custom options.
		</p>
		<hr />
		<p>
		Another, potentially better method involving defining custom <code>xkb_options</code>, propsed by brocellous:
		</p>
		<p>
		<b><code>$HOME/.xkb/symbols/customsymbol</code></b>
		</p>
<pre>// Remap caps to Shift_L
partial modifier_keys
xkb_symbols "caps_lshift" {
    replace key <CAPS> {
        type[group1] = "ONE_LEVEL",
        symbols[group1] = [ Shift_L ],
        actions[group1] = [ SetMods(modifiers=Shift) ]
    };
};</pre>
		<p>
		<b><code>$HOME/.xkb/rules/evdev</code></b>
		</p>
<pre>! option = symbols
  custom:caps_lshift = +customsymbol(caps_lshift)

! include %S/evdev</pre>
		<p>
		<b><code>$HOME/.config/sway/config</code></b>
		</p>
<pre>input "1:1:AT_Translated_Set_2_keyboard" {
    xkb_layout "gb"
    xkb_options "custom:caps_lshift"
}</pre>
		<div id="footer">
			<hr />
			<p><a href="/">Runxi Yu's Website</a></p>
		</div>
	</body>
</html>