i3 / i3status

Generates status bar to use with i3bar, dzen2 or xmobar
BSD 3-Clause "New" or "Revised" License
602 stars 254 forks source link

Nicely format uptime #469

Closed 10maurycy10 closed 2 years ago

10maurycy10 commented 2 years ago

read-file allows displaying uptime in seconds.

Is it possible to display uptime in nicer units?

orestisfl commented 2 years ago

The uptime in my system allows this:

$ uptime --pretty
up 4 hours, 36 minutes
10maurycy10 commented 2 years ago

The uptime in my system allows this:

$ uptime --pretty
up 4 hours, 36 minutes

calling a command in the status is rather inefficient.

I can also not find a clean way to integrate with uptime in i3status.

For now I have forked the repo.

orestisfl commented 2 years ago

The intent of the read_file directive is to run arbitrary commands. Complete example:

i3status config:

order += "read_file uptime"

read_file uptime {
    path = "/tmp/uptime"
}

And, somewhere else, start a script that will continuously update /tmp/uptime. For example:

while true; do uptime --pretty > /tmp/uptime; sleep 1; done
10maurycy10 commented 2 years ago

constant disk writes, seem inefficient.

orestisfl commented 2 years ago

/tmp is usually an in-memory tmpfs.

Besides, it's a few bytes (<100) per second. Comparatively nothing to using a modern browser.

Either way, feel free to maintain the fork if you'd prefer :)