Create a custom setxkbmap option - linux

Oddly, this seems like it should be something that's been done before: I want to swap the numbers and symbols on the 1–0 keys across the top of my keyboard so that:
When I hit the 6 key, an * is typed instead of a 6.
When I hit Shift+6 the number 6 will display instead of an *.
There were several other modifications that I wanted to make, but quickly found that others had already accomplished these layout modifications before using options for setxkbmap (like caps:swapescape, for example).
Given the above, this is a 3-part question:
Is there an option for swapping numbers and symbols on the top row of my keyboard?
Whether there is or not, is there any way to find out if such a thing exists without having to manually browse the *.lst and *.xml files in /usr/share/X11/xkb/rules/?
Finally, if I were to create an option for setxkbmap, what would be an ideal approach, and how would I see about contributing my option back to the community?
As for question 3:
I have attempted to create the option without success (setxkbmap silently fails and I'm not even confident in my approach).
I can't find where the project is hosted.
Aside from man setxkbmap and various blog posts that touch on the topic, I've been unable to find any documentation on any of this.

Question 2:
For a list of all options available, you can execute localectl list-x11-keymap-options. This seems to only provide you with the options themselves, not the descriptions, so a better approach may be to execute the following on the XKB *.lst files:
for f in /usr/share/X11/xkb/rules/*.lst; do sed -ne '/^\! option$/{s///; :a' -e 'n;p;ba' -e '}' $f; done | sort -u
(sed reference)*
If you're looking for something related to swapping numbers, you can append | grep -i num, revealing several options for working with the numpad/keypad. Unfortunately, I think that all of the layouts have the numbers laid out in the templates related to alphanumeric characters, meaning they're built in to the regional layouts themselves (or the variant, in the case of dvorak).
Question 1:
There are three approaches that you can take.
Override layouts using xmodmap
You can create a somewhat versatile approach by creating an .Xmodmap file in your home to override mappings, as described on the Arch Wiki here.
Here is an example configuration: https://github.com/karma0/layouts/blob/master/home/.Xmodmap
Steps:
Drop .Xmodmap in your home.
Add the line xmodmap $HOME/.Xmodmap to your .profile
A quick and dirty, but flexible approach:
Run xkbcomp -xkb $DISPLAY xkbmap to generate a file xkbmap with your current configuration in it.
Modify it to match the desired configuration. Here's an example:
Original:
key <AE01> { [ 1, exclam ] };
key <AE02> { [ 2, at ] };
key <AE03> { [ 3, numbersign ] };
key <AE04> { [ 4, dollar ] };
key <AE05> { [ 5, percent ] };
key <AE06> { [ 6, asciicircum ] };
key <AE07> { [ 7, ampersand ] };
key <AE08> { [ 8, asterisk ] };
key <AE09> { [ 9, parenleft ] };
key <AE10> { [ 0, parenright ] };
Modified:
key <AE01> { [ exclam, 1 ] };
key <AE02> { [ at, 2 ] };
key <AE03> { [ numbersign, 3 ] };
key <AE04> { [ dollar,i 4 ] };
key <AE05> { [ percent, 5 ] };
key <AE06> { [ asciicircum, 6 ] };
key <AE07> { [ ampersand, 7 ] };
key <AE08> { [ asterisk, 8 ] };
key <AE09> { [ parenleft, 9 ] };
key <AE10> { [ parenright, 0 ] };
Execute the command xkbcomp -w 0 xkbmap $DISPLAY to load the new configuration.
Get the command to run at startup using xinitrc or similar.
Modify your layout and add a new variant
Open up your favorite layout file (likely under /usr/share/X11/xkb/symbols). We'll use the us file for this example.
Find your favorite variant within the file; workman-intl if you're like me.
Assuming you want to replicate the workman-intl layout, you can duplicate that section, and modify it similar to how I did here (note that this is copy/pasted from the intl template and the first and second columns are simply swapped):
partial alphanumeric_keys
xkb_symbols "workman-programmer" {
include "us(workman-intl)"
name[Group1]= "English (Workman, intl., with dead keys and num/sym swapped)";
key <AE01> { [ exclam, 1, exclamdown, onesuperior ] };
key <AE02> { [ at, 2, twosuperior, dead_doubleacute ] };
key <AE03> { [ numbersign, 3, threesuperior, dead_macron ] };
key <AE04> { [ dollar, 4, currency, sterling ] };
key <AE05> { [ percent, 5, EuroSign, dead_cedilla ] };
key <AE06> { [ dead_circumflex,6, onequarter, asciicircum ] };
key <AE07> { [ ampersand, 7, onehalf, dead_horn ] };
key <AE08> { [ asterisk, 8, threequarters, dead_ogonek ] };
key <AE09> { [ parenleft, 9, leftsinglequotemark, dead_breve ] };
key <AE10> { [ parenright, 0, rightsinglequotemark, dead_abovering ] };
};
The xkb_symbols line defines the name of your variation; the include line borrows everything you need from the variation of your choice within the file (here, it's the workman-intl variation in the us layout). Then, the definitions you want are what follows.
4. Add your new definition to /usr/share/xkb/rules/base.xml to the end of the variantList tag. Here's the one I used:
<variant>
<configItem>
<name>workman-programmer</name>
<description>English (Workman, intl., with dead keys and num/sym swapped)</description>
</configItem>
</variant>
Add the new variant and description to the ! variant section of /usr/share/X11/xkb/rules/base.lst as:
workman-programmer us: English (Workman, intl., with dead keys and num/sys swapped)'
Restart your Xorg server.
Setup the setxkbmap command to run using the new variant. Here's the one for this demonstration: setxkbmap -layout us -variant workman-programmer -option
Question 3:
Try as you might, you're not going to find the documentation until you start looking for xkb documentation, which is situated within the xorg ecosystem.
The best write-up out there is probably this one:
https://www.charvolant.org/doug/xkb/html/index.html
QUOTE:
Before you read this, please understand that I never wanted to write this document, being grossly under-qualified, but I always wanted to read it, and this was the only way.
Additionally, here are a list of links as well to get started on learning all of the intricacies of the xkb system in xorg: https://www.x.org/wiki/XKB/
Note: most of the documentation references relative paths within xkb as it is installed on your system. This is typically under /usr/share/X11/xkb
If you wish to contribute, this project lives under the xorg, which provides developer documentation here: https://www.x.org/wiki/guide/, or better, here: https://www.x.org/wiki/Development/

Related

Xkb custom shortcut

Added following instruction to /usr/share/X11/xkb/symbols/group :
// LControl + Space toggle
partial modifier_keys
xkb_symbols "lctrl_space_toggle" {
key <SPCE> {
type="PC_SUPER_LEVEL2",
symbols[Group1]= [ space, ISO_Next_Group ],
symbols[Group2]= [ space, ISO_Next_Group ]
};
key <LCTL> { [ Control_L, ISO_Next_Group ] };
};
after that added following to /usr/share/X11/xkb/rules/evdev.lst :
grp:lctrl_space_toggle Left Ctrl+Space
after that added following to /etc/default/keyboard :
XKBOPTIONS="grp:lctrl_space_toggle,grp_led:scroll"
as i press ctrl+space nothing happening, same as setxkbmap -option grp:lctrl_space_toggle, tell me please where am i wrong

Azure Search, mapping, merge collections

I have the following data :
From SELECT c.addresses[0] address, [ c.name ] filenames FROM c
[
{
"address": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855",
"filenames": [
"File 01.docx"
]
},
{
"address": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855",
"filenames": [
"File 02.docx"
]
},
{
"address": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855",
"filenames": [
"File 03.docx"
]
}, ....
The address field is the key, I have an index with a field defined as follows :
new Field()
{
Name = "filenames",
Type = DataType.Collection(DataType.String),
IsSearchable = true,
IsFilterable = true,
IsSortable = false,
IsFacetable = false
},
As you can see, I create an array for the filenames with [ c.name ] filenames.
When I index the data displayed above, the index contains one row in the filenames collection, that row is the last one that has been indexed. Can I make it add to the collection (merge) rather than replace?
I am also looking at solving this with the Query, but CosmosDB does not support a subselect (yet) and a UDF can only see the data that's passed into it.
Fundamentally, the way you have structured your Cosmos DB collection makes this scenario unworkable because Azure search does not support merging into a collection.
Consider changing your design to so that address is a key (that is, unique) in the collection, and all filenames are gathered in a single document per address:
{
"address": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855",
"filenames": [ "File 01.docx", "File 02.docx", "File 03.docx", ... ]
}
Also, please add a suggestion on Azure Search UserVoice site to add support for merging collections, which would make your scenario easier to achieve.

Xkb three key shortcut to acyclic switch keyboart layout like in Windows

The MS Windows introduced ability to switch current keyboard layout by press specific hotkey for each specific language.
I found very comfortable to have acyclic shortcuts to switch layout to target language with following shortcuts: Alt+Shift+1, Alt+Shift+2, Alt+Shift+3.
When i moved to Linux i run into problem with configure same shortcuts.
I tried to create custom ~/.config/xkb/my file with following content:
xkb_keymap {
xkb_keycodes { include "evdev+aliases(qwerty)" };
xkb_types { include "complete" };
xkb_compat {
include "complete"
interpret ISO_Second_Group {
action= LockGroup(group=2);
};
interpret ISO_Third_Group {
action= LockGroup(group=3);
};
};
xkb_symbols {
include "pc+us:1+ru:2:ua:3+inet(evdev)+group(ctrl_shift_toggle)"
key <AE01> { [ ISO_First_Group ] };
key <AE02> { [ ISO_Second_Group ] };
key <AE03> { [ ISO_Third_Group ] };
};
xkb_geometry { include "pc(pc104)" };
};
to future load via:
$xkbcomp ~/.config/xkb/my $DISPLAY
Howto properly define ALT and SHIFT modifiers?

sublime-hooks plugin - multiple commands on event hook

I use sublime-hooks plugin to run a sublime command on event hook. I usually use it to run only one command on event hook. I don't know how to run multiple commands on one event hook. I tried this, but it does not work.
CSS.sublime-settings
{
"on_pre_save_language": [
{
"command": [
"autoprefixer",
"css_comb"
]
}
]
}
According to the plugin docs given in the provided link:
Hooks are stored in the User, Project, or Language settings. Each of
these expects a list of dictionaries. Each of those dictionaries
satisfies the following:
command [...]
args [...]
scope [...]
views [...]
So don't make an array of commands but add an object (with command/args) to the array for every command:
{
"on_pre_save_language": [
{
"command": "autoprefixer"
},
{
"command": "css_comb"
}
]
}

Convert Heira variable to comma separated token

I have a yaml file where I can specify n number of options:
---
solr:
- dev
- test
I then call them into a puppet variable using heira:
if $solr_values == undef {
$solr_values = hiera('solr', false)
}
if count($solr_values) > 0 {
class { solr:
cores => [ $solr_values ],
}
}
However $solr_values is coming through as 'devtest' and not 'dev'. 'test' as I'd expect given that it's a list in yaml. Can someone advise on the best approach here?
The expression [ $solr_values ] gives you an array of arrays, e.g. [ [ 'dev', 'test', ... ] ], which is likely not what you want.
I suggest plain
cores => $solr_values,
Note that when you use the array variable $core/$solr_values in a string, e.g.
$debug = "VALUES: '$solr_values'"
Puppet will coerce the array into a string by simply concatenating the values, so you will still end up with 'devtest...'
What you want to do is make use of the join function from the stdlib module, e.g.
cores => join($solr_values, ','),

Resources