Skip to main content

An external xmobar plugin for customizable weather info!

Project description

xmobar_wttr is a command-line program which fetches weather info from wttr.in and applies direct formatting to be used by xmobar. Different from already available plugins, it can easily be configured to use any kind of combination of numbers, icons, and colors. It implements a custom syntax with which a single line in the xmobar_wttr.yml configuration file translates to an xmobar field entry.

In the commands list of your xmobarrc, add something along the lines of

Run Com "xmobar_wttr" ["-c", "~/.config/xmobar/xmobar_wttr.yml"] "wttr" 9000

Prerequisites

This program mainly uses following python3 modules

  • requests
  • pyyaml

Furthermore, the program uses weather icons from https://github.com/erikflowers/weather-icons. Install them directly from the website, using an AUR helper such as

yay -S ttf-weather-icons

or by other means.

Install

pip install xmobar-wttr

For installing from source, clone the repository, and run

cd xmobar_wttr
python setup.py install --user

or create a virtual environment with

pipenv install
pipenv install -e .

To activate the virtual environment run

pipenv shell

or start every command with pipenv run.

Usage

usage: xmobar_wttr [-h] [-c <path>] [-l <loc>] [-f <format>] [-o <path>] [-s <section>] [-p <par-list> [<par-list> ...]] [-v]

optional arguments:
  -h, --help            show this help message and exit
  -c <path>, --config <path>
			Path to the config file
  -l <loc>, --location <loc>
			Location for which to pull information.
  -f <format>, --format <format>
			Format template for xmobarrc
  -o <path>, --output <path>
			Path to the output file
  -s <section>, --section <section>
			Section in the yaml file to be parsed
  -p <par-list> [<par-list> ...], --pars <par-list> [<par-list> ...]
			Select parameters to be fetched from wttr.in
			excluded parameters are not available in xmobar template format
  -v, --verbose         Run program in verbose mode

Configuration

xmobar_wttr works with both command-line arguments as well as YAML configuration files (the first takes precedence over the latter). To set your desired defaults edit the configuration file xmobar_wttr.yml and place it in either

  • ~/.config/xmobar_wttr/xmobar_wttr.yml
  • ~/.config/xmobar/xmobar_wttr.yml
  • ~/.xmobar_wttr/xmobar_wttr.yml
  • ~/.xmobar_wttr.yml

Notation

  • Fields are separated by %.
  • Each field should have a parameter entry prefixed by an exclamation mark !, e.g. !h.
  • Units can be placed using .u
  • Fonts can be selected using <N:...> where N is the xmobar font index, e.g. <2:weather condition> formats to <fn=2>weather condition</fn>
  • Analogously colors can be used using {#dedede:...}.
Notation *Description
%[!par] parameter value
%g[!par] render parameter only as icon
%G[!par] prefix icon to parameter value
.u append units of previous parameter
Format map Result
<2:…> <fn=2>…</fn>
{#dedede:…} <fc=#dedede>…</fc>
\… \x…

Example:

'%g!x %!t(%!f)<1: >.u {#46d9ff:%G}<1: >!h' could format to something like <fn=6></fn> 3(1)<fn=1> </fn>°C <fc=#46d9ff><fn=6></fn></fc><fn=1> </fn>81 and renders in xmobar as

img

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

xmobar_wttr-0.1a0.tar.gz (24.9 kB view details)

Uploaded Source

Built Distribution

xmobar_wttr-0.1a0-py3.10.egg (25.4 kB view details)

Uploaded Source

File details

Details for the file xmobar_wttr-0.1a0.tar.gz.

File metadata

  • Download URL: xmobar_wttr-0.1a0.tar.gz
  • Upload date:
  • Size: 24.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.8.0 pkginfo/1.8.2 readme-renderer/32.0 requests/2.27.1 requests-toolbelt/0.9.1 urllib3/1.26.9 tqdm/4.62.3 importlib-metadata/4.8.1 keyring/23.5.0 rfc3986/2.0.0 colorama/0.4.4 CPython/3.10.2

File hashes

Hashes for xmobar_wttr-0.1a0.tar.gz
Algorithm Hash digest
SHA256 a5f070f9e2ee8b53b5939818d2a0b9cbff19a83114a926f16badb0b5ffdc44d2
MD5 38ddf6323bd75e4dc5d8a9573b390f08
BLAKE2b-256 846b2f83cb08fda117d552abadeff5e7c02d4dac7b95a204ddf56415ecefe583

See more details on using hashes here.

File details

Details for the file xmobar_wttr-0.1a0-py3.10.egg.

File metadata

  • Download URL: xmobar_wttr-0.1a0-py3.10.egg
  • Upload date:
  • Size: 25.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.8.0 pkginfo/1.8.2 readme-renderer/32.0 requests/2.27.1 requests-toolbelt/0.9.1 urllib3/1.26.9 tqdm/4.62.3 importlib-metadata/4.8.1 keyring/23.5.0 rfc3986/2.0.0 colorama/0.4.4 CPython/3.10.2

File hashes

Hashes for xmobar_wttr-0.1a0-py3.10.egg
Algorithm Hash digest
SHA256 31f02e7ed8d92559b91d448789839db2a1fb3f138aac61e3f82a0154a87c61d9
MD5 fb350a097613d1abc369d45b37867236
BLAKE2b-256 1812bb9f4917f5c4f47722d91650d7fe5456ad633e599b40b81c3c437b107466

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page