summaryrefslogtreecommitdiffhomepage
path: root/UI.hs
diff options
context:
space:
mode:
authorJoey Hess <joeyh@joeyh.name>2016-08-12 11:44:34 -0400
committerJoey Hess <joeyh@joeyh.name>2016-08-12 11:44:34 -0400
commit3ee306d3d4bda52268f07df874070b65d171694e (patch)
tree4ed6a83a2e4358b0dd0ff4a0a5c62108a99286c2 /UI.hs
parenta58aea595a780c91bbbe26d2d24a63abcd835994 (diff)
downloadkeysafe-3ee306d3d4bda52268f07df874070b65d171694e.tar.gz
add --gui option
Diffstat (limited to 'UI.hs')
-rw-r--r--UI.hs17
1 files changed, 15 insertions, 2 deletions
diff --git a/UI.hs b/UI.hs
index 0ce87db..a97f3c1 100644
--- a/UI.hs
+++ b/UI.hs
@@ -10,5 +10,18 @@ import Control.Monad
import UI.Zenity
import UI.Readline
-availableUI :: IO [UI]
-availableUI = filterM isAvailable [zenityUI, readlineUI]
+availableUIs :: IO [UI]
+availableUIs = filterM isAvailable [zenityUI, readlineUI]
+
+selectUI :: Bool -> IO UI
+selectUI needgui
+ | needgui = do
+ ok <- isAvailable zenityUI
+ if ok
+ then return zenityUI
+ else error "zenitty is not installed, GUI not available"
+ | otherwise = do
+ l <- availableUIs
+ case l of
+ (u:_) -> return u
+ [] -> error "Neither zenity nor the readline UI are available"