summaryrefslogtreecommitdiffstats
path: root/XMonad/Stockholm
diff options
context:
space:
mode:
Diffstat (limited to 'XMonad/Stockholm')
-rw-r--r--XMonad/Stockholm/Shutdown.hs14
1 files changed, 12 insertions, 2 deletions
diff --git a/XMonad/Stockholm/Shutdown.hs b/XMonad/Stockholm/Shutdown.hs
index 373214e..9d759db 100644
--- a/XMonad/Stockholm/Shutdown.hs
+++ b/XMonad/Stockholm/Shutdown.hs
@@ -9,14 +9,24 @@ module XMonad.Stockholm.Shutdown
import Control.Concurrent (threadDelay)
import Control.Monad (forever, when)
import Data.Monoid (All(All))
+import System.Directory (getAppUserDataDirectory)
import System.Exit (exitSuccess)
+import System.Environment (lookupEnv)
import System.FilePath ((</>))
import System.IO.Error (isDoesNotExistError, tryIOError)
import System.IO (hPutStrLn, stderr)
import System.Posix.Process (getProcessID)
import System.Posix.Signals (nullSignal, signalProcess)
import System.Posix.Types (ProcessID)
-import XMonad
+import XMonad hiding (getXMonadDataDir)
+
+
+-- XXX this is shim so xmonad-stockholm can be used for both xmonad-0.15 and
+-- xmonad-0.17 based configurations. This will break on xmonad>=0.17 if
+-- non-default directories are used.
+getXMonadDataDir :: IO String
+getXMonadDataDir =
+ maybe (getAppUserDataDirectory "xmonad") pure =<< lookupEnv "XMONAD_DATA_DIR"
newShutdownEventHandler :: IO (Event -> X All)
newShutdownEventHandler = do
@@ -65,7 +75,7 @@ waitProcess pid = forever (signalProcess nullSignal pid >> threadDelay 10000)
-- PID file stuff
--
-getProcessIDFileName :: (Functor m, MonadIO m) => m FilePath
+getProcessIDFileName :: IO FilePath
getProcessIDFileName = (</> "xmonad.pid") <$> getXMonadDataDir
writeProcessIDToFile :: IO ()