Coder Social home page Coder Social logo

covsum's Introduction

COVID-19 CLI Summarizer

This is a little script I wrote for myself to track COVID-19 in a taskbar widget. There are 2 parts: a covsum script and a location handler.

$ covsum
  World: 1,095,917 confirmed, 58,787 deaths

$ covsum -e
  World: 1,095,917 ๐Ÿ“ˆ 58,787 ๐Ÿ’€

$ covsum Italy Germany
  Italy: 119,827 confirmed, 14,681 deaths | Germany: 91,159 confirmed, 1,275 deaths

$ covsum -f confirmed,recovered
  World: 1,095,917 confirmed, 225,796 recovered

$ covsum --help
  COVID-19 Summarizer

  Usage: covsum [OPTIONS] [COUNTRY] [COUNTRY (...)]

  Examples:

      covsum

      covsum -e US world

      covsum "united kingdom" -f active,recovered,deaths,confirmed

      covsum Italy Germany Spain

      covsum -C | fzf | xargs covsum

  Country names are space separated and case insensitive. Wrap multi-word
  names in quotes. For global data either use 'world' or leave blank.

  Fields may be any combination of 'confirmed', 'recovered', 'deaths',
  or 'active'. Note that  the API only returns confirmed, recovered, and
  deaths; 'active' is calculated by subtracting 'recovered' and 'deaths'
  from the confirmed count.

  Data is saved in ~/.cache/coronavirus_data.json, and will be updated if
  more than 6 hours old. Force an update now with the -U flag.

  Options:
      -h, --help
      -e, --emojis
      -f, --fields [Fields]            Comma separated, no spaces
      -U, --update                     Force Download
      -C, --countries

It uses this api, and caches data for 6 hours.

covsum-location-handler

This isn't a general purpose tool, it's a starting point for you to adapt. Its purpose is to cycle through a list of interesting locations, which is useful because it lets you do this: covsum $(covsum-location-handler)

The increment and decrement operations also send a signal to waybar, which I have configured to reload the module.

Note that there's no configuration here. To change the list of locations, you need to edit the script itself.

$ covsum-location-handler
World

$ covsum-location-handler -i
US

$ covsum-location-handler -i
Poland

$ covsum-location-handler -i
World

$ covsum-location-handler -i
US

$ covsum-location-handler
US

$ covsum-location-handler -d
World

$ covsum-location-handler --help
covsum location handler
    -h, --help                       Print Help
    -i, --increment                  Increment Location
    -d, --decrement                  Decrement Location
  • Select a location from a hard-coded list. Run with no arguments to see currently selected location.
  • Increment and decrement that location (call these on click & scroll events).
  • Send waybar a signal to update the widget

Dependencies

  • Ruby >= 2.5

Installation

Both scripts are self contained.

  • Download/clone
  • You may have to chmod +x
  • Check that $ /bin/ruby --version >= 2.5
  • If applicable, modify the location handler for your use case.
  • Run

Integration

Here's my waybar module:

{
  "custom/covsum": {
    "exec": "~/development/covsum/covsum -e $(~/development/covsum/covsum-location-handler)",
    "interval": 600,
    "on-click": "~/development/covsum/covsum-location-handler --increment",
    "on-right-click": "~/development/covsum/covsum-location-handler --decrement",
    "signal": 8,
    "tooltip": false
  }
}

Others will be similar, I'm sure you can figure it out.

License

Do whatever you want.

covsum's People

Contributors

rbuchberger avatar

Watchers

 avatar  avatar

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.