2

I would like to display uptime in common units (so not just in minutes if it is over an hour; also not just in seconds if it is over a minute; e.g., "1:02:30" for 1 hour, 2 minutes and 30 seconds would be my ideal time format) in my i3status bar. I have not even been able to find how to show uptime in the i3status bar in any units. I found this repo on GitHub that seemed to claim to do this but copying these configs gave me errors related to difficulty executing the status_command line in this repo's config. Namely the status_command line is:

status_command ~/.i3/i3status.sh ~/.i3/i3status.conf

guessing it only works with an older version of i3. Any ideas how to do this? here is my present ~/.i3status.conf file. My distribution is Gentoo Linux.

3

I have found the solution. I simply did not understand its syntax well enough. I just had to edit my ~/.i3/i3status.sh file. It is now:

#!/bin/sh

/usr/bin/i3status -c $HOME/.i3status.conf | while :
do
    read line
    RAM=`free -kh | grep Mem | awk '{print $3}'`
    TOTR=$(cat /proc/meminfo | grep MemT | sed 's/.*\://g' | sed 's/ *//g' | sed 's/kB//g')
    TOT=$(octave --eval "$TOTR/1024^2" | sed 's/ans = *//g' | sed 's/$/G/g' )

    # Put uptime
    uptime=`uptime | awk '{print $3 " " $4}' | sed 's/,.*//'`
    hour=$(echo $uptime | sed 's/\:.*//g')
    min=$(echo $uptime | sed 's/.*\://g')
    UP="$hour h $min m"

    # Compile C++ CPU prog and run it
    g++ -o cpu.o $HOME/.i3/cpu.cpp
    CPU=$(./cpu.o)

    printf "%s\n" "Up: $UP | CPU: $CPU% | RAM: $RAM/$TOT | $line"
done

The most relevant lines to uptime are between # Put uptime and # Compile C++... and the final printf "%s\n"... command. My complete i3 configuration files can be found in this repository.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.