aboutsummaryrefslogtreecommitdiffstats
path: root/XMonad/Prompt/Shell.hs
diff options
context:
space:
mode:
authorgwern0 <gwern0@gmail.com>2008-04-01 03:34:47 +0200
committergwern0 <gwern0@gmail.com>2008-04-01 03:34:47 +0200
commit6e52f21443139d5e7766222a744a5faca075fc47 (patch)
tree5d5016555ab315644bb90f64a00a8e5ba19c8a11 /XMonad/Prompt/Shell.hs
parentd3823bf9efca64d1f0b91f3b32a6becc93c57f91 (diff)
downloadXMonadContrib-6e52f21443139d5e7766222a744a5faca075fc47.tar.gz
XMonadContrib-6e52f21443139d5e7766222a744a5faca075fc47.tar.xz
XMonadContrib-6e52f21443139d5e7766222a744a5faca075fc47.zip
Shell.hs: +getBrowser, getEditor, helper function
The helper function asks the shell for the value of a variable, else returns the second argument. getBrowser and getEditor obviously specialize it for two particular possibly queries darcs-hash:20080401013447-f7719-ef866971330f39e4938445e645a726a56707d04f.gz
Diffstat (limited to 'XMonad/Prompt/Shell.hs')
-rw-r--r--XMonad/Prompt/Shell.hs19
1 files changed, 19 insertions, 0 deletions
diff --git a/XMonad/Prompt/Shell.hs b/XMonad/Prompt/Shell.hs
index d28f92d..be928ee 100644
--- a/XMonad/Prompt/Shell.hs
+++ b/XMonad/Prompt/Shell.hs
@@ -17,6 +17,8 @@ module XMonad.Prompt.Shell
-- $usage
shellPrompt
, getCommands
+ , getBrowser
+ , getEditor
, getShellCompl
, split
, prompt
@@ -122,3 +124,20 @@ escape (x:xs)
isSpecialChar :: Char -> Bool
isSpecialChar = flip elem "\\@\"'#?$*()[]{};"
+
+-- | Ask the shell environment for
+env :: String -> String -> IO String
+env variable fallthrough = getEnv variable `catch` \_ -> return fallthrough
+
+{- | Ask the shell what browser the user likes. If the user hasn't defined any
+ $BROWSER, defaults to returning \"firefox\", since that seems to be the most
+ common X web browser.
+ Note that if you don't specify a GUI browser but a textual one, that'll be a problem
+ as 'getBrowser' will be called by functions expecting to be able to just execute the string
+ or pass it to a shell; so in that case, define $BROWSER as something like \"xterm -e elinks\"
+ or as the name of a shell script doing much the same thing. -}
+getBrowser :: IO String
+getBrowser = env "BROWSER" "firefox"
+
+getEditor :: IO String
+getEditor = env "EDITOR" "emacs" \ No newline at end of file