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]
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
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 = 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
forall (f :: * -> *). Applicative f => Bool -> f () -> f ()
when Bool
startup X ()
act
isSessionStart :: X Bool
isSessionStart :: X Bool
isSessionStart = SessionStart -> Bool
unSessionStart forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> forall a (m :: * -> *). (ExtensionClass a, XLike m) => m a
XS.get
setSessionStarted :: X ()
setSessionStarted :: X ()
setSessionStarted = forall a (m :: * -> *). (ExtensionClass a, XLike m) => a -> m ()
XS.put forall a b. (a -> b) -> a -> b
$ Bool -> SessionStart
SessionStart Bool
False