From 4826d2644b5d491692bbbfed04780c0ac6a25065 Mon Sep 17 00:00:00 2001 From: phuhl Date: Thu, 4 Jan 2024 10:13:03 +0100 Subject: [PATCH] Fixes crash when no CSS file exists Closes #247 --- src/NotificationCenter.hs | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/src/NotificationCenter.hs b/src/NotificationCenter.hs index 1dce7a2..54b9db7 100644 --- a/src/NotificationCenter.hs +++ b/src/NotificationCenter.hs @@ -135,10 +135,15 @@ deleteInCenter tState = do setWindowStyle tState = do state <- readTVarIO tState homeDir <- getXdgDirectory XdgConfig "" - let paths = [homeDir ++ "/deadd/deadd.css", "/etc/xdg/deadd/deadd.css"] - style <- readFile =<< (filterM doesFileExist paths >>= return . head) - screen <- windowGetScreen $ stMainWindow state - setStyle screen $ BS.pack $ style + paths <- filterM doesFileExist + $ [homeDir ++ "/deadd/deadd.css", "/etc/xdg/deadd/deadd.css"] + >>= return + if length paths > 0 then do + style <- readFile =<< (filterM doesFileExist paths >>= return . head) + screen <- windowGetScreen $ stMainWindow state + setStyle screen $ BS.pack $ style + else + return () createNotiCenter :: TVar State -> Config -> Catalog -> IO () createNotiCenter tState config catalog = do