Tag Archives: Mac OS X

Applescript application interface command line mplayer

Many high quality (e.g. 1080p) movies take significant system resources to play. A GUI wrapper application only adds an extra middle man. The command line version of mplayer is very fast and has served me well many times. I am a huge fan of the command line but sometimes I just want to double click or drag and drop.

You first need to install macports and then install mplayer by typing

$ sudo port install mplayer

Here Is what I threw together:

on open movies

    — Play each file in the list of files to open.
    repeat with movie in movies

        — Convert alias to conventional path.
        set moviepath to quoted form of ¬
            (POSIX path of (movie as Unicode text))

        — play the file with mplayer.
        set command to "/opt/local/bin/mplayer " & moviepath

        do shell script command

    end repeat

end open

Open the script in Script Editor.app and save it as an Application. Unfortunately you can’t double click anything and open it with this but you can drag and drop as well as select open with.

Well it is not all that impressive but for large movie file you can’t beat mplayer on the command line.

Sweave Engine for TeXShop

Sweave is an awesome utility for including the output of R code in a LaTeX document which I have started using regularly.

TeXShop is my favorite editor/viewer for LaTeX under Mac OS X for many reasons. One of which is the speed of the edit -> compile -> view process which it enables. Therefore, I have been reluctant to use Sweave in the past because of the extra LaTeX compilation step that is not supported by default in TeXShop.

Recently, my friend Charlie Sharpsteen first showed me this way to get around this with a custom “engine”. The engine file looke like this:



export PATH=$PATH:/usr/texbin:/usr/local/bin
R CMD Sweave "$1"
pdflatex "${1%.*}"

Place this file in ~/Library/TeXShop/Engines/, make sure PATH includes the location of you TeX distribution.

Make sure executable permissions (like 744) are set on both files or TeXShop will give an error message. Now open (or re-open) TeXShop and select “Sweave” from the list at the top left. Now you can use command-t to compile Sweave and view your document in one step! Thanks Chuck!