module XMonad.Prompt.Theme
(
themePrompt,
ThemePrompt,
) where
import Control.Arrow ( (&&&) )
import qualified Data.Map as M
import XMonad.Prelude ( fromMaybe )
import XMonad
import XMonad.Prompt
import XMonad.Layout.Decoration
import XMonad.Util.Themes
data ThemePrompt = ThemePrompt
instance XPrompt ThemePrompt where
showXPrompt :: ThemePrompt -> String
showXPrompt ThemePrompt
ThemePrompt = String
"Select a theme: "
commandToComplete :: ThemePrompt -> String -> String
commandToComplete ThemePrompt
_ String
c = String
c
nextCompletion :: ThemePrompt -> String -> [String] -> String
nextCompletion ThemePrompt
_ = String -> [String] -> String
getNextCompletion
themePrompt :: XPConfig -> X ()
themePrompt :: XPConfig -> X ()
themePrompt XPConfig
c = forall p.
XPrompt p =>
p -> XPConfig -> ComplFunction -> (String -> X ()) -> X ()
mkXPrompt ThemePrompt
ThemePrompt XPConfig
c (XPConfig -> [String] -> ComplFunction
mkComplFunFromList' XPConfig
c forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall a b. (a -> b) -> [a] -> [b]
map ThemeInfo -> String
ppThemeInfo forall a b. (a -> b) -> a -> b
$ [ThemeInfo]
listOfThemes) String -> X ()
changeTheme
where changeTheme :: String -> X ()
changeTheme String
t = forall a. Message a => a -> X ()
sendMessage forall b c a. (b -> c) -> (a -> b) -> a -> c
. Theme -> DecorationMsg
SetTheme forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall a. a -> Maybe a -> a
fromMaybe forall a. Default a => a
def forall a b. (a -> b) -> a -> b
$ forall k a. Ord k => k -> Map k a -> Maybe a
M.lookup String
t Map String Theme
mapOfThemes
mapOfThemes :: M.Map String Theme
mapOfThemes :: Map String Theme
mapOfThemes = forall k a. Ord k => [(k, a)] -> Map k a
M.fromList forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall a b c. (a -> b -> c) -> (a, b) -> c
uncurry forall a b. [a] -> [b] -> [(a, b)]
zip forall b c a. (b -> c) -> (a -> b) -> a -> c
. (forall a b. (a -> b) -> [a] -> [b]
map ThemeInfo -> String
ppThemeInfo forall (a :: * -> * -> *) b c c'.
Arrow a =>
a b c -> a b c' -> a b (c, c')
&&& forall a b. (a -> b) -> [a] -> [b]
map ThemeInfo -> Theme
theme) forall a b. (a -> b) -> a -> b
$ [ThemeInfo]
listOfThemes