taffybar 3.1.1 → 3.1.2
raw patch · 7 files changed
+65/−47 lines, 7 filesdep +http-clientdep +http-client-tlsdep +http-typesdep −HTTPdep ~gi-gdkpixbuf
Dependencies added: http-client, http-client-tls, http-types
Dependencies removed: HTTP
Dependency ranges changed: gi-gdkpixbuf
Files
- CHANGELOG.md +8/−0
- src/System/Taffybar/Information/Chrome.hs +13/−10
- src/System/Taffybar/Util.hs +3/−0
- src/System/Taffybar/Widget/Generic/PollingLabel.hs +0/−1
- src/System/Taffybar/Widget/Util.hs +0/−4
- src/System/Taffybar/Widget/Weather.hs +36/−29
- taffybar.cabal +5/−3
CHANGELOG.md view
@@ -1,3 +1,11 @@+# 3.1.2++## Updates++ * Weather now uses new uris and https (Kirill Zaborsky)++ * Bump the version of gi-gdkpixbuf, this fixes nixpkgs compilation+ # 3.1.0 ## New Features
src/System/Taffybar/Information/Chrome.hs view
@@ -60,15 +60,18 @@ loader <- Gdk.pixbufLoaderNew Gdk.pixbufLoaderWriteBytes loader =<< Gdk.bytesNew (Just imageData) Gdk.pixbufLoaderClose loader- pixbuf <- Gdk.pixbufLoaderGetPixbuf loader- let chromeTabImageData =- ChromeTabImageData- { tabImageData = pixbuf- , tabImageDataId = tabID- }- modifyMVar_ infoVar $ \currentMap -> do- writeChan chan chromeTabImageData- return $ M.insert tabID chromeTabImageData currentMap+ let updateChannelAndMVar pixbuf =+ let chromeTabImageData =+ ChromeTabImageData+ { tabImageData = pixbuf+ , tabImageDataId = tabID+ }+ in+ modifyMVar_ infoVar $ \currentMap ->+ do+ writeChan chan chromeTabImageData+ return $ M.insert tabID chromeTabImageData currentMap+ Gdk.pixbufLoaderGetPixbuf loader >>= maybe (return ()) updateChannelAndMVar return $ ChromeTabImageDataState (infoVar, chan) newtype X11WindowToChromeTabId = X11WindowToChromeTabId (MVar (M.Map X11Window Int))@@ -89,7 +92,7 @@ logIO DEBUG (show newMap) return newMap handleEvent _ = return ()- subscribeToEvents ["_NET_WM_NAME"] handleEvent+ _ <- subscribeToEvents ["_NET_WM_NAME"] handleEvent return tabMapVar tabIDRegex :: Regex
src/System/Taffybar/Util.hs view
@@ -135,5 +135,8 @@ printf "Failed to load icon from filepath %s" filepath return $ rightToMaybe result +postGUIASync :: IO () -> IO () postGUIASync = Gtk.postGUIASync++postGUISync :: IO () -> IO () postGUISync = Gtk.postGUISync
src/System/Taffybar/Widget/Generic/PollingLabel.hs view
@@ -12,7 +12,6 @@ import System.Taffybar.Util import qualified Data.Text as T import GI.Gtk-import System.Taffybar.Util import System.Taffybar.Widget.Util -- | Create a new widget that updates itself at regular intervals. The
src/System/Taffybar/Widget/Util.hs view
@@ -25,14 +25,10 @@ import qualified GI.GdkPixbuf.Objects.Pixbuf as PB import GI.Gtk as Gtk import qualified GI.Gdk as D-import System.Directory import System.FilePath.Posix import System.Taffybar.Information.XDG.DesktopEntry import System.Taffybar.Util import Text.Printf-import qualified GI.Cairo-import Control.Monad.Trans.Reader (runReaderT)-import Foreign.Ptr (castPtr) import Paths_taffybar ( getDataDir )
src/System/Taffybar/Widget/Weather.hs view
@@ -2,7 +2,7 @@ -- | This module defines a simple textual weather widget that polls -- NOAA for weather data. To find your weather station, you can use ----- <http://www.nws.noaa.gov/tg/siteloc.php>+-- <https://www.weather.gov/tg/siteloc> -- -- For example, Madison, WI is KMSN. --@@ -70,15 +70,19 @@ ) where import Control.Monad.IO.Class+import qualified Data.ByteString.Lazy as LB+import Data.List (stripPrefix)+import Data.Maybe (fromMaybe) import GI.Gtk import GI.GLib(markupEscapeText)-import qualified Network.Browser as Browser-import Network.HTTP-import Network.URI+import Network.HTTP.Client+import Network.HTTP.Client.TLS (tlsManagerSettings)+import Network.HTTP.Types.Status import Text.Parsec import Text.Printf import Text.StringTemplate import qualified Data.Text as T+import qualified Data.Text.Encoding as T import System.Taffybar.Widget.Generic.PollingLabel @@ -179,30 +183,20 @@ _ <- many $ noneOf "\n\r" newline --- | Simple: download the document at a URL. Taken from Real World--- Haskell.-downloadURL :: Maybe String -> String -> IO (Either String String)-downloadURL mProxy url = do- (_, r) <- Browser.browse $ do- case mProxy of- Just proxy -> Browser.setProxy $ Browser.Proxy proxy Nothing- Nothing -> return ()- Browser.setAllowRedirects True- Browser.request request- case rspCode r of- (2,_,_) -> return $ Right (rspBody r)- _ -> return $ Left (show r)- where- request = Request { rqURI = uri- , rqMethod = GET- , rqHeaders = []- , rqBody = ""- }- Just uri = parseURI url+-- | Simple: download the document at a URL.+downloadURL :: Manager -> Request -> IO (Either String String)+downloadURL mgr request = do+ response <- httpLbs request mgr+ case responseStatus response of+ s | s >= status200 && s < status300 ->+ return $ Right (T.unpack . T.decodeUtf8 . LB.toStrict $ responseBody response)+ otherStatus ->+ return . Left $ "HTTP 2XX status was expected but received " ++ show otherStatus -getWeather :: Maybe String -> String -> IO (Either String WeatherInfo)-getWeather mProxy url = do- dat <- downloadURL mProxy url+getWeather :: Manager -> String -> IO (Either String WeatherInfo)+getWeather mgr url = do+ request <- parseRequest url+ dat <- downloadURL mgr request case dat of Right dat' -> case parse parseData url dat' of Right d -> return (Right d)@@ -254,7 +248,7 @@ -- | The NOAA URL to get data from baseUrl :: String-baseUrl = "http://tgftp.nws.noaa.gov/data/observations/metar/decoded"+baseUrl = "https://tgftp.nws.noaa.gov/data/observations/metar/decoded" -- | A wrapper to allow users to specify a custom weather formatter. -- The default interpolates variables into a string as described@@ -304,8 +298,21 @@ -> Double -- ^ Polling period in _minutes_ -> m GI.Gtk.Widget weatherNew cfg delayMinutes = liftIO $ do+ -- TODO: add explicit proxy host/port to WeatherConfig and+ -- get rid of this ugly stringly-typed setting+ let usedProxy = case weatherProxy cfg of+ Nothing -> noProxy+ Just str ->+ let strToBs = T.encodeUtf8 . T.pack+ noHttp = fromMaybe str $ stripPrefix "http://" str+ (phost, pport) = case span (':'/=) noHttp of+ (h, "") -> (strToBs h, 80) -- HTTP seems to assume 80 to be the default+ (h, ':':p) -> (strToBs h, read p)+ _ -> error "unreachable: broken span"+ in useProxy $ Proxy phost pport+ mgr <- newManager $ managerSetProxy usedProxy tlsManagerSettings let url = printf "%s/%s.TXT" baseUrl (weatherStation cfg)- getter = getWeather (weatherProxy cfg) url+ let getter = getWeather mgr url weatherCustomNew getter (weatherTemplate cfg) (weatherTemplateTooltip cfg) (weatherFormatter cfg) delayMinutes
taffybar.cabal view
@@ -1,5 +1,5 @@ name: taffybar-version: 3.1.1+version: 3.1.2 synopsis: A desktop bar similar to xmobar, but with more GUI license: BSD3 license-file: LICENSE@@ -41,7 +41,6 @@ build-depends: base > 3 && < 5 , ConfigFile , HStringTemplate >= 0.8 && < 0.9- , HTTP , X11 >= 1.5.0.1 , bytestring , containers@@ -56,7 +55,7 @@ , gi-cairo-render , gi-cairo-connector , gi-gdk- , gi-gdkpixbuf >= 2.0.16+ , gi-gdkpixbuf >= 2.0.18 , gi-gdkx11 , gi-glib >= 2.0.17 , gi-gtk@@ -67,6 +66,9 @@ , haskell-gi >= 0.21.2 , haskell-gi-base >= 0.21.1 , hslogger+ , http-client >= 0.5+ , http-client-tls+ , http-types , multimap >= 1.2.1 , old-locale , parsec >= 3.1