Skip to content
/ i3ipc Public
forked from leshow/i3ipc

Types and bindings for communicating with i3 in Haskell

License

Notifications You must be signed in to change notification settings

dgaw/i3ipc

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

33 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

i3ipc

Build Status

Haskell type-safe bindings for working with i3 using it's unix socket IPC

Subscribing

Subscribe to events:

import qualified I3IPC.Subscribe   as Sub
import           I3IPC              ( subscribe )

-- will print all events
main :: IO ()
main = subscribe print [Sub.Workspace, Sub.Window]

An example of explicitly matching on some events and printing their fields:

import qualified I3IPC.Subscribe               as Sub
import           I3IPC.Event
import           I3IPC                          ( subscribe )

main :: IO ()
main = subscribe handle [Sub.Workspace, Sub.Window]
 where
  handle :: Either String Event -> IO ()
  handle (Right evt) = case evt of
    Workspace WorkspaceEvent { wrk_current } -> print wrk_current
    Window WindowEvent { win_container } -> print win_container
    _ -> error "No other event types"
  handle (Left err) = error err

Sending Messages

Sending Messages to i3:

import           I3IPC              ( connecti3
                                    , getWorkspaces
                                    )

main :: IO ()
main = do
    soc <- connecti3
    print $ getWorkspaces soc

Alternatively, you can ignore the convenience functions and construct these messages yourself:

import qualified I3IPC.Message     as Msg
import           I3IPC              ( connecti3
                                    , receiveMsg
                                    )

main :: IO ()
main = do
    soc <- connecti3
    print $ Msg.sendMsg soc Msg.Workspaces >> receiveMsg soc

Community

I'm happy to take PRs or suggestions, or simply fix issues for this library.

About

Types and bindings for communicating with i3 in Haskell

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Haskell 100.0%