Skip to content

e1mo/waybar-iceportal

Repository files navigation

waybar-iceportal

A simple waybar module to display the status of the ICE you are currently in using the ICE Portals JSON API.

Installation

  1. Ensure python1 is installed: python3 --version
  2. Clone the git repository to a location of your choosing: git clone https://github.com/e1mo/waybar-iceportal.git
  3. Install the python dependencies: pip install -r requirements.txt
  4. Add the snippet below to your waybar configuration (usually ~/.config/waybar/config)
  5. Reload your waybar (either restart your WM such as sway or just run waybar)
    "modules-right": [
      // Your other modules
      "custom/iceportal-wifi"
    ]
    // Simply append at the bottom
    "custom/iceportal-wifi": {
        "interval": 15,
        "return-type": "json",
        "exec": "path/to/waybar-iceportal/waybar-iceportal", // Append --login if you want to auto-login into the Wifi
        "tooltip": true,
    },

For further information on custom waybar modules, refer to the waybar wiki on custom modules.

Developing / testing

The script has a couple of parameters to help with developing / debugging outside of ICEs or on those with broken WiFi. They can be shown using --help. As of writing this, the output looks like this:

$ ./waybar-iceportal --help

usage: waybar-iceportal [-h] [--dummy-data DUMMY_DATA] [--dump [DUMP]] [--skip-wifi]
                        [--extra-wifi EXTRA_WIFI [EXTRA_WIFI ...]] [--login]

Waybar module for the ICE Portal (Train Info, Stops, WiFi Status). Nothing will be displayed if the
iceportal is not reachable (e.G. you are not in an ICE or the WiFi is down)

options:
  -h, --help            show this help message and exit
  --dummy-data DUMMY_DATA
                        Folder to load dummy data from. {status,trip}.json must be present.
  --dump [DUMP]         Dump trip / status json to a subfolder within the specified folder. If no value
                        is specified, will create a folder 'data-dump' besides the script.
  --skip-wifi           Skip checking if connected to WIFI@DB or WIFIonICE
  --extra-wifi EXTRA_WIFI [EXTRA_WIFI ...]
                        SSIDs that should also be considered as being in an ICE (case sensitive)
  --login               Automatically log in to WiFi

Using the --dummy-data option, previously saved data (e.g. from --dump) will be used instead of fetching new data. For convenience, there is a dump included in this repository under data/2021-08-31-12-02-55-ice1601.

To aid with debugging (since I unfortunately don't have a BC100 :/ ) you can dump the data by passing --dump. Either a option can be specified, otherwise the data will be written to a timestamped folder, located in the data-dump located next to the script, so it will look like this: data-dump/2021-08-31-22-24-35.

Outlook

Whats next? Well, I don't know. Overall it's done I think, but some minor improovments could be made.

  • Display the WiFi status directly in the waybar
    • Either by passing a class to change the background color using styles
    • Or using emojis, but there are no reception unicocdes
  • Add different output modes
    • Simple text output for debugging
    • i3blocks style output
  • Maybe even porting this to be a gnome extension? (But I don't think this is going to happen)

Footnotes

  1. I have only tested this script in Python 3.9, but it should work on older versions.

About

A simple waybar module to display the status of the ICE you are currently in using the ICE Portals JSON API.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published