Skip to content

alexbakker/my3status

master
Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Code

Latest commit

 

Git stats

Files

Permalink
Failed to load latest commit information.
Type
Name
Latest commit message
Commit time
 
 
 
 
 
 
 
 
 
 
 
 

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.

About

A very simple alternative to i3status, written and configured entirely in Python

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages