{"id":1207,"date":"2015-09-11T10:11:50","date_gmt":"2015-09-11T06:11:50","guid":{"rendered":"http:\/\/www.celmaro.com\/bl\/?p=1207"},"modified":"2015-09-11T10:13:04","modified_gmt":"2015-09-11T06:13:04","slug":"using-the-plug-spy-2-applescript-action","status":"publish","type":"post","link":"https:\/\/www.celmaro.com\/bl\/?p=1207","title":{"rendered":"Using the Plug Spy 2 AppleScript Action"},"content":{"rendered":"<p>Some weeks ago we have added an AppleScript action to Plug Spy. With AppleScript it will be\u00a0able to do\u00a0anything you would like to do including automatically formatting\u00a0your hard drive after unexpected activity is detected. Here I will explain how you can set up an AppleScript to work with Plug Spy.<\/p>\n<p><!--more--><\/p>\n<p>Thee first thing you would do is to \u00a0open the &#8220;Action-Set&#8221; Preferences panel and select\u00a0the desired preset. After you have setup the rules which will trigger the alert you\u00a0can activate the AppleScript action by selecting it in the popup menu on the right. The\u00a0AppleScript action will appear in the action pane and is ready to be customised. Click the action to open the settings popover and open the Script handler menu. If there is no script in the script folder of Plug Spy you have to open the &#8220;Plug Spy Apple Script&#8221; folder to add a script in Finder. You may now that since Mavericks\u00a0Apps are only able to use an AppleScript if it is placed in a folder related to the application.<\/p>\n<p>To create\u00a0an Apple Script you will use the\u00a0Script Editor which is by default available on your Mac. There are plenty of sources in the internet which explain and show you how to write an Apple Script.\u00a0If you have an idea what the script should do the best way is a search a template script and modify it until if accomplish\u00a0your needs. To get the script work with Plug Spy you will have to define a function named<\/p>\n<p>plugSpy_action(message) to place your script inside. This function will be called whenever the action is triggered. The message parameter will contain a string\u00a0with the\u00a0current sensor activity. The return value should be &#8220;OK&#8221; but is currently not evaluated in Plug Spy.<\/p>\n<p>Example script:<\/p>\n<p><b>on<\/b> plugSpy_action(message)<\/p>\n<p><b>\u00a0 \u00a0 display dialog<\/b> message<\/p>\n<p><b>\u00a0 \u00a0 return<\/b> &#8220;ok&#8221;<\/p>\n<p><b>end<\/b> plugSpy_action<\/p>\n<p>&nbsp;<\/p>\n<p>When you are\u00a0ready with the script, place it in the Plug Spy script folder and select it in the Apple Script action settings script handler menu.\u00a0If you are done you can test the script with the test button. Please consider that under normal circumstances there is a maximum of 15 seconds to run the script after\u00a0the lid get closed before your Mac Book will sleep. Of course you can install a kernel extension\u00a0like NoSleep or InsomniaX for Mac to prevent your computer from sleep.<\/p>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Some weeks ago we have added an AppleScript action to Plug Spy. With AppleScript it will be\u00a0able to do\u00a0anything you would like to do including automatically formatting\u00a0your hard drive after unexpected activity is detected. Here I will explain how you can set up an AppleScript to work with Plug Spy.<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[15,1],"tags":[],"class_list":["post-1207","post","type-post","status-publish","format-standard","hentry","category-plug-spy","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/www.celmaro.com\/bl\/index.php?rest_route=\/wp\/v2\/posts\/1207","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.celmaro.com\/bl\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.celmaro.com\/bl\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.celmaro.com\/bl\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.celmaro.com\/bl\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=1207"}],"version-history":[{"count":3,"href":"https:\/\/www.celmaro.com\/bl\/index.php?rest_route=\/wp\/v2\/posts\/1207\/revisions"}],"predecessor-version":[{"id":1211,"href":"https:\/\/www.celmaro.com\/bl\/index.php?rest_route=\/wp\/v2\/posts\/1207\/revisions\/1211"}],"wp:attachment":[{"href":"https:\/\/www.celmaro.com\/bl\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=1207"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.celmaro.com\/bl\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=1207"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.celmaro.com\/bl\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=1207"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}