diff options
author | Michael Stapelberg <michael@stapelberg.de> | 2018-03-30 21:06:18 +0200 |
---|---|---|
committer | Michael Stapelberg <michael@stapelberg.de> | 2018-03-30 21:09:52 +0200 |
commit | eca8fae2de2a2f7d6a8953d5ce6e0a76c6dc1264 (patch) | |
tree | b0ad25288b96af1f2e435f41b3373aa97e525a31 /AnyEvent-I3 | |
parent | 725ee3ce6269947577deb7a67a0e1d9762c21600 (diff) | |
download | i3-eca8fae2de2a2f7d6a8953d5ce6e0a76c6dc1264.tar.gz i3-eca8fae2de2a2f7d6a8953d5ce6e0a76c6dc1264.zip |
introduce the sync IPC command
Sending the sync command via IPC ensures pending IPC messages are handled by i3
before the sync response is read. This is rarely useful for direct IPC
connections to i3, but becomes useful when synchronizing with i3bar, which might
have pending IPC messages in response to button clicks.
Diffstat (limited to 'AnyEvent-I3')
-rw-r--r-- | AnyEvent-I3/lib/AnyEvent/I3.pm | 16 |
1 files changed, 15 insertions, 1 deletions
diff --git a/AnyEvent-I3/lib/AnyEvent/I3.pm b/AnyEvent-I3/lib/AnyEvent/I3.pm index 198c41c9..ae9e5bea 100644 --- a/AnyEvent-I3/lib/AnyEvent/I3.pm +++ b/AnyEvent-I3/lib/AnyEvent/I3.pm @@ -100,11 +100,12 @@ use constant TYPE_GET_VERSION => 7; use constant TYPE_GET_BINDING_MODES => 8; use constant TYPE_GET_CONFIG => 9; use constant TYPE_SEND_TICK => 10; +use constant TYPE_SYNC => 11; our %EXPORT_TAGS = ( 'all' => [ qw(i3 TYPE_RUN_COMMAND TYPE_COMMAND TYPE_GET_WORKSPACES TYPE_SUBSCRIBE TYPE_GET_OUTPUTS TYPE_GET_TREE TYPE_GET_MARKS TYPE_GET_BAR_CONFIG TYPE_GET_VERSION - TYPE_GET_BINDING_MODES TYPE_GET_CONFIG TYPE_SEND_TICK) + TYPE_GET_BINDING_MODES TYPE_GET_CONFIG TYPE_SEND_TICK TYPE_SYNC) ] ); our @EXPORT_OK = ( @{ $EXPORT_TAGS{all} } ); @@ -534,6 +535,19 @@ sub send_tick { $self->message(TYPE_SEND_TICK, $payload); } +=head2 sync + +Sends an i3 sync event. Requires i3 >= 4.16 + +=cut +sub sync { + my ($self, $payload) = @_; + + $self->_ensure_connection; + + $self->message(TYPE_SYNC, $payload); +} + =head2 command($content) Makes i3 execute the given command |