Compare commits

...

34 Commits

Author SHA1 Message Date
Ben Reaves
58da4fcd90 Merge branch 'master' into dev 2020-02-05 16:06:41 -06:00
Ben Reaves
20170f0a7d - Removed the explicit reference to bin bash in the service file, also removed the Environment variable to avoid issues for when Display is not 0. 2020-02-05 16:05:41 -06:00
Ben Reaves
d90829928b Merge pull request #27 from rbreaves/dev
Fixes tweak selection during install
2020-02-05 21:35:03 +00:00
Ben Reaves
6f913538e8 - Fixed tweak selection in python installer 2020-02-05 15:33:51 -06:00
Ben Reaves
7dfbe884ff - Added medium article in readme 2020-02-05 14:11:13 -06:00
Ben Reaves
3a115f91ae Merge branch 'dev' 2020-02-05 14:06:57 -06:00
Ben Reaves
4c218b55bd - Updated uninstaller to remove kinto.desktop from startup 2020-02-05 14:06:37 -06:00
Ben Reaves
94cd3ed907 Merge pull request #26 from rbreaves/dev
Kintox11 binary will now always apply gui keymap on init unless a term app has focus
2020-02-05 19:56:20 +00:00
Ben Reaves
b0bde4fecf Merge branch 'master' into dev 2020-02-05 13:54:20 -06:00
Ben Reaves
b930b96066 - Fixed kintox11 to always apply gui keymap on initialization unless a term app has focus. (aka boot and user logoff/logon) 2020-02-05 13:52:25 -06:00
Ben Reaves
2df4920344 Merge pull request #25 from rbreaves/dev
- Corrected path of systemctl for desktop autostart file
2020-02-05 19:17:40 +00:00
Ben Reaves
ce9c80a02f - Corrected path of systemctl for desktop autostart file 2020-02-05 13:17:13 -06:00
Ben Reaves
e599562ec1 Merge pull request #24 from rbreaves/dev
- Added desktop startup of kinto service
2020-02-05 11:28:15 +00:00
Ben Reaves
b8b81bd907 - Added desktop startup of kinto service 2020-02-05 05:24:40 -06:00
Ben Reaves
22e5462fbc Merge pull request #23 from rbreaves/dev
Updated service
2020-02-05 10:22:55 +00:00
Ben Reaves
72d2007267 - Added restartsec interval on service to 1 second to try and avoid burst limit of systemd 2020-02-05 04:19:44 -06:00
Ben Reaves
3c5b49324c - Removed the creation of the autostart folder 2020-02-05 04:09:20 -06:00
Ben Reaves
3f37ef6e28 - Added back in the enable command for the keyswap service. 2020-02-05 04:01:17 -06:00
Ben Reaves
35cfcce748 Merge pull request #22 from rbreaves/dev
Updated kintox11 binary with better error handling
2020-02-05 09:20:05 +00:00
Ben Reaves
d288048ed4 - Due to updates in kintox11 error handling the services timer is no longer needed, the application will restart properly if it encounters an unrecoverable error on boot, login or any other unexpected event. 2020-02-05 03:01:22 -06:00
Ben Reaves
a30671b08c - Enabled full error handling 2020-02-05 02:47:53 -06:00
Ben Reaves
2f2afecb6d - Added more verbosity to kintox11 and added more functions to increase accuracy of the keyswap on all windows 2020-02-05 02:41:47 -06:00
Ben Reaves
072249d5d4 - Corrected chromebook config file and updated the initialization of the keyswap service file to work when re-running the installer on a currently running version of kinto 2020-02-05 00:12:44 -06:00
Ben Reaves
a6b9b1ffbb Merge pull request #21 from rbreaves/dev
- Fixes login/logout and reboot startup issues
2020-02-05 01:48:19 +00:00
Ben Reaves
d8c516c13c - Fixes login/logout and reboot startup issues, delays the start by 5 seconds 2020-02-04 19:45:39 -06:00
Ben Reaves
b763703d70 Merge pull request #19 from rbreaves/dev
App breaking bug resolved and improved initialization on boot
2020-02-04 22:02:38 +00:00
Ben Reaves
ecaf413fa4 - Removed 5 second restart delay, I think the new changes makes it irrelevant 2020-02-04 15:58:09 -06:00
Ben Reaves
48e01750e5 - Fixed breaking bug exception on how gui apps are initially handled. Also improved the initialization of kintox11. 2020-02-04 15:36:26 -06:00
Ben Reaves
5ec8c076a3 - Added more verbosity to the dynamic app output 2020-02-04 14:48:40 -06:00
Ben Reaves
c620b299bd - Added a more verbose initial startup to kintox11 for easier debugging purposes 2020-02-04 14:41:55 -06:00
Ben Reaves
496cb4d340 - Added O2 optimization to kintox11 binary 2020-02-03 22:52:19 -06:00
Ben Reaves
5f1e82fb24 - Fixed bug that prevented the new keymap from working under Chromebooks with Linux/GalliumOS 2020-02-03 16:27:59 -06:00
Ben Reaves
46e81640c6 - Updated readme again, keeping it shorter 2020-02-03 14:25:22 -06:00
Ben Reaves
1c56c98ab9 - Updated readme to properly link to releases and provide more info 2020-02-03 13:23:51 -06:00
12 changed files with 142 additions and 44 deletions

1
.gitignore vendored
View File

@@ -1,2 +1,3 @@
.env/
.DS_Store
__pycache__/

View File

@@ -0,0 +1,14 @@
default partial xkb_symbols "mac_levelssym" {
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) ]
};
};

View File

@@ -2,15 +2,13 @@
![alt text](https://raw.githubusercontent.com/rbreaves/kinto/master/Kinto.png)
[![GitHub release](https://img.shields.io/github/release/rbreaves/kinto.svg)](https://github.com/rbreaves/kinto/releases)
[![GitHub release](https://img.shields.io/github/release/rbreaves/kinto.svg)](https://github.com/rbreaves/kinto/releases/latest)
![alt text](https://github.com/rbreaves/kinto/blob/master/splash.png)
\- Type in Linux like it's a Mac. \-
Memory muscle matters for programmers and developers.
If it happens on your mac keyboard then it should happen the same in linux.
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.
@@ -196,6 +194,7 @@ https://superuser.com/questions/385748/binding-superc-superv-to-copy-and-paste
## More information about Kinto
https://medium.com/@benreaves/kinto-v1-0-released-2018e6401d2e
https://medium.com/@benreaves/kinto-a-mac-inspired-keyboard-mapping-for-linux-58f731817c0
## License

View File

@@ -49,10 +49,10 @@
"type":"chromebook",
"active": false,
"description":"Standard Chromebook Keyboards",
"gui":"setxkbmap -option;xkbcomp -w0 -I$HOME/.xkb ~/.xkb/keymap/kbd.chromebook.gui $DISPLAY",
"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":"+chromebook(swap_lalt_lctrl)+mac_gui(mac_levelssym)",
"xkb_symbols_term":"+altwin(swap_alt_win)+mac_term(mac_levelssym)",
"xkb_symbols_term":"+altwin(swap_alt_win)+mac_term_chromebook(mac_levelssym)",
"xkb_types_gui":"+mac_gui(addmac_levels)",
"xkb_types_term":""
},
@@ -62,11 +62,11 @@
"type":"chromebook",
"active": false,
"description":"Chromebook with Windows 104 Keyboard",
"gui":"setxkbmap -option;xkbcomp -w0 -I$HOME/.xkb ~/.xkb/keymap/kbd.chromebook.gui $DISPLAY; setxkbmap -device $usbid -option altwin:ctrl_alt_win",
"gui":"setxkbmap -option;xkbcomp -w0 -I$HOME/.xkb ~/.xkb/keymap/kbd.mac.gui $DISPLAY; setxkbmap -device $usbid -option altwin:ctrl_alt_win",
"term":"setxkbmap -option;xkbcomp -w0 -I$HOME/.xkb ~/.xkb/keymap/kbd.mac.term $DISPLAY",
"fallbackgui":"setxkbmap -option;xkbcomp -w0 -I$HOME/.xkb ~/.xkb/keymap/kbd.chromebook.gui $DISPLAY",
"fallbackgui":"setxkbmap -option;xkbcomp -w0 -I$HOME/.xkb ~/.xkb/keymap/kbd.mac.gui $DISPLAY",
"xkb_symbols_gui":"+chromebook(swap_lalt_lctrl)+mac_gui(mac_levelssym)",
"xkb_symbols_term":"+altwin(swap_alt_win)+mac_term(mac_levelssym)",
"xkb_symbols_term":"+altwin(swap_alt_win)+mac_term_chromebook(mac_levelssym)",
"xkb_types_gui":"+mac_gui(addmac_levels)",
"xkb_types_term":""
},
@@ -76,10 +76,10 @@
"type":"chromebook",
"active": false,
"description":"Chromebook with Mac Keyboard",
"gui":"setxkbmap -option;setxkbmap -option ctrl:swap_lwin_lctl; xkbcomp -w0 -i $internalid -I$HOME/.xkb ~/.xkb/keymap/kbd.chromebook.gui $DISPLAY",
"gui":"setxkbmap -option;setxkbmap -option ctrl:swap_lwin_lctl; xkbcomp -w0 -i $internalid -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":"+chromebook(swap_lalt_lctrl)+mac_gui(mac_levelssym)",
"xkb_symbols_term":"+altwin(swap_alt_win)+mac_term(mac_levelssym)",
"xkb_symbols_term":"+altwin(swap_alt_win)+mac_term_chromebook(mac_levelssym)",
"xkb_types_gui":"+mac_gui(addmac_levels)",
"xkb_types_term":""
}]

View File

@@ -1,13 +1,18 @@
#!/bin/bash
swapcmd="\/bin\/bash\ \/home\/`whoami`\/.config\/kinto\/xactive.sh"
systemctl --user stop keyswap >/dev/null 2>&1
systemctl --user disable keyswap >/dev/null 2>&1
systemctl --user stop keyswap.timer >/dev/null 2>&1
systemctl --user disable keyswap.timer >/dev/null 2>&1
swapcmd="\/home\/`whoami`\/.config\/kinto\/xactive.sh"
mkdir -p ~/.config/systemd/user
mkdir -p ~/.config/autostart
cp ./system-config/keyswap.service ~/.config/systemd/user/keyswap.service
cp ./system-config/keyswap.sh ~/.config/autostart/keyswap.sh
cp ./system-config/kinto.desktop ~/.config/autostart/kinto.desktop
cp ./kintox11/binary/kintox11 ~/.config/kinto/kintox11
cp ./system-config/xactive.sh ~/.config/kinto/xactive.sh
sed -i "s/{username}/`whoami`/g" ~/.config/systemd/user/keyswap.service
sed -i "s/ExecStart=/ExecStart=${swapcmd}/g" ~/.config/systemd/user/keyswap.service
systemctl --user daemon-reload
systemctl --user enable keyswap
systemctl --user start keyswap
systemctl --user start keyswap

Binary file not shown.

View File

@@ -10,7 +10,7 @@
//
// To compile with static library json-c
// Make sure archive with object files exist ar -t /usr/local/lib/libjson-c.a
// gcc -L/usr/local/lib/ kintox11.c -ljson-c -lXmu -lXt -lX11 -o kintox11
// gcc -L/usr/local/lib/ kintox11.c -ljson-c -lXmu -lXt -lX11 -O2 -o kintox11
//
#include <stdlib.h>
@@ -67,10 +67,10 @@ Display* open_display(){
}
int handle_error(Display* display, XErrorEvent* error){
// printf("X11 error: type=%d, serial=%lu, code=%d\n",
// error->type, error->serial, (int)error->error_code);
// xerror = True;
return 0;
printf("X11 error: type=%d, serial=%lu, code=%d\n",
error->type, error->serial, (int)error->error_code);
xerror = True;
return 1;
}
Window get_focus_window(Display* d){
@@ -88,6 +88,50 @@ Window get_focus_window(Display* d){
return w;
}
// get the top window.
// a top window have the following specifications.
// * the start window is contained the descendent windows.
// * the parent window is the root window.
Window get_top_window(Display* d, Window start){
Window w = start;
Window parent = start;
Window root = None;
Window *children;
unsigned int nchildren;
Status s;
// printf("getting top window ... \n");
while (parent != root) {
w = parent;
s = XQueryTree(d, w, &root, &parent, &children, &nchildren); // see man
if (s)
XFree(children);
if(xerror || w == 0){
printf("fail\n");
exit(1);
}
// printf(" get parent (window: %d)\n", (int)w);
}
// printf("success (window: %d)\n", (int)w);
return w;
}
// search a named window (that has a WM_STATE prop)
// on the descendent windows of the argment Window.
Window get_named_window(Display* d, Window start){
Window w;
// printf("getting named window ... ");
w = XmuClientWindow(d, start); // see man
// if(w == start)
// printf("fail\n");
// printf("success (window: %d)\n", (int) w);
return w;
}
const char * str_window_class(Display* d, Window w, char *prior_app ){
Status s;
@@ -128,7 +172,8 @@ int main(void){
int system(const char *command);
size_t i,n,r;
printf("Importing user_config.json...\n");
fp = fopen("user_config.json","r");
fread(buffer, 10240, 1, fp);
fclose(fp);
@@ -209,13 +254,13 @@ int main(void){
}
else{
appnames_array[i][n] = json_object_get_string(json_object_array_get_idx(config_obj_appnames, n));
// printf("%s i:%ld n:%ld %s\n",name_array[i],i,n,appnames_array[i][n]);
//printf("%s i:%ld n:%ld %s\n",name_array[i],i,n,appnames_array[i][n]);
}
}
if(appnames_max > appnames_len){
for (n = appnames_len; n < appnames_max; n++){
appnames_array[i][n] = NULL;
// printf("%s i:%ld n:%ld %s\n",name_array[i],i,n,appnames_array[i][n]);
//printf("%s i:%ld n:%ld %s\n",name_array[i],i,n,appnames_array[i][n]);
}
}
@@ -233,6 +278,8 @@ int main(void){
}
}
printf("Data from user_config.json imported successfully.\n");
for (i = 0; i < init_len; i++) {
init_array[i] = json_object_get_int(json_object_array_get_idx(init, i));
@@ -243,6 +290,7 @@ int main(void){
Display* d;
Window w;
char *name;
// for XmbTextPropertyToTextList
setlocale(LC_ALL, ""); // see man locale
@@ -252,34 +300,48 @@ int main(void){
XSetErrorHandler(handle_error);
char * prior_app;
char * current_app;
prior_app = malloc(sizeof(char)*100);
strcpy(prior_app,"none");
int remap_bool = 2;
printf("Starting keyswap...\n");
// get active window
w = get_focus_window(d);
w = get_top_window(d, w);
w = get_named_window(d, w);
// XFetchName(d, w, &name);
// printf("window:%#x name:%s\n", w, name);
printf("First window name: %s \n",str_window_class(d, w,prior_app));
int breakouter;
for (;;)
{
current_app = str_window_class(d, w,prior_app);
breakouter = 0;
// XFetchName(d, w, &name);
// printf("window:%#x name:%s\n", w, name);
// printf("%s\n","1");
// printf("%s\n",str_window_class(d, w,prior_app));
if(strcmp(str_window_class(d, w,prior_app),prior_app)){
if(strcmp(current_app,prior_app) || !strcmp(current_app,"none")){
// printf("%s\n","2");
for(i = 0; i < arraylen; ++i){
if(breakouter == 0){
if(strcmp(name_array[i],"gui")){
// printf("%s\n","3");
for(n = 0; n < appnames_max; ++n){
// printf("2nd elseif %s i:%ld n:%ld %s\n",name_array[i],i,n,appnames_array[i][n]);
// printf("3rd elseif (i:%ld == arraylen-1:%d && appnames_array[i:%ld][n:%ld+1]:%s == NULL) && (remap_bool: %i == 0 || 2)\n",i,arraylen-1,i,n,appnames_array[i][n+1],remap_bool);
if (appnames_array[i][n] != NULL){
// printf("%s\n",appnames_array[i][n]);
// If statement for triggering terminal config
if((strcicmp(appnames_array[i][n], str_window_class(d, w,prior_app)) == 0 && (remap_bool == 1 || remap_bool == 2))) {
if((strcicmp(appnames_array[i][n], current_app) == 0 && (remap_bool == 1 || remap_bool == 2))) {
// printf("1st if %s i:%ld n:%ld %s\n",name_array[i],i,n,appnames_array[i][n]);
printf("%s\n",name_array[i]);
printf("%s: %s\n",name_array[i],current_app);
system(run_array[i]);
for(r = 0; r < config_de_max; r++){
if(config_de_array[i][r] != -1){
@@ -293,18 +355,20 @@ int main(void){
breakouter = 1;
break;
} // Else command for ignoring similar app category based on config
else if((strcicmp(appnames_array[i][n], str_window_class(d, w,prior_app)) == 0 && remap_bool == 0)){
// printf("2nd elseif %s i:%ld n:%ld %s\n",name_array[i],i,n,appnames_array[i][n]);
else if((strcicmp(appnames_array[i][n], current_app) == 0 && remap_bool == 0)){
printf(" %s\n",current_app);
// printf("in 2nd elseif %s i:%ld n:%ld %s\n",name_array[i],i,n,appnames_array[i][n]);
// printf("%s\n","4");
breakouter = 1;
break;
} // Else command for triggering gui config
else if ((i == arraylen-1 || appnames_array[i][n+1] == NULL) && (remap_bool == 0 || remap_bool == 2)){
else if ((i == arraylen-1 && (appnames_array[i][n] == NULL || appnames_max == n+1)) && (remap_bool == 0 || remap_bool == 2)){
// printf("in 3rd elseif (i:%ld == arraylen-1:%d && appnames_array[i:%ld][n:%ld+1]:%s == NULL) && (remap_bool: %i == 0 || 2)\n",i,arraylen-1,i,n,appnames_array[i][n+1],remap_bool);
char *find = "gui";
int gui_idx = in(name_array, arraylen, find);
if(gui_idx >= 0) {
printf("%s\n",name_array[gui_idx]);
printf("%s: %s\n",name_array[gui_idx],current_app);
system(run_array[gui_idx]);
}
for(r = 0; r < config_de_max; r++){
@@ -314,11 +378,17 @@ int main(void){
system(de_rungui_array[de_id_idx]);
}
}
// printf("3rd elseif %s i:%ld n:%ld %s\n",name_array[i],i,n,appnames_array[i][n]);
remap_bool = 1;
fflush(stdout);
breakouter = 1;
break;
} // GUI app still - no switching needed
else if ((i == arraylen-1 && appnames_max == n+1) && remap_bool == 1){
printf(" %s\n",current_app);
}
else if ((i == arraylen-1 && appnames_max == n+1)){
printf("%s - Failed to match any keyswap requirements\n",current_app);
}
}
}
@@ -335,6 +405,7 @@ int main(void){
XEvent e;
XNextEvent(d, &e);
w = get_focus_window(d);
w = get_top_window(d, w);
w = get_named_window(d, w);
}
}

View File

@@ -130,23 +130,28 @@ if(onetime):
print("\nDynamic shortcut tweaks\n")
intents = [obj for obj in user_config['de'] if(obj['intent'] == "gui_term")]
tweaks = []
tweaks_selected = []
for index, k in enumerate(intents):
print(color_arr[default-1] + bcolors.BOLD + str(index+1) + '. ' + k['name'] + bcolors.ENDC)
print(bcolors.CYELLOW + 'Description: ' + k['description'] + bcolors.ENDC)
print(bcolors.CYELLOW + 'run in gui mode: ' + k['run_gui'].replace(";", "\n") + bcolors.ENDC)
print(bcolors.CYELLOW + 'run in terminal mode: ' + k['run_term'].replace(";", "\n") + bcolors.ENDC + '\n')
tweaks.append(k['id'])
print(bcolors.CYELLOW + "Please enter your dynamic shortcut tweak(s) (eg 1 or 1 2 3 - leave blank to skip): " + bcolors.ENDC)
defaultde = [int(i) for i in input().split()]
if len(defaultde) != 0:
# gui
user_config['config'][0]['de'] = defaultde
# term
user_config['config'][1]['de'] = defaultde
for d in defaultde:
user_config['de'][d-1]['active'] = True
user_config['de'][tweaks[d-1]]['active'] = True
tweaks_selected.append(tweaks[d-1])
if len(defaultde) != 0:
# gui
user_config['config'][0]['de'] = tweaks_selected
# term
user_config['config'][1]['de'] = tweaks_selected
user_config['config'][0]['run'] = keyboardconfigs[defaultkb-1]['gui']
user_config['config'][1]['run'] = keyboardconfigs[defaultkb-1]['term']

View File

@@ -4,10 +4,8 @@ PartOf=graphical-session.target
[Service]
Type=simple
#User={username}
#Group={username}
Environment=DISPLAY=:0
Restart=always
RestartSec=1
WorkingDirectory=/home/{username}/.config/kinto
ExecStart=

View File

@@ -1,3 +0,0 @@
#/bin/bash
systemctl --user start keyswap

View File

@@ -0,0 +1,8 @@
[Desktop Entry]
Name=Kinto
GenericName=Kinto
Comment=Make Linux Type Like it's a Mac
Exec=/usr/bin/systemctl --user start keyswap
Terminal=false
Type=Application
X-GNOME-Autostart-enabled=true

View File

@@ -2,7 +2,7 @@
systemctl --user stop keyswap
systemctl --user disable keyswap
rm -rf ~/.config/autostart/keyswap.sh
rm -rf ~/.config/autostart/kinto.desktop
rm -rf ~/.config/kinto
rm -rf ~/.xkb