{"id":87222,"date":"2020-04-30T19:15:56","date_gmt":"2020-04-30T11:15:56","guid":{"rendered":"http:\/\/4563.org\/?p=87222"},"modified":"2020-04-30T19:15:56","modified_gmt":"2020-04-30T11:15:56","slug":"macos-%e8%87%aa%e5%8a%a8%e5%88%87%e6%8d%a2-app-%e5%bd%93%e5%89%8d%e8%be%93%e5%85%a5%e6%b3%95%e5%b0%8f%e5%b7%a5%e5%85%b7-1-1-0-%e6%9b%b4%e6%96%b0","status":"publish","type":"post","link":"http:\/\/4563.org\/?p=87222","title":{"rendered":"MacOS \u81ea\u52a8\u5207\u6362 APP \u5f53\u524d\u8f93\u5165\u6cd5\u5c0f\u5de5\u5177 1.1.0 \u66f4\u65b0"},"content":{"rendered":"<div>\n<div>\n<div>\n<h1>                  MacOS \u81ea\u52a8\u5207\u6362 APP \u5f53\u524d\u8f93\u5165\u6cd5\u5c0f\u5de5\u5177 1.1.0 \u66f4\u65b0               <\/h1>\n<p> <\/p>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : leaves615 <\/span>  <span><i><\/i> 8<\/span> <\/div>\n<div> <\/div>\n<\/p><\/div>\n<\/p><\/div>\n<\/p><\/div>\n<div isfirst=\"1\">                        \u524d\u60c5\u63d0\u8981\uff1a<br \/>https:\/\/www.v2ex.com\/t\/624091 <\/p>\n<p>1.1.0 \u66f4\u65b0\u5185\u5bb9<br \/>\u589e\u52a0\u914d\u7f6e\u754c\u9762<br \/>\u652f\u6301\u914d\u7f6e\u9ed8\u8ba4\u8f93\u5165\u6cd5<br \/>\u652f\u6301\u6309 app \u914d\u7f6e app \u6fc0\u6d3b \/\u542f\u52a8\u65f6\u7684\u9ed8\u8ba4\u8f93\u5165\u6cd5<\/p>\n<p>\u4e0b\u8f7d\u94fe\u63a5\uff1a<br \/>https:\/\/github.com\/leaves615\/KeyboardHolder\/releases      <\/div>\n<div> <b>\u5927\u4f6c\u6709\u8a71\u8aaa<\/b> (<span>3<\/span>)        <\/div>\n<div> <\/div>\n<\/p><\/div>\n<\/p><\/div>\n<ul>\n<li data-pid=\"1371268\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : cookiejaysj <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             \u633a\u597d\u7528\u7684 \u652f\u6301\uff01                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"1371269\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u4e3b<\/span> <span>\u8cc7\u6df1\u5927\u4f6c : leaves615 <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             @cookiejaysj \u8c22\u8c22\u652f\u6301\u3002                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"1371270\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : nl101531 <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             \u53ef\u4ee5\u7528 Hammerspoon \u6765\u5b9e\u73b0\uff0c\u811a\u672c\u53ef\u4ee5\u6309\u7167\u4e0b\u9762\u65b9\u5f0f\u5199\uff0c\u5bf9\u4e8e Item \u7684\u6d6e\u52a8\u7a97\u53e3\u4e5f\u80fd\u5f88\u597d\u652f\u6301<\/p>\n<p>&#8220;`lua<\/p>\n<p>local function Chinese()<br \/> hs.keycodes.currentSourceID(&#8220;im.rime.inputmethod.Squirrel.Rime&#8221;)<br \/>end<\/p>\n<p>local function English()<br \/> hs.keycodes.currentSourceID(&#8220;com.apple.keylayout.ABC&#8221;)<br \/>end<\/p>\n<p>&#8212; app to expected ime config<br \/>local app2Ime = {}<br \/>app2Ime[&#8216;iTerm2&#8217;] = &#8216;English&#8217;<br \/>app2Ime[&#8216;Alfred 3&#8217;] = &#8216;English&#8217;<\/p>\n<p>function updateFocusAppInputMethod(appName)<br \/> local ime = &#8216;Chinese&#8217;<\/p>\n<p> if app2Ime[appName] then<br \/> ime = app2Ime[appName]<br \/> end<\/p>\n<p> if ime == &#8216;English&#8217; then<br \/> English()<br \/> else<br \/> Chinese()<br \/> end<br \/>end<\/p>\n<p>local focusedApp = {&#8216;iTerm2&#8242;,&#8217;Google Chrome&#8217;,&#8217;IntelliJ IDEA&#8217;,&#8217;IntelliJ IDEA-EAP&#8217;,&#8217;\u9489\u9489&#8217;,&#8217;Code&#8217;,&#8217;\u5e55\u5e03&#8217;}<\/p>\n<p>&#8212; \u89e3\u51b3\u56fa\u5b9a APP<br \/>hs.window.filter.new(focusedApp)<br \/> :subscribe(hs.window.filter.windowFocused,function (win, appName)<br \/> &#8211;print(&#8216;windowFocused&#8217;..appName)<br \/> updateFocusAppInputMethod(appName)<br \/>end)<\/p>\n<p>&#8212; \u89e3\u51b3\u6d6e\u52a8\u7a97\u53e3<br \/>hs.window.filter.new{&#8216;iTerm2&#8242;,&#8217;Alfred 3&#8217;}:subscribe(hs.window.filter.windowOnScreen,function (win, appName)<br \/> &#8211;print(&#8216;windowOnScreen&#8217;..appName)<br \/> updateFocusAppInputMethod(appName)<br \/>end):subscribe(hs.window.filter.windowNotOnScreen,function (win, appName)<br \/> local frontMostApp = hs.application.frontmostApplication()<br \/> updateFocusAppInputMethod(frontMostApp:name())<br \/>end)<\/p>\n<p>&#8220;`                                                            <\/p><\/div>\n<\/p><\/div>\n<\/li>\n<li>\n","protected":false},"excerpt":{"rendered":"<p>MacOS \u81ea\u52a8\u5207\u6362 APP \u5f53\u524d&hellip;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[],"tags":[],"_links":{"self":[{"href":"http:\/\/4563.org\/index.php?rest_route=\/wp\/v2\/posts\/87222"}],"collection":[{"href":"http:\/\/4563.org\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/4563.org\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/4563.org\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/4563.org\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=87222"}],"version-history":[{"count":0,"href":"http:\/\/4563.org\/index.php?rest_route=\/wp\/v2\/posts\/87222\/revisions"}],"wp:attachment":[{"href":"http:\/\/4563.org\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=87222"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/4563.org\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=87222"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/4563.org\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=87222"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}