qi3pc 0.4.1
Qt based library to communicate with i3wm via its IPC API
Loading...
Searching...
No Matches
qi3pc Class Reference

Mapping to the i3wm IPC interface. More...

#include <qi3pc.h>

Inheritance diagram for qi3pc:

Classes

struct  ParseError
 The Err struct contains the attributes of a parsing error from i3wm when trying to run an unparsable command;. More...

Public Types

enum class  IpcEvent : quint32 {
  Workspace = I3_IPC_EVENT_WORKSPACE ,
  Output = I3_IPC_EVENT_OUTPUT ,
  Mode = I3_IPC_EVENT_MODE ,
  Window = I3_IPC_EVENT_WINDOW ,
  BarUpdate = I3_IPC_EVENT_BARCONFIG_UPDATE ,
  Binding = I3_IPC_EVENT_BINDING ,
  Shutdown = I3_IPC_EVENT_SHUTDOWN ,
  Tick = I3_IPC_EVENT_TICK
}
 Types of events offered by i3wm's IPC API. More...
enum class  IpcType : quint32 {
  Command = I3_IPC_REPLY_TYPE_COMMAND ,
  Workspaces = I3_IPC_REPLY_TYPE_WORKSPACES ,
  Subscribe = I3_IPC_REPLY_TYPE_SUBSCRIBE ,
  Outputs = I3_IPC_REPLY_TYPE_OUTPUTS ,
  Tree = I3_IPC_REPLY_TYPE_TREE ,
  Marks = I3_IPC_REPLY_TYPE_MARKS ,
  BarConfig = I3_IPC_REPLY_TYPE_BAR_CONFIG ,
  Version = I3_IPC_REPLY_TYPE_VERSION ,
  BindingModes = I3_IPC_REPLY_TYPE_BINDING_MODES ,
  Config = I3_IPC_REPLY_TYPE_CONFIG ,
  Tick = I3_IPC_REPLY_TYPE_TICK ,
  Sync = I3_IPC_REPLY_TYPE_SYNC ,
  BindingState = I3_IPC_REPLY_TYPE_GET_BINDING_STATE
}
 Types of message/replies the API send/expect to/from i3wm. More...
enum class  WorkspaceChange {
  Empty ,
  Focus ,
  Init ,
  Move ,
  Reload ,
  Rename ,
  Restored ,
  Urgent ,
  Unknown
}
 Types of change a workspace event can have. More...
enum class  OutputChange {
  Unspecified ,
  Unknown
}
 Types of change an output event can have. More...
enum class  WindowChange {
  New ,
  Close ,
  Focus ,
  Title ,
  Fullscreen ,
  Move ,
  Floating ,
  Urgent ,
  Mark ,
  Unknown
}
 Types of change a window event can have. More...
enum class  ShutdownChange {
  Restart ,
  Exit ,
  Unknown
}
 Types of change a shutdown event can have. More...
enum class  BindingChange {
  Run ,
  Unknown
}
 Types of change a binding event can have. More...
using DataObject = std::optional<std::pair<QJsonObject, qint64>>
 Optional pair of a JSON object with its last update time.
using DataArray = std::optional<std::pair<QJsonArray, qint64>>
 Optional pair of a JSON array with its last update time.
using DataString = std::optional<std::pair<QString, qint64>>
 Optional pair of a string with its last update time.
using Error = std::optional<ParseError>
 Optional qi3pc::ParseError. The optional is empty when the error could not be parsed.
using CommandResults = std::vector<std::pair<bool, Error>>
 Pairs of qi3pc::Error and boolean.
using Message = std::optional<std::pair<QJsonDocument, quint32>>
 Optional pair of a JSON document with a qi3pc::IpcType received with a message or an event before it has been processed.

Public Slots

void fetchWorkspaces ()
 Signal to emit to trigger an update of the list of workspace cache.
void fetchTree ()
 Signal to emit to trigger an update of the (cached) layout tree.
void fetchOutputs ()
 Signal to emit to trigger an update of the (cached) outputs.
void fetchMarks ()
 Signal to emit to trigger an update of the (cached) list of marks.
void fetchBarConfig (const QString &id)
 Signal to emit to update the (cached) configuration of a certain bar.
void fetchBarConfigs ()
 Signal to emit to update the list of bar configurations.
void fetchVersion ()
 Signal to emit to trigger a cache update for the i3wm version.
void fetchBindingModes ()
 Signal to emit to trigger an update of the (cached) list of modes.
void fetchConfig ()
 Signal to emit to trigger an update of the (cached) config.
void fetchBindingState ()
 Request update of the (cached) binding state.

Signals

void commandRan (CommandResults result)
 Signal emitted when a command have been ran by i3.
void tickSent (bool success)
 Signal emitted when a tick have been processed by i3.
void synced (bool success)
 Signal emitted when a sync message have been replied to by i3.
void subscribed (bool success)
 Signal emitted when a subscribe message have been replied to.
void workspaceEvent (qi3pc::WorkspaceChange change, const QJsonObject &current, const QJsonObject &old)
 Signal emitted with a workspace event's data preprocessed.
void outputEvent (qi3pc::OutputChange change)
 Signal emitted when the output(s) change.
void modeEvent (QString change, bool pango)
 Signal emitted when the binding mode changes.
void windowEvent (qi3pc::WindowChange change, const QJsonObject &container)
 Signal emitted when a window changes.
void barUpdateEvent (const QJsonObject &doc)
 Signal emitted when a bar's configuration have been updated.
void bindingEvent (qi3pc::BindingChange change, const QJsonObject &binding, const QString &mode)
 Signal emitteed when a binding have been triggered to run a command.
void shutdownEvent (qi3pc::ShutdownChange change)
 Signal emitted when the ipc socket is about to shutdown.
void tickEvent (const QString &payload)
 Signal emitted when subscribing to tick events or when a tick message have been sent to the ipc connection.
void workspacesUpdated (const qi3pc::DataArray &workspaces)
 Signal emitted when the (cached) list of workspaces have been updated.
void treeUpdated (const qi3pc::DataObject &tree)
 Signal emitted when the layout tree cache have been updated.
void outputsUpdated (const qi3pc::DataArray &outputs)
 Signal emitted when (cached) outputs have been updated.
void marksUpdated (const qi3pc::DataArray &marks)
 Signal emitted when the (cached) list of marks have been updated.
void barConfigUpdated (const QJsonObject &config)
 Signal emitted when a specific bar's (cached) config have been updated. At this point the configuration for the bar has been cached.
void newBarConfig (const QString &id)
 Signal emitted when a new bar config have been added to the cache.
void versionUpdated (const qi3pc::DataObject &version)
 Signal emitted when the (cached) i3 version have been updated.
void bindingModesUpdated (const qi3pc::DataArray &modes)
 Signal emitted when the (cached) list of modes have been updated.
void configUpdated (const qi3pc::DataObject &config)
 Signal emitted when the (cached) config have been updated.
void bindingStateUpdated (const qi3pc::DataString &state)
 Signal emitted when the (cached) current binding state have been updated.

Public Member Functions

 qi3pc (QObject *parent=nullptr)
 Construct a qi3pc object.
 qi3pc (const QString &socketPath, QObject *parent)
 Construct a qi3pc object connected to the provided socket.
virtual ~qi3pc ()
 Simple destructor for the qi3pc class.
bool connect ()
 Start listening to messages and events from the window manager.
bool isConnected ()
 Check if the connection to the ipc socket is established.
bool disconnect ()
 Stop listening to messages and events from the window manager.
void subscribe (const QStringList &events)
 Subscribe to a list of events.
QString socketPath () const
 Get the socket path selected at construction.
template<IpcType Type>
requires (Type != IpcType::Subscribe && Type != IpcType::Tick)
void sendMessage (const QByteArray &payload=QByteArray())
 Send a message with the specified type and payload to i3.
void sendTick (const QByteArray &payload=QByteArray())
 Send a tick message with the spoecified payload.
const DataArrayworkspaces () const
 Get the list of (cached) workspaces.
const DataObjecttree () const
 Get the (cached) i3 layout tree.
const DataArrayoutputs () const
 Get the (cached) list of outputs.
const DataArraymarks () const
 Get the (cached) list of set marks.
const DataObjectbarConfigs () const
 Get the (cached) list of all bar configurations.
const DataObjectversion () const
 Get the (cached) i3 version object.
const DataArraybindingModes () const
 Get the (cached) list of binding modes.
const DataObjectconfig () const
 Get the (cached) data read from the config file.
const DataStringbindingState () const
 Get the (cached) binding state.

Static Public Member Functions

static QString FindSocketPath ()
 Find the path to the i3 ipc local unix socket.
static QString FindSocketPathFromI3Binary ()
 Find the path to the i3 ipc local unix socket using the i3 binary.

Static Public Attributes

static constexpr auto IpcMagicString = std::string("i3-ipc")
static constexpr auto IpcMagicLength = IpcMagicString.length()

Private Member Functions

Message processMessage (QLocalSocket &socket)
 Read one message using the socket parameter.
void processEvent ()
 Read data from the event socket.
void processReply ()
 Read data from the message socket.
void processWorkspaceEvent (const QJsonDocument &doc)
 Handle data received from a workspace event.
void processOutputEvent (const QJsonDocument &doc)
 Handle data received from an output event.
void processModeEvent (const QJsonDocument &doc)
 Handle data received from a mode event.
void processWindowEvent (const QJsonDocument &doc)
 Handle data received from a window event.
void processBarUpdateEvent (const QJsonDocument &doc)
 Handle data received from a bar update event.
void processBindingEvent (const QJsonDocument &doc)
 Handle data received from a binding event.
void processShutdownEvent (const QJsonDocument &doc)
 Handle data received from a shutdowm event.
void processTickEvent (const QJsonDocument &doc)
 Handle data received from a tick event.
void processCommandReply (const QJsonDocument &doc)
 Handle data received from a run command reply.
void processWorkspaceReply (const QJsonDocument &doc)
 Handle data received from a workspace reply.
void processOutputReply (const QJsonDocument &doc)
 Handle data received from an output reply.
void processTreeReply (const QJsonDocument &doc)
 Handle data received from a tree reply.
void processMarkReply (const QJsonDocument &doc)
 Handle data received from a mark reply.
void processBarConfigReply (const QJsonDocument &doc)
 Handle data received from a bar config reply.
void processVersionReply (const QJsonDocument &doc)
 Handle data received from a version reply.
void processBindingModesReply (const QJsonDocument &doc)
 Handle data received in a binding mode reply.
void processConfigReply (const QJsonDocument &doc)
 Handle data received from a config reply.
void processTickReply (const QJsonDocument &doc)
 Handle data received from a tick reply.
void processSyncReply (const QJsonDocument &doc)
 Handle data received from a sync reply.
void processBindingStateReply (const QJsonDocument &doc)
 Handle data received from a binding state event reply.

Static Private Member Functions

static WorkspaceChange WorkspaceChangeFromString (const QString &s)
 Convert a string into a workspace change object.
static WindowChange WindowChangeFromString (const QString &s)
 Convert a string into a window change object.
static ShutdownChange ShutdownChangeFromString (const QString &s)
 Convert a string into a shutdown change object.
static OutputChange OutputChangeFromString (const QString &s)
 Convert a string into an output change object.
static BindingChange BindingChangeFromString (const QString &s)
 Convert a string into a binding change object.
static void WritePayload (QLocalSocket &socket, const QByteArray &payload, IpcType type)
 Send a message with the specified type and payload to i3 using the specified socket.

Private Attributes

QString m_socketPath
QLocalSocket m_eventSocket
QLocalSocket m_messageSocket
DataObject m_tree
DataArray m_workspaces
DataArray m_outputs
DataArray m_marks
DataObject m_barConfigs
DataObject m_version
DataArray m_bindingModes
DataString m_bindingState
DataObject m_config

Detailed Description

Mapping to the i3wm IPC interface.

This is an intuitive layer over the API offered by the i3wm IPC interface. The workflow follows the usual mechanisms available by Qt with signals and slots.

Definition at line 29 of file qi3pc.h.

Member Typedef Documentation

◆ DataObject

using qi3pc::DataObject = std::optional<std::pair<QJsonObject, qint64>>

Optional pair of a JSON object with its last update time.

Definition at line 156 of file qi3pc.h.

◆ DataArray

using qi3pc::DataArray = std::optional<std::pair<QJsonArray, qint64>>

Optional pair of a JSON array with its last update time.

Definition at line 159 of file qi3pc.h.

◆ DataString

using qi3pc::DataString = std::optional<std::pair<QString, qint64>>

Optional pair of a string with its last update time.

Definition at line 162 of file qi3pc.h.

◆ Error

using qi3pc::Error = std::optional<ParseError>

Optional qi3pc::ParseError. The optional is empty when the error could not be parsed.

Definition at line 231 of file qi3pc.h.

◆ CommandResults

using qi3pc::CommandResults = std::vector<std::pair<bool, Error>>

Pairs of qi3pc::Error and boolean.

For each element, if the boolean is false, the command was ran successfully. Otherwise information about the parse error encountered is in the second element.

Definition at line 239 of file qi3pc.h.

◆ Message

using qi3pc::Message = std::optional<std::pair<QJsonDocument, quint32>>

Optional pair of a JSON document with a qi3pc::IpcType received with a message or an event before it has been processed.

See also
qi3pc::IpcType
qi3pc::IpcEvent

Definition at line 247 of file qi3pc.h.

Member Enumeration Documentation

◆ IpcEvent

enum class qi3pc::IpcEvent : quint32
strong

Types of events offered by i3wm's IPC API.

See i3 docs.

Definition at line 43 of file qi3pc.h.

◆ IpcType

enum class qi3pc::IpcType : quint32
strong

Types of message/replies the API send/expect to/from i3wm.

See i3 docs.

Definition at line 61 of file qi3pc.h.

◆ WorkspaceChange

enum class qi3pc::WorkspaceChange
strong

Types of change a workspace event can have.

Mapping of the change property received in a workspace event.

Enumerator
Empty 

A workspace became empty.

Focus 

A workspace received input focus.

Init 

A workspace was created.

Move 

A workspace was moved to a different output.

Reload 

The window manager's config was reloaded.

Rename 

A workspace was renamed.

Restored 

A workspace's layout was restored to a saved layout.

Urgent 

A workspace gained/lost urgent status.

Unknown 

Unsupported change.

Definition at line 85 of file qi3pc.h.

◆ OutputChange

enum class qi3pc::OutputChange
strong

Types of change an output event can have.

Mapping of the change property received in a output event.

Enumerator
Unspecified 

See i3 docs.

Unknown 

Unsupported change.

Definition at line 104 of file qi3pc.h.

◆ WindowChange

enum class qi3pc::WindowChange
strong

Types of change a window event can have.

Mapping of the change property received in a window event.

Enumerator
New 

A new window is created.

Close 

A window is closed.

Focus 

A window gained focus.

Title 

A window's title changed.

Fullscreen 

A window entered/left fullscreen mode.

Move 

A window have been moved.

Floating 

A window entered/left floating mode.

Urgent 

A window gained/lost urgent status.

Mark 

A mark was added/remvoed to/from a window.

Unknown 

Unsupported change.

Definition at line 116 of file qi3pc.h.

◆ ShutdownChange

enum class qi3pc::ShutdownChange
strong

Types of change a shutdown event can have.

Mapping of the change property received in a shutdown event.

Enumerator
Restart 

The window mananger is restarted.

Exit 

The window manager is exiting.

Unknown 

Unsupported change.

Definition at line 136 of file qi3pc.h.

◆ BindingChange

enum class qi3pc::BindingChange
strong

Types of change a binding event can have.

Mapping of the change property received in a binding event.

Enumerator
Run 

A binding was run.

Unknown 

Unsupported change.

Definition at line 149 of file qi3pc.h.

Constructor & Destructor Documentation

◆ qi3pc() [1/2]

qi3pc::qi3pc ( QObject * parent = nullptr)
explicit

Construct a qi3pc object.

Parameters
parentParent of the qi3pc object to create (matching Qt conventions).

Definition at line 7 of file qi3pc.cpp.

References qi3pc(), and FindSocketPath().

◆ qi3pc() [2/2]

qi3pc::qi3pc ( const QString & socketPath,
QObject * parent )
explicit

Construct a qi3pc object connected to the provided socket.

Parameters
socketPathThe path to the server to use (e.g. /tmp/some-service.socket)
parentParent of the qi3pc object to create (matching Qt conventions).

Definition at line 11 of file qi3pc.cpp.

References m_barConfigs, m_eventSocket, m_messageSocket, m_socketPath, processEvent(), and processReply().

◆ ~qi3pc()

qi3pc::~qi3pc ( )
virtual

Simple destructor for the qi3pc class.

Disconnects the used sockets.

See also
qi3pc::disconnect

Definition at line 27 of file qi3pc.cpp.

References m_eventSocket, and m_messageSocket.

Member Function Documentation

◆ connect()

bool qi3pc::connect ( )

Start listening to messages and events from the window manager.

Returns
The success of the operation

This method may wait up to 3 seconds for the connection to be established. If it takes more than 3 seconds to connect, the connection might be established later, but the returned value will not reflect that.

See also
qi3pc::connected

Definition at line 581 of file qi3pc.cpp.

References m_eventSocket, m_messageSocket, and m_socketPath.

◆ isConnected()

bool qi3pc::isConnected ( )

Check if the connection to the ipc socket is established.

Returns
Return if the connection to the two sockets (message/events) were established.
See also
qi3pc::connect

Definition at line 622 of file qi3pc.cpp.

References m_eventSocket, and m_messageSocket.

◆ disconnect()

bool qi3pc::disconnect ( )

Stop listening to messages and events from the window manager.

Returns
Return if the socket connections have been closed.
See also
qi3pc::isConnected

Definition at line 602 of file qi3pc.cpp.

References m_eventSocket, and m_messageSocket.

◆ subscribe()

void qi3pc::subscribe ( const QStringList & events)

Subscribe to a list of events.

Parameters
eventsA list of strings with the events to subscribe to.

Definition at line 641 of file qi3pc.cpp.

References m_eventSocket, and WritePayload().

◆ FindSocketPath()

QString qi3pc::FindSocketPath ( )
static

Find the path to the i3 ipc local unix socket.

First tries to read the I3SOCK environment variable. If I3SOCK is empty or not set, calls

i3 --get-socketpath
Returns
The path to the unix socket.

Definition at line 488 of file qi3pc.cpp.

References FindSocketPathFromI3Binary().

◆ FindSocketPathFromI3Binary()

QString qi3pc::FindSocketPathFromI3Binary ( )
static

Find the path to the i3 ipc local unix socket using the i3 binary.

Calls

i3 --get-socketpath

and returns its output.

Returns
The path to the unix socket.

Definition at line 500 of file qi3pc.cpp.

◆ socketPath()

QString qi3pc::socketPath ( ) const

Get the socket path selected at construction.

Returns
The i3 socket path from when the object was created.

Definition at line 512 of file qi3pc.cpp.

References m_socketPath.

◆ sendMessage()

template<IpcType Type>
requires (Type != IpcType::Subscribe && Type != IpcType::Tick)
void qi3pc::sendMessage ( const QByteArray & payload = QByteArray())
inline

Send a message with the specified type and payload to i3.

Template Parameters
TypeThe type of the message to send.
Parameters
payloadThe content of the message.

Available message types.

Do not use this method to send qi3pc::IpcType::Subscribe or qi3pc::IpcType::Tick messages, use qi3pc::subscribe and qi3pc::sendTick instead.

Definition at line 345 of file qi3pc.h.

References m_messageSocket, and WritePayload().

◆ sendTick()

void qi3pc::sendTick ( const QByteArray & payload = QByteArray())

Send a tick message with the spoecified payload.

Parameters
payloadArbitrary string to send with the tick

Definition at line 635 of file qi3pc.cpp.

References m_eventSocket, and WritePayload().

◆ workspaces()

const qi3pc::DataArray & qi3pc::workspaces ( ) const

Get the list of (cached) workspaces.

Returns
The list of workspaces with their last update time.
See also
qi3pc::fetchWorkspaces

Definition at line 519 of file qi3pc.cpp.

References m_workspaces.

◆ tree()

const qi3pc::DataObject & qi3pc::tree ( ) const

Get the (cached) i3 layout tree.

Returns
The layout tree with their last update time
See also
qi3pc::fetchTree

Definition at line 526 of file qi3pc.cpp.

References m_tree.

◆ outputs()

const qi3pc::DataArray & qi3pc::outputs ( ) const

Get the (cached) list of outputs.

Returns
The list of outputs with their last update time.
See also
qi3pc::fetchOutputs

Definition at line 533 of file qi3pc.cpp.

References m_outputs.

◆ marks()

const qi3pc::DataArray & qi3pc::marks ( ) const

Get the (cached) list of set marks.

Returns
The list of marks and their last update time.
See also
qi3pc::fetchMarks

Definition at line 540 of file qi3pc.cpp.

References m_marks.

◆ barConfigs()

const qi3pc::DataObject & qi3pc::barConfigs ( ) const

Get the (cached) list of all bar configurations.

Returns
A map of bar configurations and its last update time.
See also
qi3pc::fetchBarConfig
qi3pc::barConfigUpdated
qi3pc::newBarConfig

Definition at line 547 of file qi3pc.cpp.

References m_barConfigs.

◆ version()

const qi3pc::DataObject & qi3pc::version ( ) const

Get the (cached) i3 version object.

Returns
The i3 version and the last time it was updated.
See also
qi3pc::fetchVersion
qi3pc::versionUpdated

Definition at line 554 of file qi3pc.cpp.

References m_version.

◆ bindingModes()

const qi3pc::DataArray & qi3pc::bindingModes ( ) const

Get the (cached) list of binding modes.

Returns
The list of binding modes and their last update time.
See also
qi3pc::fetchBindingModes
qi3pc::bindingModesUpdated

Definition at line 561 of file qi3pc.cpp.

References m_bindingModes.

◆ config()

const qi3pc::DataObject & qi3pc::config ( ) const

Get the (cached) data read from the config file.

Returns
The config and the last time it was updated.
See also
qi3pc::fetchConfig
qi3pc::configUpdated

Definition at line 568 of file qi3pc.cpp.

References m_config.

◆ bindingState()

const qi3pc::DataString & qi3pc::bindingState ( ) const

Get the (cached) binding state.

Returns
The binding state and the last time it was updated.
See also
qi3pc::fetchBindingState
qi3pc::bindingStateUpdated

Definition at line 575 of file qi3pc.cpp.

References m_bindingState.

◆ fetchWorkspaces

void qi3pc::fetchWorkspaces ( )
slot

Signal to emit to trigger an update of the list of workspace cache.

See also
qi3pc::workspaces
qi3pc::workspacesUpdated

Definition at line 675 of file qi3pc.cpp.

References sendMessage().

◆ fetchTree

void qi3pc::fetchTree ( )
slot

Signal to emit to trigger an update of the (cached) layout tree.

See also
qi3pc::tree
qi3pc::treeUpdated

Definition at line 681 of file qi3pc.cpp.

References sendMessage().

◆ fetchOutputs

void qi3pc::fetchOutputs ( )
slot

Signal to emit to trigger an update of the (cached) outputs.

See also
qi3pc::outputs
qi3pc::outputsUpdated

Definition at line 687 of file qi3pc.cpp.

References sendMessage().

◆ fetchMarks

void qi3pc::fetchMarks ( )
slot

Signal to emit to trigger an update of the (cached) list of marks.

See also
qi3pc::marks
qi3pc::marksUpdated

Definition at line 693 of file qi3pc.cpp.

References sendMessage().

◆ fetchBarConfig

void qi3pc::fetchBarConfig ( const QString & id)
slot

Signal to emit to update the (cached) configuration of a certain bar.

Parameters
idString identifying to bar to update.
See also
qi3pc::barConfigUpdated
qi3pc::newBarConfig
qi3pc::barConfigs

Definition at line 723 of file qi3pc.cpp.

References sendMessage().

◆ fetchBarConfigs

void qi3pc::fetchBarConfigs ( )
slot

Signal to emit to update the list of bar configurations.

See also
qi3pc::barConfigUpdated
qi3pc::newBarConfig
qi3pc::barConfigs

Definition at line 717 of file qi3pc.cpp.

References sendMessage().

◆ fetchVersion

void qi3pc::fetchVersion ( )
slot

Signal to emit to trigger a cache update for the i3wm version.

See also
qi3pc::version
qi3pc::versionUpdated

Definition at line 699 of file qi3pc.cpp.

References sendMessage().

◆ fetchBindingModes

void qi3pc::fetchBindingModes ( )
slot

Signal to emit to trigger an update of the (cached) list of modes.

See also
qi3pc::bindingModes
qi3pc::bindingModesUpdated

Definition at line 705 of file qi3pc.cpp.

References sendMessage().

◆ fetchConfig

void qi3pc::fetchConfig ( )
slot

Signal to emit to trigger an update of the (cached) config.

See also
qi3pc::config
qi3pc::configUpdated

Definition at line 711 of file qi3pc.cpp.

References sendMessage().

◆ fetchBindingState

void qi3pc::fetchBindingState ( )
slot

Request update of the (cached) binding state.

See also
qi3pc::bindingState
qi3pc::bindingStateUpdated

Definition at line 731 of file qi3pc.cpp.

References sendMessage().

◆ processMessage()

qi3pc::Message qi3pc::processMessage ( QLocalSocket & socket)
private

Read one message using the socket parameter.

Parameters
socketLocal unix socket from which the message is read
Returns
An optional json doc and the type of the message read

Definition at line 438 of file qi3pc.cpp.

References IpcMagicLength, and IpcMagicString.

◆ processEvent()

◆ processReply()

◆ processWorkspaceEvent()

void qi3pc::processWorkspaceEvent ( const QJsonDocument & doc)
private

Handle data received from a workspace event.

Parameters
docDocument containing the data

Definition at line 269 of file qi3pc.cpp.

References Unknown, WorkspaceChangeFromString(), and workspaceEvent().

◆ processOutputEvent()

void qi3pc::processOutputEvent ( const QJsonDocument & doc)
private

Handle data received from an output event.

Parameters
docDocument containing the data

Definition at line 284 of file qi3pc.cpp.

References OutputChangeFromString(), outputEvent(), and Unknown.

◆ processModeEvent()

void qi3pc::processModeEvent ( const QJsonDocument & doc)
private

Handle data received from a mode event.

Parameters
docDocument containing the data

Definition at line 297 of file qi3pc.cpp.

References modeEvent().

◆ processWindowEvent()

void qi3pc::processWindowEvent ( const QJsonDocument & doc)
private

Handle data received from a window event.

Parameters
docDocument containing the data

Definition at line 303 of file qi3pc.cpp.

References Unknown, WindowChangeFromString(), and windowEvent().

◆ processBarUpdateEvent()

void qi3pc::processBarUpdateEvent ( const QJsonDocument & doc)
private

Handle data received from a bar update event.

Parameters
docDocument containing the data

Definition at line 316 of file qi3pc.cpp.

References barUpdateEvent().

◆ processBindingEvent()

void qi3pc::processBindingEvent ( const QJsonDocument & doc)
private

Handle data received from a binding event.

Parameters
docDocument containing the data

Definition at line 322 of file qi3pc.cpp.

References BindingChangeFromString(), bindingEvent(), and Unknown.

◆ processShutdownEvent()

void qi3pc::processShutdownEvent ( const QJsonDocument & doc)
private

Handle data received from a shutdowm event.

Parameters
docDocument containing the data

Definition at line 335 of file qi3pc.cpp.

References ShutdownChangeFromString(), shutdownEvent(), and Unknown.

◆ processTickEvent()

void qi3pc::processTickEvent ( const QJsonDocument & doc)
private

Handle data received from a tick event.

Parameters
docDocument containing the data

Definition at line 348 of file qi3pc.cpp.

References tickEvent().

◆ processCommandReply()

void qi3pc::processCommandReply ( const QJsonDocument & doc)
private

Handle data received from a run command reply.

Parameters
docDocument containing the data

Definition at line 155 of file qi3pc.cpp.

References commandRan(), and qi3pc::ParseError::FromJSON().

◆ processWorkspaceReply()

void qi3pc::processWorkspaceReply ( const QJsonDocument & doc)
private

Handle data received from a workspace reply.

Parameters
docDocument containing the data

Definition at line 182 of file qi3pc.cpp.

References m_workspaces, and workspacesUpdated().

◆ processOutputReply()

void qi3pc::processOutputReply ( const QJsonDocument & doc)
private

Handle data received from an output reply.

Parameters
docDocument containing the data

Definition at line 189 of file qi3pc.cpp.

References m_outputs, and outputsUpdated().

◆ processTreeReply()

void qi3pc::processTreeReply ( const QJsonDocument & doc)
private

Handle data received from a tree reply.

Parameters
docDocument containing the data

Definition at line 196 of file qi3pc.cpp.

References m_tree, and treeUpdated().

◆ processMarkReply()

void qi3pc::processMarkReply ( const QJsonDocument & doc)
private

Handle data received from a mark reply.

Parameters
docDocument containing the data

Definition at line 203 of file qi3pc.cpp.

References m_marks, and marksUpdated().

◆ processBarConfigReply()

void qi3pc::processBarConfigReply ( const QJsonDocument & doc)
private

Handle data received from a bar config reply.

Parameters
docDocument containing the data

Definition at line 210 of file qi3pc.cpp.

References barConfigUpdated(), config(), m_barConfigs, and newBarConfig().

◆ processVersionReply()

void qi3pc::processVersionReply ( const QJsonDocument & doc)
private

Handle data received from a version reply.

Parameters
docDocument containing the data

Definition at line 229 of file qi3pc.cpp.

References m_version, and versionUpdated().

◆ processBindingModesReply()

void qi3pc::processBindingModesReply ( const QJsonDocument & doc)
private

Handle data received in a binding mode reply.

Parameters
docDocument containing the data

Definition at line 236 of file qi3pc.cpp.

References bindingModesUpdated(), and m_bindingModes.

◆ processConfigReply()

void qi3pc::processConfigReply ( const QJsonDocument & doc)
private

Handle data received from a config reply.

Parameters
docDocument containing the data

Definition at line 243 of file qi3pc.cpp.

References configUpdated(), and m_config.

◆ processTickReply()

void qi3pc::processTickReply ( const QJsonDocument & doc)
private

Handle data received from a tick reply.

Parameters
docDocument containing the data

Definition at line 250 of file qi3pc.cpp.

References tickSent().

◆ processSyncReply()

void qi3pc::processSyncReply ( const QJsonDocument & doc)
private

Handle data received from a sync reply.

Parameters
docDocument containing the data

Definition at line 256 of file qi3pc.cpp.

References synced().

◆ processBindingStateReply()

void qi3pc::processBindingStateReply ( const QJsonDocument & doc)
private

Handle data received from a binding state event reply.

Parameters
docDocument containing the data

Definition at line 262 of file qi3pc.cpp.

References bindingStateUpdated(), and m_bindingState.

◆ WorkspaceChangeFromString()

qi3pc::WorkspaceChange qi3pc::WorkspaceChangeFromString ( const QString & s)
staticprivate

Convert a string into a workspace change object.

Parameters
sThe string to convert
Returns
A qi3pc::WorkspaceChange value.

Definition at line 356 of file qi3pc.cpp.

References Empty, Focus, Init, Move, Reload, Rename, Restored, Unknown, and Urgent.

◆ WindowChangeFromString()

qi3pc::WindowChange qi3pc::WindowChangeFromString ( const QString & s)
staticprivate

Convert a string into a window change object.

Parameters
sThe string to convert
Returns
A qi3pc::WindowChange value.

Definition at line 380 of file qi3pc.cpp.

References Close, Floating, Focus, Fullscreen, Mark, Move, New, Title, Unknown, and Urgent.

◆ ShutdownChangeFromString()

qi3pc::ShutdownChange qi3pc::ShutdownChangeFromString ( const QString & s)
staticprivate

Convert a string into a shutdown change object.

Parameters
sThe string to convert
Returns
A qi3pc::ShutdownChange value.

Definition at line 406 of file qi3pc.cpp.

References Exit, Restart, and Unknown.

◆ OutputChangeFromString()

qi3pc::OutputChange qi3pc::OutputChangeFromString ( const QString & s)
staticprivate

Convert a string into an output change object.

Parameters
sThe string to convert
Returns
A qi3pc::OutputChange value.

Definition at line 418 of file qi3pc.cpp.

References Unknown, and Unspecified.

◆ BindingChangeFromString()

qi3pc::BindingChange qi3pc::BindingChangeFromString ( const QString & s)
staticprivate

Convert a string into a binding change object.

Parameters
sThe string to convert
Returns
A qi3pc::BindingChange value.

Definition at line 428 of file qi3pc.cpp.

References Run, and Unknown.

◆ WritePayload()

void qi3pc::WritePayload ( QLocalSocket & socket,
const QByteArray & payload,
IpcType type )
staticprivate

Send a message with the specified type and payload to i3 using the specified socket.

Parameters
socketThe socket where the payload should be written.
payloadThe content to be written on the socket.
typeThe type of the payload.

Definition at line 656 of file qi3pc.cpp.

References IpcMagicLength, and IpcMagicString.

◆ commandRan

void qi3pc::commandRan ( CommandResults result)
signal

Signal emitted when a command have been ran by i3.

Parameters
resultPairs of boolean and optional parse error.

Use qi3pc::sendMessage to run command with the qi3pc::IpcType::Command type.

◆ tickSent

void qi3pc::tickSent ( bool success)
signal

Signal emitted when a tick have been processed by i3.

Parameters
success

Use qi3pc::sendMessage to send tick messages with the qi3pc::IpcType::Tick type.

◆ synced

void qi3pc::synced ( bool success)
signal

Signal emitted when a sync message have been replied to by i3.

Parameters
success

Use qi3pc::sendMessage to send sync messages with the qi3pc::IpcTypeSync type.

◆ subscribed

void qi3pc::subscribed ( bool success)
signal

Signal emitted when a subscribe message have been replied to.

Parameters
successIndicates whether the subscription was successfull
See also
qi3pc::subscribe

◆ workspaceEvent

void qi3pc::workspaceEvent ( qi3pc::WorkspaceChange change,
const QJsonObject & current,
const QJsonObject & old )
signal

Signal emitted with a workspace event's data preprocessed.

Parameters
changeThe type of change
currentThe current workspace
oldThe old workspace

◆ outputEvent

void qi3pc::outputEvent ( qi3pc::OutputChange change)
signal

Signal emitted when the output(s) change.

Parameters
changeThe type of change

◆ modeEvent

void qi3pc::modeEvent ( QString change,
bool pango )
signal

Signal emitted when the binding mode changes.

Parameters
changeThe name of the current mode.
pangoBoolean telling whether to display the mode with pango markup.

◆ windowEvent

void qi3pc::windowEvent ( qi3pc::WindowChange change,
const QJsonObject & container )
signal

Signal emitted when a window changes.

Parameters
changeThe type of change.
containerThe parent of the changed window.

◆ barUpdateEvent

void qi3pc::barUpdateEvent ( const QJsonObject & doc)
signal

Signal emitted when a bar's configuration have been updated.

Parameters
docJson object containing the bar configuration.

◆ bindingEvent

void qi3pc::bindingEvent ( qi3pc::BindingChange change,
const QJsonObject & binding,
const QString & mode )
signal

Signal emitteed when a binding have been triggered to run a command.

Parameters
changeThe type of change.
bindingThe binding that was run.
modeThe name of the mode the binding was run in.
See also
qi3pc::bindingState

◆ shutdownEvent

void qi3pc::shutdownEvent ( qi3pc::ShutdownChange change)
signal

Signal emitted when the ipc socket is about to shutdown.

Parameters
changeThe type of change.

◆ tickEvent

void qi3pc::tickEvent ( const QString & payload)
signal

Signal emitted when subscribing to tick events or when a tick message have been sent to the ipc connection.

Parameters
payloadArbitrary payload sent with the tick message.
Note
This signal is not emitted for subscriptions to tick messages.

◆ workspacesUpdated

void qi3pc::workspacesUpdated ( const qi3pc::DataArray & workspaces)
signal

Signal emitted when the (cached) list of workspaces have been updated.

Parameters
workspacesThe last list of workspaces with the update time.
See also
qi3pc::fetchWorkspaces

References workspaces().

◆ treeUpdated

void qi3pc::treeUpdated ( const qi3pc::DataObject & tree)
signal

Signal emitted when the layout tree cache have been updated.

Parameters
treeThe most recent layout tree cached and its update time.
See also
qi3pc::fetchTree

References tree().

◆ outputsUpdated

void qi3pc::outputsUpdated ( const qi3pc::DataArray & outputs)
signal

Signal emitted when (cached) outputs have been updated.

Parameters
outputsThe latest list of outputs and its update time.
See also
qi3pc::fetchOutputs

References outputs().

◆ marksUpdated

void qi3pc::marksUpdated ( const qi3pc::DataArray & marks)
signal

Signal emitted when the (cached) list of marks have been updated.

Parameters
marksThe most recent list of marks and the time when it was updated.
See also
qi3pc::fetchMarks

References marks().

◆ barConfigUpdated

void qi3pc::barConfigUpdated ( const QJsonObject & config)
signal

Signal emitted when a specific bar's (cached) config have been updated. At this point the configuration for the bar has been cached.

Parameters
configThe relevant bar's configuration.
See also
qi3pc::barConfigs

References config().

◆ newBarConfig

void qi3pc::newBarConfig ( const QString & id)
signal

Signal emitted when a new bar config have been added to the cache.

Parameters
idThe id of the new bar.

Only the id is stored at first. Call qi3pc::fetchBarConfig with the appropriate id to update it.

◆ versionUpdated

void qi3pc::versionUpdated ( const qi3pc::DataObject & version)
signal

Signal emitted when the (cached) i3 version have been updated.

Parameters
versionJSON object with the latest cached version and the time when it was updated.
See also
qi3pc::version

References version().

◆ bindingModesUpdated

void qi3pc::bindingModesUpdated ( const qi3pc::DataArray & modes)
signal

Signal emitted when the (cached) list of modes have been updated.

Parameters
modesThe most recent list of modes and the time when it was updated.
See also
qi3pc::modes

◆ configUpdated

void qi3pc::configUpdated ( const qi3pc::DataObject & config)
signal

Signal emitted when the (cached) config have been updated.

Parameters
configThe most recent config and the time when it was updated.
See also
qi3pc::config

References config().

◆ bindingStateUpdated

void qi3pc::bindingStateUpdated ( const qi3pc::DataString & state)
signal

Signal emitted when the (cached) current binding state have been updated.

Parameters
stateThe most recent binding state and the time when it was updated.
See also
qi3pc::bindingState

Member Data Documentation

◆ IpcMagicString

auto qi3pc::IpcMagicString = std::string("i3-ipc")
staticconstexpr

Magic string used by the current API

Definition at line 34 of file qi3pc.h.

◆ IpcMagicLength

auto qi3pc::IpcMagicLength = IpcMagicString.length()
staticconstexpr

Length of the current magic string

Definition at line 35 of file qi3pc.h.

◆ m_socketPath

QString qi3pc::m_socketPath
private

Path of the local unix socket used.

Definition at line 700 of file qi3pc.h.

◆ m_eventSocket

QLocalSocket qi3pc::m_eventSocket
private

Socket used to subscribe and handle events.

Definition at line 702 of file qi3pc.h.

◆ m_messageSocket

QLocalSocket qi3pc::m_messageSocket
private

Socket used to send messages and handle replies.

Definition at line 703 of file qi3pc.h.

◆ m_tree

DataObject qi3pc::m_tree
private

Layout tree cache.

Definition at line 705 of file qi3pc.h.

◆ m_workspaces

DataArray qi3pc::m_workspaces
private

Workspace list cache.

Definition at line 706 of file qi3pc.h.

◆ m_outputs

DataArray qi3pc::m_outputs
private

Output list cache.

Definition at line 707 of file qi3pc.h.

◆ m_marks

DataArray qi3pc::m_marks
private

Mark list cache.

Definition at line 708 of file qi3pc.h.

◆ m_barConfigs

DataObject qi3pc::m_barConfigs
private

Bar configuration list cache.

Definition at line 709 of file qi3pc.h.

◆ m_version

DataObject qi3pc::m_version
private

Version cache.

Definition at line 710 of file qi3pc.h.

◆ m_bindingModes

DataArray qi3pc::m_bindingModes
private

Binding modes cache.

Definition at line 711 of file qi3pc.h.

◆ m_bindingState

DataString qi3pc::m_bindingState
private

Current binding mode cache.

Definition at line 712 of file qi3pc.h.

◆ m_config

DataObject qi3pc::m_config
private

Configuration cache.

Definition at line 713 of file qi3pc.h.


The documentation for this class was generated from the following files: