Giter Club home page Giter Club logo

i3blocks's Introduction

i3blocks

The hacker-friendly status_command for Sway and i3

i3blocks is a feed generator for text based status bars. It executes your command lines and generates a status line from their output. Commands are scheduled at configured time intervals, upon signal reception or on clicks.

The generated line is meant to be displayed by the i3 window manager through its i3bar component, as an alternative to i3status. This program naturally works out of the box with the sway Wayland compositor since it is a drop-in replacement for i3.

i3blocks is meant to be highly flexible but intuitive. No library package is required, just output what your status bar expects, from your favorite programming language and your preferred format.

Example

[click]
full_text=Click me!
command=echo "Got clicked with button $button"
color=#F79494

# Guess the weather hourly
[weather]
command=curl -Ss 'https://wttr.in?0&T&Q' | cut -c 16- | head -2 | xargs echo
interval=3600
color=#A4C2F4

# Query my default IP address only on startup
[ip]
command=hostname -i | awk '{ print "IP:" $1 }'
interval=once
color=#91E78B

# Update time every 5 seconds
[time]
command=date +%T
interval=5

Installation

i3blocks is already packaged for:

Or can be installed from source with:

git clone https://github.com/vivien/i3blocks
cd i3blocks
./autogen.sh
./configure
make
make install

Getting started

In your i3 configuration file, define i3blocks as the status line command of a new bar block:

bar {
  status_command i3blocks
}
Important
The project’s repository does not include default scripts anymore.

For the lazy, you can start from our collection of scripts:

git clone https://github.com/vivien/i3blocks-contrib ~/.config/i3blocks
cd !$
cp config.example config

For the picky, you can start a configuration file in one of the following preferred paths:

  • $XDG_CONFIG_HOME/i3blocks/config (or ~/.config/i3blocks/config);

  • ~/.i3blocks.conf;

  • $XDG_CONFIG_DIRS/i3blocks/config (or /etc/xdg/i3blocks/config);

  • /etc/i3blocks.conf;

  • or any other path that you will specify using the -c option.

Note
By default /etc is prefixed by /usr/local when you installed from source.

Use the example above or dig in the configuration details below.

Now restart i3 with i3-msg restart to apply your changes.

Blocks

The configuration file uses a simplified INI file format:

# Properties not preceded by a section are considered global
# and merged into every section declarations.
foo=bar

[block1]
baz=qux

# This is a comment
[block2]
quux= quuz

In this example, block2 contains a foo property equal to "bar" and a quux property equal to " quuz" (including the leading space). Everything after the equal sign will be part of the value, thus inline comments won’t be stripped out.

At runtime, these properties are simply variables, that are passed along to the status bar program when printing is necessary. However on startup, i3blocks checks some optional properties to eventually setup the scheduling of a command.

If a block specifies a command, then all of its properties are passed as environment variables at execution, which means that the foo=bar property will be available from a shell script with $foo. The output of the command is used to update the values of these variables. The values are reset to default (as defined in the configuration file) before the update, so that blocks get a consistent behavior at each execution.

Note
Each line from a block output must be terminated with a newline.

i3bar properties

In order to use i3blocks with i3, its status bar command i3bar expects specific keys. To know how to customize the blocks of your status line, you must refer to the i3bar protocol.

Note
full_text is the only mandatory key, the block will be skipped if this key is absent or empty.

Unless overriden, the section name of the block defines the name key.

Below are examples of static blocks interacting with i3bar.

[simple]
full_text=This is a looong white on red text
short_text=Short white on red text
background=#FF0000
color=#FFFFFF

# Block with a fixed width
[aligned]
full_text=Here.
min_width=100
align=center

# Fancy text with multiple colors and shapes
[funky]
full_text=<span foreground="red" size="x-large">Roses</span> and <i><span color="#EE37B8">violets</span></i>!
markup=pango

i3blocks properties

These are some special properties checked by i3blocks on startup. These will be considered as simple variables at runtime.

command

The optional command property specifies a command line to be executed with sh -c. The command can be relative to the configuration file where it is defined. If the command outputs some text, it is used to update the block.

An exit code of 0 means success. A special exit code of 33 will set the urgent i3bar key to true. Any other exit code will raise an error.

[pacman]
full_text=c ·
command=echo "· ${full_text~~}"
color=#FFFF00

interval

The optional interval property specifies when the command must be scheduled.

A positive value represents the number of seconds to wait between exectutions.

# Print seconds since 1970-01-01
[epoch]
command=date +%s
interval=1

A value of 0 (or undefined) means the command is not timed whatsoever and will not be executed on startup. This is useful to trigger the command only on user input (e.g. signal or click), not before.

# Restart i3 on click
[restart]
full_text=Restart
command=i3-msg -q restart
#interval=0

The interval value once (or -1) will schedule the command only on startup. This tells i3blocks not to schedule the command again on a time basis. But events such as signals and clicks will execute the command again of course.

# Fetch the public IP address only on startup
[public-ip]
command=wget -qO - icanhazip.com
interval=once

The interval value repeat (or -2) will respawn the command as soon as it terminates. This is convenient for blocking programs which exit as soon as the awaited event arises.

Note
clicks are not supported with this value, since such commands are unlikely to expect data on their standard input.
# Print the last command entered in Bash
[history]
command=inotifywait -qq -e close_write ~/.bash_history; tail -1 ~/.bash_history
interval=repeat

The interval value persist (or -3) expects the command to be an infinite loop. Each line of the output will trigger an update of the block.

[window]
command=xtitle -s
interval=persist

signal

Blocks can be scheduled upon reception of a real-time signal (think prioritized and queueable). The range of available signal numbers is 1 to N, where SIGRTMIN+N = SIGRTMAX. (Note: there are 31 real-time signals in Linux.)

[caps-lock]
command=xset -q | grep Caps | awk '{ print $2, $3, $4 }'
interval=once
signal=10

This example block above will be scheduled once i3blocks handles the SIGRTMIN+10 signal. This can be sent directly from an i3 binding on Caps Lock release with the following configuration:

bindsym --release Caps_Lock exec pkill -SIGRTMIN+10 i3blocks

format

There are several formats supported to specify which variables i3blocks must update. Some favor simplicity over flexibility but thus can be limited.

When undefined, a raw format is assumed. Each line of the output corresponds to an i3bar key, in the order of definition found in the i3bar protocol:

  • the 1st line updates the full_text;

  • the 2nd line updates the short_text;

  • the 3rd line updates the color;

  • the 4th line updates the background.

Excess lines are considered an error. Below is an example of a simple battery script.

battery.sh
#!/bin/bash

BAT=$(acpi -b | grep -E -o '[0-9][0-9]?%')

# Full and short texts
echo "Battery: $BAT"
echo "BAT: $BAT"

# Set urgent flag below 5% or use orange below 20%
[ ${BAT%?} -le 5 ] && exit 33
[ ${BAT%?} -le 20 ] && echo "#FF8000"

exit 0
[battery]
command=battery.sh
interval=10

The json format can update any variable.

[counter]
_count=0
command=printf '{"full_text":"Counter: %s", "_count":%d}\n' $_count $((_count + 1))
format=json
interval=1

Click

When you click on a block, data such as the button number and coordinates are merged into the block variables.

Note
name and instance are the two keys used by i3bar to identify a block.

The data sent on click is detailed in the i3bar protocol.

If the block command isn’t already spawned, it is executed again.

# Print click data
[clickme]
align=center
full_text=Click me!
min_width=Button=? x=? y=?
command=echo "Button=$button x=$x y=$y"

If the value of the block’s interval is persist, then the data is written on the command standard input, one line per click. What gets written depends on the block’s format. The raw format only gets the click button. The JSON format gets all block variables.

[click-loop]
full_text=Click me!
command=while read button; do echo "Got click $button"; done
interval=persist

[click-loop-json]
full_text=Click me!
command=ruby -r json -n -e '$_ = JSON.parse($_)' -e '$_["full_text"] = "Click %s at (%d,%d)" % $_.slice("button", "x", "y").values' -e 'puts JSON.dump($_)' -e 'STDOUT.flush'
interval=persist
format=json

FAQ

Frequently Asked Questions and Troubleshooting.

  1. What is a blocklet?

    A blocklet is the configuration of a single block, part of the status line. There are plenty listed in the blocklets page.

  2. Can I use my own variables?

    Yes, any variable defined in the block is exported as is to the environment of its command. The foo=bar property can be accessed with $foo from a shell script, ENV["foo"] from Ruby, and so on.

    The IEEE and The Open Group state that "The name space of environment variable names containing lowercase letters is reserved for applications.". i3bar suggests to prefix your own keys with an underscore (_), but it might be more intuitive to use uppercase environment variables, so it is your call to define your own naming convention.

  3. Why $foo doesn’t work from the configuration file?

    i3blocks does not do string interpolation of any sort. The definitions found in the configuration file are just raw strings, this means that bar=$baz defines a bar variable equal to literally $baz (a dollar sign followed by "baz").

    String interpolation does work in the command property though, since it is interpreted by a shell which has access to the environment variables.

  4. How can I simulate a button?

    This is pretty straightforward actually. Just make sure not to override the full_text, for example:

    [calc-button]
    full_text=Calculator
    command=gnome-calculator >/dev/null
  5. Can a block start a GUI application?

    Sure. And if you do not wish your command to block until the application is closed, ask i3 to start it for you with i3-msg -q exec myapp.

  6. Why Pango isn’t working?

    The Pango markup requires a Pango font. Make sure you configured i3bar to use a Pango font. For example:

    font pango:Inconsolata, Icons 12
  7. Why is printf not working?

    As of i3blocks 1.5, each line from a block output are expected to be terminated with a newline, e.g. with printf "…​\n" from a shell script.

  8. Why is the output from my persistent block not displayed?

    Make sure to flush stdout, for example:

    [ruby-loop]
    full_text=Click me
    command=ruby -p -e '$_.prepend("Got button ")' -e 'STDOUT.flush'
    interval=persist
  9. Can I use a time interval below 1 second?

    No, the time unit for interval is the second.

    But even though I wouldn’t recommend it, you can still update faster than that with loops:

    [nano1]
    command=sleep .5; date +%N
    interval=repeat
    
    [nano2]
    command=while sleep .5; do date +%N; done
    interval=persist
  10. Can I change the block separator?

    Not with i3blocks itself, separators are drawn by i3bar. You can change the separator_symbol in the i3bar configuration.

    Alternatively, you can define static blocks as custom separators in your i3blocks configuration. In the example below, we use the "\xe3\x80\x89" UTF-8 character:

    # Define the custom separator in global properties for boilerplate
    full_text=〉
    align=center
    color=#666666
    separator=false
    separator_block_width=7
    
    [time]
    instance=la
    TZ=America/Los_Angeles
    command=date +%T
    interval=5
    
    [separator]
    
    [time]
    instance=nc
    TZ=Pacific/Noumea
    command=date +%T
    interval=5
    
    [separator]
    
    [time]
    instance=mtl
    TZ=America/Montreal
    command=date +%T
    interval=5

Debugging

The log level can be increased with the -v option.

If your window manager (and thus this program) is run via systemd, you can inspect the program outputs with journalctl -t <identifier> -f. You may also use this in conjonction with running the program manually with systemd-cat -t <identifier> ./i3blocks.

Alternatively you can redirect the standard output and error streams from the program invokation with:

bar {
  status_command 2>/tmp/i3blocks.err /path/to/i3blocks -vvv -c /path/to/config | tee /tmp/i3blocks.out
}

And inspect the log with tail -f /tmp/i3blocks.err.

See the manpage for details about the command line options and i3blocks usage.

License

i3blocks is Copyright © Vivien Didelot

See the file COPYING for information of licensing and distribution.

i3blocks's People

Contributors

acrisci avatar airblader avatar alaviss avatar anlutro avatar brown121407 avatar deimosfr avatar dinduks avatar eepp avatar elitetk avatar fridim avatar gitter-badger avatar gportay avatar jbonjean avatar jjerphan avatar jpleau avatar kb100 avatar medvid avatar mhcerri avatar or avatar pink-mist avatar r-value avatar revan avatar roobre avatar setzer22 avatar thor avatar timp3289 avatar tmatth avatar valeriangalliat avatar vivien avatar yuce 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  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  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  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  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  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

i3blocks's Issues

Define BLOCK_BUTTON, BLOCK_X, BLOCK_Y to 0 if no click

Not resetting these variables to zero causes commands using them to run their onclick events every time.

The following patch removes the if condition preventing the reset to 0.

From 042527117d66359531af0e003a54f54e9719b89f Mon Sep 17 00:00:00 2001
From: Imran Sobir
Date: Sat, 8 Mar 2014 03:27:21 +0800
Subject: [PATCH] Fix sticky clicks

---
From aca40cbbc05f00eb9060a7dae167bbdf17010a60 Mon Sep 17 00:00:00 2001
From: Imran Sobir
Date: Sat, 8 Mar 2014 03:48:59 +0800
Subject: [PATCH] Fix sticky clicks

---
 block.c | 39 ++++++++++++++++++---------------------
 1 file changed, 18 insertions(+), 21 deletions(-)

diff --git a/block.c b/block.c
index 85b3a00..a662a36 100644
--- a/block.c
+++ b/block.c
@@ -42,27 +42,24 @@ setup_env(struct block *block)
        return 1;
    }

-   /* FIXME define BLOCK_{BUTTON,X,Y} to 0 if no click? */
-   if (block->click.button) {
-       char s[8];
-
-       snprintf(s, sizeof(s), "%d", block->click.button);
-       if (setenv("BLOCK_BUTTON", s, 1) == -1) {
-           errorx("setenv BLOCK_BUTTON");
-           return 1;
-       }
-
-       snprintf(s, sizeof(s), "%d", block->click.x);
-       if (setenv("BLOCK_X", s, 1) == -1) {
-           errorx("setenv BLOCK_X");
-           return 1;
-       }
-
-       snprintf(s, sizeof(s), "%d", block->click.y);
-       if (setenv("BLOCK_Y", s, 1) == -1) {
-           errorx("setenv BLOCK_Y");
-           return 1;
-       }
+   char s[8];
+
+   snprintf(s, sizeof(s), "%d", block->click.button);
+   if (setenv("BLOCK_BUTTON", s, 1) == -1) {
+       errorx("setenv BLOCK_BUTTON");
+       return 1;
+   }
+
+   snprintf(s, sizeof(s), "%d", block->click.x);
+   if (setenv("BLOCK_X", s, 1) == -1) {
+       errorx("setenv BLOCK_X");
+       return 1;
+   }
+
+   snprintf(s, sizeof(s), "%d", block->click.y);
+   if (setenv("BLOCK_Y", s, 1) == -1) {
+       errorx("setenv BLOCK_Y");
+       return 1;
    }

    return 0;
-- 
1.9.0

Upgrade breaks i3blocks unless make clean is run first.

This may be common knowledge that I just wasn't aware of, but in order to upgrade i3blocks, one needs to

git remote update
git pull
make clean
make
sudo make install

For some reason, after a git pull, a plain old make will say that everything is up to date and consequently not compile anything. I'm not sure if this is how make is meant to work or if you need to change the Makefile, but I thought I should let you know. Adding a bit to the github docs about how to properly upgrade i3blocks from a running version (since development is so active!) might be helpful to new users.

Never again forget about your open mic!

Hi all,
@vivien, rest of the contributing folks: I just want to thank you'll for i3blocks, I just switched to it over last night and I love it.

So, here's my little contribution that I would like to add to the wiki in case anyone find it useful once we all agree it meets the minimum quality standards :)


mic

I use Skype, Linphone and Hangouts every day at work and I constantly forget to mute the damn mic whenever I'm on a call but not participating on it actively or just waiting for my turn to speak.
I created this little blocklet that hopefully will help me be aware whenever my mic is open so I can mute it and keep things professionally :D

Also I hope my pal @cawa will stop babysitting me and telling me to shut the mic!

So without more ado here are some screenshots and the correspondent code.

Screenshots

2015-04-04_2620_1600x900
2015-04-04_3033_1600x900
micc_alt
mico
mico_alt
micc

As you can see on the above screenshots I already ship two variants of the mics shown - also the colors can be customized too.

Fonts utilized:
i3: font pango:Terminus 9 (frames, dialog boxes, status bar)
Eye candy: Font Awesome

Code

Now the most important part is done (that is showing some fancy screenshots), here comes the code.
Relevant ~/.config/i3blocks/config stuff:

...
command=~/.config/i3blocks/blocklets/$BLOCK_NAME
[mic]
color=#FFFFFF
interval=5
...

~/.config/i3blocks/blocklets/mic:

#!/bin/bash
# Copyright (C) 2015 Martín Cigorraga <archlinux.us: msx>

# This program is free software: you can redistribute it and/or modify
# it under the terms of the Affero GNU General Public License as published
# by the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.

# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.

# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.


# Check mouse event
case $BLOCK_BUTTON in
    3)
    #/usr/bin/amixer set Capture toggle &>/dev/null;  # AlsaMixer
    /usr/bin/pactl set-source-mute 1 toggle;  # PulseAudio
esac


# Determine mic's state
#amixer contents | grep -q "values=off" && [[ $? -eq 0 ]] && state="off";  # If you use AlaMixer
pactl list sources | grep -q "Mute: yes" && [[ $? -eq 0 ]] && state="off";  # If you rather go with PulseAudio


# Toggle mic's state
case $state in
    off)
    echo "" " muted ";
    #echo "  "
    echo
    echo \#005FD7;  # Soft blue
    #echo \#00FF00;  # Bright green
    exit 0;
    ;;
    *)
    echo "" " OPEN   ";
    #echo "      ";
    exit 33;
    ;;
esac

exit 0;

Features

  • Avoids possibly mistakes when you are unaware the mic is open 👍
  • Lets you toggle MUTE state with a right-click.
  • The script reads mic's state every 5 seconds (default) so if you set the mic state using AlsaMixer or similar app the change will be reflected on next refresh.
  • I ship the script ready to use it with AlsaMixer and PulseAudio (default), you can toggle which backend you prefer by simply uncommenting the appropriate lines.
  • If you happen to sometimes be faraway as I am, you will probably choose to use the bigger alert. However as everything is in plain text you can customize anything to your liking.

Requirements

For toggling mic's state:
  • amixer (AlsaMixer)
  • pactl (PulseAudio)
Eye candy:

That's all for now, I hope mic will be useful for someone else.
Any ideas/critics on how to improve this circus is welcome (in fact I would love to know about them).
Cheers!

Removing last newline character from i3blocks.conf breaks i3blocks

i3blocks.conf ends with LF char. If you remove it, i3blocks won't start and outputs following error log instead:

line "interval=1" is not terminated by a newline
*** Error in `i3blocks': free(): invalid pointer: 0x00000000012830f8 ***
======= Backtrace: =========
/usr/lib/libc.so.6(+0x73f8e)[0x7f26b4d59f8e]
/usr/lib/libc.so.6(+0x7988e)[0x7f26b4d5f88e]
/usr/lib/libc.so.6(+0x7a04b)[0x7f26b4d6004b]
i3blocks[0x4020be]
i3blocks[0x4019e1]
i3blocks[0x401a3f]
i3blocks[0x40121d]
/usr/lib/libc.so.6(__libc_start_main+0xf0)[0x7f26b4d06000]
i3blocks[0x401294]
======= Memory map: ========
00400000-00404000 r-xp 00000000 08:06 1281530                            /usr/bin/i3blocks
00603000-00604000 r--p 00003000 08:06 1281530                            /usr/bin/i3blocks
00604000-00605000 rw-p 00004000 08:06 1281530                            /usr/bin/i3blocks
01282000-012a3000 rw-p 00000000 00:00 0                                  [heap]
7f26b4ad0000-7f26b4ae6000 r-xp 00000000 08:06 1186197                    /usr/lib/libgcc_s.so.1
7f26b4ae6000-7f26b4ce5000 ---p 00016000 08:06 1186197                    /usr/lib/libgcc_s.so.1
7f26b4ce5000-7f26b4ce6000 rw-p 00015000 08:06 1186197                    /usr/lib/libgcc_s.so.1
7f26b4ce6000-7f26b4e8a000 r-xp 00000000 08:06 1182970                    /usr/lib/libc-2.19.so
7f26b4e8a000-7f26b508a000 ---p 001a4000 08:06 1182970                    /usr/lib/libc-2.19.so
7f26b508a000-7f26b508e000 r--p 001a4000 08:06 1182970                    /usr/lib/libc-2.19.so
7f26b508e000-7f26b5090000 rw-p 001a8000 08:06 1182970                    /usr/lib/libc-2.19.so
7f26b5090000-7f26b5094000 rw-p 00000000 00:00 0 
7f26b5094000-7f26b50b5000 r-xp 00000000 08:06 1182947                    /usr/lib/ld-2.19.so
7f26b526c000-7f26b526f000 rw-p 00000000 00:00 0 
7f26b52b2000-7f26b52b4000 rw-p 00000000 00:00 0 
7f26b52b4000-7f26b52b5000 r--p 00020000 08:06 1182947                    /usr/lib/ld-2.19.so
7f26b52b5000-7f26b52b6000 rw-p 00021000 08:06 1182947                    /usr/lib/ld-2.19.so
7f26b52b6000-7f26b52b7000 rw-p 00000000 00:00 0 
7fff3eb34000-7fff3eb55000 rw-p 00000000 00:00 0                          [stack]
7fff3ebfe000-7fff3ec00000 r-xp 00000000 00:00 0                          [vdso]
ffffffffff600000-ffffffffff601000 r-xp 00000000 00:00 0                  [vsyscall]

Change separator style

Can you add feature to change separtor. I want separator can be change to something creative more than a "|"

Interval not respected with a single entry

If I use the default configuration file with a different interval, the change is ignored by i3blocks which keeps updating every 5 sec.
Adding more entries fixes the problem.

problem with current version

Current version doesn't read property my configs from arg -c (i have 2 configs for 2 monitors). When I back to 1.2-19-gb6d98be everything works with the same configuration.

load_average colors incorrect for loads > 10

I noticed that I had a load of 13 and 8 cpus but load_average didn't turn red.

The relevant section in load_average reads

# color if load is too high
if [ $(awk 'BEGIN{ print "'$cpus'"<="'$load'" }') -eq 1 ]; then
    echo "#FF0000"
fi

which compares the strings lexicographically.
It should probably say something more like

awk -v cpus=$cpus -v cpuload=$load 'BEGIN { if( cpus <= cpuload ) { print "#FF0000"; } }'

Note: -v load=$load will not work, as load is a built in awk variable.

Don't error out on unknown values

Is it possible to not let i3blocks error out when an unknown key is used, but instead just pass it on to i3bar unchanged?

My fork (i3-gaps) has some additional properties for i3bar which i3blocks currently cannot utilize, which is unfortunate for me because I really came to love using i3blocks for its signal feature. An alternative would be allowing a command-line switch for this feature.

If this is not at all feasible, that's okay – I'll just have to fork yet another project. :)

Change urgent return code

The actual return code for urgency is 127, but we need to find another one, because unfortunately, this is the code returned by sh when the specified command_file could not be found by a non-interactive shell.

Segfault

Hello,

I discover i3blocks and I probably missed something, but I prefer an error message.

$ cat ~/.i3blocks.conf 
interval=1
color=#00FF00

[time]
command=date +%T
$ gdb i3blocks                                                                                                                            
GNU gdb (GDB) 7.6.2 (Debian 7.6.2-1)
Copyright (C) 2013 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.  Type "show copying"
and "show warranty" for details.
This GDB was configured as "x86_64-linux-gnu".
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>...
Reading symbols from /home/sanpi/.local/bin/i3blocks...done.
(gdb) r
Starting program: ~/.local/bin/i3blocks 
warning: no loadable sections found in added symbol-file system-supplied DSO at 0x7ffff7ffa000
warning: Could not load shared library symbols for linux-vdso.so.1.
Do you need "set solib-search-path" or "set sysroot"?
{"version":1,"click_events":true}
[[]
,[{"full_text":"12:10:38","color":"#00FF00","name":"time","urgent":false}]

Program received signal SIGSEGV, Segmentation fault.
__GI_____strtol_l_internal (nptr=0x9 <Address 0x9 out of bounds>, endptr=endptr@entry=0x0, base=base@entry=10, group=group@entry=0, loc=0x7ffff7dd7f20 <_nl_global_locale>)
    at ../stdlib/strtol_l.c:298
298     ../stdlib/strtol_l.c: Aucun fichier ou dossier de ce type.
(gdb) bt
#0  __GI_____strtol_l_internal (nptr=0x9 <Address 0x9 out of bounds>, endptr=endptr@entry=0x0, base=base@entry=10, group=group@entry=0, 
    loc=0x7ffff7dd7f20 <_nl_global_locale>) at ../stdlib/strtol_l.c:298
#1  0x00007ffff7a6ed92 in __GI_strtol (nptr=<optimized out>, endptr=endptr@entry=0x0, base=base@entry=10) at ../stdlib/strtol.c:108
#2  0x00007ffff7a6c350 in atoi (nptr=<optimized out>) at atoi.c:27
#3  0x0000000000402bec in parse_click (json=0x7fffffffddc0 "", name=0x7fffffffddb8, instance=0x7fffffffddb0, click=0x7fffffffdda0) at sched.c:153
#4  0x0000000000402d4e in handle_click (status=0x605250) at sched.c:175
#5  0x00000000004030b4 in sched_start (status=0x605250) at sched.c:286
#6  0x0000000000401988 in main (argc=1, argv=0x7fffffffe328) at i3blocks.c:76
(gdb) 

Used atoi is not a good idea, use strtol instead: https://stackoverflow.com/questions/3792663/atol-v-s-strtol/3792676#3792676

Incorporate markup property

With the recent change, i3bar now supports the markup key. Likely, it will soon default to no markup which means i3blocks could not be used to provide blocks with markup.

We should add support for it asap to use the small transition time now.

contrib: add to Makefile

Currently, the contrib folder is not installed by the Makefile. I don't know if this was done on purpose, but the scripts there could certainly be useful to people installing i3blocks 😉

Better script for focused window

This is just in the Wiki, but I think this script is superior and not much more complex:

command=xdotool getactivewindow getwindowname 2>/dev/null || echo "None"

It will work differently if no window is focused on the workspace. In this case, xdotool will error out. This causes the window title to not change, i.e., it will keep displaying the last focused window's title.

Clicks are queued and don't execute on click

I just installed i3blocks and added

[clickme]
command=echo button=$BLOCK_BUTTON x=BLOCK_X y=$BLOCK_Y

to my ~/.i3blocks.conf file. Testing, I find that about half the time I click on the text, nothing happens. If I click around a few times, it will eventually register a click. When it does register the click, the output corresponds to that of the first click that didn't register, as if it was queued up. The intermediate registered clicks appear to be forgotten.

timestamp reset on click

Hello!

I am using a script for an MPD-block, which uses the click functionality. Normally it shows the current song but when I right-click said block, it shows the progress of the current song (i.e. "3:49/5:06 (74%)") until the next time it is updated.
In its current form i3blocks shows the song progress for the remaining time, which could be any amount within the interval range. If the block's timestamp would be updated when clicked the delay would be persistent every time.
On the other hand, if the block's timestamp is updated and no update to its text is done, it could make the display inconsistent.

What do you prefer?

Short text displayed with plenty of screen left

Currently I have three monitors, 1920x1080, 2560x1440, 2560x1440 with bars on all of them. The short text for my blocklets is getting displayed with the 1920 width screen only 80% full.

Gentoo ebuild

Hi,
i wanted to notify that i just wrote that ebuild to add i3blocks available in my sabayon repository it's here maybe can be useful for someone else
Cheers

New memory check

Hi,

I've wrote another memory check. I think this one is better because it gives the used memory and print color if your usage go up to a certain amount. It also embed swap and gives you the same color output if you're consuming too much swap.

You can find the check here:
https://gist.github.com/deimosfr/9969983

I just finished to develop it and do not have enough feedback yet but you're welcome to test. I'll update the gist and inform you if I found issues.

Thanks

Error: status_command process exited unexpectedly (exit 0)

Sometimes I'm using ability to hide bar. "i3-msg bar mode toggle"
i3blocks crashes in 98% cases. "Error: status_command process exited unexpectedly (exit 0)"
Probably, it's consequences of stopping output processing by status_command.
However, with i3-bar or dzen2 I never saw such behaviour.
Another suggestion -- it's linked to bash scripts, launched from i3-blocks.

After crash I must reload i3 to restore normal functioning of i3blocks.

Support global definition

The configuration file should support default block definition, such as below:

# Update blocks every 5sec and print them in blue
color=#0000FF
interval=5

[network]
command=~/bin/blocks/network

[battery]
command=~/bin/blocks/battery

[datetime]
command=date '+%D %T'

Most plugins exiting without (apparent) reason

Hi,

I just replaced my i3status for i3blocks, and configured it to show only five blocks. Most of them - the battery and cpu blocks, for example, weren't showing anything, so I dig through the code and found two missing dependencies (acpi and mstat), but the blocks are still not working =S

This is the output:

$ i3blocks | grep bad
ERROR block_reap:239: [memory] bad exit code 127
ERROR block_reap:239: [battery] bad exit code 127
ERROR block_reap:239: [cpu] bad exit code 127
ERROR block_reap:239: [swap] bad exit code 127

The .i3blocks.conf I'm using is the same found in the repo, excluding a few blocks. I'm using Arch Linux, if it is somehow relevant.

So, what's going on? Is there an easy way to debug it to find the exact problem?

Only run command on click

I am migrating from py3status to i3blocks due to the fact that it looks simpler and cleaner, however one nice feature I had in py3status was an item that could be clicked and a command run.

This can almost be implemented by a command and no signal / interval and full_text for the title, however one issue I have is that it runs on load. Is there a way to set up a button that would not be executed until a mouse click has been fired?

OpenVPN check

Hi,

I've made a check for OpenVPN:

  • Support multiple VPN at the same time
  • Color:
    • green on connect
    • red on disconnect
    • normal color after state change
  • Show the VPN name(s) in status bar

Please let me know what do you think about it:
https://gist.github.com/deimosfr/10234741

SCRIPT_DIR or SCRIPTS_DIR?

The default configuration calls i3blocks as

status_command SCRIPTS_DIR=[...] i3blocks

but in the default config file the variable used is SCRIPT_DIR.

One of these should be changed to the other.

Scripts criteria

This issue is meant to describe the behavior of the default status line and the acceptance criteria for scripts.

A script has good chances to be part of the default scripts if:

  • It has no external dependency (or a well justified one).
  • It is transparent: e.g. if the machine has no battery or wireless connection (think desktop), the corresponding block should not be displayed.
  • It works on any distribution (e.g. ip/ifconfig's output may differs between different versions).
  • It uses no fancy unicode chars (the default font may certainly not like it).

A useful and well-written script is a good candidate for the contrib folder, if:

  • It doesn't answer the previous points.
  • It is too much specific (e.g. a specific music player, location or service).

Otherwise, any example is welcome in the wiki.

Improve the default volume script

This is meant to regroup the different issues about the volume: #46, #47, #48 and find a convenient solution, according to #36.

Let's agree on what the default script should look like. So far, I suggest:

  • wheel up increase the volume (+10%? or +3dB?)
  • wheel down to decrease the volume (same as above, which unit?)
  • display "MUTE" if the output is off
  • Mute on middle click (I find it convenient to keep the left click free, to manually update the volume after being changed by an alternative UI)
  • convenient values for CARD, MIXER, SCONTROL? Is there a candidate for BLOCK_INSTANCE?

ATM, I ended up with this, from all the PR: https://gist.github.com/vivien/0dbbecd0372f808a895c

It would be neat to convert the Ruby snippet to Perl to avoid this dependency, if not to complicated.

Cc: @xelite, @jpleau, @Elfram, @Nycroth

cpu_usage script should include all usage, i.e. %nice as well

Currently the cpu_usage script does not include every category of cpu usage, especially ignoring niced programms leads to quite wrong results - I currently have a load of 5.5 and a cpu usage of 5% accoring to the i3blocks. I have only 4 CPUs, not a few dozen ones which would make this result correct ;)

It is probably easier to just take 100 - %idle.

Add more screenshots for prospective i3blocks users

I think we should put up screenshots of different user configs so that prospective users of i3blocks can see it's potential. Here's mine (for now!):

screenie

It benefits potential users and also promotes collaboration amongst those of us who already use i3blocks.

Center a block on i3bar?

Would it be possible to make a block centered on i3bar?
I'm using xdotool on repeat to display window titles, which works flawlessly, except for the fact that I'd love to have this centered on the bar instead of aligned to the right.

Thanks for your time

Nested functions break compilation with Clang

Hi,
I just wanted to inform you that i3blocks does not compile using clang 3.6.0 (GCC 4.9.2 works just fine). The problem is the usage of nested functions. Do you really think that they are necessary?
If you think so I will keep switching back to GCC for i3blocks everytime.

Handling line-buffered block output without respawning

Hello,

Currently blocks can either be respawn when they exit or be executed at a specific interval. While this works well for things like a clock, load average or du, I can think of many blocks that are event-driven meaning their output is constant until something happens:

  • pulseaudio volume changes
  • the next song is played in MPD
  • MPD is paused/resumed
  • brightness changes

Small examples of such "observers" can be found in this project I'm working on, which is basically a lesser-i3blocks with support for this feature. I would happily throw that away if i3blocks could support buffered output without using signals that have serious limitations.

With the current implementation, we cannot use a blocking process that would produce lines of output when something happens. We have to exit so i3blocks can read & display the output. It would be great to have something like interval=once that would select() and read a single line when stdout becomes readable. I am willing to work on this feature myself, but I am unsure where to start. The event loop is completely sigwaitinfo-based and I don't see where I could fit the (blocking) select() or something like that.

make install fails, no mention of ronn dependency

When I tried to update to the newest version I make clean all which works fine. Then I sudo make install which gives

ronn -w -r i3blocks.1.
make: ronn: Command not 
Makefile:52: recipe for target 'i3blocks.1' 
make: *** [i3blocks.1] Error 127

I found ruby-ronn in the official debian repository which appears to fulfill the dependency, and now sudo make install works. I'm submitting this as an issue because there doesn't appear to be any mention in the documentation of needing to install ronn before trying to build.

bar-aint-recursive uptade

Hi guys,

I don't know if you are familiar with LemonBoy/bar, it reads the updates from a FIFO.
Can I do that on i3blocks? for example, I want to use baskerville/xtitle with snoop flag to display the current window name every time it changes, and not every 1s. It is more efficient and as no lag. It could be used to replace the signal in case of the volume for example (no need there, but an extra option is always good).

p.s.: I can try to implement that if anyone wants it.

Make the header configurable

Looking at i3/i3#1598, the goal seems to be to move statusline related configuration into the JSON header.

With such a change, i3blocks should make an effort to make the contents of the header configurable.

Color from configuration not restored

If a color is defined in a block configuration, it should always be used if no color is returned by the command, not just for initialization.
For example, my script does not print color, except when there is an alert. When the alert is gone, I want the original color to be restored.
Thanks.

Wired check

Hi,

Here is a check for wire connection. It is smaller, detect if the device is present (nice for notebook or any laptop that needs a sub ethernet adaptator).

https://gist.github.com/deimosfr/10234327

Please let me know what do you think about it.

Support for short_text and color

It would be nice to have support for these fields, respecting the following format (same order as i3bar blocks definition):

full_text
short_text
color

For example, my network script would print:

E: 192.168.50.69 (1000 Mbits/s)
E: 192.168.50.69
#00FF00

[Feature Request] multiple colors per block

I wrote a script to check what usb devices are plugged in and display their locations, labels, partitions, mountpoints, etc. E.g. the output might be

[sdd1] "flashdrive" /mnt/flashdrive: 8G | [sde1] | [sde2] /mnt/flashdrive2: 4G | [sdf1] "other"

if I had 3 usb devices plugged (sdd, sde, sdf), having 1, 2, 1 partitions (sdd1, sde1,sde2, sdf1), of which sdd1 is labeled "flashdrive", sdf1 is labeled "other", and sdd1 and sde2 are mounted.

Currently I can only color each block a single color, so the whole string above gets one color.
I would like to be able to color each of the sub-blocks a different color in order to indicate which ones are plugged versus which ones are actually mounted.

Note that, unlike for disk entries where I might have three fixed blocks for /home, /data/ and /, I do not know how many usb devices are going to be plugged in ahead of time, so I can't just use fixed entried with different colors.

global color_bad

Hi, is there a color_bad (or something else to change the red text on my eth when it is down?) :-)

Could not finde something about it.

ncmpcpp now playing script no longer works.

ncmpcpp has seemed to of gotten rid of the --now-playing argument with the newest update on arch, I looked around a bit and they don't seem to have any replacement for it. Not really a bug with the script but it should probably be removed or worked around somehow, maybe add a notice saying it doesn't work with the newer versions of ncmpcpp?

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.