Enable random message at login screen

In Mavericks it is possible to to show a custom message on the logon/lock screen. This can be done via "Preferences" -> "Security" -> "Show a message when the screen is locked".

Now I'm wondering if it is possible to display a message that is randomly read from a provided text file and changes every time at logon. For example I'd like to have a file "quotes.txt" with each line being a quotation such that I get some kind of "Quote of the Day" feature.

I guess this could easily be achieved by a script running whenever the users logs off (log in would be possible as well, I suppose), that reads in a random line and sets the "lock screen message" string accordingly. So I'm basically asking, if there is a way to access this string for example via command line to programmatically change it.


You can set the text from Terminal by running

sudo defaults write /Library/Preferences/com.apple.loginwindow LoginwindowText "your text here"

The text is displayed in three lines with a max length of 68 characters each so it it might help to pre-select/format the quotes to match these limitations.