Fabricators are special classes that can grab you info from external shell commands or internal Python functions. Fabricators can also read streams of data like a shell command that stays running or a Python generator function.
Fabricators give you some important options during initalization, including:
The initial value the fabricator should be initialized with
Where to poll the data from, whether it is a Python function/generator or a shell command
The poll frequency: how often you want the fabricator to poll the function or command in milliseconds
Whether you want data as a stream (for polling data from generators and stream shell commands)
So, let’s look at some examples of using fabricators!
Media Player State
This example utilizes a fabricator to read a stream from an external command (playerctl -f status) and print the current media status when it changes.
Periodic Date Updates
in this example, we use a fabricator to poll data from the shell command date every 500ms and print the output of it.
Advanced Polling
In this example we fabricate a function instead of a shell command, and demonstrate how to use a stopping condition.