A very simple alternative to i3status, written and configured entirely in Python
Switch branches/tags
Nothing to show
Clone or download
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
my3status Cache block texts Feb 6, 2018
screenshots Update screenshot Oct 8, 2017
.gitignore Add an optional block for audio volume Oct 22, 2017
LICENSE Initial commit Oct 4, 2017
README.md Change the example block code to be asynchronous Apr 5, 2018
setup.py Add support for asynchronous block updates Jan 25, 2018

README.md

my3status

my3status is a very simple alternative to i3status. It is written and configured entirely in Python.

As the name suggests, this is my i3status. I will probably not accept any feature requests, but feel free to submit bug fixes.

Installation and configuration

The installation process consists of a few simple steps.

  • Clone this repository
  • Run pip install --user --upgrade .[volume,net]
  • Copy the example python script below and customize it to your liking
  • Call the script from your i3 config
#!/usr/bin/env python3

from my3status.bar import Bar
from my3status.block import *

def main():
    Bar([
        DiskBlock("ROOT", "/", separator=False),
        DiskBlock("HOME", "/home"),
        MemBlock(separator=False),
        SwapBlock(),
        NetBlock(separator=False),
        NetIOBlock(align="right"),
        CPUBlock(),
        DateTimeBlock()
    ]).run()

if __name__ == "__main__":
    main()

Writing a custom block

Eventhough my3status wasn't written with widespread use in mind, it is pretty extensible. Here's a simple block that obtains and displays your public IP address.

from my3status.block import Block
import my3status.util as util

import aiohttp
import async_timeout

class IPBlock(Block):
    def __init__(self, interval=60, **kwargs):
        super().__init__("IP", interval=interval, **kwargs)

    async def update(self):
        try:
            with async_timeout.timeout(5):
                async with aiohttp.ClientSession() as session:
                    async with session.get("https://icanhazip.com") as res:
                        text = await res.text()
                        value = text.rstrip('\n')
        except:
            value = ""
        return self.set_value(value)

    def get_text(self):
        if self._value == "":
            return util.pango_color("ERROR", util.colors["red"])
        return self._value

Obviously, you shouldn't send a request to icanhazip.com every 60 seconds, but you get the idea.