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.


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:


/usr/bin/i3status -c $HOME/.i3status.conf | while :
    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

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

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.

  • Be aware that this solution leads to quite the PID waste, as every tick (as configured via the interval option of i3status) creates a new process for every executable called in the wrapper. Also RAM info can be displayed natively via i3status (see memory). Also why the awk/sed hassle for uptime when you can just call uptime -p? Further compiling the cpu app on every tick seems rather insane, especially since i3status provide a built-in for CPU usage (see CPU usage) – Marius K. Oct 28 '19 at 8:20

My solution:

make script in cron.hourly to create formated /tmp/uptime in every one hour (I don't need more precision than one hour) and use in i3status with readfile:

read_file uptime {
        path = "/tmp/uptime"


awk '{printf("Up %dd:%02d\n",($1/60/60/24),($1/60/60%24),($1/60%60),($1%60))}' /proc/uptime > /tmp/uptime

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.