Ebook mode detection is more robust now.

This patch add the robust ebook mode detection used in
the Terminal activity
Merge pull request #1 from ignaciouy/master

Ebook mode detection is more robust now.