mirror of
https://github.com/xmonad/xmonad.git
synced 2025-05-19 00:20:22 -07:00
This resolves http://code.google.com/p/xmonad/issues/detail?id=320 by adding a --verbose-version option yielding output like "xmonad 0.9 compiled by ghc 6.10 for linux/i386"
103 lines
3.3 KiB
Haskell
103 lines
3.3 KiB
Haskell
----------------------------------------------------------------------------
|
|
-- |
|
|
-- Module : Main
|
|
-- Copyright : (c) Spencer Janssen 2007
|
|
-- License : BSD3-style (see LICENSE)
|
|
--
|
|
-- Maintainer : sjanssen@cse.unl.edu
|
|
-- Stability : unstable
|
|
-- Portability : not portable, uses mtl, X11, posix
|
|
--
|
|
-- xmonad, a minimalist, tiling window manager for X11
|
|
--
|
|
-----------------------------------------------------------------------------
|
|
|
|
module Main (main) where
|
|
|
|
import XMonad
|
|
|
|
import Control.Monad (unless)
|
|
import System.IO
|
|
import System.Info
|
|
import System.Environment
|
|
import System.Posix.Process (executeFile)
|
|
import System.Exit (exitFailure)
|
|
|
|
import Paths_xmonad (version)
|
|
import Data.Version (showVersion)
|
|
|
|
#ifdef TESTING
|
|
import qualified Properties
|
|
#endif
|
|
|
|
-- | The entry point into xmonad. Attempts to compile any custom main
|
|
-- for xmonad, and if it doesn't find one, just launches the default.
|
|
main :: IO ()
|
|
main = do
|
|
installSignalHandlers -- important to ignore SIGCHLD to avoid zombies
|
|
args <- getArgs
|
|
let launch = catchIO buildLaunch >> xmonad defaultConfig
|
|
case args of
|
|
[] -> launch
|
|
("--resume":_) -> launch
|
|
["--help"] -> usage
|
|
["--recompile"] -> recompile True >>= flip unless exitFailure
|
|
["--restart"] -> sendRestart >> return ()
|
|
["--version"] -> putStrLn ("xmonad " ++ showVersion version)
|
|
["--verbose-version"] -> putStrLn ("xmonad " ++ showVersion version ++ " compiled by " ++ compilerName
|
|
++ " " ++ showVersion compilerVersion ++ " for " ++ os ++ "/" ++ arch)
|
|
#ifdef TESTING
|
|
("--run-tests":_) -> Properties.main
|
|
#endif
|
|
_ -> fail "unrecognized flags"
|
|
|
|
usage :: IO ()
|
|
usage = do
|
|
self <- getProgName
|
|
putStr . unlines $
|
|
concat ["Usage: ", self, " [OPTION]"] :
|
|
"Options:" :
|
|
" --help Print this message" :
|
|
" --version Print the version number" :
|
|
" --recompile Recompile your ~/.xmonad/xmonad.hs" :
|
|
" --restart Request a running xmonad process to restart" :
|
|
#ifdef TESTING
|
|
" --run-tests Run the test suite" :
|
|
#endif
|
|
[]
|
|
|
|
-- | Build "~\/.xmonad\/xmonad.hs" with ghc, then execute it. If there are no
|
|
-- errors, this function does not return. An exception is raised in any of
|
|
-- these cases:
|
|
--
|
|
-- * ghc missing
|
|
--
|
|
-- * both "~\/.xmonad\/xmonad.hs" and "~\/.xmonad\/xmonad-$arch-$os" missing
|
|
--
|
|
-- * xmonad.hs fails to compile
|
|
--
|
|
-- ** wrong ghc in path (fails to compile)
|
|
--
|
|
-- ** type error, syntax error, ..
|
|
--
|
|
-- * Missing XMonad\/XMonadContrib modules due to ghc upgrade
|
|
--
|
|
buildLaunch :: IO ()
|
|
buildLaunch = do
|
|
recompile False
|
|
dir <- getXMonadDir
|
|
args <- getArgs
|
|
executeFile (dir ++ "/xmonad-"++arch++"-"++os) False args Nothing
|
|
return ()
|
|
|
|
sendRestart :: IO ()
|
|
sendRestart = do
|
|
dpy <- openDisplay ""
|
|
rw <- rootWindow dpy $ defaultScreen dpy
|
|
xmonad_restart <- internAtom dpy "XMONAD_RESTART" False
|
|
allocaXEvent $ \e -> do
|
|
setEventType e clientMessage
|
|
setClientMessageEvent e rw xmonad_restart 32 0 currentTime
|
|
sendEvent dpy rw False structureNotifyMask e
|
|
sync dpy False
|