Posts filed under ‘Operating System Tips’
Having fun with SSH, say and osascript!
Playing nerdy tricks on people always fun, especially if they are on a mac and you have SSH access to their machine
Below are some cool commands you can execute via ssh to amuse or frustrate an unsuspecting mac user!
Absolutely nasty:
sudo kill [program id learned from top]
Note: using ‘sudo open’ over ssh does not give the user super-user privileges for the opened application.
sudo halt
sudo reboot
sudo osascript -e 'tell app "[name of an open program]" to quit'
Power:
sudo osascript -e 'tell app "Finder" to sleep'
sudo osascript -e 'tell app "Finder" to shut down'
General:
sudo open /Applications/iChat.app
sudo osascript -e "set volume 0"
sudo osascript -e "beep"
sudo osascript -e 'display dialog "Did you know that you are annoying?" buttons "Yes" with icon note'
sudo osascript -e 'tell app "Finder" to quit'
sudo open [path to an application]
Speech:
sudo osascript -e 'say "[whatever]" using "Zarvox"'
sudo osascript -e 'say "Dum dum dum dum dum dum dum he he he ho ho ho fa lah lah lah lah lah lah fa lah full hoo hoo hoo" using "Cellos"'
iTunes Control:
sudo open /Applications/iTunes.app; sudo osascript -e 'say "Play some music. Go on. I dare you." using "Zarvox"'
sudo osascript -e 'tell app "iTunes" to stop' -e 'say "Please stop playing your annoying music" using "Zarvox"'
sudo osascript -e 'tell app "iTunes" to next track' -e 'say "I did not like that song very much" using "Zarvox"'
sudo osascript -e 'tell app "iTunes" to fast forward' -e 'say "This song is boring" using "Zarvox"'
sudo osascript -e 'tell app "iTunes" to quit'
Thanks to momerath for typing these up so that I didn’t have to! Sourced from Here!
Preventing OS X from creating .ds_stores
You may notice that when browsing Samba drives on OS X, a whole heap of little files named .ds_stores (Desktop Services Stores) are created. These are used by the operating system to meta data about the directory’s layout etc.
This may not be so much of a problem for us OS X users as these files are generally hidden, but when browsing the same directory from a Windows machine, you will see these files scattered all over the place. It can become quite annoying.
There is however a way to disable this behavior. Simply open your terminal, and paste the following command:
defaults write com.apple.desktopservices DSDontWriteNetworkStores true
Remember, if you ever need to re-enable these guys for some reason, you can execute the same command, replacing the true with false.
Screenshot Shortcuts in OSX
The ability to take a screenshot is fairly important no matter what you do with your computer. When it comes to screenshots in OSX, the functionality is there, but it isn’t quite intuitive. In Windows we have a ‘Print Screen’ button, but what about on a mac? Anyways the following shortcuts will surely get you on your way.
Cmd + Shift + 3:
Takes a screenshot of the entire screen, and save it to the desktop
Cmd + Shift + 4 + Area Selection:
- This will take a screenshot of an area that you select by dragging the mouse, and saves it to the desktop
Cmd + Shift + 4 + Space + Window Selection:
- Takes a screenshot of the selected window and saves it to the desktop
Cmd + Ctrl + Shift + 3:
- Takes a screenshot of the entire screen, and saves it to the clipboard
Cmd + Ctrl + Shift + 4 + Area Selection:
- Takes a screenshot of an area that you select by dragging the mouse, and saves it to the clipboard
Cmd + Ctrl + Shift + 4 + Space + Window Selection:
- Takes a screenshot of the selected window and saves it to the clipboard
Have fun!
How to silence the OSX Startup Chime
Many of you with Macbooks will most likely be aware of the annoyance of the OSX startup tone chiming away when you boot up your computer in public places. Yes it is annoying, and no, there is no built-in way to shut it up.
However, you will be relieved to know that there is a System Preferences add-on that will allow allow such modifications. Its written by a group known as Arcadia, and is simply called StartupSound.prefPane, and can be downloaded from here!
Once installed, just visit your System Preferences and click on the Start Up Sound icon at the bottom. This will bring up a window like the following:

Adjust to your preference, and you’re done!
Quicklook and Terminal
Most (if not all) users of OS X will be familiar with the Quicklook feature that was introduced with 10.5 (Leopard). Basically, by selecting a file / icon, and pressing the spacebar, you can be shown a preview of the file without having to go through the painstaking ordeal of opening the default application (ie Adobe Acrobat). This works well with most file types including images, pdf documents, videos, .plist files etc.
What you may not have known is that Quicklook can be invoked from within the terminal too. The syntax is simple:
$ qlmanage -p [file]
and can be closed with a simple ctrl + c. For more info checkout the quicklook man page.
All about Applescript
I have recently been doing some playing around with Applescript, and I have found it to be really simple to use, yet powerful. For this reason, I thought I would share with you some of what I have learned.
What is AppleScript?
AppleScript is a scripting language developed by Apple that they have built into the mac operating system since system 7 (otherwise known as OS 7).
It is similar to pseudo code in that it uses human readable terms and commands, and it uses these to invoke operating system events and actions.
A basic script will generally consist of 2 parts, a “tell” construct, that will signify which application is being referenced, and then a command, or list of commands that we will send that application. For example:
tell application "iTunes" stop end tell
or similarly
tell application "Safari" to quit
What can AppleScripts be used for?
Applescripts are most commonly used to kick off an application or script, or tell one to perform a certain task. For example, they could be used to kick off a shell script, tell iTunes to skip the current song, or tell the operating system to display the screen saver. The possibilities are limited only by the application in question.
How do I create AppleScripts?
OS X ships with a built in editor for Applescripts, funnily enough it is called AppleScript Editor and is located in /Applications/Utilities. This editor gives you the ability to create Applescripts, as well as record, compile and run them for testing / debugging purposes.
How do i know what applications accept what commands?
Dictionaries. The AppleScript Editor contains a handy little function that allows you to view the dictionaries for all compatible applications installed on your computer. To access this, open the editor, and press File -> Open Dictionary…
These dictionaries show you all the available commands for each application, as well as provide usage information for each.
How can i execute my AppleScript outside of the editor?
Of course AppleScripts would be a wh0le lot more useful if you have some way of executing it on demand or by an operating system event or trigger. Some commonly used methods include the following:
- Shortcut Keys
Now, for some reason the Apple’s implementation of keyboard shortcuts relating to Applescripts is very dodgy. Using Automator is the best method that I have found, this was introduced in 10.4 (Tiger).
Firstly, open Automator. It is located in /Applications. You will need to create a new ‘Service’.
Next, you will need to choose an action for this service to perform. We will be using ‘Run Applescript’ so enter this into the filter input field to simplify selection.
You will be given a blank Applescript template that you can use to create your script. Note, you can test your script using the run button in the above right corner.
Next save the service. Now that we have created a service using our Applescript, we can create a keyboard shortcut. From System Preferences select ‘Keyboard’ (‘Keyboard and Mouse’ for pre Snow Leopard versions) .
On the left menu, you will see ‘Services’. Select this and scroll down to find your recently created script. Here you will want to double click on the white space in the right column. These columns are not clearly defined, but you should be able to see other keyboard shortcuts in the same vertical alignment.
You will then be given a field to enter your shortcut. Do this, and you’re done! Close the window and give it a try!
- User Login
You can also set an Applescript of your choosing to execute upon user login. To do this, simply browse to ‘System Preferences’ and select ‘Accounts’. Click the ‘Login Items’ tab, and add your script using the ‘+’ button on the screen. Easy.
Useful Applescripts
If you have any useful Applescripts you have written or stumbled across, let me know and I’ll add them here for all to see.
later.
Simple iPhone 3.x Tethering
Something you may not know about the iPhone, is that with the release of the 3.0 software came the ability to simply share your iPhone’s internet connection with another device – something known as tethering.
Anyways if you signed up to the Optus network like me, you were probably offered a ‘tethering package’ that most likely came at a ridiculous price (up to $10 per month). A price which seems even more outrageous when you consider that to allow tethering, a setting just needs to be enabled on the phone. Anyways here is how to get around this little scam:
Firstly, on your iPhone, use Safari to navigate to: http://help.benm.at/help.php
Scroll a little down the page until you see the section ‘Tethering and Internet Settings’. For simplicities sake, you can use a pre-defined mobileconfig file, so click download.
Next, select your country, and then select your provider as shown below:
Then click ‘Install’:
Following a successful install, navigate your iPhone to your Settings -> General -> Network and you should now see a new menu ‘Internet Tethering’
Click on this, and switch it to ‘On’

Now you can choose to tether via Bluetooth or USB. For the purpose of this entry, I selected USB, and my Macbook Pro immediately detected the shared network and allowed me to connect to it
As for performance, well it seems to function quite well! I actually posted this entry whilst tethering!
At this point I probably should warn you that tethering is a GREAT way to use up your download allowance, and ensures a nice healthy phone bill is waiting for you at the end of the month.. be careful
Any questions feel free to ask!
My switch to Snow Leopard
The Install
Last week I was lucky enough to be given a copy of the latest version of OSX, Snow Leopard. After running a quick Time Machine backup, I threw in the disk, and the update was quickly underway. As per all updates and installations on OSX, everything was ridiculously easy and logical.
Anyways the installation didn’t take too long, and as soon as it finished I quickly ran the software update and updated the lot – giving me a fresh, up to date operating system
The OS
To look at, everything was exactly the same, obviously as this update was not aimed at graphical user interface upgrades. Anyways first thing I did was jump on the nearest wireless network, and I immediately noticed a cool little improvement with the available wireless network display. As you can see below, there has been a small update allowing the user to see the signal strength of each network in the list; quite handy (not the best example image but you get the idea).
Anyways after playing around I quickly became aware of how much faster the operating system was running. Opening programs, using spaces and expose, literally EVERYTHING is twice as fast as before.
Expose has a cool new feature – when showing all windows, it now includes minimised windows as well! These guys show up down the bottom below a horizontal rule.
The latest version of Safari, 4, is now insanely fast, with upgrades to the javascript engine making it up to 6 times faster than IE8 and 4 times faster than Firefox 3.1. Oh, and Safari 4 was the first web browser to get 100 on the acid3 test, meaning it can now fully render pages exactly to web standards
Other new features to the OS include the addition of Quicktime 10, some new customisation options for spotlight, and finally finder provides a long overdue ‘cut’ command! There are apparently a whole heap of benefits for developers, but I am yet to find some time to check these out
Anyways I’ll keep this list updated with any cool features or issues I may stumble across . As yet I am still to find issues, although I’m sure there are plenty floating around.
cheers.


















