module XMonad.Util.SessionStart
( doOnce
, isSessionStart
, setSessionStarted
)
where
import XMonad.Prelude (when)
import XMonad
import qualified XMonad.Util.ExtensibleState as XS
newtype SessionStart = SessionStart { SessionStart -> Bool
unSessionStart :: Bool }
deriving (ReadPrec [SessionStart]
ReadPrec SessionStart
Int -> ReadS SessionStart
ReadS [SessionStart]
(Int -> ReadS SessionStart)
-> ReadS [SessionStart]
-> ReadPrec SessionStart
-> ReadPrec [SessionStart]
-> Read SessionStart
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [SessionStart]
$creadListPrec :: ReadPrec [SessionStart]
readPrec :: ReadPrec SessionStart
$creadPrec :: ReadPrec SessionStart
readList :: ReadS [SessionStart]
$creadList :: ReadS [SessionStart]
readsPrec :: Int -> ReadS SessionStart
$creadsPrec :: Int -> ReadS SessionStart
Read, Int -> SessionStart -> ShowS
[SessionStart] -> ShowS
SessionStart -> String
(Int -> SessionStart -> ShowS)
-> (SessionStart -> String)
-> ([SessionStart] -> ShowS)
-> Show SessionStart
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [SessionStart] -> ShowS
$cshowList :: [SessionStart] -> ShowS
show :: SessionStart -> String
$cshow :: SessionStart -> String
showsPrec :: Int -> SessionStart -> ShowS
$cshowsPrec :: Int -> SessionStart -> ShowS
Show)
instance ExtensionClass SessionStart where
initialValue :: SessionStart
initialValue = Bool -> SessionStart
SessionStart Bool
True
extensionType :: SessionStart -> StateExtension
extensionType = SessionStart -> StateExtension
forall a. (Read a, Show a, ExtensionClass a) => a -> StateExtension
PersistentExtension
doOnce :: X () -> X ()
doOnce :: X () -> X ()
doOnce X ()
act = do
Bool
startup <- X Bool
isSessionStart
Bool -> X () -> X ()
forall (f :: * -> *). Applicative f => Bool -> f () -> f ()
when Bool
startup X ()
act
isSessionStart :: X Bool
isSessionStart :: X Bool
isSessionStart = SessionStart -> Bool
unSessionStart (SessionStart -> Bool) -> X SessionStart -> X Bool
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> X SessionStart
forall a (m :: * -> *). (ExtensionClass a, XLike m) => m a
XS.get
setSessionStarted :: X ()
setSessionStarted :: X ()
setSessionStarted = SessionStart -> X ()
forall a (m :: * -> *). (ExtensionClass a, XLike m) => a -> m ()
XS.put (SessionStart -> X ()) -> SessionStart -> X ()
forall a b. (a -> b) -> a -> b
$ Bool -> SessionStart
SessionStart Bool
False