Quicksilver Large Type - bash

You know how you can make Quicksilver display massive large type on your screen? (By Hitting . then typing free text, select View Large Type under actions and hit Enter).
Well, does anyone know of a way to do that programmatically? Also, is quicksilver even required or is it built into OS X? I would love to be able to trigger that from bash.

You can do this with Applescript, so therefore you can so it in bash with the osascript command:
osascript -e 'tell application "Quicksilver" to show large type "Hello, world."'
I think that "Large Type" was previously available in the services menu, but I don't see it in Snow Leopard. I might be wrong about that. A similar feature is found in Address Book -- right click on a telephone number.

There's no special sauce here. It's putting up a window with the text you type displayed in a large font. Duplicating the effect in a Cocoa app is trivial.

If you like to know how they exactly implemented it, you can look at the global method QSShowLargeType in their source here:
https://github.com/quicksilver/Quicksilver/blob/master/Quicksilver/Code-QuickStepInterface/QSLargeTypeDisplay.m

You could do it inside your browser with large-type.com:
$ open http://large-type.com/#YourText

It is confirmed to be fixed in the next release (after b56a7). Better keep an eye on the download area:
http://code.google.com/p/blacktree-alchemy/downloads/list

Related

Clear Recent items in Preview Application of Mac OS X..?

Hello all,
Can anyone tell me how to clear the 'Recent items' list in Preview application of Mac OS X through code? Is there a terminal command that can do this?
Or is there any way to click on 'Clear Menu' in 'Open Recent' of the 'File' menu in Preview?
Alternatively, does someone know where Preview stores this information and how do to remove it?
Check out this image to see what I mean.
Ok, so none of the described methods on the websites I could find actually succeeded in getting rid of all the 'recent document' lists in all of my apps.
I feel the most common sense approach would be (for OSX 10.12 / Sierra):
First go to system settings > general and choose "none" in the recent file dropdown menu (my OSX is in another language so the exact terms might be different, but you should be able to see what I mean). / This will get rid of most, but not all recent-items in different apps.
Get familiar with Apple's 'defaults' command in terminal. Now, hunt for any lists you might still want to get rid off, e.g. none of the options mentioned in the answers already listed here helped to get rid of the recent-items list in Finders "GO" menu. I played around with the defaults command and found that: "write com.apple.finder "FXRecentFolders" '({})' && killall Finder" does the trick for me. Playing around I found similar solutions for many of the other apps that where still able to maintain a list of recent items.
Create a shell script containing the commands you found during step 2.
Schedule the script to be run automatically on a preset interval or action (e.g. log out). AND/OR create an alias in your shell's profile (or directly apply the script as a function inside it) so you can call it with a single command from your terminal. (for instance: I have created an alias to it, so when I now type "killrecent" in terminal, it empties all the recent-items lists I've been able to find.
Hope this will be of some help to others. Good luck!
open Preview ->- go to File ->- Open Recent ->- Clear Menu
You may try the approach outlined here, which is to run
defaults delete com.apple.Preview.LSSharedFileList RecentDocuments
in the Terminal (manually or through your app). However I tried this and it didn't work for me (OSX 10.11), since the Preview defaults file doesn't contain this entry.
You can use
defaults write com.apple.Preview NSRecentDocumentsLimit 0
which will hide all recently used items, but as soon as you set that number to anything greater than 0, they will show up again.
I also checked the ScriptingBridge Interface for Preview, but couldn't find anything useful. So unfortunately it looks like this is not possible.
with 10.11, there are at
~/Library/Application\ Support/com.apple.sharedfilelist/com.apple.LSSharedFileList.ApplicationRecentDocuments/com.apple.preview.sfl

Putting the display to sleep (⇧⌃⏏/shift+control+eject) in AppleScript

Is it possible to write an AppleScript to put the display to sleep (which locks the display if the computer is set to lock on sleep)? You can do this from the keyboard by entering ⌃⇧⏏ (shift+control+eject); this leaves all the programs, etc., running, and just turns off the screen.
I've been wanting to do this for a while now. I just found out how in the man pages. You can use the following command to achieve instant display sleep. (I have tested it on OS X 10.10.)
pmset displaysleepnow
(no root privileges / sudo required!)
I'm not sure if this works for 10.9.4 yet but by all means give it a shot!
you can use: tell application "Finder" to sleep
Or use bettertouchtool. It is a small app which you can use native functions in addition to applescript.
do shell script "pmset displaysleepnow"
Edit 2015-08-23: This is possible (from the shell) as of OS X 10.9! Go see user3064009's answer for the update :-)
There's no good way to do this; there's a SuperUser question about this same thing. Depending on why you want this, however, there's one workaround I know: activate the screen saver. (This is what they suggest over on SuperUser). You can do this in AppleScript with launch application id "com.apple.ScreenSaver.Engine", or from the command line by running the application /System/Library/Frameworks/ScreenSaver.framework/Resources/ScreenSaverEngine.app/Contents/MacOS/ScreenSaverEngine. I don't know whether or not this is technically documented anywhere, but it's worked for several iterations of the OS now. It may not do exactly what you want—your screen saver may, for instance, be colorful, which isn't helpful if you want a black screen—but it will be the same in that it does lock the screen if you have that set up.
For a nice catalog of other workarounds, check out this MacScripter thread: it documents that
There's no scriptable way to do this.
You can't tell AppleScript to key code EJECT, as there's no such key code.
You can use pmset to tell the display to go to sleep in one minute, but then you have to wait.
There's an undocumented IOKit way to do this; there's a mailing list post explaining how.
I haven't found an easy way to do it programmatically, but I did find a very small, free app that puts the display immediately to sleep, called "SleepDisplay." (There is another app of the same name that did NOT work for me.)
So you can just
tell application "SleepDisplay" to activate
Link: http://www.macupdate.com/app/mac/26234/sleep-display

Open an application in a space using applescripts

I am trying to create a script that will open an application in a specific "space". So let's say I am on space 1 working in the terminal and then I want to be able to open safari in space 4. Is there a way to do this?
I have done some searching and found only ways to set the system profile options. Maybe I should tell you my end goal in case what I am attempting is not possible.
I use a laptop and plugin in to multiple stations, home, office, and travel. I want to create different window layouts for each one. So I will need an apple script telling it to open applications in varios spaces and different dimensions. I hope this makes sense. Ask me for clarification if it doesn't thanks!
PS the answer doesn't necessarily have to be any applescript I just thought that would be the easiest way :)
Here's a list of applescript commands for Spaces. There's a couple things there that might help you.
It is possible to do some scripting of application Space preferences by using the scripting interface to the System Events.app. See the answer to a similar question here.
The easiest way I've found is via GUI scripting. Make sure the Spaces menu is active on the upper right of your computer. That lists the spaces by number. You can then just write a GUI script to select the menu item of the space you wish. That will switch to that space. Then do an activate Applescript to open the application there.
Let me know if you need sample code demonstrating this. I have some in Python + Appsscript that does this but I should be easily able to convert it back to Applescript proper if you need it.

Creating quick GUI front ends

I wanted to have a GUI front-end for a script that accepts numerous command-line options, most of them are UNIX paths. So I thought rather than typing them in (even with auto-completion) every time, I'd create a GUI front end which contains text boxes with buttons beside them, which when clicked will invoke the file browser dialogue. Later, I thought I'd extend this to other scripts which would sure require a different set of GUI elements. This made me think if there's any existing app that would let me create a GUI dialog, after parsing some kind of description of the items that I want that window should contain.
I know of programs like Zenity, but I think it's doesn't give me what I want. For example, if I were to use it for the first script, it'll end up flashing sequence of windows in succession rather than getting everything done from a single window.
So, basically I'm looking at some corss-platform program that lets me create a window from a text description, probably XML or the like. Please suggest.
Thanks
Jeenu
Mozilla's XUL is a cross platform application framework - . You could write an app as a Firefox plugin or a standalone XUL application.
mono and monodevelop could work for this. Or even something super simple like shoes.

run applescript on 2x-click

OK, this feels like an idiot question, but I'm stuck - I don't know the first thing about AppleScript. I have a .scpt file and I want to double-click it and just have it run, but instead every time I click, it opens up the AppleScript Editor. This feels like it should just be an option on the file, but I'm missing something obvious.
Please help me feel less dumb, thank you.
From the “File” menu, choose “Export”; there’ll be a “File Format” dropdown underneath the file browser. To get a double-clickable application instead of a document, choose “Application”. This will produce a .app bundle like ordinary Mac applications (this will also let you package other resources with your script if you need to). You can choose “Run Only” or not; if you do, then anybody with just the .app won’t be able to edit your script further, since it’ll be compiled. (But if you’re saving a copy as the application, that might be what you want.)
Another option, as per an anonymous user on Ask Different, would be to save/export your file as a “Script” (.scpt) or “Script Bundle” (.scptd), save it in ~/Library/Scripts/, and check “Show Script menu in menu bar” in Script Editor’s preferences.
(If you’re running an old version of OS X, the first version of this answer has the information you’re looking for.)
There's more than one way to do it; i have found this to be the simplest:
In sum, you create an Automator application and place your applescript inside it (easier than it sounds, and it's not a hack either--there's actually a specific Automator action for this). Then when you are finished, you select "File" from the menubar, next "Save As Application", then select a location. Now check there and you'll see the newly-created Automator icon (little white robot holding a grenade launcher).
You can do anything that you would ordinarily do with this application icon--double click to open, drag it to your dock, etc.
Appstorm has created an excellent step-by-step tutorial for building an applescript-embedded automator action. On the page i linked to, the tutorial author has also supplied an Automator script that you can download and use as a template.
While it's certainly not the simplest route, one benefit to running your script from Automator, as doug suggested, is that you can set a hotkey or keyboard shortcut to execute your script if you hide it in an Automator Service (OSX 10.6+). See:
http://blog.fosketts.net/2010/08/09/assign-keyboard-shortcut-applescript-automator-service/
When you save a new script, a menu should appear asking what you want the file name to be, where it will be stored, any tags for it, and what script format you want it to be. There should be 4 scripts formats:
Script
Script Bundle
Application
Text
The script format you want to use would be "Application." This will turn it into a double-click application if its not in the dock.

Resources