2 # vim:ts=4:sw=4:expandtab
3 # © 2012 Michael Stapelberg, Public Domain
5 # This script is a simple wrapper which prefixes each i3status line with custom
6 # information. To use it, ensure your ~/.i3status.conf contains this line:
7 # output_format = "i3bar"
8 # in the 'general' section.
9 # Then, in your ~/.i3/config, use:
10 # status_command i3status | ~/i3status/contrib/wrapper.pl
11 # In the 'bar' section.
15 # You can install the JSON module with 'cpan JSON' or by using your
16 # distribution’s package management system, for example apt-get install
17 # libjson-perl on Debian/Ubuntu.
20 # Don’t buffer any output.
23 # Skip the first line which contains the version header.
26 # The second line contains the start of the infinite array.
29 # Read lines forever, ignore a comma at the beginning if it exists.
30 while (my ($statusline) = (<STDIN> =~ /^,?(.*)/)) {
31 # Decode the JSON-encoded line.
32 my @blocks = @{decode_json($statusline)};
34 # Prefix our own information (you could also suffix or insert in the
37 full_text => 'MPD: not running',
41 # Output the line as JSON.
42 print encode_json(\@blocks) . ",\n";