2023-02-22 23:02:04 -05:00
|
|
|
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" $
|
2024-08-09 12:09:42 -04:00
|
|
|
maybe args ((\b -> args ++ [b]) . T.unpack)
|
|
|
|
body
|
2023-02-22 23:02:04 -05:00
|
|
|
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
|