halostatue / fish-battery

Battery function for Fish - deprecated

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

halostatue/fish-battery

Version

A rewrite of oh-my-fish/plugin-battery for the fish shell, providing a battery utility that is compatible with macOS and Linux.

NOTE: I do not use Linux on a laptop, so the Linux battery detection code is based on oh-my-fish/plugin-battery with some changes. It may not be correct, and there may be ways of reading the battery data that do not require upower. Pull requests to enhance this functionality are greatly appreciated.

Installation

Install with Fisher (recommended):

fisher install halostatue/fish-battery@1.x
Not using a package manager?

Copy functions/*.fish and completions/*.fish to your fish configuration directory preserving the directory structure.

Usage

Display battery status (slots, charging state, percentage and time remaining).

% battery
▮▮▮▮▮▮▮▮▮▯ 🔌 ↑⚡️ 93.6 % ⏱️  0:32

Customize battery options.

% battery -f-e ▷
▶▶▶▶▶▶▶▶▶▷ 🔌 ↑⚡️ 93.6 % ⏱️  0:32

Environment Variables

Unlike oh-my-fish/plugin-battery, this battery function does not export environment variables. That is done with battery.info -x. Instead, the helper function battery.info and the platform-specific versions (battery.info.linux and battery.info.darwin) use the --no-scope-shadowing flag so that calling battery.info will expose the variables to a function calling it, but does not export variables without an explicit opt-in, making battery.info safe to use in prompt functions without affecting the external environment.

In the list below, the first value is the exported version (battery.info -x) and the second value is the local scope version.

BATTERY_IS_PLUGGED / __battery_is_plugged

State BATTERY_IS_PLUGGED __battery_is_plugged
Plugged In true true
Unplugged unset false

If the battery is plugged in, this will be true for both versions. If it is not plugged in, the exported variable will be unset and the local variable will be false.

battery.info -x
set -q BATTERY_IS_PLUGGED; and echo Plugged 🔌

BATTERY_IS_CHARGING / __battery_is_charged

State BATTERY_IS_CHARGING __battery_is_charging
Plugged In true true
Uncharging unset false

If the battery is charging, this will be true for both versions. If it is discharging, the exported variable will be unset and the local variable will be false.

battery.info -x
set -q BATTERY_IS_CHARGING; and echo Charging ⌁

BATTERY_TIME_LEFT / __battery_time_left

Time left in HH:MM format. On macOS, this will be empty if there are more than 1,000 minutes left (the value 65535 is used to indicate that there is no estimate possible).

BATTERY_SLOTS

Number of slots/gauges from 10 available.

BATTERY_MAX_CAP

Battery maximum capacity.

BATTERY_CUR_CAP

Battery current capacity.

BATTERY_PCT

Current battery charge expressed as a percentage.

System Requirements

  • fish 3.0+
  • upower (Linux only)

Licence

MIT

Change Log

CHANGELOG

Contributing

About

Battery function for Fish - deprecated

License:Other


Languages

Language:Shell 100.0%