Common segments

powerline.segments.common.battery(empty_heart=u'\u2665', full_heart=u'\u2665', gamify=False, steps=5, format=u'{capacity:3.0%}')[source]

Return battery charge status.

Parameters:
  • format (str) – Percent format in case gamify is False.
  • 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.
  • 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, so it is OK for it to be the same as full_heart.

Highlight groups used: battery_gradient (gradient), battery.

powerline.segments.common.branch(status_colors=False)[source]

Return the current VCS branch.

Parameters:status_colors (bool) – determines whether repository status will be used to determine highlighting. Default: False.

Highlight groups used: branch_clean, branch_dirty, branch.

powerline.segments.common.cpu_load_percent(interval=1, update_first=True, format=u'{0:.0f}%', shutdown_event=None)

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) or cpu_load_percent.

powerline.segments.common.cwd(ellipsis=u'\u22ef', use_path_separator=False, dir_limit_depth=None, dir_shorten_len=None)[source]

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.
  • 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 or cwd. It is recommended to define all highlight groups.

powerline.segments.common.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 or date.

powerline.segments.common.email_imap_alert(username, password, interval=60, update_first=True, after_update=False, key=None, shutdown_event=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.

Highlight groups used: email_alert_gradient (gradient), email_alert.

powerline.segments.common.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.external_ip(interval=300, update_first=True, 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:

Divider highlight group used: background:divider.

powerline.segments.common.fuzzy_time(unicode_text=True)[source]

Display the current time as fuzzy time, e.g. “quarter past six”.

Parameters:unicode_text (bool) – If true then hyphenminuses (regular ASCII -) and single quotes are replaced with unicode dashes and apostrophes.
powerline.segments.common.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.network_load(interval=1, update_first=True, after_update=False, key=None, shutdown_event=None, interface=u'detect', si_prefix=False, suffix=u'B/s', sent_format=u'\u2b06 {value:>8}', recv_format=u'\u2b07 {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 “detect” 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, receives value as argument
  • sent_format (str) – format string, 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: background:divider.

Highlight groups used: network_load_sent_gradient (gradient) or network_load_recv_gradient (gradient) or network_load_gradient (gradient), network_load_sent or network_load_recv or network_load.

powerline.segments.common.system_load(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 and system_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 and threshold_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.

Divider highlight group used: background:divider.

Highlight groups used: system_load_gradient (gradient) or system_load.

powerline.segments.common.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.

powerline.segments.common.user(hide_user=None)[source]

Return the current user.

Parameters:hide_user (str) – Omit showing segment for users with names equal to this string.

Highlights the user with the superuser if the effective user ID is 0.

Highlight groups used: superuser or user. It is recommended to define all highlight groups.

powerline.segments.common.virtualenv()[source]

Return the name of the current Python virtualenv.

powerline.segments.common.weather(interval=600, update_first=True, temp_hottest=40, temp_coldest=-30, temp_format=None, unit=u'C', icons=None, location_query=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 or K
  • 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 and temp_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 or weather, weather_temp_gradient (gradient) or weather. Also uses weather_conditions_{condition} for all weather conditions supported by Yahoo.

Previous topic

License and credits

Next topic

Shell segments

This Page