X-Git-Url: http://47.100.26.94:8080/?a=blobdiff_plain;f=scripts%2Femacs_toggle.applescript;h=4873117d302066e98e36a9165c4fc8926390c31f;hb=b2725076c59211d49274c0c124df06abb7defb0f;hp=d3bbe3b1ca541255cf0b41762912c75e4b33da2a;hpb=512b2880e283c38095954db422531ad81da4dc9e;p=dotfiles.git diff --git a/scripts/emacs_toggle.applescript b/scripts/emacs_toggle.applescript index d3bbe3b..4873117 100644 --- a/scripts/emacs_toggle.applescript +++ b/scripts/emacs_toggle.applescript @@ -1,10 +1,31 @@ + +## this scirpt works together with Quicksilver +## copy/link this file to ~/Library/Application Support/Quicksilver/Action +## and set a toggle event on Quicksilver preference +#tell application "System Events" +# tell application process "Emacs" +# if visible then +# set visible to false +# else +# set visible to true +# tell application "Emacs" to activate +# end if +# end tell +#end tell +# +## http://brettterpstra.com/2011/01/22/quick-tip-applescript-application-toggle/ +set appName to "Emacs" +set startIt to false tell application "System Events" - tell application process "Emacs" - if visible then - set visible to false - else - set visible to true - tell application "Emacs" to activate - end if - end tell + if not (exists process appName) then + set startIt to true + else if frontmost of process appName then + set visible of process appName to false + else + set frontmost of process appName to true + end if end tell +if startIt then + tell application appName to activate +end if +