GithubHelp home page GithubHelp logo

thiagokokada / i3pyblocks Goto Github PK

View Code? Open in Web Editor NEW
19.0 2.0 2.0 702 KB

A replacement for i3status, written in Python using asyncio.

License: MIT License

Makefile 0.72% Nix 1.15% Python 98.13%
i3status python3 asyncio i3wm python swaywm

i3pyblocks's Introduction

i3pyblocks

PyPI version Test Lint Documentation Status Codecov

Screenshot

A replacement for i3status, written in Python using asyncio.

Works in both i3wm and sway.

For Python 3.7+.

Installation and Usage

Look at the example.py file for inspiration and check the User guide section of documentation.

Development

To setup a development environment, create a new venv first and run:

make dev-install

To run the tests, you may run:

make test

Look at the included Makefile for more available commands.

If you're using NixOS or nixpkgs, an alternative way to get a working environment variable is using the shell.nix file included in this repo:

nix-shell shell-dev.nix

For more information, look at Creating a new block section of documentation.

Contributing

Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.

Please make sure to update tests as appropriate.

License

MIT

i3pyblocks's People

Contributors

larsley avatar thiagokokada avatar ttrei avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

i3pyblocks's Issues

Add way to register default_state at Runner.register_block call

This would make easier to make customizations, something like:

runner = core.Runner(default_state={"background": "#00FF00"})
await runner.register_block(SomeBlock())
await runner.register_block(SomeOtherBlock(default_state={"background": "#FFFFFF"})) # this wouldn't be affected

aionotify not compatible with Python 3.11

I am running Python 3.11.3 on Arch Linux. Your example config i3pyblocks/example.py fails to run because aionotify doesn't work with 3.11.

See:

This references another bug report:

Which contains a link to a fork of aionotify which does support 3.11:

The changes required to aionotify are quite small.

I am a beginner when it comes to Python so not sure how you would handle this. But hopefully this helps.

Improve i3pyblocks.types.Dictable

i3pyblocks.types.Dictable is very useful, but for now it is kind limited since it is always result in a Dict from Any to Any.

Would be nice to allow Dictable to be more precise, for example:

foo: Dictable[str, bool] = {1: null}  # Error

Publish first release

If we can automatize the release process, it is better.

Some things to keep in mind:

  • Generate the package automatically and publish to https://pypi.org
  • Generate the version automatically and write to i3pyblocks.__version__

Make NetworkSpeedBlock more smart

  • Give preference of the current interface instead of switching to another one
  • Allow switching between interfaces if more than one interface is active (but remember first rule)

abnormal memory and CPU usage

Sometimes i3pyblocks takes several GB of RAM or 100% CPU.
Does it happen also to other users?
@thiagokokada, could you help me to debug the problem -- for example how to access logging information?
I have some widgets that i wrote myself, so the problem might be also there.

Create an entrypoint

This project needs to have an entrypoint, a simple command-line interface that accepts a config file and runs it.

The reason for it is to be more user friendly and allows us to package it on a NixOS buildPythonApplication. In special match-nix:

let
  mach-nix = import (builtins.fetchGit {
    url = "https://github.com/DavHau/mach-nix/";
    ref = "refs/tags/2.3.0";
  });
in
mach-nix.buildPythonApplication {
  src = "https://github.com/thiagokokada/i3pyblocks/tarball/master";
  extras = "aionotify,i3ipc,psutil,pulsectl";

  propagatedBuildInputs = [
    libffi
    libpulseaudio
  ];

  nativeBuildInputs = [ makeWrapper ]; # wrapper binary here
}

Add PollingExecutorBlock

This is a combination of PollingBlock and ExecutorBlock (not necessary it will use multiple inheritance, while Python supports this it can be messy), allowing completely synchronous libraries to be integrated with i3pyblocks using a polling strategy.

We can convert i3pyblocks.blocks.x11.CaffeineBlock as an example of this block.

Convert path usage to use pathlib instead

Most APIs that works with paths in i3pyblocks are using strings. Since the whole API of i3pyblocks are typed this seems like a waste when we could use typed paths instead, and also pathlib makes the manipulation of paths much easier.

So convert all path usage to use pathlib instead.

Create MediaPlayerBlock using a MPRIS2 library

I think it might be beneficial to rewrite the MediaPlayerBlock based on a MPRIS2 library to more easily add features to it.

Features I have in mind are:

  • everything that is possible already
  • automatically selecting an instance, when one is not explicitly given
  • automatically selecting a player when one is not explicitly given (which makes it possible to have just one block for all players)
  • Adding a short_text_format
  • controlling the player through click events:
    • play/pause
    • next media
    • cycle through eligible players
    • toggling between normal text or always short text
  • an option to make the block disappear from the bar when no player is

Create BatteryBlock using FileWatcherBlock

There is already a SensorsBatteryBlock, but it is based on PollingBlock. Instead, let's reimplement it using sysfs interface (https://www.kernel.org/doc/Documentation/ABI/testing/sysfs-class-power) and FileWatcherBlock (based on aionotify).

Some posts in StackOverflow on how to calculate the remaining time:
https://stackoverflow.com/questions/26888636/how-to-calculate-the-time-remaining-until-the-end-of-the-battery-charge
https://stackoverflow.com/questions/35516424/calculate-time-left-until-battery-is-discharged

(They're probably not precise, but I don't think the current battery calculations from psutil are different from this).

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.