Safe Haskell | None |
---|---|
Language | Haskell2010 |
A clipboard management CLI tool built with Polysemy, Servant and GI.Gtk.
Synopsis
- data Agent :: Effect
- data AgentTag
- type Agents = [Tagged AgentTmux Agent, Tagged AgentX Agent, Tagged AgentNet Agent]
- data XClipboard :: Effect
- interpretAgentNet :: Members [Manager, Events resource Event, Reader InstanceName, Reader NetConfig] r => Members [AtomicState (Seq Event), Log, Interrupt, Race, Resource, Async, Embed IO, Final IO] r => InterpreterFor (Tagged AgentNet Agent) r
- interpretAgentX :: Members [EventConsumer xr XClipboardEvent, Events er Event, Reader InstanceName, XClipboard, ChronosTime] r => Members [Events xr XClipboardEvent, Error Text, Race, Resource, Async, Embed IO, Final IO] r => InterpreterFor (Tagged AgentX Agent) r
- interpretAgentTmux :: Members [Reader TmuxConfig, Log, Async, Race, Resource, Embed IO] r => InterpreterFor (Tagged AgentTmux Agent) r
- interpretXClipboardGtk :: Members [Reader GtkState, Embed IO] r => InterpreterFor XClipboard r
- data Event
- transformXEvents :: Member (Reader InstanceName) r => Members [EventConsumer xr XClipboardEvent, Events er Event, XClipboard, ChronosTime, Resource, Race, Async] r => Sem r a -> Sem r a
- withMainLoop :: Members [Resource, Error Text, Race, Async, Embed IO] r => InterpreterFor (Reader GtkState) r
- subscribeToClipboard :: Members [Events resource XClipboardEvent, Reader GtkState, Embed IO, Final IO] r => Clipboard -> Selection -> Sem r ()
- clipboardEvents :: Members [Events resource XClipboardEvent, Reader GtkState, Embed IO, Final IO] r => Sem r ()
- listenXClipboard :: Members [Events resource XClipboardEvent, Error Text, Race, Resource, Async, Embed IO, Final IO] r => InterpreterFor (Reader GtkState) r
- type Api = "event" :> (Get '[JSON] (Seq Event) :<|> (ReqBody '[JSON] Event :> PostCreated '[JSON] ()))
- serve :: Members [Events resource Event, Reader NetConfig] r => Members [AtomicState (Seq Event), Reader InstanceName, Sync ServerReady, Log, Interrupt, Final IO] r => Sem r ()
- listen :: Members Agents r => Members [EventConsumer token Event, AtomicState (Seq Event), ChronosTime, Log] r => Maybe Int -> Sem r ()
- yank :: Members [Reader InstanceName, ChronosTime, Manager, Log, Race, Error Text, Embed IO] r => NetConfig -> YankConfig -> Sem r ()
Documentation
Helic is primarily a CLI tool that listens for clipboard events and broadcasts them to other hosts and tmux.
The program is built with Polysemy, so its effects and interpreters may be useful for other developers. Some utilities for interfacing with GTK are exposed as well.
An agent is an interface to an external entity that can receive clipboard events. The Helic CLI uses agents for remote hosts over network, tmux, and X11.
type Agents = [Tagged AgentTmux Agent, Tagged AgentX Agent, Tagged AgentNet Agent] Source #
The default agents for the Helic CLI.
XClipboard
data XClipboard :: Effect Source #
Communicate with the X11 clipboard.
Interpreters
interpretAgentNet :: Members [Manager, Events resource Event, Reader InstanceName, Reader NetConfig] r => Members [AtomicState (Seq Event), Log, Interrupt, Race, Resource, Async, Embed IO, Final IO] r => InterpreterFor (Tagged AgentNet Agent) r Source #
Interpret Agent
using remote hosts as targets.
This also starts the HTTP server that listens to network events, which are used both for remote hosts and CLI
events.
interpretAgentX :: Members [EventConsumer xr XClipboardEvent, Events er Event, Reader InstanceName, XClipboard, ChronosTime] r => Members [Events xr XClipboardEvent, Error Text, Race, Resource, Async, Embed IO, Final IO] r => InterpreterFor (Tagged AgentX Agent) r Source #
Interpret Agent
using the X11 clipboard as target.
This interpreter also runs a thread that converts events generated by the XClipboard
interpreter
(XClipboardEvent
) to the main Event
type.
interpretAgentTmux :: Members [Reader TmuxConfig, Log, Async, Race, Resource, Embed IO] r => InterpreterFor (Tagged AgentTmux Agent) r Source #
Interpret Agent
using a tmux server as the target.
interpretXClipboardGtk :: Members [Reader GtkState, Embed IO] r => InterpreterFor XClipboard r Source #
Interpret XClipboard
using a GTK backend.
This uses the gi-gtk
library to access the X11 clipboard.
Data
The central data type representing a clipboard event.
Utilities
transformXEvents :: Member (Reader InstanceName) r => Members [EventConsumer xr XClipboardEvent, Events er Event, XClipboard, ChronosTime, Resource, Race, Async] r => Sem r a -> Sem r a Source #
Listen for XClipboardEvent
s and publish them as Event
s.
withMainLoop :: Members [Resource, Error Text, Race, Async, Embed IO] r => InterpreterFor (Reader GtkState) r Source #
subscribeToClipboard :: Members [Events resource XClipboardEvent, Reader GtkState, Embed IO, Final IO] r => Clipboard -> Selection -> Sem r () Source #
Listen to clipboard events for a specific source, like "primary selection", and publish them via Events
.
clipboardEvents :: Members [Events resource XClipboardEvent, Reader GtkState, Embed IO, Final IO] r => Sem r () Source #
Listen to clipboard events and publish them via Events
.
listenXClipboard :: Members [Events resource XClipboardEvent, Error Text, Race, Resource, Async, Embed IO, Final IO] r => InterpreterFor (Reader GtkState) r Source #
Run a GTK main loop and listen to clipboard events, publishing them via Events
.
type Api = "event" :> (Get '[JSON] (Seq Event) :<|> (ReqBody '[JSON] Event :> PostCreated '[JSON] ())) Source #
The Servant API of the daemon, providing endpoints for getting all events and creating one.
serve :: Members [Events resource Event, Reader NetConfig] r => Members [AtomicState (Seq Event), Reader InstanceName, Sync ServerReady, Log, Interrupt, Final IO] r => Sem r () Source #
Run the daemon API.