Compare commits

..

35 Commits

Author SHA1 Message Date
Ben Reaves
1c51db9078 Merge pull request #41 from rbreaves/dev
- Added support for Fedora and rpm/dnf based distros
2020-02-21 15:25:13 -06:00
Ben Reaves
524fe93d1c - Added support for Fedora and rpm/dnf based distros 2020-02-21 15:22:15 -06:00
Ben Reaves
4bb6f89a22 Merge pull request #40 from rbreaves/dev
- Fixes mapping issue on Windows keyboards
2020-02-20 20:52:10 -06:00
Ben Reaves
3185bc068a - Fixes mapping issue on Windows keyboards 2020-02-20 20:36:04 -06:00
Ben Reaves
c2b8304991 Merge pull request #38 from rbreaves/dev
Updating the readme
2020-02-20 17:51:10 -06:00
Ben Reaves
03f4cd5bbe Update fixing the formatting in Readme 2020-02-20 17:48:19 -06:00
Ben Reaves
3b4e02525d - Updated Readme 2020-02-20 17:44:41 -06:00
Ben Reaves
b8b588e727 Updated Readme 2020-02-20 17:42:36 -06:00
Ben Reaves
f77610e6a1 - Updated Readme, includes detailed info on adding keymaps 2020-02-20 17:37:57 -06:00
Ben Reaves
7007cbefc5 - Updated readme with more info on the json config layout as it currently is. 2020-02-20 12:26:33 -06:00
Ben Reaves
2419511da4 - Updated readme and improved formatting of symbols for readability. 2020-02-19 22:12:29 -06:00
Ben Reaves
07f74e478b Merge pull request #37 from rbreaves/dev
Error fix related to mac_term
2020-02-19 16:19:28 -06:00
Ryan Reaves
b038d2a065 Merge branch 'master' into dev 2020-02-19 16:16:23 -06:00
Ryan Reaves
86a92cf836 - Updated mac_term file with proper labels to avoid error 2020-02-19 16:14:58 -06:00
Ben Reaves
38b4521023 Merge pull request #36 from rbreaves/dev
Wordwise selections
2020-02-19 16:07:53 -06:00
Ryan Reaves
2c7f20df63 - Added 5th level to mac gui for wordwise to work with shift for selections 2020-02-19 16:03:09 -06:00
Ryan Reaves
e014c2bc95 - Partially added Cmd+Shift+3/4 Printscreen shortcuts to mac_gui and mac_term 2020-02-19 14:06:02 -06:00
Ben Reaves
3e9b93dcad Merge pull request #35 from rbreaves/dev
- Corrected new Home and End remaps in terminal
2020-02-19 13:08:50 -06:00
Ryan Reaves
d8da8d3b31 - Corrected new Home and End remaps in terminal, accidentally mapped normal arrow keys incorrectly 2020-02-19 13:07:03 -06:00
Ben Reaves
ce99f4da23 Merge pull request #34 from rbreaves/dev
Added PgUp, PgDn, Home, and End to terminal Cmd+Arrow keys
2020-02-19 02:13:03 -06:00
Ben Reaves
5207428abd - Added PgUp, PgDn, Home, and End to terminal keymap on Cmd+Up/Dn/Left/Right 2020-02-19 02:08:46 -06:00
Ryan Reaves
b846b29ff1 - Updated script to report back true if there is no program to end or cleanup 2020-02-19 00:32:38 -06:00
Ryan Reaves
1a482e3c8c - Removed the removal of carets on service restarts, and mention of no carets file found. IBus is optional. 2020-02-18 23:50:45 -06:00
Ryan Reaves
1e0f7259c1 - Updated readme to include a better command to check the systemd log 2020-02-18 22:56:32 -06:00
Ryan Reaves
e6dbd5ea13 - Updated setup.py installer to set the IBus Input Method for the installer if it is not currently set as the default. 2020-02-18 21:20:01 -06:00
Ryan Reaves
6b0f3fc0dd - Updated readme with more troubleshooting tips 2020-02-18 20:24:05 -06:00
Ryan Reaves
c9bf5c1937 - cleanup script needs to be executable or an error will occur if the service has to be restarted for any reason. 2020-02-18 19:22:12 -06:00
Ryan Reaves
0f0c86af0f - Added support for standard version of Chrome for linux, not just Chromium 2020-02-18 19:02:45 -06:00
Ryan Reaves
ce937065c9 - Updated installer, some sort of regression on a copy .xkb directory fix.. Also updated readme 2020-02-18 18:57:44 -06:00
Ben Reaves
acf6bd9317 - Updated readme with credits to people who have contributor to this project over time 2020-02-18 17:30:57 -06:00
Ben Reaves
19d58a3a05 Merge branch 'dev' 2020-02-17 23:35:45 -06:00
Ben Reaves
cf8e78073a - Added Alt+Backspace = Delete key, particularly useful for chromebooks 2020-02-17 23:35:08 -06:00
Ben Reaves
86c5715853 Merge branch 'dev' 2020-02-17 22:01:18 -06:00
Ben Reaves
4e75cfb047 - Updated readme 2020-02-17 22:00:43 -06:00
Ben Reaves
159d2b63f0 - Removed and added comments 2020-02-17 20:52:49 -06:00
12 changed files with 623 additions and 89 deletions

View File

@@ -2,45 +2,125 @@ default partial xkb_symbols "mac_levelssym" {
// LEFT to Begin Line or Beginning of word
replace key <LEFT> {
type[Group1]= "ONE_LEVEL_CTRL",
symbols[Group1]= [ Left, Left, NoSymbol ],
actions[Group1]= [ NoAction(), RedirectKey(key=<LEFT>,modifiers=Control,clearmods=Mod1), RedirectKey(key=<HOME>,clearmods=Control)]
symbols[Group1]= [ Left, Left, NoSymbol,NoSymbol,Left ],
actions[Group1]= [
NoAction(),
RedirectKey(key=<LEFT>,modifiers=Control,clearmods=Mod1),
RedirectKey(key=<HOME>,clearmods=Control),
RedirectKey(key=<HOME>,modifiers=Shift,clearmods=Control+Mod1),
RedirectKey(key=<LEFT>,modifiers=Shift+Control,clearmods=Mod1)
]
};
// Right to End of Line or end of word
replace key <RGHT> {
type[Group1]= "ONE_LEVEL_CTRL",
symbols[Group1]= [ Right, Right, NoSymbol ],
actions[Group1]= [ NoAction(), RedirectKey(key=<RGHT>,modifiers=Control,clearmods=Mod1), RedirectKey(key=<END>,clearmods=Control)]
symbols[Group1]= [ Right, Right, NoSymbol, NoSymbol,Right ],
actions[Group1]= [
NoAction(),
RedirectKey(key=<RGHT>,modifiers=Control,clearmods=Mod1),
RedirectKey(key=<END>,clearmods=Control),
RedirectKey(key=<END>,modifiers=Shift,clearmods=Control+Mod1),
RedirectKey(key=<RGHT>,modifiers=Shift+Control,clearmods=Mod1)
]
};
// Up to Mac Home
replace key <UP> {
type[Group1]= "ONE_LEVEL_CTRL",
symbols[Group1]= [ Up, Up, NoSymbol ],
actions[Group1]= [ NoAction(), NoAction(), RedirectKey(key=<HOME>)]
symbols[Group1]= [
Up,
Up,
NoSymbol
],
actions[Group1]= [
NoAction(),
NoAction(),
RedirectKey(key=<HOME>)
]
};
// Down to Mac End
replace key <DOWN> {
type[Group1]= "ONE_LEVEL_CTRL",
symbols[Group1]= [ Down, Down, NoSymbol ],
actions[Group1]= [ NoAction(), NoAction(), RedirectKey(key=<END>)]
symbols[Group1]= [
Down,
Down,
NoSymbol
],
actions[Group1]= [
NoAction(),
NoAction(),
RedirectKey(key=<END>)
]
};
// CTRL BKSP to DELETE
// replace key <BKSP> {
// type[Group1]= "TWO_LEVEL_CTRL",
// symbols[Group1]= [ BackSpace, BackSpace, NoSymbol ],
// actions[Group1]= [ NoAction(), NoAction(), RedirectKey(key=<DELE>,clearmods=Control)]
// Alt BKSP to DELETE
replace key <BKSP> {
type[Group1]= "ONE_LEVEL_CTRL",
symbols[Group1]= [
BackSpace,
BackSpace,
NoSymbol
],
actions[Group1]= [
NoAction(),
RedirectKey(key=<DELE>,clearmods=Mod1),
NoAction()
]
};
// // Full Print Screen
// // GalliumOS
// replace key <AE03> {
// type[Group1]= "ONE_LEVEL_CTRL",
// symbols[Group1]= [ 3, 3, 3, F5 ],
// actions[Group1]= [ NoAction(), NoAction(), NoAction(), RedirectKey(key=<FK05>,clearmods=Shift) ]
// };
// // Region Print Screen
// // GalliumOS
// replace key <AE04> {
// type[Group1]= "ONE_LEVEL_CTRL",
// symbols[Group1]= [ 4, 4, 4, F5 ],
// actions[Group1]= [ NoAction(), NoAction(), NoAction(), RedirectKey(key=<FK05>) ]
// };
// // Full Print Screen
// // Standard Ubuntu
// replace key <AE03> {
// type[Group1]= "ONE_LEVEL_CTRL",
// symbols[Group1]= [ 3, 3, 3, F5 ],
// actions[Group1]= [ NoAction(), NoAction(), RedirectKey(key=<PRSC>,clearmods=Shift+Control) ]
// };
// // Region Print Screen
// // Standard Ubuntu
// replace key <AE04> {
// type[Group1]= "ONE_LEVEL_CTRL",
// symbols[Group1]= [ 4, 4, 4, F5 ],
// actions[Group1]= [ NoAction(), NoAction(), RedirectKey(key=<PRSC>,clearmods=Control) ]
// };
};
partial xkb_symbols "mac_chrome" {
// Back Button
replace key <LEFT> {
type[Group1]= "ONE_LEVEL_CTRL",
symbols[Group1]= [ Left, Left, Left ],
actions[Group1]= [ NoAction(), RedirectKey(key=<UP>), RedirectKey(key=<LEFT>,modifiers=Mod1,clearmods=Control)]
symbols[Group1]= [
Left,
Left,
Left
],
actions[Group1]= [
NoAction(),
RedirectKey(key=<UP>),
RedirectKey(key=<LEFT>,modifiers=Mod1,clearmods=Control)
]
};
// Forwards Button
replace key <RGHT> {
type[Group1]= "ONE_LEVEL_CTRL",
symbols[Group1]= [ Right, Right, Right ],
actions[Group1]= [ NoAction(), RedirectKey(key=<DOWN>), RedirectKey(key=<RGHT>,modifiers=Mod1,clearmods=Control)]
symbols[Group1]= [
Right,
Right,
Right
],
actions[Group1]= [
NoAction(),
RedirectKey(key=<DOWN>),
RedirectKey(key=<RGHT>,modifiers=Mod1,clearmods=Control)
]
};
};

View File

@@ -1,4 +1,4 @@
default partial xkb_symbols "mac_levelssym" {
default partial xkb_symbols "mac_apple" {
key <LWIN> {
repeat= no,
type= "ONE_LEVEL",
@@ -11,4 +11,105 @@ default partial xkb_symbols "mac_levelssym" {
symbols[Group1]= [ Hyper_R ],
actions[group1]=[ SetMods(modifiers=Shift+Control) ]
};
};
partial xkb_symbols "mac_win" {
key <LALT> {
repeat= no,
type= "ONE_LEVEL",
symbols[Group1]= [ Hyper_L ],
actions[group1]=[ SetMods(modifiers=Shift+Control) ]
};
key <RALT> {
repeat= no,
type= "ONE_LEVEL",
symbols[Group1]= [ Hyper_R ],
actions[group1]=[ SetMods(modifiers=Shift+Control) ]
};
};
partial xkb_symbols "mac_global" {
// Page Up
replace key <UP> {
type[Group1]= "ONE_LEVEL_CTRL",
symbols[Group1]= [
Up,
Up,
NoSymbol ],
actions[Group1]= [
NoAction(),
NoAction(),
RedirectKey(key=<PGUP>,clearmods=Shift+Control)
]
};
// Page Down
replace key <DOWN> {
type[Group1]= "ONE_LEVEL_CTRL",
symbols[Group1]= [
Down,
Down,
NoSymbol
],
actions[Group1]= [
NoAction(),
NoAction(),
RedirectKey(key=<PGDN>,clearmods=Shift+Control)
]
};
// HOME
replace key <LEFT> {
type[Group1]= "ONE_LEVEL_CTRL",
symbols[Group1]= [
Left,
Left,
NoSymbol
],
actions[Group1]= [
NoAction(),
NoAction(),
RedirectKey(key=<HOME>,clearmods=Shift+Control)
]
};
// END
replace key <RGHT> {
type[Group1]= "ONE_LEVEL_CTRL",
symbols[Group1]= [
Right,
Right,
NoSymbol
],
actions[Group1]= [
NoAction(),
NoAction(),
RedirectKey(key=<END>,clearmods=Shift+Control)
]
};
// Full Print Screen
// Standard Ubuntu
replace key <AE03> {
type[Group1]= "ONE_LEVEL_CTRL",
symbols[Group1]= [
3,
numbersign,
NoSymbol
],
actions[Group1]= [
NoAction(),
NoAction(),
RedirectKey(key=<PRSC>,clearmods=Shift+Control)
]
};
// Region Print Screen
// Standard Ubuntu
replace key <AE04> {
type[Group1]= "ONE_LEVEL_CTRL",
symbols[Group1]= [
4,
dollar,
NoSymbol
],
actions[Group1]= [
NoAction(),
NoAction(),
RedirectKey(key=<PRSC>,clearmods=Control)
]
};
};

View File

@@ -11,4 +11,90 @@ default partial xkb_symbols "mac_levelssym" {
symbols[Group1]= [ Hyper_R ],
actions[group1]=[ SetMods(modifiers=Shift+Control) ]
};
// Page Up
replace key <UP> {
type[Group1]= "ONE_LEVEL_CTRL",
symbols[Group1]= [
Up,
Up,
NoSymbol
],
actions[Group1]= [
NoAction(),
NoAction(),
RedirectKey(key=<PGUP>,clearmods=Shift+Control)
]
};
// Page Down
replace key <DOWN> {
type[Group1]= "ONE_LEVEL_CTRL",
symbols[Group1]= [
Down,
Down,
NoSymbol
],
actions[Group1]= [
NoAction(),
NoAction(),
RedirectKey(key=<PGDN>,clearmods=Shift+Control)
]
};
// HOME
replace key <LEFT> {
type[Group1]= "ONE_LEVEL_CTRL",
symbols[Group1]= [
Left,
Left,
NoSymbol
],
actions[Group1]= [
NoAction(),
NoAction(),
RedirectKey(key=<HOME>,clearmods=Shift+Control)
]
};
// END
replace key <RGHT> {
type[Group1]= "ONE_LEVEL_CTRL",
symbols[Group1]= [
Right,
Right,
NoSymbol
],
actions[Group1]= [
NoAction(),
NoAction(),
RedirectKey(key=<END>,clearmods=Shift+Control)
]
};
// Full Print Screen
// GalliumOS
replace key <AE03> {
type[Group1]= "ONE_LEVEL_CTRL",
symbols[Group1]= [
3,
numbersign,
F5
],
actions[Group1]= [
NoAction(),
NoAction(),
RedirectKey(key=<FK05>,clearmods=Shift)
]
};
// Region Print Screen
// GalliumOS
replace key <AE04> {
type[Group1]= "ONE_LEVEL_CTRL",
symbols[Group1]= [
4,
dollar,
F5
],
actions[Group1]= [
NoAction(),
NoAction(),
RedirectKey(key=<FK05>)
]
};
};

View File

@@ -1,11 +1,15 @@
default partial xkb_types "addmac_levels" {
type "ONE_LEVEL_CTRL" {
modifiers= Mod1+Control;
modifiers= Mod1+Control+Shift;
map[Mod1]= Level2;
map[Control]= Level3;
map[Mod1+Control]= Level3;
map[Shift+Control]= Level4;
map[Shift+Mod1] = Level5;
level_name[Level1]= "Base";
level_name[Level2]= "Alt";
level_name[Level3]= "With Control";
level_name[Level3]= "Control";
level_name[Level4]= "Shift with Control";
level_name[Level5] = "Shift Alt";
};
};

10
.xkb/types/mac_term Normal file
View File

@@ -0,0 +1,10 @@
default partial xkb_types "addmac_levels" {
type "ONE_LEVEL_CTRL" {
modifiers= Shift+Control;
map[Shift]= Level2;
map[Shift+Control]= Level3;
level_name[Level1]= "Base";
level_name[Level2]= "Alt";
level_name[Level3]= "With Control";
};
};

273
README.md
View File

@@ -8,14 +8,7 @@
\- Type in Linux like it's a Mac. \-
Cmd = Ctrl+Shift for all terminals.
Note: As of version 1.0 Kinto no longer maps Cmd/Alt to Super while using the Terminal, it is now mapping to Ctrl+Shift by default. Please reset your terminal's keymaps back to their defaults.
Gnome-terminal reset
```
dconf reset -f /org/gnome/terminal/legacy/keybindings/
```
Seamless copy and paste with all apps and terminals. Also the only linux remapper that is aware of your cursor/caret status - meaning it avoids shortcut conflicts within an app versus wordwise shortcuts when a text field is in use.
## What does this do exactly?
@@ -32,20 +25,16 @@ Kinto works for standard Windows, Apple and Chromebook keyboards. The following
- Python (initial install only)
- systemd
- x11
- IBus
- IBus*
- Debian/Ubuntu based distro 16.04+
If you need kintox11 recompiled for your distro please let me know and I will add a binary for your distro if my binary fails.
You can also attempt to compile kintox11.c on your system as well, but you will need to compile and install json-c first as its libraries will be required to compile and run the program.
IBUS is needed to support wordwise during browser app usage as the keymap will need to change slightly depending if the cursor/caret is on screen waiting for input. You may install ibus with the following.
*IBUS is needed to support wordwise during browser app usage as the keymap will need to change slightly depending if the cursor/caret is on screen waiting for input. Setup.py will set it but you can manually set it as well or check your current Input Method.
```
ibus-setup
```
And then navigate to your "Language Support" and set "Keyboard input method system:" to IBus for full word-wise support with web browsers.
To confirm navigate to your "Language Support" and set "Keyboard input method system:" to IBus for full word-wise support with web browsers.
Wayland support is planned, but not ready yet.
@@ -68,6 +57,180 @@ sudo apt install python3
./setup.py
```
## How to Add or Change keymaps for Applications
**First it is important to understand how Kinto operates.**
1. It listens for any focus/active window changes
2. It applies the proper keymap based on the programs name.
3. It may monitor your caret/cursor input status, if the app is known to cause shortcut conflicts with wordwise
4. It runs anywhere from 1 to 3 commands to fully remap your computer.
Ok great, we've covered the basics, now what are your options on modifying functionality?
It depends.
Do you want to remap keys using xkb or xbindkeys with xdotool, or something else entirely?
The choice is yours, but I'd recommend xbindkeys with xdotool for anyone that doesn't want to spend the time or learn xkb. I prefer xkb but it completely remaps your keyboard and it could break things if done poorly.
**How to Remap using XBindKeys with Xdotool - Firefox**
1. By default Firefox is mapped with the standard gui based xkb config, and only if no input has focus does it then run xbindkeys to map the Cmd+Left/Right arrow key location to the Back and Forwards functionality you'd expect.
2. The xbindkeys script takes into account the xkb mapping being the base because it is actually remapping Home and End to Back and Forwards as there is no real reason to reload an entire xkb layout.
~/.config/kinto/user_config.json
```
...
{
"name": "firefox",
"run": "setxkbmap -option;xkbcomp -w0 -I$HOME/.xkb ~/.xkb/keymap/kbd.mac.gui $DISPLAY",
"run_onInput": "killall xbindkeys > /dev/null 2>&1",
"run_offInput": "killall xbindkeys > /dev/null 2>&1;xbindkeys -f $HOME/.config/kinto/.firefox-nw",
"symbols": "",
"types": "",
"de": [
2
],
"appnames": [
"Firefox"
]
},
...
```
~/.config/kinto/.firefox-nw
```
"xdotool key --delay 0 --clearmodifiers Control_L+bracketleft"
// Alt/Cmd + Left
Home + Release
"xdotool key --delay 0 --clearmodifiers Control_L+bracketright"
// Alt/Cmd + Right
End + Release
# Note additional keymaps can easily be added to this file and I will accept any PR's with keymaps that align with macs
```
Once you have made your changes you can restart the Kinto service and the changes will take affect.
```
systemctl --user restart keyswap
```
Under normal circumstances this keymap would not have worked well had Firefox not included 2 keymap options for going forwards or back. In the next example, Chrome, you will see how to solve this very same problem but in xkb format and it is the only way to fix it for Chrome due to conflicting with wordwise shortcuts.
Also the choice of xdotool over something like xte (xautomation) was explicit, xdotool allows you to hold down a modifier and continue to repeat the action(s) and xte does not.
**How to Remap Using XKB - Chrome**
This gets to be a little more complicated, but this is what you have to do to accomplish the same on the xkb level.
**Summary**
1. Copy ~/.xkb/keymap/kbd.mac.gui and append the name of the app. (e.g. chrome)
2. Edit ~/.xkb/keymap/kbd.mac.gui.chrome
3. Add new keybindings to ~/.xkb/symbols/mac_gui
4. Only edit types if you absolutely need to add another modifier level (~/.xkb/types/mac_gui)
Understand that as you add or modify the ~/.xkb/symbols/ files that these two groups **symbols[Group1]** and **actions[Group1]** will be following the order of the modifier levels that are configured in the related ~/.xkb/types/mac_gui or mac_term file.
Also you will have to discover the proper xkb names for keys and that they will often follow *two different* labels/names. eg RGHT vs Right ... **replace key \<RGHT\>** vs **symbols[Group1]= [ Right, ...**.
A good place to get the proper names/labels are these two files.
```
/usr/share/X11/xkb/symbols/us
/usr/share/X11/xkb/symbols/inet
```
Ok, so here are the detailed instructions.
1. cp ~/.xkb/keymap/kbd.mac.gui ~/.xkb/keymap/kbd.mac.gui.chrome
2. nano ~/.xkb/keymap/kbd.mac.gui.chrome
```
# Change mac_gui(mac_levelssym)
...
xkb_symbols { include "pc+us+us:2+inet(evdev)+ctrl(swap_lwin_lctl)+ctrl(swap_rwin_rctl)+mac_gui(mac_levelssym)" };
...
# To +mac_gui(mac_chrome)
xkb_symbols { include "pc+us+us:2+inet(evdev)+ctrl(swap_lwin_lctl)+ctrl(swap_rwin_rctl)+mac_gui(mac_chrome)" };
...
};
```
3. Add your new "partial xkb_symbols" via nano ~/.xkb/symbols/mac_gui
```
partial xkb_symbols "mac_chrome" {
// Back Button
replace key <LEFT> {
type[Group1]= "ONE_LEVEL_CTRL",
symbols[Group1]= [
Left,
Left,
Left
],
actions[Group1]= [
NoAction(),
RedirectKey(key=<UP>),
RedirectKey(key=<LEFT>,modifiers=Mod1,clearmods=Control)
]
};
// Forwards Button
replace key <RGHT> {
type[Group1]= "ONE_LEVEL_CTRL",
symbols[Group1]= [
Right,
Right,
Right
],
actions[Group1]= [
NoAction(),
RedirectKey(key=<DOWN>),
RedirectKey(key=<RGHT>,modifiers=Mod1,clearmods=Control)
]
};
```
~/.config/kinto/user_config.json
```
{
"name": "chrome",
"run": "setxkbmap -option;xkbcomp -w0 -I$HOME/.xkb ~/.xkb/keymap/kbd.mac.gui.chrome $DISPLAY",
"run_onInput": "xkbcomp -w0 -I$HOME/.xkb ~/.xkb/keymap/kbd.mac.gui $DISPLAY",
"run_offInput": "xkbcomp -w0 -I$HOME/.xkb ~/.xkb/keymap/kbd.mac.gui.chrome $DISPLAY",
"symbols": "",
"types": "",
"de": [
2
],
"appnames": [
"Chromium",
"Chromium-browser",
"Google-chrome"
]
}
```
4. Not making changes to types but it looks like this. It contains 5 levels of modifiers, Base, Alt, Control, Shift+Control, and Shift+Alt. Additional Levels can and may be added later, but please do not change the order of the Levels or existing symbols files will break!! You can add new levels however without issue.
```
default partial xkb_types "addmac_levels" {
type "ONE_LEVEL_CTRL" {
modifiers= Mod1+Control+Shift;
map[Mod1]= Level2;
map[Control]= Level3;
map[Mod1+Control]= Level3;
map[Shift+Control]= Level4;
map[Shift+Mod1] = Level5;
level_name[Level1]= "Base";
level_name[Level2]= "Alt";
level_name[Level3]= "Control";
level_name[Level4]= "Shift with Control";
level_name[Level5] = "Shift Alt";
};
};
```
Once you have made your changes you can restart the Kinto service and the changes will take affect.
```
systemctl --user restart keyswap
```
## JSON config files
Features
@@ -79,20 +242,51 @@ Located at ~/.config/kinto/ you will find user_config.json which will look like
You can also add additional Desktop Environment related tweaks to user_config.json in the install directory as well and the installer will prompt you to install them. You may also fork and submit any json or additional .xkb configurations to me for approval if you believe it makes Linux more like typing on a Mac.
```
{"config":[{
{"config":[
//
// Each config category contains the category name, and references to the de tweaks
// And contains the default run commands plus what behavior they should exhibit for
// input fields on/off focus, if any.
// Symbols and types are not currently used - may later replace the need for static
// files with xkbcomp.
//
// If you use xbindkeys outside of Kinto then you may want to remove xbindkeys from
// this config after setup or rewrite the command to exclude your own xbindkeys.
//
{
"name":"gui",
"run":"setxkbmap -option;xkbcomp -w0 -I$HOME/.xkb ~/.xkb/keymap/kbd.mac.gui $DISPLAY",
"de":[2],
"appnames":[ "" ],
"run_onInput":"",
"run_offInput": "killall xbindkeys > /dev/null 2>&1",
"symbols":"",
"types":"",
"de":[],
"appnames":[ "" ]
},
{
"name":"term",
"run":"setxkbmap -option;xkbcomp -w0 -I$HOME/.xkb ~/.xkb/keymap/kbd.mac.term $DISPLAY",
"de":[2],
"appnames":[ "Gnome-terminal","konsole","io.elementary.terminal","terminator","sakura","guake","tilda","xterm","eterm" ]
"appnames":[ "Gnome-terminal","konsole","io.elementary.terminal","terminator","sakura","guake","tilda","xterm","eterm" ],
"run_onInput":"",
"run_offInput": "killall xbindkeys > /dev/null 2>&1",
"symbols":"",
"types":"",
"de":[],
"appnames":[ "" ]
}],
// Init - Array that references de objects by their ID and runs the "run" command
// when the app initially runs.
"init": [1],
// detypes - DE's with support or planned support
"detypes":["gnome2","gnome3","kde4","kde5","xfce","i3wm"],
// de - tweak objects and initial command to be ran on start.
//
// Intent - init or gui_term, to signify what type of tweak it is.
// run, run_term, run_gui - run is only relevant for init, and the
// other two relate to gui_term and running under those modes.
"de":[{
"id": 1,
"type": ["gnome3"],
@@ -138,9 +332,9 @@ Status
systemctl --user status keyswap
```
Stop (and reset keyboard to normal)
Stop (your keymap will return to normal)
```
systemctl --user stop keyswap && setxkbmap -option
systemctl --user stop keyswap
```
Start
@@ -182,10 +376,28 @@ systemctl --user status keyswap
```
2. Check the service journal
```
journalctl -xe
journalctl --user-unit=keyswap.service -b
```
Open a ticket and send me the info.
You may need to manually set your DISPLAY in the systemd service file. Normally it pulls in the proper DISPLAY value but if it doesn't you can try this.
```
echo $DISPLAY
# :0.0
```
nano ~/.config/systemd/user/keyswap.service
```
...
[Service]
Type=simple
Restart=always
Environment=DISPLAY=:0.0
...
```
If you continue to have issues then open a ticket and send me the info.
### Keyswap is not occurring, but it was working.
@@ -231,3 +443,22 @@ https://medium.com/@benreaves/kinto-a-mac-inspired-keyboard-mapping-for-linux-58
## License
GPL v2
## Credits and Contributions
I would just like to thank a few people here directly that have helped me tremendously with completing this project and without their support, direct, indirect or otherwise I would have had difficulty completing this undertaking. I will list these things off in chronological order mostly.
First off I'd like to thank the Stackoverflow and Stackexchange community. I have probably rubbed some mods the wrong way over there, but the people from the community in general are extremely helpful and gracious and without their contributions would have made this much more difficult. The person I'd like to thank most though from over there is Glen Whitney. Without his detailed explaining of how to rebind keys in xkb this would not have come together at all, as every other remapping solution were non-starters as complexity increases.
Secondarily I'd like to thank Christian Eriksson*, as he provided information that kept me up at night.. literally. Even after I implemented a similar bash script to one he had suggested I knew that fully implementing a c/c++ solution was where Kinto needed to head to and his explaination was better than I remember it being now that I have gone back to read it again. He also never provided a full implementation of a c/c++ solution - he did hit on the pain points pretty well of what one would need to do and watch out for. I am not sure where I got the first example code of implementing a based solution, but he definitely went over it well.
Kui and his gist file** was really the c based solution that I found had the fewest issues to resolve to making it a reliable solution. It didn't account for all failures very well, aka BadWindow issues, but it made for a great foundation on which Kintox11 is built. I cannot thank him enough for putting it out there for others to work with.
Lastly these four people were also very helpful to me as well. @probonopd for being one of the first people to install and use Kinto and gave me the initial feedback to include wordwise support! He also has really great articles*** posted on HackerNews & Medium about UI/UX design. Another person I'd like to thank is @owzim, his feedback allowed me to rapidly iterate and fix several bugs to support additional platforms better. The last two are members of the #ubuntu channel in IRC on freenode, tarzeau ( @alexmyczko ) and sarnold. Alex contributing a proper Makefile, so the project can be packaged properly, and sarnold help me find that IBus could resolve an issue I was having with needing to detect the caret status.
If I left anyone out then I apologize, that was not intentional. I am happy to say that this project is at a state of completion. Bug fixes will primarily be the only activity happening going forward and possibly a rewrite for Wayland at some point. Contributions as mentioned above are welcomed, and will be merged into master if they help with the goal of making typing on linux more like a mac.
*https://askubuntu.com/questions/1010276/can-i-act-on-the-event-that-a-window-opens-without-polling
**https://gist.github.com/kui/2622504
***https://medium.com/@probonopd/make-it-simple-linux-desktop-usability-part-1-5fa0fb369b42

View File

@@ -12,9 +12,9 @@
"gui":"setxkbmap -option;xkbcomp -w0 -I$HOME/.xkb ~/.xkb/keymap/kbd.mac.gui $DISPLAY",
"term":"setxkbmap -option;xkbcomp -w0 -I$HOME/.xkb ~/.xkb/keymap/kbd.mac.term $DISPLAY",
"xkb_symbols_gui":"+altwin(ctrl_alt_win)+mac_gui(mac_levelssym)",
"xkb_symbols_term":"+altwin(swap_alt_win)+mac_term(mac_levelssym)",
"xkb_symbols_term":"+altwin(swap_alt_win)+mac_term(mac_win)+mac_term(mac_global)",
"xkb_types_gui":"+mac_gui(addmac_levels)",
"xkb_types_term":""
"xkb_types_term":"+mac_term(addmac_levels)"
},
{
"id": 2,
@@ -25,9 +25,9 @@
"gui":"setxkbmap -option;xkbcomp -w0 -I$HOME/.xkb ~/.xkb/keymap/kbd.mac.gui $DISPLAY",
"term":"setxkbmap -option;xkbcomp -w0 -I$HOME/.xkb ~/.xkb/keymap/kbd.mac.term $DISPLAY",
"xkb_symbols_gui":"+altwin(ctrl_alt_win)+mac_gui(mac_levelssym)",
"xkb_symbols_term":"+altwin(swap_alt_win)+mac_term(mac_levelssym)",
"xkb_symbols_term":"+altwin(swap_alt_win)+mac_term(mac_win)+mac_term(mac_global)",
"xkb_types_gui":"+mac_gui(addmac_levels)",
"xkb_types_term":"",
"xkb_types_term":"+mac_term(addmac_levels)",
"hack": "echo '1' | sudo tee -a /sys/module/hid_apple/parameters/swap_opt_cmd;echo 'options hid_apple swap_opt_cmd=1' | sudo tee -a /etc/modprobe.d/hid_apple.conf;sudo update-initramfs -u -k all"
},
{
@@ -39,9 +39,9 @@
"gui":"setxkbmap -option;xkbcomp -w0 -I$HOME/.xkb ~/.xkb/keymap/kbd.mac.gui $DISPLAY",
"term":"setxkbmap -option;xkbcomp -w0 -I$HOME/.xkb ~/.xkb/keymap/kbd.mac.term $DISPLAY",
"xkb_symbols_gui":"+ctrl(swap_lwin_lctl)+ctrl(swap_rwin_rctl)+mac_gui(mac_levelssym)",
"xkb_symbols_term":"+altwin(alt_super_win)+mac_term(mac_levelssym)",
"xkb_symbols_term":"+altwin(alt_super_win)+mac_term(mac_apple)+mac_term(mac_global)",
"xkb_types_gui":"+mac_gui(addmac_levels)",
"xkb_types_term":""
"xkb_types_term":"+mac_term(addmac_levels)"
},
{
"id": 4,
@@ -54,7 +54,7 @@
"xkb_symbols_gui":"+chromebook(swap_lalt_lctrl)+mac_gui(mac_levelssym)",
"xkb_symbols_term":"+altwin(swap_alt_win)+mac_term_chromebook(mac_levelssym)",
"xkb_types_gui":"+mac_gui(addmac_levels)",
"xkb_types_term":""
"xkb_types_term":"+mac_term(addmac_levels)"
},
{
"id": 5,
@@ -68,7 +68,7 @@
"xkb_symbols_gui":"+chromebook(swap_lalt_lctrl)+mac_gui(mac_levelssym)",
"xkb_symbols_term":"+altwin(swap_alt_win)+mac_term_chromebook(mac_levelssym)",
"xkb_types_gui":"+mac_gui(addmac_levels)",
"xkb_types_term":""
"xkb_types_term":"+mac_term(addmac_levels)"
},
{
"id": 6,
@@ -81,6 +81,6 @@
"xkb_symbols_gui":"+chromebook(swap_lalt_lctrl)+mac_gui(mac_levelssym)",
"xkb_symbols_term":"+altwin(swap_alt_win)+mac_term_chromebook(mac_levelssym)",
"xkb_types_gui":"+mac_gui(addmac_levels)",
"xkb_types_term":""
"xkb_types_term":"+mac_term(addmac_levels)"
}]
}

View File

@@ -47,32 +47,19 @@ static int wait_fd(int fd, double seconds)
int XNextEventTimeout(Display *d, XEvent *e, double seconds, long long event_ts, int last_event, long long *event_ts_ptr, int *last_event_ptr)
{
if (XPending(d) || wait_fd(ConnectionNumber(d),seconds)) {
// XNextEvent(d, e);
// while (1) {
// XNextEvent(d, e);
// if(e->type != 16){
// printf("Inside XNextEvent timeout\n");
// break;
// }
// }
while (1) {
XNextEvent(d, e);
long long int new_ts = timeInMilliseconds();
// Make sure window dragging or resizing is not occuring
if(!(e->type == 22 && (e->type == last_event) && timeInMilliseconds()-event_ts < 419)){
// printf("%d == %d\n",e->type, last_event);
// printf("Timestamp: %lld\n",timeInMilliseconds()-event_ts);
*event_ts_ptr = new_ts;
*last_event_ptr = e->type;
// printf("in event_ts_ptr: %lld\n",*event_ts_ptr);
// printf("in last_event_ptr: %d\n",*last_event_ptr);
break;
}
*event_ts_ptr = new_ts;
*last_event_ptr = e->type;
// printf("event_ts_ptr: %lld\n",*event_ts_ptr);
// printf("last_event_ptr: %d\n",*last_event_ptr);
}
return 0;
} else {
@@ -123,7 +110,7 @@ int check_caret()
return 0;
}
else{
printf("file %s does not exist\n",fpname);
// printf("file %s does not exist\n",fpname);
return 0;
}
}
@@ -541,15 +528,12 @@ int main(void){
system(run_offInput);
ran_onInput = 0;
}
// e.type = Expose;
// e.xexpose.count = 0;
}
}
else{
// XNextEvent(d, &e);
while (1) {
XNextEvent(d, &e);
// Make sure window dragging or resizing is not occuring
if(!(e.type == 22 && (e.type == last_event) && timeInMilliseconds()-event_ts < 300)){
// printf("%d == %d\n",e.type, last_event);
// printf("Timestamp: %lld\n",timeInMilliseconds()-event_ts);

View File

@@ -1,5 +1,5 @@
#!/usr/bin/env python3
import json, time, os
import json, time, os, sys
from shutil import copyfile
from subprocess import PIPE, Popen
from prekinto import *
@@ -15,16 +15,40 @@ def cmdline(command):
)
return process.communicate()[0]
def requirements():
def requirements(pkgm):
print(bcolors.CYELLOW + "You need to install some packages, " +run_pkg+ ", for Kinto to fully remap browsers during input focus.\n" + bcolors.ENDC)
print("sudo apt-get install -y " + run_pkg + "\n")
run_install = yn_choice(bcolors.CYELLOW + "Would you like to run it now? (Will require sudo privileges.)\n" + bcolors.ENDC)
if(run_install):
os.system("sudo apt-get install -y " + run_pkg)
os.system("sudo " + pkgm + " install -y " + run_pkg)
print("\n")
check_xbind = symbols_gui_line = cmdline("which xbindkeys").strip()
check_xdotool = symbols_gui_line = cmdline("which xdotool").strip()
def install_ibus():
print(bcolors.CYELLOW + "You need to set IBus as the default Input Method for full word-wise support and re-run this installer.\n" + bcolors.ENDC)
print("im-config -n ibus\n")
run_install = yn_choice(bcolors.CYELLOW + "Would you like to run it now? (Will require logoff and logon.)\n" + bcolors.ENDC)
if(run_install):
os.system("im-config -n ibus")
print("\n")
input("IBus has been set as the default Input Method.\nPress any key to exit and re-run after logoff & logon...")
sys.exit()
check_x11 = cmdline("env | grep -i x11").strip()
if len(check_x11) == 0:
print("You are not using x11, please logout and back in using x11/Xorg")
sys.exit()
check_xbind = cmdline("which xbindkeys 2>/dev/null").strip()
check_xdotool = cmdline("which xdotool 2>/dev/null").strip()
pkgm = cmdline("which apt 2>/dev/null").strip()
if len(pkgm) == 0:
pkgm = cmdline("which dnf 2>/dev/null").strip()
if len(pkgm) == 0:
print("No supported package manager found. Exiting...")
sys.exit()
runpkg = 0
run_pkg = ""
@@ -39,7 +63,19 @@ if len(check_xdotool) == 0:
runpkg = 1
if runpkg != 0:
requirements()
requirements(pkgm)
if os.path.exists(homedir + '/.config/ibus/bus') and cmdline("ls ~/.config/ibus/bus -1rt") == "":
install_ibus()
try:
f = open("defaults.json")
except IOError:
print("defaults.json file is missing. Will exit.\n")
exit()
f.close()
try:
f = open("defaults.json")
@@ -116,7 +152,7 @@ if 'hack' in keyboardconfigs[defaultkb-1]:
os.system(keyboardconfigs[defaultkb-1]['hack'])
# Setup the selected keyboards config
os.system("cp -rf ./.xkb ~/.xkb/")
os.system("cp -TRv ./.xkb ~/.xkb/")
if os.path.isdir(homedir + "/.xkb/keymap") == False:
os.mkdir(homedir + "/.xkb/keymap")
time.sleep(0.5)
@@ -127,18 +163,18 @@ os.system('setxkbmap -print > ~/.xkb/keymap/kbd.mac.gui.chrome')
os.system('setxkbmap -print > ~/.xkb/keymap/kbd.mac.term')
time.sleep(0.5)
symbols_gui_line = cmdline("cat ~/.xkb/keymap/kbd.mac.gui | grep -n 'xkb_symbols' | cut -f1 -d:").strip()
types_gui_line = cmdline("cat ~/.xkb/keymap/kbd.mac.gui | grep -n 'xkb_types' | cut -f1 -d:").strip()
symbols_term_line = cmdline("cat ~/.xkb/keymap/kbd.mac.term | grep -n 'xkb_symbols' | cut -f1 -d:").strip()
symbols_line = cmdline("cat ~/.xkb/keymap/kbd.mac.gui | grep -n 'xkb_symbols' | cut -f1 -d:").strip()
types_line = cmdline("cat ~/.xkb/keymap/kbd.mac.gui | grep -n 'xkb_types' | cut -f1 -d:").strip()
cmdline('sed -i '' -e "' + symbols_gui_line + 's/\\"/' + keyboardconfigs[defaultkb-1]['xkb_symbols_gui'] + '\\"/2" ~/.xkb/keymap/kbd.mac.gui')
cmdline('sed -i '' -e "' + types_gui_line + 's/\\"/' + keyboardconfigs[defaultkb-1]['xkb_types_gui'] + '\\"/2" ~/.xkb/keymap/kbd.mac.gui')
cmdline('sed -i '' -e "' + symbols_term_line + 's/\\"/' + keyboardconfigs[defaultkb-1]['xkb_symbols_term'] + '\\"/2" ~/.xkb/keymap/kbd.mac.term')
cmdline('sed -i '' -e "' + symbols_line + 's/\\"/' + keyboardconfigs[defaultkb-1]['xkb_symbols_gui'] + '\\"/2" ~/.xkb/keymap/kbd.mac.gui')
cmdline('sed -i '' -e "' + types_line + 's/\\"/' + keyboardconfigs[defaultkb-1]['xkb_types_gui'] + '\\"/2" ~/.xkb/keymap/kbd.mac.gui')
cmdline('sed -i '' -e "' + symbols_line + 's/\\"/' + keyboardconfigs[defaultkb-1]['xkb_symbols_term'] + '\\"/2" ~/.xkb/keymap/kbd.mac.term')
cmdline('sed -i '' -e "' + types_line + 's/\\"/' + keyboardconfigs[defaultkb-1]['xkb_types_term'] + '\\"/2" ~/.xkb/keymap/kbd.mac.term')
cmdline('sed -i '' -e "' + symbols_gui_line + 's/\\"/' + keyboardconfigs[defaultkb-1]['xkb_symbols_gui'].replace("+mac_gui(mac_levelssym)","") + '\\"/2" ~/.xkb/keymap/kbd.mac.gui.nw')
cmdline('sed -i '' -e "' + symbols_gui_line + 's/\\"/' + keyboardconfigs[defaultkb-1]['xkb_symbols_gui'].replace("+mac_gui(mac_levelssym)","+mac_gui(mac_chrome)") + '\\"/2" ~/.xkb/keymap/kbd.mac.gui.chrome')
cmdline('sed -i '' -e "' + types_gui_line + 's/\\"/' + keyboardconfigs[defaultkb-1]['xkb_types_gui'] + '\\"/2" ~/.xkb/keymap/kbd.mac.gui.nw')
cmdline('sed -i '' -e "' + types_gui_line + 's/\\"/' + keyboardconfigs[defaultkb-1]['xkb_types_gui'] + '\\"/2" ~/.xkb/keymap/kbd.mac.gui.chrome')
cmdline('sed -i '' -e "' + symbols_line + 's/\\"/' + keyboardconfigs[defaultkb-1]['xkb_symbols_gui'].replace("+mac_gui(mac_levelssym)","") + '\\"/2" ~/.xkb/keymap/kbd.mac.gui.nw')
cmdline('sed -i '' -e "' + symbols_line + 's/\\"/' + keyboardconfigs[defaultkb-1]['xkb_symbols_gui'].replace("+mac_gui(mac_levelssym)","+mac_gui(mac_chrome)") + '\\"/2" ~/.xkb/keymap/kbd.mac.gui.chrome')
cmdline('sed -i '' -e "' + types_line + 's/\\"/' + keyboardconfigs[defaultkb-1]['xkb_types_gui'] + '\\"/2" ~/.xkb/keymap/kbd.mac.gui.nw')
cmdline('sed -i '' -e "' + types_line + 's/\\"/' + keyboardconfigs[defaultkb-1]['xkb_types_gui'] + '\\"/2" ~/.xkb/keymap/kbd.mac.gui.chrome')
user_file = homedir + '/.config/kinto/user_config.json'

5
system-config/cleanup.sh Normal file → Executable file
View File

@@ -1,5 +1,6 @@
#!/bin/bash
setxkbmap -option
killall xbindkeys > /dev/null 2>&1
rm /tmp/kinto/caret
# force command to run silently and report true
killall xbindkeys > /dev/null 2>&1 || :
# rm /tmp/kinto/caret

View File

@@ -5,6 +5,7 @@ PartOf=graphical-session.target
[Service]
Type=simple
Restart=always
#Environment=DISPLAY=:0.0
RestartSec=1
WorkingDirectory=/home/{username}/.config/kinto
ExecStart=/bin/bash -c "/home/{username}/.config/kinto/xactive.sh carrots"

View File

@@ -36,7 +36,7 @@
"symbols": "",
"types": "",
"de": [],
"appnames": [ "Chromium","Chromium-browser" ]
"appnames": [ "Chromium","Chromium-browser","Google-chrome" ]
}],
"init": [],
"detypes":["gnome2","gnome3","kde4","kde5","xfce","i3wm"],