diff options
author | tv <tv@krebsco.de> | 2019-02-07 22:05:33 +0100 |
---|---|---|
committer | tv <tv@krebsco.de> | 2019-02-07 22:08:44 +0100 |
commit | 03623ce6c011c1e85df7d91aed4458c098ff22ff (patch) | |
tree | 5a1a44376beb1bd6b12c20fbc4272188e9d7f677 /src/Flameshot | |
parent | fb5636483871fbafe9b286b377c339c8ddf8b4f8 (diff) |
Main.app: call graphicCapture directlyv1.0.1
Diffstat (limited to 'src/Flameshot')
-rw-r--r-- | src/Flameshot/Internal.hs | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/src/Flameshot/Internal.hs b/src/Flameshot/Internal.hs index 28b33cf..56a35b4 100644 --- a/src/Flameshot/Internal.hs +++ b/src/Flameshot/Internal.hs @@ -9,11 +9,17 @@ import Blessings.Text import Control.Concurrent.Async (race) import Control.Concurrent.Extended import Control.Exception +import Data.ByteString (ByteString) +import qualified Data.ByteString as BS import qualified Data.Char as C import Data.Function (on) +import Data.Maybe (fromMaybe) +import Data.Time.Clock import Data.Time.Clock.System +import Data.Time.Format import Data.Time.ISO8601 import DBus +import DBus.Internal.Message import DBus.Socket import Data.Text (Text) import qualified Data.Text.Extended as T @@ -25,6 +31,14 @@ blessBusName = Plain . T.pack . formatBusName blessMemberName :: MemberName -> Blessings Text blessMemberName = Plain . T.pack . formatMemberName +blessMethodError :: MethodError -> Blessings Text +blessMethodError err@MethodError{..} = + red . Plain $ fromMaybe (T.show err) msg + where + msg = if length methodErrorBody > 0 + then fromVariant (methodErrorBody !! 0) + else Nothing + blessShow :: Show a => a -> Blessings Text blessShow = Plain . T.show @@ -94,3 +108,16 @@ showUnprintable = toEither p = map (\s -> if p (T.head s) then Right s else Left s) . T.groupBy ((==) `on` p) + + +saveImage :: FilePath -> ByteString -> IO () +saveImage cGuiPath rawImage = do + t <- formatISO8601Seconds . systemToUTCTime <$> getSystemTime + let path = cGuiPath <> "/" <> baseName + baseName = t <> "_flameshot.png" + BS.writeFile path rawImage + + +formatISO8601Seconds :: UTCTime -> String +formatISO8601Seconds = + formatTime defaultTimeLocale (iso8601DateFormat $ Just "%H:%M:%SZ") |