diff --git a/keyswap_service.sh b/keyswap_service.sh index f8f4316..f0c41b5 100755 --- a/keyswap_service.sh +++ b/keyswap_service.sh @@ -14,7 +14,9 @@ cp ./kintox11/binary/kintox11 ~/.config/kinto/kintox11 cp ./system-config/xactive.sh ~/.config/kinto/xactive.sh cp ./system-config/caret_status.sh ~/.config/kinto/caret_status.sh cp ./system-config/cleanup.sh ~/.config/kinto/cleanup.sh -cp ./system-config/.browsers ~/.config/kinto/.browsers +cp ./system-config/.firefox ~/.config/kinto/.firefox +cp ./system-config/.chrome-ww ~/.config/kinto/.chrome-ww +cp ./system-config/.chrome-nw ~/.config/kinto/.chrome-nw sed -i "s/{username}/`whoami`/g" ~/.config/systemd/user/keyswap.service systemctl --user daemon-reload systemctl --user enable keyswap diff --git a/kintox11/binary/kintox11 b/kintox11/binary/kintox11 index e376c77..5d3b6db 100755 Binary files a/kintox11/binary/kintox11 and b/kintox11/binary/kintox11 differ diff --git a/kintox11/src/kintox11.c b/kintox11/src/kintox11.c index afae930..cf599db 100644 --- a/kintox11/src/kintox11.c +++ b/kintox11/src/kintox11.c @@ -99,6 +99,7 @@ char *trimwhitespace(char *str) int check_caret() { + int caretint; char * fpname; fpname = malloc(sizeof(char)*20); strcpy(fpname,"/tmp/kinto/caret"); @@ -113,10 +114,12 @@ int check_caret() fread(buffer, size, 1, fp); buffer[size] = '\0'; trimwhitespace(buffer); - if(strncmp(buffer,"1",1) == 0){ + caretint = atoi(buffer); + if(caretint == 1){ // printf("caret: %s\n", buffer); return 1; } + // printf("found nothing\n"); return 0; } else{ @@ -528,13 +531,13 @@ int main(void){ XEvent e; if(strlen(run_onInput) > 0){ while(XNextEventTimeout(d, &e, .5, event_ts, last_event, &event_ts, &last_event)){ - if(check_caret(run_onInput) && ran_onInput == 0){ + if(check_caret() && ran_onInput == 0){ // printf("run_onInput: %s\n",run_onInput); system(run_onInput); ran_onInput = 1; } - else if(!check_caret(run_onInput) && ran_onInput == 1){ - // printf("run_normal: %s\n",run_normal); + else if(!check_caret() && ran_onInput == 1){ + // printf("run_offInput: %s\n",run_offInput); system(run_offInput); ran_onInput = 0; } diff --git a/setup.py b/setup.py index edfb6ff..c6639f4 100755 --- a/setup.py +++ b/setup.py @@ -25,17 +25,20 @@ def requirements(): check_xbind = symbols_gui_line = cmdline("which xbindkeys").strip() check_xte = symbols_gui_line = cmdline("which xte").strip() +check_xdotool = symbols_gui_line = cmdline("which xdotool").strip() -if len(check_xbind) > 0 and len(check_xte) > 0: - print("Xbindkeys and xte requirement is installed.") -elif len(check_xbind) == 0 and len(check_xbind) == 0: - run_pkg = "xbindkeys xautomation" - requirements() -elif len(check_xbind) == 0: +runpkg = 0 + +if len(check_xbind) > 0 and len(check_xte) > 0 and len(check_xdotool) > 0: + print("Xbindkeys, xdotool and xte requirement is installed.") +if len(check_xbind) == 0: run_pkg = "xbindkeys" - requirements() -elif len(check_xte) == 0: - run_pkg = "xautomation" +if len(check_xte) == 0: + run_pkg += " xautomation" +if len(check_xdotool) == 0: + run_pkg += " xdotool" + +if runpkg != 0: requirements() try: @@ -119,6 +122,7 @@ if os.path.isdir(homedir + "/.xkb/keymap") == False: time.sleep(0.5) os.system('setxkbmap -option') os.system('setxkbmap -print > ~/.xkb/keymap/kbd.mac.gui') +os.system('setxkbmap -print > ~/.xkb/keymap/kbd.mac.gui.nw') os.system('setxkbmap -print > ~/.xkb/keymap/kbd.mac.term') time.sleep(0.5) @@ -130,6 +134,9 @@ cmdline('sed -i '' -e "' + symbols_gui_line + 's/\\"/' + keyboardconfigs[default 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_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 "' + types_gui_line + 's/\\"/' + keyboardconfigs[defaultkb-1]['xkb_types_gui'] + '\\"/2" ~/.xkb/keymap/kbd.mac.gui.nw') + user_file = homedir + '/.config/kinto/user_config.json' with open(user_file, 'r') as f: @@ -175,12 +182,15 @@ if len(defaultde) != 0: user_config['config'][0]['de'] = tweaks_selected # term user_config['config'][1]['de'] = tweaks_selected - # browsers + # firefox user_config['config'][2]['de'] = tweaks_selected + # chrome + user_config['config'][3]['de'] = tweaks_selected user_config['config'][0]['run'] = keyboardconfigs[defaultkb-1]['gui'] user_config['config'][1]['run'] = keyboardconfigs[defaultkb-1]['term'] user_config['config'][2]['run'] = keyboardconfigs[defaultkb-1]['gui'] +user_config['config'][3]['run'] = keyboardconfigs[defaultkb-1]['gui'].replace("kbd.mac.gui","kbd.mac.gui.nw") os.remove(user_file) with open(user_file, 'w') as f: diff --git a/system-config/.chrome-nw b/system-config/.chrome-nw new file mode 100644 index 0000000..7fd0b99 --- /dev/null +++ b/system-config/.chrome-nw @@ -0,0 +1,7 @@ +"xdotool key --delay 0 --clearmodifiers Alt+Left" + Control + Left + Release + #Home + release + +"xdotool key --delay 0 --clearmodifiers Alt+Right" + Control + Right + Release + #End + release diff --git a/system-config/.chrome-ww b/system-config/.chrome-ww new file mode 100644 index 0000000..9717ad1 --- /dev/null +++ b/system-config/.chrome-ww @@ -0,0 +1,5 @@ +"xdotool key --delay 0 --clearmodifiers Home" + Control + Left + Release + +"xdotool key --delay 0 --clearmodifiers End" + Control + Right + Release diff --git a/system-config/.browsers b/system-config/.firefox similarity index 50% rename from system-config/.browsers rename to system-config/.firefox index 7128056..b9aacf8 100644 --- a/system-config/.browsers +++ b/system-config/.firefox @@ -1,5 +1,5 @@ "xte 'keydown Control_L' 'key bracketleft' 'keyup Control_L'" Home + release -"xte 'keydown Control_L' 'key bracketright' 'keyup Control_L'" - End + release +"xte 'keydown Control_R' 'key bracketright' 'keyup Control_R'" + End + release \ No newline at end of file diff --git a/user_config.json b/user_config.json index a6f0e46..31e42cb 100644 --- a/user_config.json +++ b/user_config.json @@ -19,15 +19,25 @@ "appnames":[ "Gnome-terminal","konsole","io.elementary.terminal","terminator","sakura","guake","tilda","xterm","eterm" ] }, { - "name": "browsers", - "run": "", - "run_onInput": "killall xbindkeys > /dev/null 2>&1", - "run_offInput": "xbindkeys -f $HOME/.config/kinto/.browsers", - "symbols":"", - "types":"", - "de": [], - "appnames":[ "Chromium","Firefox" ] - }], + "name": "firefox", + "run": "", + "run_onInput": "killall xbindkeys > /dev/null 2>&1", + "run_offInput": "killall xbindkeys > /dev/null 2>&1;xbindkeys -f $HOME/.config/kinto/.firefox", + "symbols": "", + "types": "", + "de": [], + "appnames": [ "Firefox" ] + }, + { + "name": "chrome", + "run": "", + "run_onInput": "killall xbindkeys > /dev/null 2>&1;xbindkeys -f $HOME/.config/kinto/.chrome-ww", + "run_offInput": "killall xbindkeys > /dev/null 2>&1;xbindkeys -f $HOME/.config/kinto/.chrome-nw", + "symbols": "", + "types": "", + "de": [], + "appnames": [ "Chromium" ] + }], "init": [], "detypes":["gnome2","gnome3","kde4","kde5","xfce","i3wm"], "de":[{