diff options
-rw-r--r-- | lib/Data/Text/Encoding/Extra.hs | 11 | ||||
-rw-r--r-- | lib/Graphics/X11/EWMH.hs | 19 | ||||
-rw-r--r-- | lib/Graphics/X11/Xlib/Extras/Extra.hs | 13 | ||||
-rw-r--r-- | pager.cabal | 7 | ||||
-rw-r--r-- | src/main.hs | 4 |
5 files changed, 19 insertions, 35 deletions
diff --git a/lib/Data/Text/Encoding/Extra.hs b/lib/Data/Text/Encoding/Extra.hs deleted file mode 100644 index a8e6234..0000000 --- a/lib/Data/Text/Encoding/Extra.hs +++ /dev/null @@ -1,11 +0,0 @@ -module Data.Text.Encoding.Extra where - -import Data.ByteString (ByteString) -import Data.Text (Text) -import qualified Data.Text.Encoding as Text -import qualified Data.Text.Encoding.Error as Text - - -decodeUtf8Lenient :: ByteString -> Text -decodeUtf8Lenient = - Text.decodeUtf8With Text.lenientDecode diff --git a/lib/Graphics/X11/EWMH.hs b/lib/Graphics/X11/EWMH.hs index 4f539ad..210d1bf 100644 --- a/lib/Graphics/X11/EWMH.hs +++ b/lib/Graphics/X11/EWMH.hs @@ -4,16 +4,15 @@ module Graphics.X11.EWMH ) where import Control.Applicative ((<|>)) -import Data.Text (Text) +import Data.List.Extra (split) import Foreign.C.Types (CLong) import Graphics.X11.EWMH.Atom import Graphics.X11.Types (Window) import Graphics.X11.Xlib.Atom.Extra import Graphics.X11.Xlib.Display (defaultRootWindow) import Graphics.X11.Xlib.Extras (getWindowProperty32) -import Graphics.X11.Xlib.Extras.Extra (getWindowPropertyText) +import Graphics.X11.Xlib.Extras.Extra (getWindowPropertyString) import Graphics.X11.Xlib.Types (Display) -import qualified Data.Text as Text getActiveWindow :: Display -> IO (Maybe Window) @@ -29,11 +28,11 @@ getCurrentDesktop dpy = getWindowProperty32 dpy _WIN_WORKSPACE w where w = defaultRootWindow dpy -getDesktopNames :: Display -> IO (Maybe [Text]) +getDesktopNames :: Display -> IO (Maybe [String]) getDesktopNames dpy = do - (fmap (init . Text.split (=='\NUL')) <$>) $ - getWindowPropertyText dpy _NET_DESKTOP_NAMES w <|> - getWindowPropertyText dpy _WIN_WORKSPACE_NAMES w + (fmap (init . split (=='\NUL')) <$>) $ + getWindowPropertyString dpy _NET_DESKTOP_NAMES w <|> + getWindowPropertyString dpy _WIN_WORKSPACE_NAMES w where w = defaultRootWindow dpy getWindowDesktop :: Display -> Window -> IO (Maybe CLong) @@ -42,7 +41,7 @@ getWindowDesktop dpy w = getWindowProperty32 dpy _NET_WM_DESKTOP w <|> getWindowProperty32 dpy _WIN_WORKSPACE w -getWindowTitle :: Display -> Window -> IO (Maybe Text) +getWindowTitle :: Display -> Window -> IO (Maybe String) getWindowTitle dpy w = - getWindowPropertyText dpy _NET_WM_NAME w <|> - getWindowPropertyText dpy _WM_NAME w + getWindowPropertyString dpy _NET_WM_NAME w <|> + getWindowPropertyString dpy _WM_NAME w diff --git a/lib/Graphics/X11/Xlib/Extras/Extra.hs b/lib/Graphics/X11/Xlib/Extras/Extra.hs index d88bf9d..7633f8d 100644 --- a/lib/Graphics/X11/Xlib/Extras/Extra.hs +++ b/lib/Graphics/X11/Xlib/Extras/Extra.hs @@ -1,14 +1,11 @@ module Graphics.X11.Xlib.Extras.Extra where -import Data.Text (Text) +import Codec.Binary.UTF8.String (decode) import Foreign.C.String.Extra (castCCharToWord8) -import qualified Data.ByteString as ByteString -import qualified Data.Text.Encoding.Extra as Text +import Graphics.X11.Xlib.Extras (getWindowProperty8) import qualified Graphics.X11 as X11 -import qualified Graphics.X11.Xlib.Extras as X11 -getWindowPropertyText :: X11.Display -> X11.Atom -> X11.Window -> IO (Maybe Text) -getWindowPropertyText d a w = - fmap (Text.decodeUtf8Lenient . ByteString.pack . map castCCharToWord8) <$> - X11.getWindowProperty8 d a w +getWindowPropertyString :: X11.Display -> X11.Atom -> X11.Window -> IO (Maybe String) +getWindowPropertyString d a w = + fmap (decode . map castCCharToWord8) <$> getWindowProperty8 d a w diff --git a/pager.cabal b/pager.cabal index c2fccc0..d588963 100644 --- a/pager.cabal +++ b/pager.cabal @@ -50,12 +50,11 @@ executable pager library build-depends: base , X11 - , bytestring - , text + , extra + , utf8-string default-language: Haskell2010 exposed-modules: - Data.Text.Encoding.Extra - , Foreign.C.String.Extra + Foreign.C.String.Extra , Graphics.X11.Extra , Graphics.X11.EWMH , Graphics.X11.EWMH.Atom diff --git a/src/main.hs b/src/main.hs index 2c500c7..41c6eec 100644 --- a/src/main.hs +++ b/src/main.hs @@ -68,7 +68,7 @@ getWorkspaces display screenGeometry focusWindows = do return Workspace { workspace_geometry = screenGeometry , workspace_focused = currentDesktop == index - , workspace_name = name + , workspace_name = Text.pack name , workspace_windows = [] } return $ Map.fromList $ zip [0..] ws @@ -90,7 +90,7 @@ getWorkspaces display screenGeometry focusWindows = do window = Window { window_id = fromIntegral w - , window_title = fromMaybe "" title + , window_title = Text.pack $ fromMaybe "" title , window_geometry = geometry , window_focused = Set.member w focusWindows , window_urgent = urgent |