i3pyblocks.blocks.ps
Blocks related to process and system information, based on psutil.
This is a collection of many Blocks based on psutil, a cross-platform
library for retrieving information on running processes and system utilization
(CPU, memory, disks, network, sensors) in Python.
Blocks in this module show information about your running system, including
useful information i.e.: how many memory is in currently use
(VirtualMemoryBlock) or the current speed of the connected Ethernet/Wi-Fi
interface (NetworkSpeedBlock).
All Blocks in this module are based on PollingBlock since this kinda of
measurement only makes sense over time (i.e.: memory is always changing so we
can’t just update when memory usage increase/decrease or we would use too much
resources for it).
Module Contents
Classes
Block that shows the current CPU percentage. |
|
Block that shows the current disk usage for path. |
|
Block that shows the current load average, in the last 1, 5 or 15 minutes. |
|
Block that shows the current network speed for the connect interface. |
|
Block that shows battery information. |
|
Block that shows sensor temperature information. |
|
Block that shows virtual memory information. |
- class i3pyblocks.blocks.ps.CpuPercentBlock(format: str = 'C: {percent}%', colors: i3pyblocks._internal.models.Threshold = {0: types.Color.NEUTRAL, 75: types.Color.WARN, 90: types.Color.URGENT}, backgrounds: i3pyblocks._internal.models.Threshold = {}, icons: i3pyblocks._internal.models.Threshold = {0.0: '▁', 12.5: '▂', 25.0: '▃', 37.5: '▄', 50.0: '▅', 62.5: '▆', 75.0: '▇', 87.5: '█'}, sleep: int = 5, **kwargs)
Bases:
i3pyblocks.blocks.PollingBlockBlock that shows the current CPU percentage.
- Parameters
format – Format string to shown. Supports both
{percent}and{icon}placeholders.colors –
A mapping that represents the color that will be shown in each CPU interval. For example:
{ 0: "000000", 10: "#FF0000", 50: "#FFFFFF", }
When the CPU % is between [0, 10) the color is set to “000000”, from [10, 50) is set to “FF0000” and from 50 and beyond it is “#FFFFFF”.
backgrounds – Similar to
colors, but for the background.icons – Similar to
colors, but for icons. Can be used to create a graphic representation of the CPU %. Only displayed whenformatincludes{icon}placeholder.sleep – Sleep in seconds between each call to
run().**kwargs – Extra arguments to be passed to
PollingBlockclass.
- async run(self) None
Main loop in PollingBlock.
This is the method that will be run at each X
sleepseconds.Since this is an abstract method, it should be overriden before usage.
- class i3pyblocks.blocks.ps.DiskUsageBlock(path: Union[pathlib.Path, str] = '/', format: str = '{path}: {free:.1f}GiB', colors: i3pyblocks._internal.models.Threshold = {0: types.Color.NEUTRAL, 75: types.Color.WARN, 90: types.Color.URGENT}, backgrounds: i3pyblocks._internal.models.Threshold = {}, icons: i3pyblocks._internal.models.Threshold = {0.0: '▁', 12.5: '▂', 25.0: '▃', 37.5: '▄', 50.0: '▅', 62.5: '▆', 75.0: '▇', 87.5: '█'}, divisor: int = types.IECUnit.GiB, sleep: int = 5, **kwargs)
Bases:
i3pyblocks.blocks.PollingBlockBlock that shows the current disk usage for path.
- Parameters
path – Path to the disk to shown.
format –
Format string to shown. Supports the following placeholders:
{path}: Disk path, for example:/mnt/backup{short_path}: Disk path, but only show the first letter of each directory, for example:/m/b{total}: Disk total size{used}: Disk used size{free}: Disk free size{percent}: Disk usage in percentage{icon}: Show disk usage percentage in icon representation
colors –
A mapping that represents the color that will be shown in each disk usage in percentage interval. For example:
{ 0: "000000", 10: "#FF0000", 50: "#FFFFFF", }
When the disk % is between [0, 10) the color is set to “000000”, from [10, 50) is set to “FF0000” and from 50 and beyond it is “#FFFFFF”.
backgrounds – Similar to
colors, but for the background.icons – Similar to
colors, but for icons. Can be used to create a graphic representation of the disk %. Only displayed whenformatincludes{icon}placeholder.divisor – Divisor used for all size reportings for this Block. For example, using
1024 ** 1024here makes all sizes return in MiB.sleep – Sleep in seconds between each call to
run().**kwargs – Extra arguments to be passed to
PollingBlockclass.
- async run(self) None
Main loop in PollingBlock.
This is the method that will be run at each X
sleepseconds.Since this is an abstract method, it should be overriden before usage.
- class i3pyblocks.blocks.ps.LoadAvgBlock(format: str = 'L: {load1}', colors: i3pyblocks._internal.models.Threshold = {0: types.Color.NEUTRAL, 2: types.Color.WARN, 4: types.Color.URGENT}, backgrounds: i3pyblocks._internal.models.Threshold = {}, sleep: int = 5, **kwargs)
Bases:
i3pyblocks.blocks.PollingBlockBlock that shows the current load average, in the last 1, 5 or 15 minutes.
- Parameters
format – Format string to shown. Supports the
{load1},{load5}and{load15}placeholders.colors –
A mapping that represents the color that will be shown in each load1 interval. For example:
{ 0: "000000", 2: "#FF0000", 4: "#FFFFFF", }
When the load1 is between [0, 2) the color is set to “000000”, from [2, 4) is set to “FF0000” and from 4 and beyond it is “#FFFFFF”.
backgrounds – Similar to
colors, but for the background.sleep – Sleep in seconds between each call to
run().**kwargs – Extra arguments to be passed to
PollingBlockclass.
- async run(self) None
Main loop in PollingBlock.
This is the method that will be run at each X
sleepseconds.Since this is an abstract method, it should be overriden before usage.
- class i3pyblocks.blocks.ps.NetworkSpeedBlock(format_up: str = '{interface}: U {upload} D {download}', format_down: str = 'No network', colors: i3pyblocks._internal.models.Threshold = {0: types.Color.NEUTRAL, 2 * types.IECUnit.MiB: types.Color.WARN, 5 * types.IECUnit.MiB: types.Color.URGENT}, backgrounds: i3pyblocks._internal.models.Threshold = {}, interface_regex: str = 'en*|eth*|ppp*|sl*|wl*|ww*', sleep: int = 3, **kwargs)
Bases:
i3pyblocks.blocks.PollingBlockBlock that shows the current network speed for the connect interface.
- Parameters
format_up –
Format string to shown when there is at least one connected interface. Supports the following placeholders:
{interface}: Interface name, for example:eno1{upload}: Upload speed{download}: Download speed
Since upload/download speeds varies greatly during usage, this module automatically finds the most compact speed representation. So instead of showing
1500Kit will show1.5M, for example.format_down – Format string to shown when there is no connected interface.
colors –
A mapping that represents the color that will be shown in each load1 interval. For example:
{ 0: "000000", 2 * types.IECUnit.MIB: "#FF0000", 4 * types.IECUnit.MIB: "#FFFFFF", }
When the network speed is between [0, 2) MiB the color is set to “000000”, from [2, 4) is set to “FF0000” and from 4 and beyond it is “#FFFFFF”.
backgrounds – Similar to
colors, but for the background.interface_regex – Regex for which interfaces to use. By default it already includes the most common ones and excludes things like
lo(loopback interface).sleep – Sleep in seconds between each call to
run().**kwargs – Extra arguments to be passed to
PollingBlockclass.
- async run(self) None
Main loop in PollingBlock.
This is the method that will be run at each X
sleepseconds.Since this is an abstract method, it should be overriden before usage.
- class i3pyblocks.blocks.ps.SensorsBatteryBlock(format_plugged: str = 'B: PLUGGED {percent:.0f}%', format_unplugged: str = 'B: {icon} {percent:.0f}% {remaining_time}', format_unknown: str = 'B: {icon} {percent:.0f}%', format_no_battery: str = 'No battery', colors: i3pyblocks._internal.models.Threshold = {0: types.Color.URGENT, 10: types.Color.WARN, 25: types.Color.NEUTRAL}, backgrounds: i3pyblocks._internal.models.Threshold = {}, icons: i3pyblocks._internal.models.Threshold = {0.0: '▁', 12.5: '▂', 25.0: '▃', 37.5: '▄', 50.0: '▅', 62.5: '▆', 75.0: '▇', 87.5: '█'}, sleep: int = 5, **kwargs)
Bases:
i3pyblocks.blocks.PollingBlockBlock that shows battery information.
- Parameters
format_plugged –
Format string to shown when the battery is plugged (charging). support the following placeholders:
{percent}: battery capacity in percentage{remaining_time}: battery remaining time{icon}: show battery capacity percentage in icon representation
format_unplugged – Format string to shown when the battery is unplugged (discharging). Supports the same placeholders as
format_unplugged.format_unknown – Format string to shown when the battery is an unknown state. Supports the same placeholders as
format_unplugged.format_no_battery – Format string to shown when no battery is detected.
colors –
A mapping that represents the color that will be shown in each battery percentage interval. For example:
{ 0: "000000", 10: "#FF0000", 25: "#FFFFFF", }
When the battery percentage is between [0, 10) % the color is set to “000000”, from [10, 25) is set to “FF0000” and from 25 and beyond it is “#FFFFFF”.
backgrounds – Similar to
colors, but for the background.icons – Similar to
colors, but for icons. Can be used to create a graphic representation of the battery %. Only displayed whenformatincludes{icon}placeholder.sleep – Sleep in seconds between each call to
run().**kwargs – Extra arguments to be passed to
PollingBlockclass.
- async run(self)
Main loop in PollingBlock.
This is the method that will be run at each X
sleepseconds.Since this is an abstract method, it should be overriden before usage.
- class i3pyblocks.blocks.ps.SensorsTemperaturesBlock(format: str = 'T: {current:.0f}°C', format_no_sensor: str = 'No sensor', colors: i3pyblocks._internal.models.Threshold = {0: types.Color.NEUTRAL, 60: types.Color.WARN, 85: types.Color.URGENT}, backgrounds: i3pyblocks._internal.models.Threshold = {}, icons: i3pyblocks._internal.models.Threshold = {0.0: '▁', 12.5: '▂', 25.0: '▃', 37.5: '▄', 50.0: '▅', 62.5: '▆', 75.0: '▇', 87.5: '█'}, fahrenheit: bool = False, sensor_regex: str = '.*', sensor_index: int = 0, sleep: int = 5, **kwargs)
Bases:
i3pyblocks.blocks.PollingBlockBlock that shows sensor temperature information.
- Parameters
format –
Format string to shown. Support the following placeholders:
{label}: Label of the sensor. Architecture specific{current}: Current temperature reported by sensor{high}: Highest temperature reported by sensor{critical}: Critical temperature reported by sensor{icon}: Show sensor temperature in icon representation
colors –
A mapping that represents the color that will be shown in each temperature interval. For example:
{ 0: "000000", 50: "#FF0000", 80: "#FFFFFF", }
When the sensor temperature is between [0, 50) % the color is set to “000000”, from [50, 80) is set to “FF0000” and from 80 and beyond it is “#FFFFFF”.
backgrounds – Similar to
colors, but for the background.icons – Similar to
colors, but for icons. Can be used to create a graphic representation of the temperature. Only displayed whenformatincludes{icon}placeholder.fahrenheit – Show temperature in in Fahrenheit instead of Celsius.
sensor_regex – Regex to be used by search the sensor name. If it matches more than one, the first one will be picked.
sensor_index – Sensor index that should be used. Most sensors have more than one sensor (for example, one for each CPU), so this setting allow you to pick each one you want.
sleep – Sleep in seconds between each call to
run().**kwargs – Extra arguments to be passed to
PollingBlockclass.
- async run(self) None
Main loop in PollingBlock.
This is the method that will be run at each X
sleepseconds.Since this is an abstract method, it should be overriden before usage.
- class i3pyblocks.blocks.ps.VirtualMemoryBlock(format: str = 'M: {available:.1f}GiB', colors: i3pyblocks._internal.models.Threshold = {0: types.Color.NEUTRAL, 75: types.Color.WARN, 90: types.Color.URGENT}, backgrounds: i3pyblocks._internal.models.Threshold = {}, icons: i3pyblocks._internal.models.Threshold = {0.0: '▁', 12.5: '▂', 25.0: '▃', 37.5: '▄', 50.0: '▅', 62.5: '▆', 75.0: '▇', 87.5: '█'}, divisor: int = types.IECUnit.GiB, sleep: int = 3, **kwargs)
Bases:
i3pyblocks.blocks.PollingBlockBlock that shows virtual memory information.
- Parameters
format –
Format string to shown. Support the following placeholders:
{total}: Total installed memory{available}: Available memory{used}: Used memory{free}: Free memory{percent}: Percent used memory{icon}: Show memory percent in icon representation
colors –
A mapping that represents the color that will be shown in each used memory percentage. For example:
{ 0: "000000", 50: "#FF0000", 80: "#FFFFFF", }
When the used memory % is between [0, 50) % the color is set to “000000”, from [50, 80) is set to “FF0000” and from 80 and beyond it is “#FFFFFF”.
backgrounds – Similar to
colors, but for the background.divisor – Divisor used for all size reportings for this Block. For example, using
1024 ** 1024here makes all sizes return in MiB.icons – Similar to
colors, but for icons. Can be used to create a graphic representation of the used memory. Only displayed whenformatincludes{icon}placeholder.sleep – Sleep in seconds between each call to
run().**kwargs – Extra arguments to be passed to
PollingBlockclass.
- async run(self) None
Main loop in PollingBlock.
This is the method that will be run at each X
sleepseconds.Since this is an abstract method, it should be overriden before usage.