Commit Graph

58 Commits

Author SHA1 Message Date
Orestis Floros 0b62129224
Remove unused headers
With help from
https://github.com/include-what-you-use/include-what-you-use/
2020-04-20 04:25:06 +02:00
Orestis Floros 3c522d9f2f
Sort includes in *.c files
Not enabling in .clang-format because it breaks headers files.

Used:
    IncludeCategories:
      - Regex:           '^<config'
        Priority:        0
      - Regex:           '^".*"'
        Priority:        1
      - Regex:           '^<(xcb|xkb|yajl|X11)'
        Priority:        3
      - Regex:           '.*'
        Priority:        2
2020-04-19 09:58:25 +02:00
Orestis Floros ea6068a02d
Replace scalloc + strncpy with sstrndup 2019-04-03 18:51:34 +03:00
Nils ANDRÉ-CHANG 72ccd341fc Add proper return code for i3-msg 2019-02-21 19:52:55 +00:00
Vivien Didelot cff4fadd72 i3-msg: add support for SUBSCRIBE message type
If i3-msg is invoked with -t subscribe, it will wait for the first event
matching the given payload, before exiting.

For instance, get the number of the next focused workspace with:

    i3-msg -t subscribe '[ "workspace" ]' | jshon -e current -e num

Like inotifywait, the -m flag allows to wait indefinitely for events,
instead of exiting right after receiving the first one.

For example, continuously monitor the names of focused windows with:

    i3-msg -t subscribe -m '[ "window" ]' | jq .container.name
2018-10-04 12:54:45 -04:00
Vivien Didelot d722d1b0e6 i3-msg: check reply in quiet mode
i3-msg currently exits right after sending the IPC message if the quiet
flag is set. This means that if an error occurred when issuing a
command, e.g. "i3-msg -q foobar", it gets silently ignored.

What we really want is to just skip printing but still check the reply.

At the same time, explicitly print the reply when we need to, instead of
using an exit label.
2018-10-03 10:43:09 -04:00
Orestis Floros 124e64767e i3-msg: only print input + errorposition if they exist
Before:
$ i3-msg floating disable, move window to position 100 px 100 px
ERROR: Your command: (null)
ERROR:               (null)
ERROR: Cannot change position of a window/container because it is not floating.
[{"success":true},{"success":false,"error":"Cannot change position of a window/container because it is not floating."}]

After:
$ i3-msg floating disable, move window to position 100 px 100 px
ERROR: Cannot change position of a window/container because it is not floating.
[{"success":true},{"success":false,"error":"Cannot change position of a window/container because it is not floating."}]
2018-03-18 03:38:06 +02:00
Michael Stapelberg c07936d91b no-op refactoring: make ipc_connect find socket path 2017-11-26 16:41:59 +01:00
Michael Stapelberg ce21de8dde Implement the tick event
This makes our tests less flaky, shorter, and more readable.

fixes #2988
2017-09-30 11:41:57 +02:00
Michael Stapelberg 607e97e651 ipc: rename COMMAND to RUN_COMMAND for consistency (#2956)
All other message types are verbs, only our first-ever message COMMAND wasn’t.

While we’re here, also change the message type dictionary into a table with
clickable links to the corresponding reply type.

Authors of downstream IPC libraries are encouraged to keep the old name around
so as to not break existing code, but mark it as deprecated.
2017-09-17 15:25:00 +02:00
Michael Stapelberg a6d8ed9b1a Introduce the GET_CONFIG IPC request
This introduces memory usage by one copy of the config file, which is an
acceptable trade-off for being able to easily revert data loss.
The default config is 6KB, user configs will be in the same ballpark.

fixes #2856
2017-08-19 19:08:51 +02:00
hwangcc23 5362876b60 i3-msg: Return an exit code upon missing -t arg
If getopt() returns '?' (option with a missing argument), exit the program with an error code rather than continuing the execution.

Fix the issue #2804 (https://github.com/i3/i3/issues/2804).
2017-06-22 22:53:08 +08:00
Ingo Bürk 9c6a21f2d4 Fix memory leak in i3-msg. (#2542)
relates to #2541
2016-11-06 08:14:37 -08:00
Ingo Bürk fea0bc1a45 Fix memory leaks. (#2530)
fixes #2529
2016-11-03 00:18:18 -07:00
Michael Stapelberg f354f53435 Ensure all *.[ch] files include config.h
Including config.h is necessary to get e.g. the _GNU_SOURCE define and
any other definitions that autoconf declares. Hence, config.h needs to
be included as the first header in each file.

This is done either via:
1. Including "common.h" (i3bar)
2. Including "libi3.h"
3. Including "all.h" (i3)
4. Including <config.h> directly

Also remove now-unused I3__FILE__, add copyright/license statement
where missing and switch include/all.h to #pragma once.
2016-10-23 21:09:24 +02:00
Ingo Bürk b1d70f25b3 Introduced a new GET_BINDING_MODES message type and reply. (#2376)
This type dumps all currently configured binding modes.

fixes #2375
2016-06-15 22:25:22 +02:00
Theo Buehler a1d1f456a1 Add pledge(2) support for OpenBSD
pledges for i3:
"stdio rpath unix" for talking to the i3 socket usually in /tmp
"proc exec" for executing programs
"wpath cpath" are needed for the restart-in-place functionality

To make this work, @semarie pointed out that it is sufficient to ensure
that we get physical_mem_bytes only once, namely in init_logging().

pledges for i3-msg:
"stdio rpath unix" are needed for talking to the i3-socket

pledges for i3-nagbar
"rpath getpw" to find the home directory
"wpath cpath" to write the script
"proc exec" to execute the script
2016-01-17 18:49:00 +01:00
shdown f8b0ac2bff i3-msg: strdup getenv() result before freeing
Fixes #1852.
2015-08-20 23:07:41 +03:00
shdown c85d16faa4 Use safe wrappers wherever possible 2015-08-03 12:50:50 +03:00
shdown bc52fae15c libi3: change scalloc() signature to match calloc() 2015-08-03 12:50:13 +03:00
Deiz 884214f14f Update copyright notices and get rid of ranges
The script used to make these changes can be found at:

   https://gist.github.com/Deiz/32322020f76d23e2bf8f
2015-04-20 17:50:21 -04:00
Michael Stapelberg 9200094203 format **/*.c with clang-format-3.5
This has multiple effects:

1) The i3 codebase is now consistently formatted. clang-format uncovered
   plenty of places where inconsistent code made it into our code base.

2) When writing code, you don’t need to think or worry about our coding
   style. Write it in yours, then run clang-format-3.5

3) When submitting patches, we don’t need to argue about coding style.

The basic idea is that we don’t want to care about _how_ we write the
code, but _what_ it does :). The coding style that we use is defined in
the .clang-format config file and is based on the google style, but
adapted in such a way that the number of modifications to the i3 code
base is minimal.
2014-06-15 19:07:02 +02:00
Tony Crisci 13db562551 Remove yajl major version conditionals
Yajl version ≥ 2 is required.

fixes #1156
2014-05-04 22:52:37 +02:00
Alexander Kedrik de3901bb29 use designated initializers for yajl_callbacks struct 2014-01-06 22:12:14 +01:00
Michael Stapelberg 2fea5ef82b Revert "use designated initializers for yajl_callbacks struct"
This reverts commit 705b43294a.

This commit broke i3bar for some users.
2014-01-05 13:05:31 +01:00
Alexander Kedrik 705b43294a use designated initializers for yajl_callbacks struct 2014-01-04 20:46:46 +01:00
Peter Boström 9c15b9504e Fix clang -Wextra except -Wunused-parameter.
Cleared all warnings that occur when passing
CFLAGS="-Wall -Wextra -Wno-unused-parameter" to make using clang 3.3 on
Linux x86-64.
2014-01-02 22:15:33 +01:00
Michael Stapelberg d3beff2339 make i3bar use libi3’s root_atom_contents()
This removes code duplication, which will be useful for a subsequent
commit.

Furthermore, we now don’t open X11 connections unnecessarily in some
corner cases.
2013-11-22 15:48:45 +01:00
Michael Stapelberg c300d216ec i3-msg: parse command replies and display errors nicely if there were errors
fixes #737
2013-01-26 17:56:43 +01:00
Michael Stapelberg dcb8ac84f8 ipc_recv_message: store message_type, don’t compare. add distinct EOF retval
Also use ELOG, which requires i3-msg to provide logging functions.
2013-01-23 18:51:39 +01:00
Michael Stapelberg e8fa3eeebd i3-msg: include socket path in error message 2013-01-23 08:11:27 +01:00
Oliver Kiddle f7d825062a remove superfluous ev.h include statements 2012-09-20 11:15:17 +02:00
Michael Stapelberg 78f5f2204d ipc: implement GET_VERSION to find out the i3 version
This is useful for third-party scripts which require certain features
and want to error out cleanly when they are run with an old i3 version.

Additionally, i3 --version might be different from what’s actually
running (an old version of the binary), so i3-msg -t get_version will be
the best way to figure out the i3 version you are actually running from
this commit on.
2012-08-05 14:30:05 +02:00
Michael Stapelberg dee7c07ad2 shmlog: store meta information in the buffer itself, store path as X11 atom
This makes i3-dump-log completely independent of a running i3 instance.
2012-01-06 23:40:07 +00:00
Michael Stapelberg d25a05f06b add TYPE_GET_LOG_MARKERS to i3-msg 2011-12-10 11:16:12 +00:00
Michael Stapelberg 726f2a1e5a normalize file headers across **/*.{h,c} 2011-10-25 21:19:38 +01:00
Michael Stapelberg 24ede1c834 add an IPC request to get the bar configuration (by ID) 2011-10-18 19:05:49 +01:00
Michael Stapelberg 046cf99585 Move ipc_send_message and ipc_recv_message to libi3
Make i3-msg and src/ipc.c use it
2011-10-02 18:33:36 +01:00
Michael Stapelberg ff86852453 i3-msg: use smalloc, sstrdup from libi3 2011-10-02 18:11:01 +01:00
Michael Stapelberg 6af8b0941c i3-msg: use socket_path_from_x11 from libi3 2011-10-02 16:11:55 +01:00
Michael Stapelberg 32ad9f7e3a i3-msg: include newline at the end of the reply 2011-09-05 22:55:31 +02:00
Helgi Kristvin Sigurbjarnarson 96ed68de16 Add support for get_marks in i3-msg 2011-08-09 08:19:11 +02:00
Michael Stapelberg fdd098b010 secure strscpy by replacing with strncpy 2011-07-23 22:22:36 +02:00
Michael Stapelberg 5c276be3d5 i3-msg: concatenate all arguments. now you can use i3-msg mark foo 2011-07-13 18:01:24 +02:00
Michael Stapelberg ba7e82fc94 i3-msg: re-indent main.c 2011-07-13 17:53:07 +02:00
Michael Stapelberg 307a036d5c i3-msg, i3-input: get the I3_SOCKET_PATH atoms if socket path was not specified 2011-03-19 21:23:55 +01:00
Michael Stapelberg d9dd245bcc Bugfix: Use strdup() for the initial value of socket_path (Thanks mseed) 2011-01-22 17:00:27 +01:00
Axel Wagner 4caf85aa0b Use I3SOCK-environment-variable 2011-01-12 10:15:48 +01:00
Michael Stapelberg cd2ee61ee8 fix some memory leaks when user passes command line arguments twice (Thanks Tiago) 2011-01-12 10:12:24 +01:00
Michael Stapelberg 0f083f6f78 i3-msg: s/tree/get_tree for consistency, add new types to error message 2010-11-21 21:39:09 +01:00