{"id":956,"date":"2015-09-03T12:42:00","date_gmt":"2015-09-03T18:42:00","guid":{"rendered":"http:\/\/islascruz.org\/blog\/?p=956"},"modified":"2016-11-29T17:15:38","modified_gmt":"2016-11-29T23:15:38","slug":"modify-preferences-using-alfredosascript","status":"publish","type":"post","link":"https:\/\/islascruz.org\/blog\/2015\/09\/03\/modify-preferences-using-alfredosascript\/","title":{"rendered":"Modify preferences using Alfred+OsaScript"},"content":{"rendered":"<p><a href=\"http:\/\/islascruz.org\/blog\/wp-content\/uploads\/2015\/09\/1441304401_full.png\" target=\"_blank\"><img decoding=\"async\" class=\"aligncenter\" src=\"http:\/\/islascruz.org\/blog\/wp-content\/uploads\/2015\/09\/1441304401_thumb.png\" alt=\"\" align=\"middle\" \/><\/a><\/p>\n<p>Since I start using OS X I\u2019ve never been a \u201cspotlight\u201d user. Althought it is there and never really used it as my daily driver, for some time I used <a href=\"http:\/\/qsapp.com\/\" target=\"_blank\" rel=\"noopener\">QuickSilver<\/a> because when I was using Linux I used <a href=\"http:\/\/do.cooperteam.net\/\" target=\"_blank\" rel=\"noopener\">GNOME do<\/a>, but then I switched to <a href=\"https:\/\/www.alfredapp.com\/\" target=\"_blank\" rel=\"noopener\">Alfred<\/a>. The main reason is that is super fast and let me execute custom commands from a couple of key strokes.<\/p>\n<p><!--more--><\/p>\n<p>Alfred have several features by default, like searching in files\/folders (using spotlight API) or the Web by opening the browser and Google to the search terms. The calculator, and one of the things that I use<strong> all day every day<\/strong>: The Clipboard, super useful.<\/p>\n<p><a href=\"http:\/\/islascruz.org\/blog\/wp-content\/uploads\/2015\/09\/1441304818_full.png\" target=\"_blank\"><img decoding=\"async\" class=\"alignright\" src=\"http:\/\/islascruz.org\/blog\/wp-content\/uploads\/2015\/09\/1441304818_thumb.png\" alt=\"\" align=\"right\" \/><\/a>But today I\u2019m going to talk about the Workflows, workflows let you create custom commands, like the one that let me tweet from alfred, open a custom page by using a keyword, tweet the itunes current song and today I made a small script to switch my settings in Mission Control to disable and enable hot corners.<\/p>\n<p>First of all, the hot corners feature is a must to me, I\u2019ve used it when I was using Linux with Compiz, is super fast to have all open windows and choose the one I want (although in OS X when you are in \u201cexpos\u00e9\u201d mode it would be great to let you type and filter with using the application name). So, I use hot corners a lot. I also use virtual machines, and I use them in full screen, so when the mouse points to the hot corner then it enters in expos\u00e9 mode, the worse is that when I click again in the virtual machine the mouse points to the hot corner again and the loop beings.<\/p>\n<p><a href=\"http:\/\/islascruz.org\/blog\/wp-content\/uploads\/2015\/09\/1441305230_full.png\" target=\"_blank\"><img decoding=\"async\" class=\"aligncenter\" src=\"http:\/\/islascruz.org\/blog\/wp-content\/uploads\/2015\/09\/1441305230_thumb.png\" alt=\"\" align=\"middle\" \/><\/a><\/p>\n<p>So, when using the virtual machine (Windows to play or to do some windows exclusive thing), I have to disable hot corners and when I finish re-enable hot corners which is a PITA when you have to do it continuously.<\/p>\n<p>So, I made this custom command, which is basically <a href=\"https:\/\/developer.apple.com\/library\/mac\/documentation\/Darwin\/Reference\/ManPages\/man1\/osascript.1.html\" target=\"_blank\" rel=\"noopener\">osascript<\/a> launched with an Alfred command<\/p>\n<p><a href=\"http:\/\/islascruz.org\/blog\/wp-content\/uploads\/2015\/09\/1441305576_full.png\" target=\"_blank\"><img decoding=\"async\" class=\"aligncenter\" src=\"http:\/\/islascruz.org\/blog\/wp-content\/uploads\/2015\/09\/1441305576_thumb.png\" alt=\"\" align=\"middle\" \/><\/a><\/p>\n<h3>The Script<\/h3>\n<pre class=\"lang:python decode:1 \" >\nset settings1 to {&quot;Mission Control&quot;, &quot;-&quot;, &quot;-&quot;, &quot;Mission Control&quot;} -- for example\nset settings2 to {&quot;-&quot;, &quot;-&quot;, &quot;-&quot;, &quot;-&quot;} -- for example\n\ntell application &quot;System Preferences&quot;\n    reveal pane id &quot;com.apple.preference.expose&quot;\n    activate\n    tell application &quot;System Events&quot;\n        tell window &quot;Mission Control&quot; of process &quot;System Preferences&quot;\n            click button &quot;Hot Corners\u2026&quot;\n            tell sheet 1\n                tell group 1\n                    if value of pop up buttons is settings1 then\n                        set theSettings to settings2\n                        set functionKeys to false\n                    else\n                        set theSettings to settings1\n                        set functionKeys to true\n                    end if\n                    repeat with k from 1 to 4\n                        set theValue to item k of theSettings\n                        tell pop up button k\n                            if value is not theValue then\n                                click\n                                click menu item theValue of menu 1\n                            end if\n                        end tell\n                    end repeat\n                end tell\n                click button &quot;OK&quot;\n            end tell\n        end tell\n    end tell\n    quit\nend tell\n<\/pre>\n<h3>How does it looks?<\/h3>\n<p>Like this.<\/p>\n<p>[KGVID]http:\/\/islascruz.org\/blog\/wp-content\/uploads\/2015\/09\/Screeny-Video-Sep-3-2015-1.40.23-PM.mov[\/KGVID]<\/p>\n<p>It have to open the preferences pane and move around the buttons and options but it does automatically, and in a couple of seconds \ud83d\ude09<\/p>\n<h3>At the end<\/h3>\n<p>So, as you can see the script is not dynamic, because I want to have hot corners disabled or enabled depending on what I need, but you can tweak it to use whatever you want.<\/p>\n<p>That\u2019s just an example, you can write your own even in other languages like PHP, BASH, Python or any other by using the appropriate interpreter. But please, don\u2019t make a \u201c<strong>Launch Nuclear Bomb<\/strong>\u201d script and if you do it, share with the others \ud83d\ude09<\/p>\n<div class=\"pvc_clear\"><\/div>\n<p id=\"pvc_stats_956\" class=\"pvc_stats all  \" data-element-id=\"956\" style=\"\"><i class=\"pvc-stats-icon medium\" aria-hidden=\"true\"><svg aria-hidden=\"true\" focusable=\"false\" data-prefix=\"far\" data-icon=\"chart-bar\" role=\"img\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" viewBox=\"0 0 512 512\" class=\"svg-inline--fa fa-chart-bar fa-w-16 fa-2x\"><path fill=\"currentColor\" d=\"M396.8 352h22.4c6.4 0 12.8-6.4 12.8-12.8V108.8c0-6.4-6.4-12.8-12.8-12.8h-22.4c-6.4 0-12.8 6.4-12.8 12.8v230.4c0 6.4 6.4 12.8 12.8 12.8zm-192 0h22.4c6.4 0 12.8-6.4 12.8-12.8V140.8c0-6.4-6.4-12.8-12.8-12.8h-22.4c-6.4 0-12.8 6.4-12.8 12.8v198.4c0 6.4 6.4 12.8 12.8 12.8zm96 0h22.4c6.4 0 12.8-6.4 12.8-12.8V204.8c0-6.4-6.4-12.8-12.8-12.8h-22.4c-6.4 0-12.8 6.4-12.8 12.8v134.4c0 6.4 6.4 12.8 12.8 12.8zM496 400H48V80c0-8.84-7.16-16-16-16H16C7.16 64 0 71.16 0 80v336c0 17.67 14.33 32 32 32h464c8.84 0 16-7.16 16-16v-16c0-8.84-7.16-16-16-16zm-387.2-48h22.4c6.4 0 12.8-6.4 12.8-12.8v-70.4c0-6.4-6.4-12.8-12.8-12.8h-22.4c-6.4 0-12.8 6.4-12.8 12.8v70.4c0 6.4 6.4 12.8 12.8 12.8z\" class=\"\"><\/path><\/svg><\/i> <img loading=\"lazy\" decoding=\"async\" width=\"16\" height=\"16\" alt=\"Loading\" src=\"https:\/\/islascruz.org\/blog\/wp-content\/plugins\/page-views-count\/ajax-loader-2x.gif\" border=0 \/><\/p>\n<div class=\"pvc_clear\"><\/div>\n","protected":false},"excerpt":{"rendered":"<p>Since I start using OS X I\u2019ve never been a \u201cspotlight\u201d user. Althought it is there and never really used it as my daily driver, for some time I used QuickSilver because when I was using Linux I used GNOME do, but then I switched to Alfred. The main reason is that is super fast [&hellip;]<\/p>\n<div class=\"pvc_clear\"><\/div>\n<p id=\"pvc_stats_956\" class=\"pvc_stats all  \" data-element-id=\"956\" style=\"\"><i class=\"pvc-stats-icon medium\" aria-hidden=\"true\"><svg aria-hidden=\"true\" focusable=\"false\" data-prefix=\"far\" data-icon=\"chart-bar\" role=\"img\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" viewBox=\"0 0 512 512\" class=\"svg-inline--fa fa-chart-bar fa-w-16 fa-2x\"><path fill=\"currentColor\" d=\"M396.8 352h22.4c6.4 0 12.8-6.4 12.8-12.8V108.8c0-6.4-6.4-12.8-12.8-12.8h-22.4c-6.4 0-12.8 6.4-12.8 12.8v230.4c0 6.4 6.4 12.8 12.8 12.8zm-192 0h22.4c6.4 0 12.8-6.4 12.8-12.8V140.8c0-6.4-6.4-12.8-12.8-12.8h-22.4c-6.4 0-12.8 6.4-12.8 12.8v198.4c0 6.4 6.4 12.8 12.8 12.8zm96 0h22.4c6.4 0 12.8-6.4 12.8-12.8V204.8c0-6.4-6.4-12.8-12.8-12.8h-22.4c-6.4 0-12.8 6.4-12.8 12.8v134.4c0 6.4 6.4 12.8 12.8 12.8zM496 400H48V80c0-8.84-7.16-16-16-16H16C7.16 64 0 71.16 0 80v336c0 17.67 14.33 32 32 32h464c8.84 0 16-7.16 16-16v-16c0-8.84-7.16-16-16-16zm-387.2-48h22.4c6.4 0 12.8-6.4 12.8-12.8v-70.4c0-6.4-6.4-12.8-12.8-12.8h-22.4c-6.4 0-12.8 6.4-12.8 12.8v70.4c0 6.4 6.4 12.8 12.8 12.8z\" class=\"\"><\/path><\/svg><\/i> <img loading=\"lazy\" decoding=\"async\" width=\"16\" height=\"16\" alt=\"Loading\" src=\"https:\/\/islascruz.org\/blog\/wp-content\/plugins\/page-views-count\/ajax-loader-2x.gif\" border=0 \/><\/p>\n<div class=\"pvc_clear\"><\/div>\n","protected":false},"author":1,"featured_media":955,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[6,2],"tags":[7],"class_list":["post-956","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-apple","category-personal","tag-os-x"],"brizy_media":[],"_links":{"self":[{"href":"https:\/\/islascruz.org\/blog\/wp-json\/wp\/v2\/posts\/956","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/islascruz.org\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/islascruz.org\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/islascruz.org\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/islascruz.org\/blog\/wp-json\/wp\/v2\/comments?post=956"}],"version-history":[{"count":11,"href":"https:\/\/islascruz.org\/blog\/wp-json\/wp\/v2\/posts\/956\/revisions"}],"predecessor-version":[{"id":3130,"href":"https:\/\/islascruz.org\/blog\/wp-json\/wp\/v2\/posts\/956\/revisions\/3130"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/islascruz.org\/blog\/wp-json\/wp\/v2\/media\/955"}],"wp:attachment":[{"href":"https:\/\/islascruz.org\/blog\/wp-json\/wp\/v2\/media?parent=956"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/islascruz.org\/blog\/wp-json\/wp\/v2\/categories?post=956"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/islascruz.org\/blog\/wp-json\/wp\/v2\/tags?post=956"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}