in the wiki I found the option to create your own custom blocks and also control the state and icons with JSON like this
[[block]]
block = "custom"
command = "echo '{\"icon\":\"weather_thunder\",\"state\":\"Critical\", \"text\": \"Danger!\"}'"
json = true
Now if I want to output the json with a script e.g.
#!/usr/bin/env bash
echo '{\"icon\":\"weather_thunder\",\"state\":\"Critical\", \"text\": \"Danger!\"}'
and the toml respectively
[[block]]
block = "custom"
command = "bash scr"
json = true
will result in
Error in block 'custom': Error parsing JSON: EOF while parsing a value at line 1 column 0
How do I parse the JSON correctly?
EDIT:
Without json nothing is being displayed either e.g.
#!/usr/bin/env bash
printf 'test'
#or printf 'test\n' or echo whatever
No error here however no output either.
SOLUTION:
Well apparently I just had to give an absolute path to the script.
I don't use bash but the below works for me:
>./target/debug/i3status-rs testjson.toml master|22ms|19:58:37
{"version": 1, "click_events": true}
[[{"background":"#000000","color":"#a9a9a9","full_text":"| ","markup":"pango","separator":false,"separator_block_width":0},{"background":"#000000","color":"#b58900","full_text":"AUR 2 ","markup":"pango","name":"42045349bb524fc482931165fb83c5c7","separator":false,"separator_block_width":0},{"background":"#000000","color":"#a9a9a9","full_text":"| ","markup":"pango","separator":false,"separator_block_width":0},{"background":"#000000FF","color":"#DC322FFF","full_text":" STORM Danger! ","markup":"pango","name":"dacfbf39918c495ab9b93597e2c2c951","separator":false,"separator_block_width":0}],
^Cโ
[[block]]
block = "custom"
command = "fish --command testjson"
json = true
[[block]]
block = "custom"
command = "echo '{\"icon\":\"weather_thunder\",\"state\":\"Critical\", \"text\": \"Danger!\"}'"
json = true
function testjson
set val (pikaur --query --sysupgrade --aur 2>/dev/null | wc --lines)
if test $val -eq 0
echo "{\"state\": \"Idle\", \"text\": \"AUR $val\"}"
else
echo "{\"state\": \"Warning\", \"text\": \"AUR $val\"}"
end
end
SOLUTION:
Well apparently I just had to give an absolute path to the script.
Ah I see. I'll see if I can improve the error message so that it's more obvious why it's failing.
SOLUTION:
Well apparently I just had to give an absolute path to the script.Ah I see. I'll see if I can improve the error message so that it's more obvious why it's failing.
Why can't I use relative paths btw? The script im calling in the example is located in the same directory.
Probably because the shell invoked by i3status-rust has a different working directory to wherever it is that you have stored your script.