30 lines
831 B
Haskell
30 lines
831 B
Haskell
|
module Rofi.IO where
|
||
|
|
||
|
import RIO
|
||
|
import RIO.Directory
|
||
|
import qualified RIO.Text as T
|
||
|
import System.Process
|
||
|
|
||
|
data NotifyIcon = IconError | IconInfo
|
||
|
|
||
|
instance Show NotifyIcon where
|
||
|
show IconError = "dialog-error-symbolic"
|
||
|
show IconInfo = "dialog-information-symbolic"
|
||
|
|
||
|
notify :: MonadIO m => NotifyIcon -> T.Text -> Maybe T.Text -> m ()
|
||
|
notify icon summary body =
|
||
|
liftIO $
|
||
|
void $
|
||
|
spawnProcess "notify-send" $
|
||
|
maybe args (\b -> args ++ [b]) $
|
||
|
fmap T.unpack body
|
||
|
where
|
||
|
args = ["-i", show icon, T.unpack summary]
|
||
|
|
||
|
checkExe :: (HasLogFunc c, MonadReader c m, MonadUnliftIO m) => FilePath -> m ()
|
||
|
checkExe cmd = do
|
||
|
res <- findExecutable cmd
|
||
|
unless (isJust res) $ do
|
||
|
logError $ displayBytesUtf8 $ encodeUtf8 $ T.append "Could not find executable: " $ T.pack cmd
|
||
|
exitWith $ ExitFailure 1
|