diff --git a/setup.py b/setup.py index 24f1543..34a352e 100755 --- a/setup.py +++ b/setup.py @@ -8,26 +8,30 @@ homedir = os.path.expanduser("~") kintotype = 0 def windows_setup(): - keymaps = ["Apple keyboard standard", "Windows keyboard standard","Uninstall"] + keymaps = ["Apple keyboard standard", "Windows keyboard standard","Chromebook","IBM - No Super/Win","Uninstall"] for index, item in enumerate(keymaps): - print(" %i. %s" % (index+1, item.capitalize())) + print(" %i. %s" % (index+1, item)) default = 0 while not int(default) in range(1,len(keymaps)+1): default = int(input("\nPlease enter your desired keymap (1 - " + str(len(keymaps)) + ") : ")) print("") # Short DOS path notation path= cmdline('echo ''%cd%''')[:-1] - if default > 0 and default < 3: + if default > 0 and default < 5: print("Will now install chocolatey and autohotkey with elevated privileges...") print("This install will fail if you are not running with elevated privileges") os.system('powershell -executionpolicy bypass ".\\windows\\autohotkey.ps1"') print("Copying autohotkey combinations for Terminals & Editors...") os.system('copy /Y "' + path + '\\windows\\kinto.ahk" "' + path + '\\windows\\kinto-new.ahk"') + if default < 3: + os.system('C:\\Strawberry\\perl\\bin\\perl.exe -pi -e "s/(; )(.*)(; Default)(?!( - ST2CODE))(.*)/$2$3$5/g" .\\windows\\kinto-new.ahk') if default == 1: + kbtype = "mac" os.system('C:\\Strawberry\\perl\\bin\\perl.exe -pi -e "s/(; )(.*)(; MacModifiers)/$2$3/g" .\\windows\\kinto-new.ahk') - elif default == 2: + elif default == 2: + kbtype = "win" os.system('C:\\Strawberry\\perl\\bin\\perl.exe -pi -e "s/(; )(.*)(; WinModifiers)/$2$3/g" .\\windows\\kinto-new.ahk') - elif default == 3: + elif default == 5: print("Removing any old registry keys from prior versions...") p = subprocess.Popen(['powershell.exe', "Remove-ItemProperty -Path HKLM:'SYSTEM\CurrentControlSet\Control\Keyboard Layout' -Name 'Scancode Map' -ErrorAction SilentlyContinue"], stdout=sys.stdout) print("Removing Kinto from Startup folder...") @@ -39,14 +43,27 @@ def windows_setup(): os.system('(rd /s /q "%userprofile%\\.kinto") 2> nul') print("") print("Uninstall of Kinto is Complete.") - if default > 0 and default < 3: + if default == 3: + kbtype = "chrome" + os.system('C:\\Strawberry\\perl\\bin\\perl.exe -pi -e "s/(; )(.*)(; Chromebook)/$2$3/g" .\\windows\\kinto-new.ahk') + os.system('C:\\Strawberry\\perl\\bin\\perl.exe -pi -e "s/(; )(.*)(; WinModifiers/CB)/$2$3/g" .\\windows\\kinto-new.ahk') + if default == 3 or default == 4: + os.system('C:\\Strawberry\\perl\\bin\\perl.exe -pi -e "s/(; )(.*)(; CB/IBM)/$2$3/g" .\\windows\\kinto-new.ahk') + if default == 4: + kbtype = "ibm" + os.system('C:\\Strawberry\\perl\\bin\\perl.exe -pi -e "s/(; )(.*)(; IBM)/$2$3/g" .\\windows\\kinto-new.ahk') + os.system('C:\\Strawberry\\perl\\bin\\perl.exe -pi -e "s/(; )(.*)(; WinModifiers/CB/IBM)/$2$3/g" .\\windows\\kinto-new.ahk') + if default > 0 and default < 5: stvscode = yn_choice(bcolors.CYELLOW2 + "Would you like to use Sublime Text 3 keymaps in VS Code?\n" + bcolors.ENDC) print("\nWill now install Ubuntu Termimnal Theme as default...") os.system('regedit "' + path + '\\windows\\theme_ubuntu.reg"') os.system('robocopy "'+ path + '\\assets" "%userprofile%\\.kinto\\assets" /E') - if(stvscode): - os.system('C:\\Strawberry\\perl\\bin\\perl.exe -pi -e "s/(; )(.*)(; ST2CODE)/$2$3/g" .\\windows\\kinto-new.ahk') + if (stvscode and (default > 0 or default < 3)): + os.system('C:\\Strawberry\\perl\\bin\\perl.exe -pi -e "s/(; )(.*)(; Default - ST2CODE)/$2$3/g" .\\windows\\kinto-new.ahk') + elif (stvscode and (default == 3 or default == 4 )): + os.system('C:\\Strawberry\\perl\\bin\\perl.exe -pi -e "s/(; )(.*)(; CB/IBM - ST2CODE)/$2$3/g" .\\windows\\kinto-new.ahk') os.system('copy /Y "' + path + '\\windows\\kinto-start.vbs" "%userprofile%\\.kinto\\kinto-start.vbs"') + os.system('C:\\Strawberry\\perl\\bin\\perl.exe -pi -e "s/{kbtype}/' + kbtype + '/g" "%userprofile%\\.kinto\\kinto-start.vbs"') os.system('copy /Y "' + path + '\\windows\\usb.vbs" "%userprofile%\\.kinto\\usb.vbs"') os.system('copy /Y "' + path + '\\windows\\detectUSB.ahk" "%userprofile%\\.kinto\\detectUSB.ahk"') os.system('mklink "%userprofile%\\Start Menu\\Programs\\Startup\\kinto-start.vbs" "%userprofile%\\.kinto\\kinto-start.vbs"') diff --git a/windows/kinto-start.vbs b/windows/kinto-start.vbs index 374a1a4..4084a24 100644 --- a/windows/kinto-start.vbs +++ b/windows/kinto-start.vbs @@ -3,5 +3,5 @@ Set wShell = WScript.CreateObject("WScript.Shell") Set fso = CreateObject("Scripting.FileSystemObject") path = wShell.ExpandEnvironmentStrings("""%userprofile%") -strFolder = fso.BuildPath( path, "\.kinto\kinto.ahk""") +strFolder = fso.BuildPath( path, "\.kinto\kinto.ahk"" {kbtype}") oShell.ShellExecute "C:\Program Files\AutoHotkey\AutoHotkey.exe", strFolder, , "runas", 0 \ No newline at end of file diff --git a/windows/kinto.ahk b/windows/kinto.ahk index 9e722aa..1fa9768 100644 --- a/windows/kinto.ahk +++ b/windows/kinto.ahk @@ -2,8 +2,8 @@ #NoEnv #Persistent -DetectHiddenWindows, On -Run, %A_ScriptDir%\detectUSB.ahk +; DetectHiddenWindows, On ; Autodetect +; Run, %A_ScriptDir%\detectUSB.ahk ; Autodetect ; Enable Left clicks on Kinto Icon ; https://www.autohotkey.com/boards/viewtopic.php?t=9501 @@ -29,18 +29,40 @@ AHK_NOTIFYICON(wParam, lParam) ; Menu, Tray, Icon, %I_Icon%,, 1 ; MacModifiers ; Menu, Tray, Tip, Mac - Kinto ; MacModifiers -; I_Icon = %A_ScriptDir%\assets\kinto-white-invert.ico ; WinModifiers -; IfExist, %I_Icon% ; WinModifiers -; Menu, Tray, Icon, %I_Icon%,, 1 ; WinModifiers +; I_Icon = %A_ScriptDir%\assets\kinto-white-invert.ico ; WinModifiers/CB/IBM +; IfExist, %I_Icon% ; WinModifiers/CB/IBM +; Menu, Tray, Icon, %I_Icon%,, 1 ; WinModifiers/CB/IBM ; Menu, Tray, Tip, Windows - Kinto ; WinModifiers +; Menu, Tray, Tip, Chromebook - Kinto ; Chromebook +; Menu, Tray, Tip, IBM - Kinto ; IBM + +Menu, Keyboards, Add, Windows, winkb +Menu, Keyboards, Add, Apple, mackb +Menu, Keyboards, Add, Chromebook, chromekb +Menu, Keyboards, Add, IBM (No Super/Win key), ibmkb + +paramkb=%1% + +if paramkb = mac + checkKB = Apple +if paramkb = win + checkKB = Windows +if paramkb = chrome + checkKB = Chromebook +if paramkb = ibm + checkKB = IBM (No Super/Win key) + +menu, Keyboards, check, %checkKB% ; Set Tray menu ; Menu, Tray, Standard Menu, Tray, NoStandard ; to remove default menu -Menu, Tray, Add, Set Windows Keyboard, winkb -Menu, Tray, Add, Set Apple Keyboard, mackb +Menu, Tray, Add, Keyboard Types, :Keyboards +Menu, Tray, Add, Autodetect Keyboards, autodetect +; Menu, Tray, check, Autodetect Keyboards ; Autodetect +; Menu, Tray, disable, Autodetect Keyboards ; CB/IBM Menu, Tray, Add, Suspend Kinto, tray_suspend -Menu, Tray, Add, Returns to Desktop, min +; Menu, Tray, Add, Returns to Desktop, min Menu, Tray, Add Menu, Tray, Add, Close, Exit Menu, Tray, Click, 1 @@ -53,6 +75,18 @@ mackb(){ Run, "%A_ScriptDir%\NoShell.vbs" "%A_ScriptDir%\toggle_kb.bat" mac, "%A_ScriptDir%" } +chromekb(){ + Run, "%A_ScriptDir%\NoShell.vbs" "%A_ScriptDir%\toggle_kb.bat" chrome, "%A_ScriptDir%" +} + +ibmkb(){ + Run, "%A_ScriptDir%\NoShell.vbs" "%A_ScriptDir%\toggle_kb.bat" ibm, "%A_ScriptDir%" +} + +autodetect(){ + Run, "%A_ScriptDir%\NoShell.vbs" "%A_ScriptDir%\toggle_kb.bat" auto, "%A_ScriptDir%" +} + min(){ ; Refocus last active Window Send {LAlt down}{tab}{LAlt up} @@ -71,7 +105,7 @@ tray_suspend(){ else{ menu, tray, unCheck, Suspend Kinto ; I_Icon = %A_ScriptDir%\assets\kinto-white.ico ; MacModifiers -; I_Icon = %A_ScriptDir%\assets\kinto-white-invert.ico ; WinModifiers +; I_Icon = %A_ScriptDir%\assets\kinto-white-invert.ico ; WinModifiers/CB/IBM Menu, Tray, Icon, %I_Icon%,,1 Run, %A_ScriptDir%\detectUSB.ahk } @@ -147,31 +181,35 @@ GroupAdd, intellij, ahk_exe idea64.exe ; Send {LCtrl down}{Secondary up}{tab} ; Send {LCtrl down}{LWin up}{tab} ; WinModifiers ; Send {LCtrl down}{LAlt up}{tab} ; MacModifiers + ; Send {LCtrl down}{CapsLock up}{tab} ; CB/IBM KeyWait, tab ; Tertiary } else if (GetKeyState("LCtrl", "P") AND GetKeyState("LShift", "P")) { ; Secondary ; Send {LCtrl down}{Secondary up}{LShift down}{tab} - ; Send {LCtrl down}{LWin up}{LShift down}{tab} ; WinModifiers - ; Send {LCtrl down}{LAlt up}{LShift down}{tab} ; MacModifiers + ; Send {LCtrl down}{LWin up}{LShift down}{tab} ; WinModifiers/CB + ; Send {LCtrl down}{LAlt up}{LShift down}{tab} ; MacModifiers + ; Send {LCtrl down}{CapsLock up}{LShift down}{tab} ; IBM KeyWait, tab ; Primary - ; } else if (GetKeyState("LAlt", "P") AND GetKeyState("LShift", "P") = false) { ; WinModifiers + ; } else if (GetKeyState("LAlt", "P") AND GetKeyState("LShift", "P") = false) { ; WinModifiers/CB/IBM ; } else if (GetKeyState("LWin", "P") AND GetKeyState("LShift", "P") = false) { ; MacModifiers Send {LAlt down}{tab} KeyWait, tab ; Primary - ; } else if (GetKeyState("LAlt", "P") AND GetKeyState("LShift", "P")) { ; WinModifiers + ; } else if (GetKeyState("LAlt", "P") AND GetKeyState("LShift", "P")) { ; WinModifiers/CB/IBM ; } else if (GetKeyState("LWin", "P") AND GetKeyState("LShift", "P")) { ; MacModifiers Send {LAlt down}{LShift down}{tab} KeyWait, tab ; Secondary - ; } else if (GetKeyState("LWin", "P") AND GetKeyState("LShift", "P")) = false { ; WinModifiers - ; } else if (GetKeyState("LAlt", "P") AND GetKeyState("LShift", "P") = false) { ; MacModifiers + ; } else if (GetKeyState("LWin", "P") AND GetKeyState("LShift", "P")) = false { ; WinModifiers/CB + ; } else if (GetKeyState("LAlt", "P") AND GetKeyState("LShift", "P") = false) { ; MacModifiers + ; } else if (GetKeyState("CapsLock", "P") AND GetKeyState("LShift", "P")) = false { ; IBM return ; Secondary - ; } else if (GetKeyState("LWin", "P") AND GetKeyState("LShift", "P")) { ; WinModifiers - ; } else if (GetKeyState("LAlt", "P") AND GetKeyState("LShift", "P")) { ; MacModifiers + ; } else if (GetKeyState("LWin", "P") AND GetKeyState("LShift", "P")) { ; WinModifiers/CB + ; } else if (GetKeyState("LAlt", "P") AND GetKeyState("LShift", "P")) { ; MacModifiers + ; } else if (GetKeyState("CapsLock", "P") AND GetKeyState("LShift", "P")) { ; IBM return } else { send {Blind}{tab} @@ -189,6 +227,11 @@ GroupAdd, intellij, ahk_exe idea64.exe ; Secondary::LAlt ; Tertiary::LWin + ; $LAlt::LCtrl ; CB/IBM + ; $RAlt::RCtrl ; CB/IBM + ; $CapsLock::LWin ; IBM + ; $LCtrl::LAlt ; CB/IBM + ; $LAlt::LCtrl ; WinModifiers ; $RAlt::RCtrl ; WinModifiers ; $LWin::LAlt ; WinModifiers @@ -207,6 +250,7 @@ GroupAdd, intellij, ahk_exe idea64.exe ; Primary ; $LAlt up::Send {LWin up}{LAlt up}{LCtrl up} ; WinModifiers ; $LWin up::Send {LWin up}{LAlt up}{LCtrl up} ; MacModifiers + ; $LAlt up::Send {LWin up}{CapsLock up}{LAlt up}{LCtrl up} ; CB/IBM ; Close Apps ^q::Send !{F4} @@ -301,7 +345,8 @@ GroupAdd, intellij, ahk_exe idea64.exe ^#g::Send ^!+j ;Select all occurrences #+g::Send !+j ;Unselect occurrence ; Editing - #Space::Send ^{Space} ;Basic code completion + ; #Space::Send ^{Space} ; Default - Basic code completion + ; !Space::Send ^{Space} ; CB/IBM - Basic code completion #+Space::Send ^+{Space} ;Smart code completion #j::Send ^q ;Quick documentation lookup ^n::Send !{Insert} ;Generate code... @@ -312,7 +357,7 @@ GroupAdd, intellij, ahk_exe idea64.exe #+q::Send !q ;Context info #!o::Send ^!o ;Optimize imports #!i::Send ^!i ;Auto-indent line(s) - $^Backspace::Send ^y ;Delete line at caret + $^Backspace::Send ^y ;Delete line at caret #+j::Send ^+j ;Smart line join !Delete::Send ^{Delete} ;Delete to word end !Backspace::Send ^{Backspace} ;Delete to word start @@ -332,7 +377,8 @@ GroupAdd, intellij, ahk_exe idea64.exe #Left::Send !{Left} ;Go to previous editor tab #l::Send ^g ;Go to line #e::Send ^e ;Recent files popup - !Space::Send ^+i ;Open quick definition lookup + ; !Space::Send ^+i ; Default - Open quick definition lookup + ; #Space::Send ^+i ; CB/IBM - Open quick definition lookup ^Y::Send ^+i ;Open quick definition lookup #+b::Send ^+b ;Go to type declaration #Up::Send !{Up} ;Go to previous @@ -374,20 +420,26 @@ GroupAdd, intellij, ahk_exe idea64.exe #IfWinActive ahk_group vscode #p::send {Up} ; Allow for traversing quick list #n::send {Down} ; Allow for traversing quick list - #Space::Send ^{Space} ; Basic code completion ; Remap Ctrl+Shift to behave like macOS Sublimetext ; Will extend cursor to multiple lines - ; #+Up::send ^!{Up} ; ST2CODE - ; #+Down::send ^!{Down} ; ST2CODE + ; #+Up::send ^!{Up} ; Default - ST2CODE + ; !+Up::send ^!{Up} ; CB/IBM - ST2CODE + ; #+Down::send ^!{Down} ; Default - ST2CODE + ; !+Down::send ^!{Down} ; CB/IBM - ST2CODE ; Remap Ctrl+Cmd+G to select all matches - ; #^g::send ^+{L} ; ST2CODE - !+g::send ^+{G} ; View source control - ; Sigints - interrupt - $#c::Send {Ctrl down}c{Ctrl up} + ; #^g::send ^+{L} ; Default - ST2CODE + ; !^g::send ^+{L} ; CB/IBM - ST2CODE + !+g::send ^+{G} ; View source control + ; $#c::Send {Ctrl down}c{Ctrl up} ; Default - Sigints interrupt + ; $!c::Send {Ctrl down}c{Ctrl up} ; CB/IBM + + ; #Space::Send ^{Space} ; Default - Basic code completion + ; !Space::Send ^{Space} ; CB/IBM - Basic code completion #If #IfWinActive ahk_exe sublime_text.exe - #Space::Send ^{Space} ; Basic code completion + ; #Space::Send ^{Space} ; Default - Basic code completion + ; !Space::Send ^{Space} ; CB/IBM - Basic code completion #^Up::send !{O} ; Switch file #^f::send {F11} ; toggle_full_screen ^!v::send {Ctrl Down}k{Ctrl Up}{Ctrl Down}v{Ctrl Up} ; paste_from_history @@ -395,8 +447,10 @@ GroupAdd, intellij, ahk_exe idea64.exe ^!Up::send ^{Up} ; scroll_lines up ^Down::Return ; cancel scroll_lines down ^!Down::send ^{Down} ; scroll_lines down - #+Up::send {shift up}^!{Up} ; multi-cursor up - #+Down::send {shift up}^!{Down} ; multi-cursor down + ; #+Up::send {shift up}^!{Up} ; Default - multi-cursor up + ; #+Down::send {shift up}^!{Down} ; Default - multi-cursor down + ; #+Up::send {shift up}^!{Up} ; CB/IBM - multi-cursor up + ; #+Down::send {shift up}^!{Down} ; CB/IBM - multi-cursor down ^PgDn::Return ; cancel next_view ^PgUp::Return ; cancel prev_view ^+{::send ^{PgDn} ; next_view @@ -417,7 +471,8 @@ GroupAdd, intellij, ahk_exe idea64.exe ^+g::send +{F3} ; find_prev #!g::send ^{F3} ; find_under #!+g::send ^+{F3} ; find_under_prev - #^g::send !{F3} ; find_all_under + ; #^g::send !{F3} ; Default - find_all_under + ; !^g::send !{F3} ; CB/IBM - find_all_under ^+Up::Return ; cancel swap_line_up #!Up::send ^+{Up} ; swap_line_up ^+Down::Return ; cancel swap_line_down @@ -447,12 +502,14 @@ GroupAdd, intellij, ahk_exe idea64.exe #IfWinActive ahk_group terminals ; End of Line - #e:: + #e:: ; Default + !e:: ; CB/IBM Send {End} return ; Beginning of Line - #a:: + ; #a:: ; Default + ; !a:: ; CB/IBM Send {Home} return @@ -468,7 +525,8 @@ GroupAdd, intellij, ahk_exe idea64.exe return ; Sigints - interrupt - $#c::Send {Ctrl down}c{Ctrl up} + ; $#c::Send {Ctrl down}c{Ctrl up} ; Default + ; $!c::Send {Ctrl down}c{Ctrl up} ; CB/IBM ; Paste ^v:: @@ -509,19 +567,33 @@ GroupAdd, intellij, ahk_exe idea64.exe ; Clear Terminal and Scroll Buffer ^k::Send clear && printf '\e[3J'{Enter} ; Nano editor shortcuts - #g::Send {LCtrl down}g{LCtrl Up} - #k::Send {LCtrl down}k{LCtrl Up} - #x::Send {LCtrl down}x{LCtrl Up} - #o::Send {LCtrl down}o{LCtrl Up} - #r::Send {LCtrl down}r{LCtrl Up} - #w::Send {LCtrl down}w{LCtrl Up} - #\::Send {LCtrl down}\{LCtrl Up} - #u::Send {LCtrl down}u{LCtrl Up} - #j::Send {LCtrl down}j{LCtrl Up} - #t::Send {LCtrl down}t{LCtrl Up} - #_::Send {LCtrl down}_{LCtrl Up} - #z::Send {LCtrl down}z{LCtrl Up} - #y::Send {LCtrl down}y{LCtrl Up} - #v::Send {LCtrl down}v{LCtrl Up} + #g::Send {LCtrl down}g{LCtrl Up} ; Default + #k::Send {LCtrl down}k{LCtrl Up} ; Default + #x::Send {LCtrl down}x{LCtrl Up} ; Default + #o::Send {LCtrl down}o{LCtrl Up} ; Default + #r::Send {LCtrl down}r{LCtrl Up} ; Default + #w::Send {LCtrl down}w{LCtrl Up} ; Default + #\::Send {LCtrl down}\{LCtrl Up} ; Default + #u::Send {LCtrl down}u{LCtrl Up} ; Default + #j::Send {LCtrl down}j{LCtrl Up} ; Default + #t::Send {LCtrl down}t{LCtrl Up} ; Default + #_::Send {LCtrl down}_{LCtrl Up} ; Default + #z::Send {LCtrl down}z{LCtrl Up} ; Default + #y::Send {LCtrl down}y{LCtrl Up} ; Default + #v::Send {LCtrl down}v{LCtrl Up} ; Default + !g::Send {LCtrl down}g{LCtrl Up} ; CB/IBM + !k::Send {LCtrl down}k{LCtrl Up} ; CB/IBM + !x::Send {LCtrl down}x{LCtrl Up} ; CB/IBM + !o::Send {LCtrl down}o{LCtrl Up} ; CB/IBM + !r::Send {LCtrl down}r{LCtrl Up} ; CB/IBM + !w::Send {LCtrl down}w{LCtrl Up} ; CB/IBM + !\::Send {LCtrl down}\{LCtrl Up} ; CB/IBM + !u::Send {LCtrl down}u{LCtrl Up} ; CB/IBM + !j::Send {LCtrl down}j{LCtrl Up} ; CB/IBM + !t::Send {LCtrl down}t{LCtrl Up} ; CB/IBM + !_::Send {LCtrl down}_{LCtrl Up} ; CB/IBM + !z::Send {LCtrl down}z{LCtrl Up} ; CB/IBM + !y::Send {LCtrl down}y{LCtrl Up} ; CB/IBM + !v::Send {LCtrl down}v{LCtrl Up} ; CB/IBM #If #If \ No newline at end of file diff --git a/windows/toggle_kb.bat b/windows/toggle_kb.bat index bfb82f3..59ffa35 100644 --- a/windows/toggle_kb.bat +++ b/windows/toggle_kb.bat @@ -2,20 +2,58 @@ IF "%1"=="mac" goto mac IF "%1"=="win" goto win +IF "%1"=="chrome" goto chrome +IF "%1"=="ibm" goto ibm +IF "%1"=="auto" goto auto echo Not found. goto commonexit +:auto +C:\Strawberry\perl\bin\perl.exe -pi -e "s/^(;)( )(.*)(; Autodetect)|^(?!; )(.*)(; )(Autodetect)/$6$5$6$7$3$4/g" "%userprofile%\.kinto\kinto.ahk" +"%userprofile%\.kinto\kinto-start.vbs" +goto commonexit + :win C:\Strawberry\perl\bin\perl.exe -pi -e "s/(; )(.*)(; WinModifiers)/$2$3/g" "%userprofile%\.kinto\kinto.ahk" C:\Strawberry\perl\bin\perl.exe -pi -e "s/^(?!;)(.*)(; MacModifiers)/; $1$2/gm" "%userprofile%\.kinto\kinto.ahk" -"C:\Program Files\AutoHotkey\AutoHotkey.exe" "%userprofile%\.kinto\kinto.ahk" +C:\Strawberry\perl\bin\perl.exe -pi -e "s/^(?!;)(.*)(; CB\/IBM)/; $1$2/gm" "%userprofile%\.kinto\kinto.ahk" +C:\Strawberry\perl\bin\perl.exe -pi -e "s/^(?!;)(.*)(; IBM)/; $1$2/gm" "%userprofile%\.kinto\kinto.ahk" +C:\Strawberry\perl\bin\perl.exe -pi -e "s/(ahk\"\" )(\w*)/$1win/gm" "%userprofile%\.kinto\kinto-start.vbs" +"C:\Program Files\AutoHotkey\AutoHotkey.exe" "%userprofile%\.kinto\kinto.ahk" win goto commonexit :mac C:\Strawberry\perl\bin\perl.exe -pi -e "s/(; )(.*)(; MacModifiers)/$2$3/g" "%userprofile%\.kinto\kinto.ahk" C:\Strawberry\perl\bin\perl.exe -pi -e "s/^(?!;)(.*)(; WinModifiers)/; $1$2/gm" "%userprofile%\.kinto\kinto.ahk" -"C:\Program Files\AutoHotkey\AutoHotkey.exe" "%userprofile%\.kinto\kinto.ahk" +C:\Strawberry\perl\bin\perl.exe -pi -e "s/^(?!;)(.*)(; CB\/IBM)/; $1$2/gm" "%userprofile%\.kinto\kinto.ahk" +C:\Strawberry\perl\bin\perl.exe -pi -e "s/^(?!;)(.*)(; IBM)/; $1$2/gm" "%userprofile%\.kinto\kinto.ahk" +C:\Strawberry\perl\bin\perl.exe -pi -e "s/(ahk\"\" )(\w*)/$1mac/gm" "%userprofile%\.kinto\kinto-start.vbs" +"C:\Program Files\AutoHotkey\AutoHotkey.exe" "%userprofile%\.kinto\kinto.ahk" mac +goto commonexit + +:chrome +C:\Strawberry\perl\bin\perl.exe -pi -e "s/^(?!; )(.*)(; Autodetect)/; $1$2/gm" "%userprofile%\.kinto\kinto.ahk" +C:\Strawberry\perl\bin\perl.exe -pi -e "s/^(?!;)(.*)(; WinModifiers)/; $1$2/gm" "%userprofile%\.kinto\kinto.ahk" +C:\Strawberry\perl\bin\perl.exe -pi -e "s/^(?!;)(.*)(; MacModifiers)/; $1$2/gm" "%userprofile%\.kinto\kinto.ahk" +C:\Strawberry\perl\bin\perl.exe -pi -e "s/^(?!;)(.*)(; Default)/; $1$2/gm" "%userprofile%\.kinto\kinto.ahk" +C:\Strawberry\perl\bin\perl.exe -pi -e "s/(; )(.*)(; Chromebook)/$2$3/g" "%userprofile%\.kinto\kinto.ahk" +C:\Strawberry\perl\bin\perl.exe -pi -e "s/(; )(.*)(; WinModifiers\/CB)/$2$3/g" "%userprofile%\.kinto\kinto.ahk" +C:\Strawberry\perl\bin\perl.exe -pi -e "s/(; )(.*)(; CB\/IBM)/$2$3/g" "%userprofile%\.kinto\kinto.ahk" +C:\Strawberry\perl\bin\perl.exe -pi -e "s/(ahk\"\" )(\w*)/$1chrome/gm" "%userprofile%\.kinto\kinto-start.vbs" +"C:\Program Files\AutoHotkey\AutoHotkey.exe" "%userprofile%\.kinto\kinto.ahk" chrome +goto commonexit + +:ibm +C:\Strawberry\perl\bin\perl.exe -pi -e "s/^(?!; )(.*)(; Autodetect)/; $1$2/gm" "%userprofile%\.kinto\kinto.ahk" +C:\Strawberry\perl\bin\perl.exe -pi -e "s/^(?!;)(.*)(; WinModifiers)/; $1$2/gm" "%userprofile%\.kinto\kinto.ahk" +C:\Strawberry\perl\bin\perl.exe -pi -e "s/^(?!;)(.*)(; MacModifiers)/; $1$2/gm" "%userprofile%\.kinto\kinto.ahk" +C:\Strawberry\perl\bin\perl.exe -pi -e "s/^(?!;)(.*)(; Default)/; $1$2/gm" "%userprofile%\.kinto\kinto.ahk" +C:\Strawberry\perl\bin\perl.exe -pi -e "s/(; )(.*)(; IBM)/$2$3/g" "%userprofile%\.kinto\kinto.ahk" +C:\Strawberry\perl\bin\perl.exe -pi -e "s/(; )(.*)(; WinModifiers\/CB\/IBM)/$2$3/g" "%userprofile%\.kinto\kinto.ahk" +C:\Strawberry\perl\bin\perl.exe -pi -e "s/(; )(.*)(; CB\/IBM)/$2$3/g" "%userprofile%\.kinto\kinto.ahk" +C:\Strawberry\perl\bin\perl.exe -pi -e "s/(ahk\"\" )(\w*)/$1ibm/gm" "%userprofile%\.kinto\kinto-start.vbs" +"C:\Program Files\AutoHotkey\AutoHotkey.exe" "%userprofile%\.kinto\kinto.ahk" ibm goto commonexit :commonexit diff --git a/xkeysnail-config/kinto.py b/xkeysnail-config/kinto.py index 6f661ed..31e1286 100644 --- a/xkeysnail-config/kinto.py +++ b/xkeysnail-config/kinto.py @@ -21,6 +21,13 @@ codeStr = "|".join(str(x) for x in mscodes) # [Global modemap] Change modifier keys as in xmodmap define_conditional_modmap(lambda wm_class: wm_class.casefold() not in terminals,{ + # # IBM + # Key.LEFT_ALT: Key.RIGHT_CTRL, # IBM + # Key.LEFT_CTRL: Key.LEFT_ALT, # IBM + # Key.CAPSLOCK: Key.LEFT_META, # IBM + # Key.RIGHT_ALT: Key.RIGHT_CTRL, # IBM - Multi-language (Remove) + # Key.RIGHT_CTRL: Key.RIGHT_ALT, # IBM - Multi-language (Remove) + # # Chromebook # Key.LEFT_ALT: Key.RIGHT_CTRL, # Chromebook # Key.LEFT_CTRL: Key.LEFT_ALT, # Chromebook @@ -44,6 +51,17 @@ define_conditional_modmap(lambda wm_class: wm_class.casefold() not in terminals, # [Conditional modmap] Change modifier keys in certain applications define_conditional_modmap(re.compile(termStr, re.IGNORECASE), { + # # IBM + # Key.LEFT_ALT: Key.RIGHT_CTRL, # IBM + # # Left Ctrl Stays Left Ctrl + # Key.CAPSLOCK: Key.LEFT_ALT, # IBM + # Key.RIGHT_ALT: Key.RIGHT_CTRL, # IBM - Multi-language (Remove) + # Key.RIGHT_CTRL: Key.RIGHT_ALT, # IBM + # # Right Meta does not exist on chromebooks + + # Key.RIGHT_ALT: Key.RIGHT_CTRL, # IBM - Multi-language (Remove) + # Key.RIGHT_CTRL: Key.RIGHT_ALT, # IBM - Multi-language (Remove) + # # Chromebook # Key.LEFT_ALT: Key.RIGHT_CTRL, # Chromebook # # Left Ctrl Stays Left Ctrl @@ -183,9 +201,9 @@ define_keymap(None,{ # K("RC-Shift-Tab"): K("RC-Shift-backslash"), # xfce4 # K("RC-Grave"): K("RC-Shift-backslash"), # xfce4 # In-App Tab switching - # K("M-Tab"): K("C-Tab"), # Chromebook - In-App Tab switching - # K("M-Shift-Tab"): K("C-Shift-Tab"), # Chromebook - In-App Tab switching - # K("M-Grave") : K("C-Shift-Tab"), # Chromebook - In-App Tab switching + # K("M-Tab"): K("C-Tab"), # Chromebook/IBM - In-App Tab switching + # K("M-Shift-Tab"): K("C-Shift-Tab"), # Chromebook/IBM - In-App Tab switching + # K("M-Grave") : K("C-Shift-Tab"), # Chromebook/IBM - In-App Tab switching K("Super-Tab"): K("LC-Tab"), # Default not-chromebook K("Super-Shift-Tab"): K("LC-Shift-Tab"), # Default not-chromebook @@ -204,7 +222,7 @@ define_keymap(None,{ K("RC-Shift-Up"): K("C-Shift-Home"), # Select all to Beginning of File K("RC-Down"): K("C-End"), # End of File K("RC-Shift-Down"): K("C-Shift-End"), # Select all to End of File - # K("M-Backspace"): K("Delete"), # Chromebook - Delete + # K("M-Backspace"): K("Delete"), # Chromebook/IBM - Delete K("Super-Backspace"): K("C-Backspace"), # Default not-chromebook - Delete Left Word of Cursor K("Super-Delete"): K("C-Delete"), # Default not-chromebook - Delete Right Word of Cursor K("Alt-Backspace"): K("C-Backspace"), # Default not-chromebook - Delete Left Word of Cursor @@ -265,7 +283,7 @@ define_keymap(re.compile(codeStr, re.IGNORECASE),{ K("C-Shift-g"): K("Shift-f3"), # find_prev K("Super-c"): K("LC-c"), # Sigints - interrupt # K("Super-C-g"): K("C-f2"), # Default - Sublime - find_all_under - # K("C-M-g"): K("C-f2"), # Chromebook - Sublime - find_all_under + # K("C-M-g"): K("C-f2"), # Chromebook/IBM - Sublime - find_all_under # K("Super-Shift-up"): K("M-Shift-up"), # multi-cursor up - Sublime # K("Super-Shift-down"): K("M-Shift-down"), # multi-cursor down - Sublime # K(""): pass_through_key, # cancel @@ -307,8 +325,8 @@ define_keymap(re.compile("Sublime_text", re.IGNORECASE),{ K("C-Shift-f3"): pass_through_key, # cancel find_under_prev K("Super-M-Shift-g"): K("C-Shift-f3"), # find_under_prev K("M-f3"): pass_through_key, # Default - cancel find_all_under - # K("M-Refresh"): pass_through_key, # Chromebook - cancel find_all_under - # K("M-C-g"): K("M-Refresh"), # Chromebook - find_all_under + # K("M-Refresh"): pass_through_key, # Chromebook/IBM - cancel find_all_under + # K("M-C-g"): K("M-Refresh"), # Chromebook/IBM - find_all_under K("Super-C-g"): K("M-f3"), # Default - find_all_under K("C-Shift-up"): pass_through_key, # cancel swap_line_up K("Super-M-up"): K("C-Shift-up"), # swap_line_up diff --git a/xkeysnail-config/xkeysnail.service b/xkeysnail-config/xkeysnail.service index 7ec1d79..dc9226f 100644 --- a/xkeysnail-config/xkeysnail.service +++ b/xkeysnail-config/xkeysnail.service @@ -5,7 +5,7 @@ Description=xkeysnail Type=simple KillMode=process ExecStart=/usr/bin/sudo /bin/bash -c '/usr/bin/xhost +SI:localuser:root && {homedir}/.config/kinto/killdups.sh && /usr/local/bin/xkeysnail --quiet --watch {homedir}/.config/kinto/kinto.py' -ExecStop=/usr/bin/sudo pkill -f xkeysnail +ExecStop=/usr/bin/sudo pkill -f xkeysnail && exit 0 Restart=on-failure RestartSec=3 Environment=DISPLAY={displayid} diff --git a/xkeysnail_service.sh b/xkeysnail_service.sh index e6ae73c..a1838e4 100755 --- a/xkeysnail_service.sh +++ b/xkeysnail_service.sh @@ -186,6 +186,7 @@ if [ $# -eq 0 ]; then echo " 1) Windows & Mac (HID driver) - Most Standard keyboards (& 1st party usb/bt Apple keyboards)" echo " 2) Mac Only & VMs on Macbooks - 3rd & 1st party Apple keyboards" echo " 3) Chromebook - Chromebook running Linux" + echo " 4) IBM M - Keyboards w/o Super/Win keys" # echo " 5) Uninstall" read n @@ -200,7 +201,7 @@ rightalt=false # VS code remap vssublime=false -if [[ $1 == "1" || $1 == "2" || $1 == "3" || $1 == "winmac" || $1 == "mac" || $1 == "chromebook" ]]; then +if [[ $1 == "1" || $1 == "2" || $1 == "3" || $1 == "4" || $1 == "winmac" || $1 == "mac" || $1 == "chromebook" || $1 == "ibm" ]]; then if [[ $dename == "gnome" || $dename == "budgie" || $dename == "mate" || $dename == "xfce" ]];then installtray=true while true; do @@ -363,6 +364,11 @@ elif [[ $1 == "3" || $1 == "chromebook" ]]; then perl -pi -e "s/(# )(.*)(# Chromebook)/\$2\$3/g" ./xkeysnail-config/kinto.py.new perl -pi -e "s/(# )(.*)(# xfce4)/\$2\$3/g" ./xkeysnail-config/kinto.py.new perl -pi -e "s/(\w.*)(# Default)/# \$1\$2/g" ./xkeysnail-config/kinto.py.new +elif [[ $1 == "4" || $1 == "ibm" ]]; then + perl -pi -e "s/(# )(.*)(# IBM)/\$2\$3/g" ./xkeysnail-config/kinto.py.new + perl -pi -e "s=(# )(.*)(# Chromebook/IBM)=\$2\$3=g" ./xkeysnail-config/kinto.py.new + # perl -pi -e "s/(# )(.*)(# xfce4)/\$2\$3/g" ./xkeysnail-config/kinto.py.new + perl -pi -e "s/(\w.*)(# Default)/# \$1\$2/g" ./xkeysnail-config/kinto.py.new fi if $rightalt ; then @@ -407,6 +413,7 @@ if [[ $1 == "1" || $1 == "2" || $1 == "3" || $1 == "winmac" || $1 == "mac" || $1 # sudo systemctl enable xkeysnail.service # fi sudo systemctl restart xkeysnail + sudo pkill -f kintotray >/dev/null 2>&1 nohup python3 ~/.config/kinto/kintotray.py& >/dev/null 2>&1 echo -e "Adding xhost fix...\n"