diff --git a/CHANGES.md b/CHANGES.md
--- a/CHANGES.md
+++ b/CHANGES.md
@@ -1,3 +1,8 @@
+0.1.0.1 (Apr 2, 2014)
+=====================
+
+- Fix `IOError` if `$XDG_CURRENT_DESKTOP` is missing
+
 0.1.0.0 (Apr 1, 2014)
 =====================
 
diff --git a/README.md b/README.md
--- a/README.md
+++ b/README.md
@@ -1,7 +1,7 @@
 haskell-keyring
 ===============
 
-[![hackage][badge-hackage]][hackage] [![license][badge-license]]][license]
+[![hackage][badge-hackage]][hackage] [![license][badge-license]][license]
 
 Haskell library to access the system's keyring to securely store passwords.
 
diff --git a/keyring.cabal b/keyring.cabal
--- a/keyring.cabal
+++ b/keyring.cabal
@@ -1,5 +1,5 @@
 name:                keyring
-version:             0.1.0.0
+version:             0.1.0.1
 synopsis:            Keyring access
 description:
   keyring provides access to the system's keyring to securely store passwords.
@@ -35,7 +35,7 @@
 source-repository this
   type:              git
   location:          https://github.com/lunaryorn/haskell-keyring.git
-  tag:               0.1.0.0
+  tag:               0.1.0.1
 
 flag AllBackends
   description:         Try to build as many backends as possible
diff --git a/src/System/Keyring/Darwin.hsc b/src/System/Keyring/Darwin.hsc
--- a/src/System/Keyring/Darwin.hsc
+++ b/src/System/Keyring/Darwin.hsc
@@ -41,13 +41,13 @@
 
 import Control.Exception (Exception(..),bracket,throwIO)
 import Control.Monad (liftM,when,void)
-import Data.ByteString
+import Data.ByteString (ByteString,useAsCStringLen,packCString,packCStringLen)
 import Data.Int (Int32, Int64)
 import Data.Typeable (Typeable,cast)
 import Data.Word (Word32)
-import Foreign.C
-import Foreign.Ptr
-import Foreign.Storable
+import Foreign.C (CString,CStringLen)
+import Foreign.Ptr (Ptr,nullPtr)
+import Foreign.Storable (peek)
 import Foreign.Marshal.Alloc (alloca,allocaBytes)
 import Text.Printf (printf)
 
diff --git a/src/System/Keyring/Unix.hs b/src/System/Keyring/Unix.hs
--- a/src/System/Keyring/Unix.hs
+++ b/src/System/Keyring/Unix.hs
@@ -30,8 +30,10 @@
 
 import System.Keyring.Types
 
-import Control.Exception (throwIO)
+import Control.Exception (throwIO,handleJust)
+import Control.Monad (liftM)
 import System.Environment (getEnv)
+import System.IO.Error (isDoesNotExistError)
 
 -- |The keyring provider to use.
 --
@@ -40,10 +42,13 @@
 provider :: IO (Service -> Username -> IO (Maybe Password)
                ,Service -> Username -> Password -> IO ())
 provider = do
-  desktop <- getEnv "XDG_CURRENT_DESKTOP"
+  desktop <- handleJust (toMaybe.isDoesNotExistError) (const $ return Nothing)
+             (liftM Just (getEnv "XDG_CURRENT_DESKTOP"))
   case desktop of
-    "KDE" -> return (KDE.getPassword, KDE.setPassword)
+    Just "KDE" -> return (KDE.getPassword, KDE.setPassword)
     _ -> throwIO KeyringMissingBackendError
+   where toMaybe True = Just ()
+         toMaybe False = Nothing
 
 -- |@'getPassword' service username@ gets a password from the current keyring.
 --
