The i3 FAQ has migrated to https://github.com/i3/i3/discussions. All content here is read-only.
Ask Your Question
0

Custom status_command text update

asked 2012-08-11 21:07:20 +0000

ShadowPrince gravatar image

I have an interest to write own status command, replacement to i3status. Program make the text, dedode it to json and print. Text shows on i3bar, but not update.

Tried to print json in while-cycle with delay - text not shows al all. Tried all with simple text - similar.

Writing in python. Cant't use i3status sources becose bad in C, sorry.

edit retag flag offensive close merge delete

2 answers

Sort by » oldest newest most voted
1

answered 2012-08-21 13:14:25 +0000

Michael gravatar image

Sorry, I must have missed your question, or I’d have replied earlier.

Please read this document to understand how to send JSON to i3bar: http://i3wm.org/docs/i3bar-protocol.html (pay attention to the header part: unless you are using a recent git "next" version, you need to send it exactly as {"version":1}).

It also contains a link to a simple shell script (for illustrational purposes only!) which demonstrates how to put an (updating) clock into i3bar: http://code.stapelberg.de/git/i3/tree...

Since you are using python, there also is a wrapper script which reads i3status’s JSON and adds the current CPU governor: http://code.stapelberg.de/git/i3statu...

In case these resources don’t help, please post your code so we can tell you what’s wrong. Without the code, we can’t do anything.

edit flag offensive delete link more
0

answered 2013-04-18 11:19:28 +0000

Privan gravatar image

I made something very simple and hacky. However, I think it is efficient and sufficient. I've been using it instead of i3status or conky.

#!/bin/sh

echo '{ "version": 1 }'

echo '['

echo '[],'

readonly PRE='{ "full_text": "'
readonly COL='", "color": "'
readonly CER='" }'

KERNELV=$PRE"K: $(uname -sr)"$COL'#bbaacc'$CER

i=5

while :
do

if [ "$i" -eq "5" ]; then 
BATERIA=$PRE"B: $(acpi -b | awk '{print $NF}')"$COL'#ccbbaa'$CER
DISK=$PRE"D: $(df -h | awk '/sda1/ {print $5 " ("$4" Disp.)" }')"$COL'#ccaabb'$CER
UPTIME=$PRE"🕐: $(awk  '{printf "%.2f", $0/3600;}' /proc/uptime)h"$COL'#ccaabb'$CER
let i=0
fi

let i="$i+1"
CALOR=$PRE"T: $(acpi -t | awk '{print $(NF-2)}')°C"$COL'#ccbbaa'$CER

LOAD=$PRE"L: $(cat /proc/loadavg)"$COL'#ccbbaa'$CER
VOL=$PRE"♪: $(pactl list sinks | awk '/Volume: 0:/{print $NF}')"$COL'#bbccaa'$CER
FECHA=$PRE"$(date +'%A,%_d %B %Y  %H:%M:%S')"$COL'#aaccbb'$CER

echo "[$KERNELV,$UPTIME,$CALOR,$BATERIA,$LOAD,$DISK,$VOL,$FECHA]," || exit 1
sleep 5s;
done
edit flag offensive delete link more

Question Tools

Stats

Asked: 2012-08-11 21:07:20 +0000

Seen: 2,252 times

Last updated: Apr 18 '13