Fortunes

Back when I first discovered the fortune command (fortunes) I thought it was a great idea, though like with physical fortune cookies I wasn't enamored with quite all the ditties. That was easy to fix and better: I now have a collection of hundreds of my own fortunes, managed by MCM.

It goes like this:

MCM Fortune

import Admin.Packages as Packages
import MCM.FileChecks as FileChecks
import MCM.FilePruning as FilePruning

define fortune(frequency text
		category = misc
		source =
	)
	let dir = /usr/share/games/fortunes/@frequency
		group = fortune-@frequency-@category
	case frequency
	when never
	when often
	when rarely
	when sometimes
	Dir manage> partial path> @dir
	File content>$fragments(@group,,,@NEWLINE%@NEWLINE) path> @dir/@category
	Fragment content> @text group> @group
	.installFortuneDB dir> @dir name> @category

define installFortuneDB(name
		dir = /usr/share/games/fortunes
	)
	let dat = @dir/@name.dat
		text = @dir/@name
	Packages.add package> fortune-mod
	FileChecks.runIfNewer dest> @dat source> @text
		cmd: strfile "@text" "@dat"
	FilePruning.removeFilesOtherThan dir> @dir filename> @name
	FilePruning.removeFilesOtherThan dir> @dir filename> @name.dat

define myFortunes()
	.fortune category> debian frequency> rarely
		text: Quality control information about a package can be found
			+ by going to http://packages.qa.debian.org/<package>
	.fortune category> debian frequency> sometimes
		text: Regularly verify your backups.
	.fortune category> debian frequency> rarely
		text: Crontab jobs require % to be escaped with \.
			+ E.g.  echo /usr/sbin/rtcwake -m mem -t `date -d "tomorrow 08:35" '+\%s'`
			+ Why?  - '%' otherwise gets turned into a newline
	.fortune category> misc frequency> sometimes
		source: The Matrix Reloaded
		text: If we never take time, how can we ever have time?
	.fortune category> misc frequency> sometimes source> https://www.gnu.org/philosophy/surveillance-vs-democracy.html
		text: The point at which surveillance is too much is the point at which
			+ the state can find who spoke to a known journalist or a known
			+ dissident.
	.fortune category> misc frequency> sometimes source> http://www.bbc.co.uk/news/magazine-27186709
		text: Spend time walking, just to walk and think.
			+ Because aimless walking (anywhere) aids the thinking that builds creativity.