Giter Club home page Giter Club logo

i3ipcpp's People

Contributors

bigredeye avatar drmgc avatar enzime avatar iskustvo avatar josefutbult avatar kgilmer avatar misopeth avatar mmha avatar mox-mox avatar notfound4 avatar ramon93i7 avatar scaryrawr avatar thaodan avatar tobias-haenel avatar zebradil avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

i3ipcpp's Issues

Example of passing a command with quotes to i3

Thanks for your library, it certainly makes integrating with i3 much easier! :)

I am trying to create a program that manages window containment in i3. I wish to pass commands to i3 to move workspaces and windows around. However when I try to pass any commands with escaped quotations, I get a parse error back from i3. I cannot find an example that passes a command to i3 w/ quotes and would like to know how to do this.

For example, I can run the following command succesfully:

$ i3-msg '[workspace=" 2 <span foreground='#2aa198'></span> "]' move workspace to output eDP-1
[{"success":true}]

However when I pass the string "'[workspace=" 2 <span foreground='#2aa198'></span> "]' move workspace to output eDP-1" to i3 via bool connection::send_command(const std::string& command) const I get the general "expecting token" error from i3.

Expected results: I can pass commands with backslash-escaped quotes to i3 via send_command()
Actual results: I get a parse error for any escaped string in a command

event file descriptor

The event file descriptor can only be initialise by a call to handle_event (prepare_to_handle_event is now protected). If you want to get the fd, it is because you don't want to use handle_event before you know there is an event to handle. You should be able to initialise it without blocking your application.

Json::LogicError thrown when switching workspaces

I wrote a daemon-like program which subscribes to i3::ET_WINDOW and i3::ET_WORKSPACE. In the last months I noticed that it often crashes with the following dump:

terminate called after throwing an instance of 'Json::LogicError'
  what():  LargestInt out of UInt range

Could it be because of new parameters that i3 added to windows for which i3ipc++ doesn't properly set the parsing? I'm thinking specifically about window_icon_padding, or current_border_width (I'm not sure this is new though).

Linker Errors

Hi!
I'm trying to include your library in a Qt project, unfortunately I cannot make the project to link correctly. The structure of my project is like this

../i3_plasma_test
├── CMakeLists.txt
├── Messages.sh
├── README
└── src
    ├── CMakeLists.txt
    ├── i3ipc++
    │   ├── 3rd
    │   │   └── auss
    │   │       ├── include
    │   │       │   └── auss.hpp
    │   │       ├── LICENSE
    │   │       └── README.md
    │   ├── CHANGELOG
    │   ├── CMakeLists.txt
    │   ├── Doxyfile
    │   ├── examples
    │   │   ├── bar-configs.cpp
    │   │   ├── CMakeLists.txt
    │   │   ├── events.cpp
    │   │   └── workspaces.cpp
    │   ├── include
    │   │   └── i3ipc++
    │   │       ├── ipc.hpp
    │   │       ├── ipc-util.hpp
    │   │       └── log.hpp
    │   ├── LICENSE
    │   ├── README.md
    │   ├── src
    │   │   ├── ipc.cpp
    │   │   └── ipc-util.cpp
    │   └── test
    │       └── test_ipc.hpp
    ├── i3_plasma_test.cpp
    ├── i3_plasma_test.h
    └── package
        ├── contents
        │   ├── images
        │   │   └── pairs.svgz
        │   └── ui
        │       └── main.qml
        └── metadata.desktop

My src/CMakeLists.txt looks like this

add_definitions(-DTRANSLATION_DOMAIN=\"plasma_applet_org.kde.i3_plasma_test\")

set(i3_plasma_test_SRCS
    i3_plasma_test.cpp
)

add_library(plasma_applet_i3_plasma_test MODULE ${i3_plasma_test_SRCS})
add_subdirectory(i3ipc++)
include_directories(${I3IPCpp_INCLUDE_DIRS})
link_directories(${I3IPCpp_LIBRARY_DIRS})

kcoreaddons_desktop_to_json(plasma_applet_i3_plasma_test package/metadata.desktop SERVICE_TYPES plasma-applet.desktop)

target_link_libraries(plasma_applet_i3_plasma_test
                      Qt5::Gui
                      KF5::Plasma
                      KF5::I18n
                      ${I3IPCpp_LIBRARIES})


install(TARGETS plasma_applet_i3_plasma_test DESTINATION ${KDE_INSTALL_PLUGINDIR}/plasma/applets)

plasma_install_package(package org.kde.i3_plasma_test)

I added the lines from the README to my i3_plasma_test.h

#ifndef I3_PLASMA_TEST_H
#define I3_PLASMA_TEST_H


#include <i3ipc++/ipc.hpp>
#include <Plasma/Applet>

class i3_plasma_test : public Plasma::Applet
{
    Q_OBJECT
    Q_PROPERTY(QString nativeText READ nativeText CONSTANT)

public:
    i3_plasma_test( QObject *parent, const QVariantList &args );
    ~i3_plasma_test();

    QString nativeText() const;

private:
    QString             m_nativeText;
    i3ipc::connection   m_conn;
};

#endif

At first, the only thing I changed in the CMakeLists.txt that you provided is to uncomment CMAKE_CXX_FLAGS and add -fexceptions since it wouldn't build without it. Afterwards the project built fine but did not link correctly:

CMakeFiles/plasma_applet_i3_plasma_test.dir/i3_plasma_test.cpp.o: In function `i3_plasma_test::i3_plasma_test(QObject*, QList<QVariant> const&)':
i3_plasma_test.cpp:(.text+0x7b): undefined reference to `i3ipc::get_socketpath[abi:cxx11]()'
i3_plasma_test.cpp:(.text+0x8a): undefined reference to `i3ipc::connection::connection(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)'
CMakeFiles/plasma_applet_i3_plasma_test.dir/i3_plasma_test.cpp.o: In function `i3_plasma_test::~i3_plasma_test()':
i3_plasma_test.cpp:(.text+0xe0): undefined reference to `i3ipc::connection::~connection()'
collect2: error: ld returned 1 exit status
make[2]: *** [src/CMakeFiles/plasma_applet_i3_plasma_test.dir/build.make:99: src/plasma_applet_i3_plasma_test.so] Error 1
make[1]: *** [CMakeFiles/Makefile2:417: src/CMakeFiles/plasma_applet_i3_plasma_test.dir/all] Error 2
make: *** [Makefile:141: all] Error 2

then I added -D_GLIBCXX_USE_CXX11_ABI=0 to CMAKE_CXX_FLAGS which led to this

CMakeFiles/i3ipc++.dir/src/ipc.cpp.o: In function `i3ipc::parse_container_from_json(Json::Value const&)':
ipc.cpp:(.text+0x2eb): undefined reference to `Json::Value::asString() const'
ipc.cpp:(.text+0x34a): undefined reference to `Json::Value::asString() const'
ipc.cpp:(.text+0x588): undefined reference to `Json::Value::asString() const'
ipc.cpp:(.text+0x727): undefined reference to `Json::Value::asString() const'
CMakeFiles/i3ipc++.dir/src/ipc.cpp.o: In function `i3ipc::parse_workspace_from_json(Json::Value const&)':
ipc.cpp:(.text+0xe48): undefined reference to `Json::Value::asString() const'
CMakeFiles/i3ipc++.dir/src/ipc.cpp.o:ipc.cpp:(.text+0xf24): more undefined references to `Json::Value::asString() const' follow
CMakeFiles/i3ipc++.dir/src/ipc.cpp.o: In function `i3ipc::parse_binding_from_json(Json::Value const&)':
ipc.cpp:(.text+0x16e8): undefined reference to `Json::Value::Value(std::string const&)'
ipc.cpp:(.text+0x1913): undefined reference to `Json::Value::asString() const'
CMakeFiles/i3ipc++.dir/src/ipc.cpp.o: In function `i3ipc::parse_mode_from_json(Json::Value const&)':
ipc.cpp:(.text+0x1c12): undefined reference to `Json::Value::asString() const'
CMakeFiles/i3ipc++.dir/src/ipc.cpp.o: In function `i3ipc::parse_bar_config_from_json(Json::Value const&)':
ipc.cpp:(.text+0x1e84): undefined reference to `Json::Value::asString() const'
ipc.cpp:(.text+0x1ee2): undefined reference to `Json::Value::asString() const'
ipc.cpp:(.text+0x1f41): undefined reference to `Json::Value::asString() const'
CMakeFiles/i3ipc++.dir/src/ipc.cpp.o:ipc.cpp:(.text+0x2042): more undefined references to `Json::Value::asString() const' follow
CMakeFiles/i3ipc++.dir/src/ipc.cpp.o: In function `i3ipc::parse_bar_config_from_json(Json::Value const&)':
ipc.cpp:(.text+0x232e): undefined reference to `Json::Value::getMemberNames() const'
ipc.cpp:(.text+0x23b8): undefined reference to `Json::Value::operator[](std::string const&)'
ipc.cpp:(.text+0x23cd): undefined reference to `Json::Value::asString() const'
CMakeFiles/i3ipc++.dir/src/ipc.cpp.o: In function `i3ipc::connection::connection(std::string const&)::{lambda(i3ipc::EventType, std::shared_ptr<i3ipc::buf_t const> const&)#1}::operator()(i3ipc::EventType, std::shared_ptr<i3ipc::buf_t const> const&) const':
ipc.cpp:(.text+0x2a07): undefined reference to `Json::Reader::parse(std::string const&, Json::Value&, bool)'
ipc.cpp:(.text+0x2a80): undefined reference to `Json::Reader::getFormattedErrorMessages() const'
ipc.cpp:(.text+0x2b36): undefined reference to `Json::Value::asString() const'
ipc.cpp:(.text+0x2eda): undefined reference to `Json::Reader::parse(std::string const&, Json::Value&, bool)'
ipc.cpp:(.text+0x2f53): undefined reference to `Json::Reader::getFormattedErrorMessages() const'
ipc.cpp:(.text+0x30ed): undefined reference to `Json::Reader::parse(std::string const&, Json::Value&, bool)'
ipc.cpp:(.text+0x3166): undefined reference to `Json::Reader::getFormattedErrorMessages() const'
ipc.cpp:(.text+0x321c): undefined reference to `Json::Value::asString() const'
ipc.cpp:(.text+0x34c1): undefined reference to `Json::Reader::parse(std::string const&, Json::Value&, bool)'
ipc.cpp:(.text+0x353a): undefined reference to `Json::Reader::getFormattedErrorMessages() const'
ipc.cpp:(.text+0x36c5): undefined reference to `Json::Reader::parse(std::string const&, Json::Value&, bool)'
ipc.cpp:(.text+0x373e): undefined reference to `Json::Reader::getFormattedErrorMessages() const'
ipc.cpp:(.text+0x37f4): undefined reference to `Json::Value::asString() const'
CMakeFiles/i3ipc++.dir/src/ipc.cpp.o: In function `i3ipc::connection::subscribe(int)':
ipc.cpp:(.text+0x472c): undefined reference to `Json::Reader::parse(std::string const&, Json::Value&, bool)'
ipc.cpp:(.text+0x47a5): undefined reference to `Json::Reader::getFormattedErrorMessages() const'
CMakeFiles/i3ipc++.dir/src/ipc.cpp.o: In function `i3ipc::connection::get_version() const':
ipc.cpp:(.text+0x4af8): undefined reference to `Json::Reader::parse(std::string const&, Json::Value&, bool)'
ipc.cpp:(.text+0x4b71): undefined reference to `Json::Reader::getFormattedErrorMessages() const'
ipc.cpp:(.text+0x4cce): undefined reference to `Json::Value::asString() const'
ipc.cpp:(.text+0x4cfd): undefined reference to `Json::Value::asString() const'
CMakeFiles/i3ipc++.dir/src/ipc.cpp.o: In function `i3ipc::connection::get_tree() const':
ipc.cpp:(.text+0x4fe4): undefined reference to `Json::Reader::parse(std::string const&, Json::Value&, bool)'
ipc.cpp:(.text+0x505d): undefined reference to `Json::Reader::getFormattedErrorMessages() const'
CMakeFiles/i3ipc++.dir/src/ipc.cpp.o: In function `i3ipc::connection::get_outputs() const':
ipc.cpp:(.text+0x5334): undefined reference to `Json::Reader::parse(std::string const&, Json::Value&, bool)'
ipc.cpp:(.text+0x53ad): undefined reference to `Json::Reader::getFormattedErrorMessages() const'
CMakeFiles/i3ipc++.dir/src/ipc.cpp.o: In function `i3ipc::connection::get_workspaces() const':
ipc.cpp:(.text+0x587e): undefined reference to `Json::Reader::parse(std::string const&, Json::Value&, bool)'
ipc.cpp:(.text+0x58f7): undefined reference to `Json::Reader::getFormattedErrorMessages() const'
CMakeFiles/i3ipc++.dir/src/ipc.cpp.o: In function `i3ipc::connection::get_bar_configs_list() const':
ipc.cpp:(.text+0x5dc8): undefined reference to `Json::Reader::parse(std::string const&, Json::Value&, bool)'
ipc.cpp:(.text+0x5e41): undefined reference to `Json::Reader::getFormattedErrorMessages() const'
ipc.cpp:(.text+0x6020): undefined reference to `Json::Value::asString() const'
CMakeFiles/i3ipc++.dir/src/ipc.cpp.o: In function `i3ipc::connection::get_bar_config(std::string const&) const':
ipc.cpp:(.text+0x62fb): undefined reference to `Json::Reader::parse(std::string const&, Json::Value&, bool)'
ipc.cpp:(.text+0x6374): undefined reference to `Json::Reader::getFormattedErrorMessages() const'
CMakeFiles/i3ipc++.dir/src/ipc.cpp.o: In function `i3ipc::connection::send_command(std::string const&) const':
ipc.cpp:(.text+0x6610): undefined reference to `Json::Reader::parse(std::string const&, Json::Value&, bool)'
ipc.cpp:(.text+0x6689): undefined reference to `Json::Reader::getFormattedErrorMessages() const'
ipc.cpp:(.text+0x694c): undefined reference to `Json::Value::asString() const'
collect2: error: ld returned 1 exit status
make[2]: *** [src/i3ipc++/CMakeFiles/i3ipc++.dir/build.make:114: src/i3ipc++/libi3ipc++.so] Error 1
make[1]: *** [CMakeFiles/Makefile2:505: src/i3ipc++/CMakeFiles/i3ipc++.dir/all] Error 2
make: *** [Makefile:141: all] Error 2

At this point I added the JsonCpp Amalgamated Source to my project which brought me back to the linker error from before, just without the abi error

CMakeFiles/plasma_applet_i3_plasma_test.dir/i3_plasma_test.cpp.o: In function `i3_plasma_test::i3_plasma_test(QObject*, QList<QVariant> const&)':
i3_plasma_test.cpp:(.text+0x7b): undefined reference to `i3ipc::get_socketpath()'
i3_plasma_test.cpp:(.text+0x8a): undefined reference to `i3ipc::connection::connection(std::string const&)'
i3_plasma_test.cpp:(.text+0xab): undefined reference to `i3ipc::connection::subscribe(int)'
CMakeFiles/plasma_applet_i3_plasma_test.dir/i3_plasma_test.cpp.o: In function `i3_plasma_test::~i3_plasma_test()':
i3_plasma_test.cpp:(.text+0xf6): undefined reference to `i3ipc::connection::~connection()'
collect2: error: ld returned 1 exit status
make[2]: *** [src/CMakeFiles/plasma_applet_i3_plasma_test.dir/build.make:99: src/plasma_applet_i3_plasma_test.so] Error 1
make[1]: *** [CMakeFiles/Makefile2:417: src/CMakeFiles/plasma_applet_i3_plasma_test.dir/all] Error 2
make: *** [Makefile:141: all] Error 2

The shared library is found: attempt to open i3ipc++/libi3ipc++.so succeeded. I do not know what to try next. Do you know what's wrong? Thank you.

Ship all available information with the i3 events.

When receiving i3 events, some information, like the "current" and "old" properties of the workspace event are not passed on.
Could you please add a way to access the missing properties/information when receiving an event?

Tests are broken since 51a5ba57cc767d61e69fab87234f29d3c1e27008

/usr/bin/c++ -DDEBUG=1 -DTEST_SRC_ROOT=\"/home/bidar/dev/kde/i3ipcpp/test\" -I/usr/include/sigc++-2.0 -I/usr/lib64/sigc++-2.0/include -I/home/bidar/dev/kde/i3ipcpp/3rd/auss/include -I/home/bidar/dev/kde/i3ipcpp/include -I/home/bidar/dev/kde/i3ipcpp/include/i3ipc++ -std=c++11 -Wall -Wextra -Wno-unused-parameter -g3 -MD -MT CMakeFiles/i3ipcpp_check.dir/test.cpp.o -MF CMakeFiles/i3ipcpp_check.dir/test.cpp.o.d -o CMakeFiles/i3ipcpp_check.dir/test.cpp.o -c /home/bidar/dev/kde/i3ipcpp/build/test.cpp
In file included from /home/bidar/dev/kde/i3ipcpp/build/test.cpp:23:
/home/bidar/dev/kde/i3ipcpp/build/../test/test_ipc.hpp: In member function ‘void testsuite_ipc_util::test_pack()’:
/home/bidar/dev/kde/i3ipcpp/build/../test/test_ipc.hpp:17:57: error: ‘using std::__shared_ptr_access<i3ipc::buf_t, __gnu_cxx::_S_atomic, false, false>::element_type = struct i3ipc::buf_t’ {aka ‘struct i3ipc::buf_t’} has no member named ‘size’
   17 |                         for (uint32_t  i = 0; i < buff->size; i++) {
      |                                                         ^~~~

build failure

`home/ned/dev/i3-pager-git/src/i3-pager/i3ipc++/src/ipc.cpp: In constructor ‘i3ipc::connection::connection(const std::string&)’:
/home/ned/dev/i3-pager-git/src/i3-pager/i3ipc++/src/ipc.cpp:337:9: error: ‘signal_event’ was not declared in this scope; did you mean ‘sigevent’?
  337 |         signal_event.connect([this](EventType  event_type, const std::shared_ptr<const buf_t>&  buf) {
      |         ^~~~~~~~~~~~
      |         sigevent
/home/ned/dev/i3-pager-git/src/i3-pager/i3ipc++/src/ipc.cpp: In lambda function:
/home/ned/dev/i3-pager-git/src/i3-pager/i3ipc++/src/ipc.cpp:447:33: error: ‘signal_binding_event’ was not declared in this scope; did you mean ‘signal_window_event’?
  447 |                                 signal_binding_event.emit(*bptr);
      |                                 ^~~~~~~~~~~~~~~~~~~~
      |                                 signal_window_event
/home/ned/dev/i3-pager-git/src/i3-pager/i3ipc++/src/ipc.cpp: In member function ‘void i3ipc::connection::handle_event()’:
/home/ned/dev/i3-pager-git/src/i3-pager/i3ipc++/src/ipc.cpp:491:15: error: ‘class i3ipc::connection’ has no member named ‘signal_event’
  491 |         this->signal_event.emit(static_cast<EventType>(1 << (buf->header->type & 0x7f)), std::static_pointer_cast<const buf_t>(buf));
      |               ^~~~~~~~~~~~
`

W: Got a unknown "border" property: "pixel".

When setting "new window pixel 1" in the i3config, i3 will send "border" : "pixel" as border style in the tree reply.
Example:
{
"border" : "pixel",
"current_border_width" : -1,
"deco_rect" :
{
"height" : 0,
"width" : 0,
"x" : 0,
"y" : 0
},
"floating" : "auto_off",
"floating_nodes" : [],
"focus" : [],
"focused" : false,
"fullscreen_mode" : 0,
"geometry" :
{
"height" : 0,
"width" : 0,
"x" : 0,
"y" : 0
},
"id" : 31099360,
"last_split_layout" : "splith",
"layout" : "dockarea",
"name" : "bottomdock",
"nodes" : [],
"orientation" : "none",
"percent" : null,
"rect" :
{
"height" : 0,
"width" : 1600,
"x" : 0,
"y" : 900
},
"scratchpad_state" : "none",
"sticky" : false,
"swallows" :
[
{
"dock" : 3,
"insert_where" : 2
}
],
"type" : "dockarea",
"urgent" : false,
"window" : null,
"window_rect" :
{
"height" : 0,
"width" : 0,
"x" : 0,
"y" : 0
},
"workspace_layout" : "default"
}

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.