Skip to content

Navigation Menu

Sign up

Yi auto switch between GUI (ie, Pango) and CLI (ie, Vty)

dbp edited this page Nov 18, 2012 · 1 revision

One possible way of having a config that will start a graphical frontend if possible, and fall back on another frontend is the following:

...
import Yi.Config.Simple
import Control.Exception (catch, SomeException)
import Graphics.UI.Gtk (initGUI)
main :: IO ()
main = do
 hasGUI <- catch (initGUI >> return True) ((const $ return False)::(SomeException -> IO Bool))
 if hasGUI
 then configMain defaultEmacsConfig setupGUI
 else configMain defaultEmacsConfig setupVty
setupGUI :: ConfigM ()
setupGUI = do
 setFrontend "pango"
 setup
setupVty :: ConfigM ()
setupVty = do
 setFrontend "vty"
 setup
setup :: ConfigM ()
setup = do
 fontSize %= Just 9
 theme %= darkBlueTheme
 ...
...

Clone this wiki locally

AltStyle によって変換されたページ (->オリジナル) /