core Package¶
core
Package¶
-
class
i3pystatus.core.
CommandEndpoint
(modules, io_handler_factory)[source]¶ Bases:
object
Endpoint for i3bar click events: http://i3wm.org/docs/i3bar-protocol.html#_click_events
Parameters: - modules – dict-like object with item access semantics via .get()
- io_handler_factory – function creating a file-like object returning a JSON generator on .read()
-
class
i3pystatus.core.
Status
(standalone=False, interval=1, input_stream=<_io.TextIOWrapper name='<stdin>' mode='r' encoding='ANSI_X3.4-1968'>, click_events=True)[source]¶ Bases:
object
The main class used for registering modules and managing I/O
Parameters: - standalone – Whether i3pystatus should read i3status-compatible input from input_stream
- interval – Update interval in seconds
- input_stream – A file-like object that provides the input stream, if standalone is False.
- click_events – Enable click events
desktop
Module¶
-
class
i3pystatus.core.desktop.
BaseDesktopNotification
(title, body, icon='dialog-information', urgency=1, timeout=0)[source]¶ Bases:
object
Class to display a desktop notification
Parameters: - title – Title of the notification
- body – Body text of the notification, depending on the users system configuration HTML may be used, but is not recommended
- icon – A XDG icon name, see http://standards.freedesktop.org/icon-naming-spec/icon-naming-spec-latest.html
- urgency – A value between 1 and 3 with 1 meaning low urgency and 3 high urgency.
- timeout – Timeout in seconds for the notification. Zero means it needs to be dismissed by the user.
-
class
i3pystatus.core.desktop.
DesktopNotification
(title, body, icon='dialog-information', urgency=1, timeout=0)[source]¶ Bases:
i3pystatus.core.desktop.DesktopNotification
-
URGENCY_LUT
= (<Mock name='mock.Notify.Urgency.LOW' id='140474217644944'>, <Mock name='mock.Notify.Urgency.NORMAL' id='140474217645112'>, <Mock name='mock.Notify.Urgency.CRITICAL' id='140474217645000'>)¶
-
exceptions
Module¶
-
exception
i3pystatus.core.exceptions.
ConfigError
(module, *args, **kwargs)[source]¶ Bases:
Exception
ABC for configuration exceptions
-
exception
i3pystatus.core.exceptions.
ConfigKeyError
(module, *args, **kwargs)[source]¶ Bases:
i3pystatus.core.exceptions.ConfigError
,KeyError
imputil
Module¶
io
Module¶
-
class
i3pystatus.core.io.
IOHandler
(inp=<_io.TextIOWrapper name='<stdin>' mode='r' encoding='ANSI_X3.4-1968'>, out=<_io.TextIOWrapper name='<stdout>' mode='w' encoding='ANSI_X3.4-1968'>)[source]¶ Bases:
object
-
class
i3pystatus.core.io.
StandaloneIO
(click_events, interval=1)[source]¶ Bases:
i3pystatus.core.io.IOHandler
I/O handler for standalone usage of i3pystatus (w/o i3status)
Writing works as usual, but reading will always return a empty JSON array, and the i3bar protocol header
-
n
= -1¶
-
proto
= [{'click_events': True, 'version': 1}, '[', '[]', ',[]']¶
-
modules
Module¶
-
class
i3pystatus.core.modules.
IntervalModule
(*args, **kwargs)[source]¶ Bases:
i3pystatus.core.modules.Module
-
interval
= 5¶
-
managers
= {}¶
-
run
()[source]¶ Called approximately every self.interval seconds
Do not rely on this being called from the same thread at all times. If you need to always have the same thread context, subclass AsyncModule.
-
settings
= ('interval',)¶
-
-
class
i3pystatus.core.modules.
IntervalModuleMeta
(name, bases, namespace)[source]¶ Bases:
type
Add interval setting to settings attribute if it does not exist.
-
class
i3pystatus.core.modules.
Module
(*args, **kwargs)[source]¶ Bases:
i3pystatus.core.settings.SettingsBase
-
output
= None¶
-
position
= 0¶
-
settings
Module¶
-
class
i3pystatus.core.settings.
SettingsBase
(*args, **kwargs)[source]¶ Bases:
object
Support class for providing a nice and flexible settings interface
Classes inherit from this class and define what settings they provide and which are required.
The constructor is either passed a dictionary containing these settings, or keyword arguments specifying the same.
Settings are stored as attributes of self.
-
init
()[source]¶ Convenience method which is called after all settings are set
In case you don’t want to type that super()…blabla :-)
-
required
= ()¶ required can list settings which are required
-
settings
= ()¶ settings should be tuple containing two types of elements:
- bare strings, which must be valid Python identifiers.
- two-tuples, the first element being a identifier (as above) and the second a docstring for the particular setting
-
threading
Module¶
-
class
i3pystatus.core.threading.
Thread
(target_interval, workloads=None, start_barrier=1)[source]¶ Bases:
threading.Thread
-
time
¶
-
-
class
i3pystatus.core.threading.
WorkloadWrapper
(workload)[source]¶ Bases:
i3pystatus.core.threading.Wrapper
-
time
= 0.0¶
-
util
Module¶
-
class
i3pystatus.core.util.
KeyConstraintDict
(valid_keys, required_keys)[source]¶ Bases:
collections.UserDict
A dict implementation with sets of valid and required keys
Parameters: - valid_keys – Set of valid keys
- required_keys – Set of required keys, must be a subset of valid_keys
-
class
i3pystatus.core.util.
ModuleList
(status_handler, class_finder)[source]¶ Bases:
collections.UserList
-
class
i3pystatus.core.util.
TimeWrapper
(seconds, default_format='%m:%S')[source]¶ Bases:
object
A wrapper that implements __format__ and __bool__ for time differences and time spans.
Parameters: - seconds – seconds (numeric)
- default_format – the default format to be used if no explicit format_spec is passed to __format__
Format string syntax:
- %h, %m and %s are the hours, minutes and seconds without leading zeros (i.e. 0 to 59 for minutes and seconds)
- %H, %M and %S are padded with a leading zero to two digits, i.e. 00 to 59
- %l and %L produce hours non-padded and padded but only if hours is not zero. If the hours are zero it produces an empty string.
- %% produces a literal %
- %E (only valid on beginning of the string) if the time is null, don’t format anything but rather produce an empty string. If the time is non-null it is removed from the string.
The formatted string is stripped, i.e. spaces on both ends of the result are removed
-
class
TimeTemplate
(template)[source]¶ Bases:
string.Template
-
delimiter
= '%'¶
-
idpattern
= '[a-zA-Z]'¶
-
pattern
= re.compile('\n \\%(?:\n (?P<escaped>\\%) | # Escape sequence of two delimiters\n (?P<named>[a-zA-Z]) | # delimiter and a Python identifier\n {(?P<braced>[a-zA-Z])} | # delimiter an, re.IGNORECASE|re.VERBOSE)¶
-
-
i3pystatus.core.util.
flatten
(l)[source]¶ Flattens a hierarchy of nested lists into a single list containing all elements in order
Parameters: l – list of arbitrary types and lists Returns: list of arbitrary types
-
i3pystatus.core.util.
formatp
(string, **kwargs)[source]¶ Function for advanced format strings with partial formatting
This function consumes format strings with groups enclosed in brackets. A group enclosed in brackets will only become part of the result if all fields inside the group evaluate True in boolean contexts.
Groups can be nested. The fields in a nested group do not count as fields in the enclosing group, i.e. the enclosing group will evaluate to an empty string even if a nested group would be eligible for formatting. Nesting is thus equivalent to a logical or of all enclosing groups with the enclosed group.
Escaped brackets, i.e. \[ and \] are copied verbatim to output.
Parameters: - string – Format string
- kwargs – keyword arguments providing data for the format string
Returns: Formatted string
-
i3pystatus.core.util.
internet
()[source]¶ Checks for a internet connection by connecting to a Google DNS server.
Returns: True if internet connection is available
-
i3pystatus.core.util.
lchop
(string, prefix)[source]¶ Removes a prefix from string
Parameters: - string – String, possibly prefixed with prefix
- prefix – Prefix to remove from string
Returns: string without the prefix
-
i3pystatus.core.util.
make_bar
(percentage)[source]¶ Draws a bar made of unicode box characters.
Parameters: percentage – A value between 0 and 100 Returns: Bar as a string
-
i3pystatus.core.util.
make_graph
(values, upper_limit=100.0)[source]¶ Draws a graph made of unicode characters.
Parameters: - values – An array of values to graph.
- upper_limit – Maximum value for the y axis.
Returns: Bar as a string
-
i3pystatus.core.util.
make_vertical_bar
(percentage, width=1)[source]¶ Draws a vertical bar made of unicode characters.
Parameters: - value – A value between 0 and 100
- width – How many characters wide the bar should be.
Returns: Bar as a String
-
i3pystatus.core.util.
popwhile
(predicate, iterable)[source]¶ Generator function yielding items of iterable while predicate holds for each item
Parameters: - predicate – function taking an item returning bool
- iterable – iterable
Returns: iterable (generator function)
-
i3pystatus.core.util.
require
(predicate)[source]¶ Decorator factory for methods requiring a predicate. If the predicate is not fulfilled during a method call, the method call is skipped and None is returned.
Parameters: predicate – A callable returning a truth value Returns: Method decorator See also
-
i3pystatus.core.util.
round_dict
(dic, places)[source]¶ Rounds all values in a dict containing only numeric types to places decimal places. If places is None, round to INT.
-
i3pystatus.core.util.
user_open
(url_or_command)[source]¶ Open the specified paramater in the web browser if a URL is detected, othewrise pass the paramater to the shell as a subprocess. This function is inteded to bu used in on_leftclick()/on_rightclick() events.
Parameters: url_or_command – String containing URL or command
color
Module¶
-
class
i3pystatus.core.color.
ColorRangeModule
[source]¶ Bases:
object
Class to dynamically generate and select colors.
Requires the PyPI package colour
-
end_color
= 'red'¶
-
get_gradient
(value, colors, upper_limit=100)[source]¶ Map a value to a color :param value: Some value :return: A Hex color code
-
static
get_hex_color_range
(start_color, end_color, quantity)[source]¶ Generates a list of quantity Hex colors from start_color to end_color.
Parameters: - start_color – Hex or plain English color for start of range
- end_color – Hex or plain English color for end of range
- quantity – Number of colours to return
Returns: A list of Hex color values
-
start_color
= '#00FF00'¶
-