Use powershell to scrape battery data from win32_battery api to support .tmux.conf battery in Windows Subsystem for Linux (BASH on Windows)
This commit is contained in:
parent
264a577ba1
commit
7f572daa35
1 changed files with 22 additions and 13 deletions
|
@ -235,6 +235,7 @@ run 'cut -c3- ~/.tmux.conf | sh -s _apply_configuration'
|
||||||
#
|
#
|
||||||
# _battery() {
|
# _battery() {
|
||||||
# uname_s=$(uname -s)
|
# uname_s=$(uname -s)
|
||||||
|
# uname_a=$(uname -a)
|
||||||
# case "$uname_s" in
|
# case "$uname_s" in
|
||||||
# *Darwin*)
|
# *Darwin*)
|
||||||
# batt=$(pmset -g batt)
|
# batt=$(pmset -g batt)
|
||||||
|
@ -243,6 +244,13 @@ run 'cut -c3- ~/.tmux.conf | sh -s _apply_configuration'
|
||||||
# charge="${percentage%%%} / 100"
|
# charge="${percentage%%%} / 100"
|
||||||
# ;;
|
# ;;
|
||||||
# *Linux*)
|
# *Linux*)
|
||||||
|
# if echo $uname_a | grep -q "Microsoft"; then
|
||||||
|
# # Bash on ubuntu on windows
|
||||||
|
# discharging=$(powershell.exe "(Get-WmiObject win32_battery).BatteryStatus" | grep -q 1 && echo "true" || echo "false")
|
||||||
|
# percentage=$(powershell.exe "(Get-WmiObject win32_battery).estimatedChargeRemaining")
|
||||||
|
# charge="${percentage} / 100"
|
||||||
|
# else
|
||||||
|
# # Linux
|
||||||
# batpath=/sys/class/power_supply/BAT0
|
# batpath=/sys/class/power_supply/BAT0
|
||||||
# if [ ! -d $batpath ]; then
|
# if [ ! -d $batpath ]; then
|
||||||
# batpath=/sys/class/power_supply/BAT1
|
# batpath=/sys/class/power_supply/BAT1
|
||||||
|
@ -259,6 +267,7 @@ run 'cut -c3- ~/.tmux.conf | sh -s _apply_configuration'
|
||||||
# fi
|
# fi
|
||||||
# charge="$(cat $bat_energy_now) / $(cat $bat_energy_full)" || return
|
# charge="$(cat $bat_energy_now) / $(cat $bat_energy_full)" || return
|
||||||
# fi
|
# fi
|
||||||
|
# fi
|
||||||
# ;;
|
# ;;
|
||||||
# *CYGWIN*)
|
# *CYGWIN*)
|
||||||
# wmic path Win32_Battery 2>&1 | grep -q 'No Instance' && return
|
# wmic path Win32_Battery 2>&1 | grep -q 'No Instance' && return
|
||||||
|
|
Loading…
Reference in a new issue