krasenyp

krasenyp

I3_client - i3 IPC client, written in Erlang

This is an i3 IPC client implementation, written in Erlang, with zero dependencies. All the messages and events exposed by i3 and Sway are currently supported.

It’s a very early release but it’s fully featured. My next two priorities are improving the test coverage and extending the documentation with examples. Nevertheless, I’ll be happy to hear from early users.

Notable features

  • Variant negotiation - rudimentary capability checks but the fundamentals are ther
  • Automatic reconnection - opt-in but nice to have
  • Multiplexing - a single connection can handle request-response and out-of-band events.

Example

The following example shows how to start a client connection, subscribe to events and run commands. All using the same connection, all idiomatic OTP behaviour.

iex> {:ok, pid} = :i3_client.start_link([])
iex> {:ok, ref} = :i3_client.subscribe(pid, ["window"])
iex> {:ok, _} = :i3_client.run_command(pid, "focus right")
iex> flush()
{:i3_event, ^pid, ^ref, "window", "..."} # Pseudocode but you get the idea

Hex: i3_client | Hex
Source:

Most Liked

krasenyp

krasenyp

I’m happy to announce that v0.2.0 was just released.

This version brings one user-facing change - first tick events, the ones received right after a subscription to tick events is made, are treated as unicast events. They used to be broadcast events, like any other type of event, but it was an incorrect behaviour. I knowingly left it that way in the initial version because it was tolerable but now it’s time for correct and predictable handling of this special kind of event.

MaxRu

MaxRu

Very cool stuff!

I’m currently also working on a client like this but for wayland protocols because i am building a WM in elixir.

Whats your use case for an i3 client in erlang?

krasenyp

krasenyp

Nothing special on my side, I’m just using the swaybar protocol. I use i3_client to keep track of various pieces of state. For example, I’m subscribed to input events and update the bar accordingly whenever I change the keyboard layout.

Last Post!

krasenyp

krasenyp

I’m happy to announce that v0.3.0 was just released.

This version brings a new module - i3_client_trees which includes functions for processing i3 layout trees. Currently, it holds only two functions - table/1,2. The functions return QLC handle which allows for iterator style traversal. For example, you can very easily find the focused node:

0> QH = qlc:q([Node || #{~"focused" := true} = Node <- i3_client_trees:table(Tree)]),
1> [#{~"focused" := true}] = qlc:eval(QH).

Where Next?

Popular in Announcing Top

KronicDeth
Elixir plugin for JetBrain’s IntelliJ Platform (including Rubymine) This is a plugin that adds support for Elixir to JetBrains IntelliJ...
289 36654 110
New
jakub-zawislak
Hi everyone, I’m coming from the Symfony (PHP) framework. I like Phoenix, but it has a one thing that was build much better in the Symfo...
New
Crowdhailer
Raxx is an alternative to Plug and is inspired by projects such as Rack(Ruby) and Ring(Clojure). 1.0-rc.1 is now available. To use it re...
New
anshuman23
Hello all, I have been working on my proposed project called Tensorflex as part of Google Summer of Code 2018.. Tensorflex can be used f...
New
mindok
What is ContEx? A pure Elixir server-side data plotting/charting library outputting SVG. It has nice barcharts in particular and works g...
New
mplatts
With HEEX released we decided to start a components library using Tailwind CSS - check it out here: Petal Components. We also have a boi...
New
wojtekmach
Hey everyone! Req is an HTTP client for Elixir that I’ve been working on for quite some time. There is already a lot of HTTP clients out...
New

Other popular topics Top

electic
Hi, I am new to Elixir. I am trying to use the DateTime component to insert a date into MySQL however the there seems to be no way to fo...
New
stefanchrobot
What’s the safe way to decode a JSON string into a struct? I want to avoid calling String.to_atom. Jason.decode can give me a map with st...
New
Darmani72
If I have a post route which an argument: post /my_post_route/:my_param1, MyController.my_post_handler How would get the post params ...
New
joeerl
Hello again - after a longish gap I’ve decided I really must dig into Elixir and see what’s been happening here - so I have a few questio...
New
gshaw
What is the idiomatic way of matching for not nil in Elixir? E.g., First way: defp halt_if_not_signed_in(conn, signed_in_account) when...
New
AstonJ
Posting this to see if we can make things easier for people to get into Neovim. If you use Neovim and have a favourite distro please let ...
New

We're in Beta

About us Mission Statement