83 Commits

Author SHA1 Message Date
Michael Stapelberg
c2ccfc7e60 Merge branch 'master' into next 2014-07-11 00:33:13 +02:00
Michael Stapelberg
686a40e384 Bugfix: render bars after the first chunk of JSON (Thanks javier)
fixes #1315
2014-07-11 00:32:42 +02:00
Michael Stapelberg
4c06e7a573 clang-format-3.5 **/*.h **/*.c
This should be the last commit that formats a big bunch of files. From
here on, whenever I merge patches, I’ll run clang-format like described
in the title.
2014-06-19 11:20:32 +02: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
Michael Stapelberg
87110a87a8 i3bar: render separators retina-correctly 2014-04-26 17:20:21 +02:00
Quentin Glidic
eb7537e53d i3bar: Send mouse wheel events to child too
Signed-off-by: Quentin Glidic <sardemff7+git@sardemff7.net>
2014-03-21 19:30:17 +01:00
Tony Crisci
00909aa3b1 i3bar: Do not kill watcher on EOF
Wait for the child process to exit on its own before freeing
watcher-related resources.

i3bar shows the last received status line until the process exits.

Fixes a race condition where the termination signal was sometimes not
received to display a meaningful error message.
2014-02-15 12:55:30 +01:00
Michael Stapelberg
cd0cd0c3d2 Merge branch 'master' into next 2014-01-13 23:35:22 +01:00
Tony Crisci
612d25c12c i3bar Bugfix: don't show "EOF" status line error
When the `status_command` sends EOF, it is terminated. Terminating this
process prints an error message to the status line (hence, a race
condition). This error message is always more useful than the former
"EOF" status line error because it shows the exit code.
2014-01-13 23:35:20 +01:00
Tony Crisci
7bddf9add5 i3bar: Amend status line error 127 message
Exit 127 can be returned by the shell when the command is not found or
when the `status_command` process returns 127 because of a missing C
library dependency.
2014-01-12 22:11:11 +01: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 705b43294add2fffede086c0c072dc5a849ffc49.

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
Alexander Kedrik
f1560e5eb6 remove unnecessary forward declaration of set_statusline_error
Attributes can be added to function definitions.
Tested with gcc 4.8.2 and clang 3.3
2014-01-04 20:44:54 +01:00
Peter Boström
f78c1ba053 Fix 'gcc -Wextra -Wno-unused-parameter'. 2014-01-04 20:43:30 +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
Tony Crisci
ac74a63662 i3bar: Don't start child unless status_command
If a command is passed to `start_child` which is NULL, such as in the
case when there is no `status_command` specified in the bar config, do
not start a child process to listen on stdin.

fixes #1140
2014-01-01 15:23:50 +01:00
Tony Crisci
bfe32ad797 i3bar: Print error message when status_command fails
Add a function to i3bar to print an error message in the status line
when the child process invoked by status_command fails to provide
input that can be displayed as a statusline.

When the child provides JSON that cannot be parsed, alert the user and
convey a short message provided by yajl communicating the specific
problem.

When the child (or the shell executing the status command) exits
unexpectedly, alert the user and display the exit code. The cases where
the status command is not executable or not found in the user's PATH are
treated specially.

fixes #1130
2013-12-21 08:57:21 +01:00
Tony Crisci
39f15da82f i3bar: Group child processes for signalling
Set the process group id of the child process by calling `setpgid` after
forking and before calling `exec`.

The process group ID will be set to the process ID of the forked
process. Processes spawned by this child process will also have this
group ID.

Send signals to the process group with `killpg`. This will send the
signal to all of the process group.

fixes #1128
2013-12-04 19:45:19 +01:00
Baptiste Daroussin
f691a55923 Use _PATH_BSHELL to ensure using a bourne shell
[Michael]
This commit should fix problems with people using a non-bourne shell as
login shell, e.g. fish or rc. AFAICT, $SHELL should only be used for
interactive shells, but we just want a bourne shell, not an interactive
shell.
2013-11-09 10:11:32 +01:00
haptix@web.de
402c3db7ac restore i3bar compatibility with libyajl version 1
fixes #1004
2013-04-07 15:54:20 +02:00
Yuxuan Shui
18148205b6 Don't dup2() the parent's stdout to child's stdin.
There're DLOG()s, seriously.
2013-03-24 09:55:46 +01:00
enkore
58e68940f6 Add click events to i3bar
If the statusline generator (i.e. i3status) specifies click_events:true
in the protocol header, i3bar will write a JSON array on it's stdin
notifying it if the user clicks on a block.

The exact protocol is documented in docs/i3bar-protocol.
2013-03-21 23:55:30 +01:00
András Mohari
a0d5b744ab Allow min_width of a block in i3bar to be a string
With this change, min_width can either be an integer (as usual), or a
string. In the latter case, the width of the text given by min_width
determines the minimum width of the block. This way one does not have to
figure out a minimum width by trial and error, only to do it again every
time the font is changed.
2013-02-25 23:48:35 +01:00
Artem Shinkarov
5f05ca6b5d Separator color via config; separator width and on/off via ipc
This patch adds the following features:
1) Configure a color of the separator via config.  It is done like
   bar {
      colors {
         separator #000000
      }
   }
2) A block can have an integer entry "separator_block_width" which
   sets the width of the gap which would follow after the current block.

3) A block can have a boolean entry "separator" and if it is set
   to false, then the drawing of the separating line would be disabled.
2013-02-18 10:44:44 +01:00
Antoine Millet
e8149c77b3 i3bar: add min_width and align keys to blocks 2012-12-06 09:48:27 +01:00
Quentin Glidic
89ca48be20 i3bar: Honor "urgent" protocol hint by unhiding 2012-09-22 15:15:57 +02:00
Quentin Glidic
830829922b i3bar: Allow to force unhide with draw_bars 2012-09-22 15:15:57 +02:00
Quentin Glidic
8210c6be79 i3bar: Allow child to specify signals to use
We now wait for the child process to send the first line before stopping
it to use the signal which might be specified in the i3bar protocol
header
Since clients might use the same signal for both stop and cont, we also
save the stopped state of the child to avoid stopping it while hidden!
2012-09-22 15:13:21 +02:00
Quentin Glidic
1e114d7ab5 i3bar: Fully parse the JSON header 2012-09-22 15:13:21 +02:00
Quentin Glidic
34dc6d4d64 i3bar: Introduce i3bar_child struct 2012-09-22 15:13:21 +02:00
Quentin Glidic
310ae2d0b5 i3bar: Handle the first line with another callback 2012-09-22 15:13:21 +02:00
Quentin Glidic
f691927aa7 i3bar: Split JSON line logic to read_json_input 2012-09-22 15:13:21 +02:00
Quentin Glidic
103b1a3f3a i3bar: Split flat line logic to read_flat_input 2012-09-22 15:13:21 +02:00
Quentin Glidic
3732cef764 i3bar: Split stdin reading logic to get_buffer 2012-09-22 15:13:21 +02:00
Michael Stapelberg
f18ab28f5c bugfix: memleak: use i3STRING_FREE() instead of FREE() 2012-09-03 00:42:17 +02:00
Michael Stapelberg
2d1ebc2b90 Bugfix: memleak: because we use i3string_from_utf8(), we need to free buffer()
Previously, buffer was directly used and thus not freed, but
i3string_from_utf8() makes a copy.
2012-09-03 00:42:14 +02:00
eeemsi
b9255f51f8 Use (void) instead of () for functions without args 2012-08-23 19:34:37 +02:00
Quentin Glidic
bbd1b16043 i3bar: Port to i3String 2012-08-13 11:30:05 +02:00
Michael Stapelberg
e53405c216 i3bar: be less strict about the {"version":1} JSON header 2012-08-12 18:40:15 +02:00
Michael Stapelberg
8f2e225db9 i3bar: Fix warnings with libyajl1 (Thanks prg)
yajl1 has the status yajl_status_insufficient_data, which in our stream
parsing context basically means "ok". Therefore, in yajl1, we no longer
print an error in this case.
2012-07-16 19:23:37 +02:00
Michael Stapelberg
156a06e495 i3bar: Don’t crash when full_text is missing or null in the JSON input (Thanks fernandotcl) 2012-05-12 08:23:51 +02:00
Michael Stapelberg
24ac6e32aa Bugfix: Properly terminate lines not ending with a newline (Thanks xeen)
Previously, we didn’t check for a newline and thus could be corrupting
formerly valid UTF-8 input, such as
    echo -n '↓'

Fixes: #671
2012-04-07 19:15:41 +02:00
Michael Stapelberg
d519659ea7 i3bar: kill child processes when exit()ing (they might be stopped) (Thanks darkraven) 2012-03-26 17:36:00 +02:00
Michael Stapelberg
607ba6fcde i3bar: Fix memory for old plain-text input (Thanks Han) 2012-03-19 22:30:20 +01:00
Michael Stapelberg
a3ee8491fd i3bar: compile with yajl < 2 2012-02-16 23:41:58 +00:00
Michael Stapelberg
31b9d24c2b Implement the i3bar JSON protocol (with fallback to plain text)
If the first line of the input starts with {"version":, then the input is
considered to be JSON, otherwise it is interpreted as plain text.

Only the "full_text" and "color" parts of a block are currently understood by
i3bar.
2012-02-16 23:28:18 +00:00
Michael Stapelberg
f0cc13f356 i3bar: fix indention in src/child.c 2011-11-07 21:34:50 +00:00
Michael Stapelberg
726f2a1e5a normalize file headers across **/*.{h,c} 2011-10-25 21:19:38 +01:00