Common segments¶
VCS submodule¶
-
powerline.segments.common.vcs.
branch
(ignore_statuses=(), status_colors=False)¶ Return the current VCS branch.
Parameters: - status_colors (bool) – Determines whether repository status will be used to determine highlighting. Default: False.
- ignore_statuses (bool) – List of statuses which will not result in repo being marked as dirty. Most
useful is setting this option to
["U"]
: this will ignore repository which has just untracked files (i.e. repository with modified, deleted or removed files will be marked as dirty, while just untracked files will make segment show clean repository). Only applicable ifstatus_colors
option is True.
Highlight groups used:
branch_clean
,branch_dirty
,branch
.
System properties¶
-
powerline.segments.common.sys.
cpu_load_percent
(interval=1, format=u'{0:.0f}%', shutdown_event=None, update_first=True)¶ Return the average CPU load as a percentage.
Requires the
psutil
module.Parameters: format (str) – Output format. Accepts measured CPU load as the first argument. Highlight groups used:
cpu_load_percent_gradient
(gradient) orcpu_load_percent
.
-
powerline.segments.common.sys.
system_load
(short=False, track_cpu_count=False, threshold_bad=2, threshold_good=1, format=u'{avg:.1f}')[source]¶ Return system load average.
Highlights using
system_load_good
,system_load_bad
andsystem_load_ugly
highlighting groups, depending on the thresholds passed to the function.Parameters: - format (str) – format string, receives
avg
as an argument - threshold_good (float) – threshold for gradient level 0: any normalized load average below this value will have this gradient level.
- threshold_bad (float) – threshold for gradient level 100: any normalized load average above this
value will have this gradient level. Load averages between
threshold_good
andthreshold_bad
receive gradient level that indicates relative position in this interval: (100 * (cur-good) / (bad-good)
). Note: both parameters are checked against normalized load averages. - track_cpu_count (bool) – if True powerline will continuously poll the system to detect changes in the number of CPUs.
- short (bool) – if True only the sys load over last 1 minute will be displayed.
Divider highlight group used:
background:divider
.Highlight groups used:
system_load_gradient
(gradient) orsystem_load
.- format (str) – format string, receives
-
powerline.segments.common.sys.
uptime
(shorten_len=3, seconds_format=u' {seconds:d}s', minutes_format=u' {minutes:d}m', hours_format=u' {hours:d}h', days_format=u'{days:d}d')[source]¶ Return system uptime.
Parameters: - days_format (str) – day format string, will be passed
days
as the argument - hours_format (str) – hour format string, will be passed
hours
as the argument - minutes_format (str) – minute format string, will be passed
minutes
as the argument - seconds_format (str) – second format string, will be passed
seconds
as the argument - shorten_len (int) – shorten the amount of units (days, hours, etc.) displayed
Divider highlight group used:
background:divider
.- days_format (str) – day format string, will be passed
Network¶
-
powerline.segments.common.net.
external_ip
(interval=300, query_url=u'http://ipv4.icanhazip.com/')¶ Return external IP address.
Parameters: query_url (str) – URI to query for IP address, should return only the IP address as a text string
Suggested URIs:
- http://ipv4.icanhazip.com/
- http://ipv6.icanhazip.com/
- http://icanhazip.com/ (returns IPv6 address if available, else IPv4)
Divider highlight group used:
background:divider
.
-
powerline.segments.common.net.
hostname
(exclude_domain=False, only_if_ssh=False)[source]¶ Return the current hostname.
Parameters: - only_if_ssh (bool) – only return the hostname if currently in an SSH session
- exclude_domain (bool) – return the hostname without domain if there is one
-
powerline.segments.common.net.
internal_ip
(ipv=4, interface=u'auto')[source]¶ Return internal IP address
Requires
netifaces
module to work properly.Parameters: - interface (str) –
Interface on which IP will be checked. Use
auto
to automatically detect interface. In this case interfaces with lower numbers will be preferred over interfaces with similar names. Order of preference based on names:eth
andenp
followed by number or the end of string.ath
,wlan
andwlp
followed by number or the end of string.teredo
followed by number or the end of string.- Any other interface that is not
lo*
. lo
followed by number or the end of string.
Use
default_gateway
to detect the interface based on the machine’s default gateway (i.e., the router to which it is connected). - ipv (int) – 4 or 6 for ipv4 and ipv6 respectively, depending on which IP address you need exactly.
- interface (str) –
-
powerline.segments.common.net.
network_load
(interval=1, after_update=False, key=None, shutdown_event=None, update_first=True, interface=u'auto', si_prefix=False, suffix=u'B/s', sent_format=u'UL {value:>8}', recv_format=u'DL {value:>8}')¶ Return the network load.
Uses the
psutil
module if available for multi-platform compatibility, falls back to reading/sys/class/net/interface/statistics/rx,tx_bytes
.Parameters: - interface (str) – Network interface to measure (use the special value “auto” to have powerline try to auto-detect the network interface).
- suffix (str) – String appended to each load string.
- si_prefix (bool) – Use SI prefix, e.g. MB instead of MiB.
- recv_format (str) – Format string that determines how download speed should look like. Receives
value
as argument. - sent_format (str) – Format string that determines how upload speed should look like. Receives
value
as argument. - recv_max (float) – Maximum number of received bytes per second. Is only used to compute gradient level.
- sent_max (float) – Maximum number of sent bytes per second. Is only used to compute gradient level.
Divider highlight group used:
network_load:divider
.Highlight groups used:
network_load_sent_gradient
(gradient) ornetwork_load_recv_gradient
(gradient) ornetwork_load_gradient
(gradient),network_load_sent
ornetwork_load_recv
ornetwork_load
.
Current environment¶
-
powerline.segments.common.env.
cwd
(ellipsis=u'...', use_path_separator=False, dir_limit_depth=None, dir_shorten_len=None, shorten_home=True)¶ Return the current working directory.
Returns a segment list to create a breadcrumb-like effect.
Parameters: - dir_shorten_len (int) – shorten parent directory names to this length (e.g.
/long/path/to/powerline
→/l/p/t/powerline
) - dir_limit_depth (int) – limit directory depth to this number (e.g.
/long/path/to/powerline
→⋯/to/powerline
) - use_path_separator (bool) – Use path separator in place of soft divider.
- shorten_home (bool) – Shorten home directory to
~
. - ellipsis (str) – Specifies what to use in place of omitted directories. Use None to not show this subsegment at all.
Divider highlight group used:
cwd:divider
.Highlight groups used:
cwd:current_folder
orcwd
. It is recommended to define all highlight groups.- dir_shorten_len (int) – shorten parent directory names to this length (e.g.
-
powerline.segments.common.env.
environment
(variable=None)[source]¶ Return the value of any defined environment variable
Parameters: variable (string) – The environment variable to return if found
-
powerline.segments.common.env.
user
(hide_domain=False, hide_user=None)[source]¶ Return the current user.
Parameters: - hide_user (str) – Omit showing segment for users with names equal to this string.
- hide_domain (bool) – Drop domain component if it exists in a username (delimited by ‘@’).
Highlights the user with the
superuser
if the effective user ID is 0.Highlight groups used:
superuser
oruser
. It is recommended to define all highlight groups.
-
powerline.segments.common.env.
virtualenv
(ignore_conda=False, ignore_venv=False)[source]¶ Return the name of the current Python or conda virtualenv.
Parameters: - ignore_venv (bool) – Whether to ignore virtual environments. Default is False.
- ignore_conda (bool) – Whether to ignore conda environments. Default is False.
Battery¶
-
powerline.segments.common.bat.
battery
(offline=u' ', online=u'C', empty_heart=u'O', full_heart=u'O', gamify=False, steps=5, format=u'{ac_state} {capacity:3.0%}')[source]¶ Return battery charge status.
Parameters: - format (str) – Percent format in case gamify is False. Format arguments:
ac_state
which is equal to eitheronline
oroffline
string arguments andcapacity
which is equal to current battery capacity in interval [0, 100]. - steps (int) – Number of discrete steps to show between 0% and 100% capacity if gamify is True.
- gamify (bool) – Measure in hearts (♥) instead of percentages. For full hearts
battery_full
highlighting group is preferred, for empty hearts there isbattery_empty
.battery_online
orbattery_offline
group will be used for leading segment containingonline
oroffline
argument contents. - full_heart (str) – Heart displayed for “full” part of battery.
- empty_heart (str) – Heart displayed for “used” part of battery. It is also displayed using another gradient level and highlighting group, so it is OK for it to be the same as full_heart as long as necessary highlighting groups are defined.
- online (str) – Symbol used if computer is connected to a power supply.
- offline (str) – Symbol used if computer is not connected to a power supply.
battery_gradient
andbattery
groups are used in any case, first is preferred.Highlight groups used:
battery_full
orbattery_gradient
(gradient) orbattery
,battery_empty
orbattery_gradient
(gradient) orbattery
,battery_online
orbattery_ac_state
orbattery_gradient
(gradient) orbattery
,battery_offline
orbattery_ac_state
orbattery_gradient
(gradient) orbattery
.- format (str) – Percent format in case gamify is False. Format arguments:
Weather¶
-
powerline.segments.common.wthr.
weather
(interval=600, after_update=False, key=None, shutdown_event=None, update_first=True, location_query=None, temp_hottest=40, temp_coldest=-30, temp_format=None, unit=u'C', icons=None)¶ Return weather from Yahoo! Weather.
Uses GeoIP lookup from http://freegeoip.net/ to automatically determine your current location. This should be changed if you’re in a VPN or if your IP address is registered at another location.
Returns a list of colorized icon and temperature segments depending on weather conditions.
Parameters: - unit (str) – temperature unit, can be one of
F
,C
orK
- location_query (str) – location query for your current location, e.g.
oslo, norway
- icons (dict) – dict for overriding default icons, e.g.
{'heavy_snow' : u'❆'}
- temp_format (str) – format string, receives
temp
as an argument. Should also hold unit. - temp_coldest (float) – coldest temperature. Any temperature below it will have gradient level equal to zero.
- temp_hottest (float) – hottest temperature. Any temperature above it will have gradient level equal
to 100. Temperatures between
temp_coldest
andtemp_hottest
receive gradient level that indicates relative position in this interval (100 * (cur-coldest) / (hottest-coldest)
).
Divider highlight group used:
background:divider
.Highlight groups used:
weather_conditions
orweather
,weather_temp_gradient
(gradient) orweather
. Also usesweather_conditions_{condition}
for all weather conditions supported by Yahoo.- unit (str) – temperature unit, can be one of
Date and time¶
-
powerline.segments.common.time.
date
(istime=False, format=u'%Y-%m-%d')[source]¶ Return the current date.
Parameters: - format (str) – strftime-style date format string
- istime (bool) – If true then segment uses
time
highlight group.
Divider highlight group used:
time:divider
.Highlight groups used:
time
ordate
.
Mail¶
-
powerline.segments.common.mail.
email_imap_alert
(username, password, interval=60, after_update=False, key=None, shutdown_event=None, update_first=True, use_ssl=None, folder=u'INBOX', port=993, server=u'imap.gmail.com', max_msgs=None)¶ Return unread e-mail count for IMAP servers.
Parameters: - username (str) – login username
- password (str) – login password
- server (str) – e-mail server
- port (int) – e-mail server port
- folder (str) – folder to check for e-mails
- max_msgs (int) – Maximum number of messages. If there are more messages then max_msgs then it
will use gradient level equal to 100, otherwise gradient level is equal to
100 * msgs_num / max_msgs
. If not present gradient is not computed. - use_ssl (bool) – If
True
then use SSL connection. IfFalse
then do not use it. Default isTrue
if port is equal to 993 andFalse
otherwise.
Highlight groups used:
email_alert_gradient
(gradient),email_alert
.
Media players¶
-
powerline.segments.common.players.
clementine
(state_symbols={u'fallback': u'', u'pause': u'~', u'stop': u'X', u'play': u'>'}, format=u'{state_symbol} {artist} - {title} ({total})')¶ Return clementine player information
Requires
dbus
python module.This player segment should be added like this:
{ "function": "powerline.segments.common.players.clementine", "name": "player" }
(with additional
"args": {…}
if needed).Highlight groups used:
player_fallback
orplayer
,player_play
orplayer
,player_pause
orplayer
,player_stop
orplayer
.Parameters: - format (str) –
Format used for displaying data from player. Should be a str.format-like string with the following keyword parameters:
Parameter Description state_symbol Symbol displayed for play/pause/stop states. There is also “fallback” state used in case function failed to get player state. For this state symbol is by default empty. All symbols are defined in state_symbols
argument.album Album that is currently played. artist Artist whose song is currently played title Currently played composition. elapsed Composition duration in format M:SS (minutes:seconds). total Composition length in format M:SS. - state_symbols (dict) –
Symbols used for displaying state. Must contain all of the following keys:
Key Description play Displayed when player is playing. pause Displayed when player is paused. stop Displayed when player is not playing anything. fallback Displayed if state is not one of the above or not known.
- format (str) –
-
powerline.segments.common.players.
cmus
(state_symbols={u'fallback': u'', u'pause': u'~', u'stop': u'X', u'play': u'>'}, format=u'{state_symbol} {artist} - {title} ({total})')¶ Return CMUS player information
Requires cmus-remote command be acessible from $PATH.
This player segment should be added like this:
{ "function": "powerline.segments.common.players.cmus", "name": "player" }
(with additional
"args": {…}
if needed).Highlight groups used:
player_fallback
orplayer
,player_play
orplayer
,player_pause
orplayer
,player_stop
orplayer
.Parameters: - format (str) –
Format used for displaying data from player. Should be a str.format-like string with the following keyword parameters:
Parameter Description state_symbol Symbol displayed for play/pause/stop states. There is also “fallback” state used in case function failed to get player state. For this state symbol is by default empty. All symbols are defined in state_symbols
argument.album Album that is currently played. artist Artist whose song is currently played title Currently played composition. elapsed Composition duration in format M:SS (minutes:seconds). total Composition length in format M:SS. - state_symbols (dict) –
Symbols used for displaying state. Must contain all of the following keys:
Key Description play Displayed when player is playing. pause Displayed when player is paused. stop Displayed when player is not playing anything. fallback Displayed if state is not one of the above or not known.
- format (str) –
-
powerline.segments.common.players.
dbus_player
(player_name, state_symbols={u'fallback': u'', u'pause': u'~', u'stop': u'X', u'play': u'>'}, format=u'{state_symbol} {artist} - {title} ({total})')¶ Return generic dbus player state
- Requires
dbus
python module. Only for players that support specific protocol - (e.g. like
spotify()
andclementine()
).
This player segment should be added like this:
{ "function": "powerline.segments.common.players.dbus_player", "name": "player" }
(with additional
"args": {…}
if needed).Highlight groups used:
player_fallback
orplayer
,player_play
orplayer
,player_pause
orplayer
,player_stop
orplayer
.Parameters: - format (str) –
Format used for displaying data from player. Should be a str.format-like string with the following keyword parameters:
Parameter Description state_symbol Symbol displayed for play/pause/stop states. There is also “fallback” state used in case function failed to get player state. For this state symbol is by default empty. All symbols are defined in state_symbols
argument.album Album that is currently played. artist Artist whose song is currently played title Currently played composition. elapsed Composition duration in format M:SS (minutes:seconds). total Composition length in format M:SS. - state_symbols (dict) –
Symbols used for displaying state. Must contain all of the following keys:
Key Description play Displayed when player is playing. pause Displayed when player is paused. stop Displayed when player is not playing anything. fallback Displayed if state is not one of the above or not known. - player_name (str) – Player name. Used in error messages only.
- bus_name (str) – Dbus bus name.
- player_path (str) – Path to the player on the given bus.
- iface_prop (str) – Interface properties name for use with dbus.Interface.
- iface_player (str) – Player name.
- Requires
-
powerline.segments.common.players.
mpd
(state_symbols={u'fallback': u'', u'pause': u'~', u'stop': u'X', u'play': u'>'}, format=u'{state_symbol} {artist} - {title} ({total})', port=6600, password=None, host=u'localhost')¶ Return Music Player Daemon information
Requires
mpd
Python module (e.g.python-mpd2
orpython-mpd
Python package) or alternatively thempc
command to be acessible from $PATH.This player segment should be added like this:
{ "function": "powerline.segments.common.players.mpd", "name": "player" }
(with additional
"args": {…}
if needed).Highlight groups used:
player_fallback
orplayer
,player_play
orplayer
,player_pause
orplayer
,player_stop
orplayer
.Parameters: - format (str) –
Format used for displaying data from player. Should be a str.format-like string with the following keyword parameters:
Parameter Description state_symbol Symbol displayed for play/pause/stop states. There is also “fallback” state used in case function failed to get player state. For this state symbol is by default empty. All symbols are defined in state_symbols
argument.album Album that is currently played. artist Artist whose song is currently played title Currently played composition. elapsed Composition duration in format M:SS (minutes:seconds). total Composition length in format M:SS. - state_symbols (dict) –
Symbols used for displaying state. Must contain all of the following keys:
Key Description play Displayed when player is playing. pause Displayed when player is paused. stop Displayed when player is not playing anything. fallback Displayed if state is not one of the above or not known. - host (str) – Host on which mpd runs.
- password (str) – Password used for connecting to daemon.
- port (int) – Port which should be connected to.
- format (str) –
-
powerline.segments.common.players.
rdio
(state_symbols={u'fallback': u'', u'pause': u'~', u'stop': u'X', u'play': u'>'}, format=u'{state_symbol} {artist} - {title} ({total})')¶ Return rdio player information
Requires
osascript
available in $PATH.This player segment should be added like this:
{ "function": "powerline.segments.common.players.rdio", "name": "player" }
(with additional
"args": {…}
if needed).Highlight groups used:
player_fallback
orplayer
,player_play
orplayer
,player_pause
orplayer
,player_stop
orplayer
.Parameters: - format (str) –
Format used for displaying data from player. Should be a str.format-like string with the following keyword parameters:
Parameter Description state_symbol Symbol displayed for play/pause/stop states. There is also “fallback” state used in case function failed to get player state. For this state symbol is by default empty. All symbols are defined in state_symbols
argument.album Album that is currently played. artist Artist whose song is currently played title Currently played composition. elapsed Composition duration in format M:SS (minutes:seconds). total Composition length in format M:SS. - state_symbols (dict) –
Symbols used for displaying state. Must contain all of the following keys:
Key Description play Displayed when player is playing. pause Displayed when player is paused. stop Displayed when player is not playing anything. fallback Displayed if state is not one of the above or not known.
- format (str) –
-
powerline.segments.common.players.
rhythmbox
(state_symbols={u'fallback': u'', u'pause': u'~', u'stop': u'X', u'play': u'>'}, format=u'{state_symbol} {artist} - {title} ({total})')¶ Return rhythmbox player information
Requires
rhythmbox-client
available in $PATH.This player segment should be added like this:
{ "function": "powerline.segments.common.players.rhythmbox", "name": "player" }
(with additional
"args": {…}
if needed).Highlight groups used:
player_fallback
orplayer
,player_play
orplayer
,player_pause
orplayer
,player_stop
orplayer
.Parameters: - format (str) –
Format used for displaying data from player. Should be a str.format-like string with the following keyword parameters:
Parameter Description state_symbol Symbol displayed for play/pause/stop states. There is also “fallback” state used in case function failed to get player state. For this state symbol is by default empty. All symbols are defined in state_symbols
argument.album Album that is currently played. artist Artist whose song is currently played title Currently played composition. elapsed Composition duration in format M:SS (minutes:seconds). total Composition length in format M:SS. - state_symbols (dict) –
Symbols used for displaying state. Must contain all of the following keys:
Key Description play Displayed when player is playing. pause Displayed when player is paused. stop Displayed when player is not playing anything. fallback Displayed if state is not one of the above or not known.
- format (str) –
-
powerline.segments.common.players.
spotify
(state_symbols={u'fallback': u'', u'pause': u'~', u'stop': u'X', u'play': u'>'}, format=u'{state_symbol} {artist} - {title} ({total})')¶ Return spotify player information
Requires
dbus
python module.This player segment should be added like this:
{ "function": "powerline.segments.common.players.spotify", "name": "player" }
(with additional
"args": {…}
if needed).Highlight groups used:
player_fallback
orplayer
,player_play
orplayer
,player_pause
orplayer
,player_stop
orplayer
.Parameters: - format (str) –
Format used for displaying data from player. Should be a str.format-like string with the following keyword parameters:
Parameter Description state_symbol Symbol displayed for play/pause/stop states. There is also “fallback” state used in case function failed to get player state. For this state symbol is by default empty. All symbols are defined in state_symbols
argument.album Album that is currently played. artist Artist whose song is currently played title Currently played composition. elapsed Composition duration in format M:SS (minutes:seconds). total Composition length in format M:SS. - state_symbols (dict) –
Symbols used for displaying state. Must contain all of the following keys:
Key Description play Displayed when player is playing. pause Displayed when player is paused. stop Displayed when player is not playing anything. fallback Displayed if state is not one of the above or not known.
- format (str) –
-
powerline.segments.common.players.
spotify_apple_script
(state_symbols={u'fallback': u'', u'pause': u'~', u'stop': u'X', u'play': u'>'}, format=u'{state_symbol} {artist} - {title} ({total})')¶ Return spotify player information
Requires
osascript
available in $PATH.This player segment should be added like this:
{ "function": "powerline.segments.common.players.spotify_apple_script", "name": "player" }
(with additional
"args": {…}
if needed).Highlight groups used:
player_fallback
orplayer
,player_play
orplayer
,player_pause
orplayer
,player_stop
orplayer
.Parameters: - format (str) –
Format used for displaying data from player. Should be a str.format-like string with the following keyword parameters:
Parameter Description state_symbol Symbol displayed for play/pause/stop states. There is also “fallback” state used in case function failed to get player state. For this state symbol is by default empty. All symbols are defined in state_symbols
argument.album Album that is currently played. artist Artist whose song is currently played title Currently played composition. elapsed Composition duration in format M:SS (minutes:seconds). total Composition length in format M:SS. - state_symbols (dict) –
Symbols used for displaying state. Must contain all of the following keys:
Key Description play Displayed when player is playing. pause Displayed when player is paused. stop Displayed when player is not playing anything. fallback Displayed if state is not one of the above or not known.
- format (str) –
-
powerline.segments.common.players.
spotify_dbus
(state_symbols={u'fallback': u'', u'pause': u'~', u'stop': u'X', u'play': u'>'}, format=u'{state_symbol} {artist} - {title} ({total})')¶ Return spotify player information
Requires
dbus
python module.This player segment should be added like this:
{ "function": "powerline.segments.common.players.spotify", "name": "player" }
(with additional
"args": {…}
if needed).Highlight groups used:
player_fallback
orplayer
,player_play
orplayer
,player_pause
orplayer
,player_stop
orplayer
.Parameters: - format (str) –
Format used for displaying data from player. Should be a str.format-like string with the following keyword parameters:
Parameter Description state_symbol Symbol displayed for play/pause/stop states. There is also “fallback” state used in case function failed to get player state. For this state symbol is by default empty. All symbols are defined in state_symbols
argument.album Album that is currently played. artist Artist whose song is currently played title Currently played composition. elapsed Composition duration in format M:SS (minutes:seconds). total Composition length in format M:SS. - state_symbols (dict) –
Symbols used for displaying state. Must contain all of the following keys:
Key Description play Displayed when player is playing. pause Displayed when player is paused. stop Displayed when player is not playing anything. fallback Displayed if state is not one of the above or not known.
- format (str) –