From 0a23046a06d223caea4a02615201e05e88e0a255 Mon Sep 17 00:00:00 2001 From: Adam Vogt Date: Tue, 14 Apr 2015 20:48:21 +0200 Subject: Make ~/.xmonad/xmonad-$arch-$os handle args like /usr/bin/xmonad Ignore-this: add70a198fffaa94b14a35b585487eb3 darcs-hash:20150414184821-1499c-eebbc66c18dfc34d760357379ae5fbf224c6b7d1.gz --- Main.hs | 81 +---------------------------------------------------------------- 1 file changed, 1 insertion(+), 80 deletions(-) (limited to 'Main.hs') diff --git a/Main.hs b/Main.hs index 2fcfe13..28351d0 100644 --- a/Main.hs +++ b/Main.hs @@ -16,84 +16,5 @@ module Main (main) where import XMonad -import Control.Monad (unless) -import System.Info -import System.Environment -import System.Posix.Process (executeFile) -import System.Exit (exitFailure) - -import Paths_xmonad (version) -import Data.Version (showVersion) - -import Graphics.X11.Xinerama (compiledWithXinerama) - --- | 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 def - case args of - [] -> launch - ("--resume":_) -> launch - ["--help"] -> usage - ["--recompile"] -> recompile True >>= flip unless exitFailure - ["--replace"] -> launch - ["--restart"] -> sendRestart >> return () - ["--version"] -> putStrLn $ unwords shortVersion - ["--verbose-version"] -> putStrLn . unwords $ shortVersion ++ longVersion - _ -> fail "unrecognized flags" - where - shortVersion = ["xmonad", showVersion version] - longVersion = [ "compiled by", compilerName, showVersion compilerVersion - , "for", arch ++ "-" ++ os - , "\nXinerama:", show compiledWithXinerama ] - -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" : - " --replace Replace the running window manager with xmonad" : - " --restart Request a running xmonad process to restart" : - [] - --- | 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 +main = xmonad def -- cgit v1.2.3