tmux-plugins / tmux-battery Goto Github PK
View Code? Open in Web Editor NEWPlug and play battery percentage and icon indicator for Tmux.
License: MIT License
Plug and play battery percentage and icon indicator for Tmux.
License: MIT License
I'm running tmux on a debian server Debian 4.9.13-1 (2017-02-27)
(so there is no battery), and I'm using the latest version of tmux-battery
โฆ
I have only #{battery_percentage}
in my status line and it's showing this value : -2147483647%
I tried to look into scripts and none of the command used return content (when I enter them manually in a term), I don't know where this value can come from...
Any hint ? Maybe I can hide the #{battery_percentage}
with a condition ?
My laptop is an over achiever and has two batteries. BAT0 and BAT1. Only BAT0 shows up in tmux. While helpful, it only shows me accurate status info when BAT0 acted on.
Is this something that would need extra lines in the script, or is this something I could
accommodate in settings?
The output of pmset -g batt
is
Now drawing from 'AC Power' -InternalBattery-0 (id=3801187) 59%; charging; 1:39 remaining present: true
.
Piping it to awk 'NR==2 { gsub(/;/,""); print $2 }'
prints (id=3801187). Can this be changed to $3, i noticed this on the new preview of OSX, so I doubt if you'll be able to reproduce it, just a heads up!!
I noticed this bug when trying to use a space for padding in either sides of the tmux status bar, so that the time and session name don't look so "squashed" against the side of the screen.
If I have something like set -g status-left ' [#S]'
and this plugin's enabled, the leading whitespace gets stripped, whereas if I don't include it in the plugins list I get the proper spacing. The same happens for status-right
.
I've discovered an unhandled battery state. My MacBook charging cable was plugged in, but it was a little loose and the light wasn't on.
~$ pmset -g batt
Now drawing from 'AC Power'
-InternalBattery-0 2%; AC attached; not charging
battery_icon
is blank in this scenario because that state (neither charging nor discharging) is not accounted for. Maybe it can be handled by creating @batt_attached_icon
defaulted to one of these?
I am sure something is wrong with my config. I am very new to shell scripting, and not sure if I am constructing the battery template right.
Can you please take a look at this change set. nerdpad/dotfiles@4b430ca#diff-e4a99bf3a7fbdabd6456dad3160011e3
I added the following lines to my theme.sh, which is sourced in tmux.config after tmp is loaded.
I am running OSX Sierra
tm_battery="$battery_icon $battery_percentage $battery_remain"
set -g status-right $tm_tunes' '$tm_battery' '$tm_date' '$tm_host
###########################
### Tmux Plugin Manager ###
###########################
# List of plugins
set -g @tpm_plugins ' \
tmux-plugins/tpm \
tmux-plugins/tmux-sensible \
tmux-plugins/tmux-resurrect \
tmux-plugins/tmux-battery \
'
# Initialize TMUX plugin manager
run '~/.tmux/plugins/tpm/tpm'
# load tmux plugin manager
source ~/.dotfiles/tmux/tmux.plugins.sh
#######################
### Color & Style Settings ###
#######################
source ~/.dotfiles/tmux/theme.sh
All the plugins are installed.
Using the following config:
#tmux.conf
set -g @batt_charged_icon "๐"
set -g @batt_charging_icon "๐บ"
set -g @batt_discharging_icon "๐ป"
set -g @batt_attached_icon "๐"
set -ga status-right #{battery_percentage}#{battery_icon} #{battery_remain}
Battery full: ๐
Battery charging: ๐บ
Battery discharging: ๐ป
Plug attached: <state never used?>
Perhaps I'm misunderstanding the states? At full power you are either attached or have a full battery (for a few minutes anyway!). The attached icon would be used when the battery is full and the power adapter is connected. This doesn't seem to be the case however.
Alternatively the attached state (plug or battery) could optionally be a separate icon from the charging/discharging status indicator.
I have both acpi and upower installed, but the battery percentage won't show up. I have the plugin installed via tpm, pretty sure I have the status-right correct, but there's no percentage, though I have noticed it appears for a split second when the environment reloads during package installation. Same goes for the battery graph.
OS is Arch Linux, kernel 6.4.12-arch1-1
I am running this netbook with KMSCON only, which made it kinda dificult to get a screenshot to github, but I managed it using fbgrab (and also git ๐).
Note: to save time, I have tried just installing acpi and also just installing upower, no change.
I have tried to follow the setup steps, but it seems not to be working on my env.
Here are the versions I am using:
OSX El Capitan, 10.11.2
iTerm 2.1.4
Tmux 2.1
The final result is that the battery percentage/icon appears for less than a second then disappears. (it just blinks, really)
I've tested with changing the status-interval
to 10, 15, 60 seconds but it did not change anything.
2015-01-21
UPDATE: If I run, from inside tmux: run ~/.tmux/plugins/tmux-battery/battery.tmux
it starts working. But I have to run it every time I source the ~/.tmux.conf
file.
Hello.
in battery_remain.sh
upower -i $battery | grep remain | awk '{print $4}'
is used to retrieve the remaining battery duration.
However, on Arch I'm not seeing a line that contains "remain". Instead, the field is named "time to empty".
cole@pixel ๎ฐ ~ ๎ฐ upower -i /org/freedesktop/UPower/devices/battery_BAT0
native-path: BAT0
vendor: SMP-ATL
model: A55
serial: 080A
power supply: yes
updated: Mon 14 Dec 2015 01:15:07 PM PST (62 seconds ago)
has history: yes
has statistics: yes
battery
present: yes
rechargeable: yes
state: discharging
warning-level: none
energy: 24.966 Wh
energy-empty: 0 Wh
energy-full: 67.0472 Wh
energy-full-design: 72.314 Wh
energy-rate: 9.2188 W
voltage: 7.48 V
time to empty: 2.7 hours
percentage: 37%
capacity: 91.9811%
technology: lithium-ion
icon-name: 'battery-good-symbolic'
History (rate):
1450127707 9.219 discharging
upower
has a bug and it shows a wrong info in energy-full
after resume. For example, it outputs the following on Xubuntu 17.10:
battery
present: yes
rechargeable: yes
state: charging
warning-level: none
energy: 33.9598 Wh
energy-empty: 0 Wh
energy-full: 52.9452 Wh
energy-full-design: 52.9452 Wh
energy-rate: 22.0185 W
voltage: 8.398 V
time to full: 51.7 minutes
percentage: 75%
capacity: 85.4978%
technology: lithium-polymer
icon-name: 'battery-full-charging-symbolic'
energy-full
and energy-full-design
are same despite the capacity
to be at 85%.
Hence when the script uses these values it yields the wrong percentage.
I was wondering why isn't the percentage
value being taken directly?
I'm not sure if this is a bug or not.
When my mac is charging it displays the lightning bolt icon, when it's full it displays a battery icon, when it's using the battery, it displays nothing, shouldn't there be a 'on battery power' icon?
p.s. this is an awesome plugin, I love having a status bar at the bottom of my terminal, with battery power in it, sooo useful.
Instead of battery_icon I see blank space.
Terminal: iTerm2 3.0.1
OS: Mac OS X 10.11.6
TMUX: 2.3
tmux config line:
set -g status-right 'Battery: #{battery_icon} #{battery_percentage} (#{battery_remain}) | %a %h-%d %H:%M '
I'm not sure if I'm doing something wrong. Everything else I've set up there is working correctly. Is it supported on Mac OS X? I've tried Terminal.app 2.6.1 and the result is same.
Time part of 'status right' is cut off.
In WSL 5.10.16.3-microsoft-standard-WSL2 #1, the status of discharging battery becomes "not charging", so the status_icon shows a "?"
Everything used to work until the last batch of updates to Gnome 3.20 that I've applied, now where it was supposed to display the icon and percentage is just blank.
Hi,
I've got a weird bug, I load the plugin, configure it in my status-right - hit reload - battery icon + percentage appears, then .5s later - disappears, never to be seen again. I reload, same thing happens. Restarting tmux, brand new session doesn't fix. Nor does emptying my config of everything but the status-right + TPM.
Every seen this before? How can I fix it, or even debug?
Thanks
It's usually great to keep your computer's charge between 20 and 80% and we can add this feature to this plugin.
Thank you for this, its great!! but battery status is not showing in Termux, shows: ?
I had been having a problem with tmux whereby after it being running for periods of upwards of 12 or 24 hours I would observe spikes in cpu usage and it would always be caused by tmux. Cpu usage would oscillate between 15% to 80% in 2 seconds and keep on doing so. Similar problems were being faced by users of powerline with tmux. I however don't so I thought it could be tmux-battery as I don't have any intensive plugins and after removing it from the statusline the load vanished.
My .tmux.conf relevant to this is below; the rest doesn't seem to be part of the problem.
#commented out setting including tmux-battery use
#set -g status-right '#{battery_status_fg}Batt:#{battery_icon} #{battery_percentage}\
#[fg=colour114]cont:#{continuum_status}\
#[fg=colour233,bg=colour241,bold] %d/%m #[fg=colour233,bg=colour245,bold] %H:%M '
#after removing the use of tmux-battery
set -g status-right '\
#[fg=colour114]cont:#{continuum_status}\
#[fg=colour233,bg=colour241,bold] %d/%m #[fg=colour233,bg=colour245,bold] %H:%M '
I have the following snippet in my status-right:
#{?#{!=:#{battery_percentage},}, #{battery_status_bg} #{battery_remain} [#{battery_percentage}],}
The idea being that I only want to display battery info, etc. if the current machine I'm on actually has a battery. However, when I do have a battery, I get output like ~1:27 []
instead of ~1:27 [22%]
as expected.
Is there a better way to detect the presence/absence of a battery rather than just testing the output of #{battery_percentage}
?
If I set the icons as follow:
set -g @batt_charged_icon "โ"
#set -g @batt_charging_icon "๐ฒ"
set -g @batt_discharging_icon '๐'
set -g @batt_attached_icon '๐'
The UI broke loose when I unplug my laptop and switch to discharging and the tmux status bar appear twice each time it refresh.
If I replace charging icon ๐ฒ
(U+1F5F2 LIGHTNING MOOD
, UTF-16: 0xD83D 0xDDF2
) by โก
(U+26A1 HIGH VOLTAGE SIGN
, UTF-16: 0x26A1
) there is no more problem while charging.
I'm using Noto Sans as main font but the 2-bytes unicode character are rendered by Symbola Font.
I'd like to follow your recommendation to use acpi over upower.
However, I get no battery status via acpid, only via upowerd. Each or both
are lauched via systemd.
I assume acpi should work though.
Can you please give a hint where to start debugging? I do not see any error
messages and such.
when would the contributors section in README.md be updated? XD
Hi,
Thanks for great tmux plug-in!
It might be great to have UPS support. On my workstation it's reported as ups device
>> upower -e
/org/freedesktop/UPower/devices/ups_hiddev0
/org/freedesktop/UPower/devices/mouse_0003
/org/freedesktop/UPower/devices/mouse_hidpp_battery_0
/org/freedesktop/UPower/devices/DisplayDevice
Thank you in advance!
The Mac calculates the time until the battery is fully charged. It would be useful to display this with the #{battery_remain} flag when the battery is charging rather than showing nothing.
Android's normal APP doesn't have enough permission to get battery information like GNU/Linux.
We must use a different way.
Refer https://github.com/lambdalisue/battery.vim/blob/master/autoload/battery/backend/termux.vim
which is a vim statusbar plugin to display battery information.
Hi - Thank you for providing and maintaining this plugin. It's a nice addition to my tmux status.
Please note that I have updated the plugins and see the battery image icon. However, the percent remaining displays the id:xxxx and time remaining output is blank. Is this a formatting issue? Thanks for letting me know if there is anything I can add to the configuration. - E
Hi,
I'm new to tux and pwerline, and I'm trying to use this plugin. Though, there is no indication at the pwerline status bar. I only get Batt:
and no other indication (OK, plus the | date
at the end). Can you please help?
My laptop is MacOS and it has the pmset
and I also installed the acpi from brew. But still nothing.
I am using Ubuntu installed through the Microsoft Store. Here is my .tmux.conf
:
set -g @plugin 'tmux-plugins/tpm'
set -g @plugin 'tmux-plugins/tmux-sensible'
set -g @plugin 'tmux-plugins/tmux-battery'
set -g status-right "#{battery_status_bg} #{battery_percentage} #[bg=default,fg=default] #H %d/%m %H:%M"
# Initialize TMUX plugin manager (keep this line at the very bottom of tmux.conf)
run -b '~/.tmux/plugins/tpm/tpm'
After sourcing with tmux source ~/.tmux.conf
and installing with <prefix> I
, the battery info does not show up in my status bar. Could this have something to do with WSL or am I just doing something wrong? Please let me know if you need any more information.
Hi Martin,
Back in the day, I contributed to tmux-battery by adding the support for chromebooks. Could you update my name on contributor from Joseph to HyunJong (Joseph) Lee?
Thanks!
@asethwright Hey, I found a bug:
On OS X, when it's unplugged, this can be the output for battery_remain:
Now drawing from 'Battery Power'
-InternalBattery-0 100%; discharging; (no estimate)
In this case the battery_remain
interpolation will show only (no
in tmux status line.
At the moment battery_status colour is defined only based on battery percentage. When using short format for remaining time, one can't distinguish between charging and discharging.
Therefore a colour indicating charging could be added.
I used to see time remaining in the format HH:MM
, now it seems to be showing as H.M
. Have only noticed in the past few days so assume it must be a recent change.
The battery_remain interpolation currently shows both the discharging
and time to fully charge.
To keep this simple I think only the remaining time (when the laptop is discharging) should be shown. We don't want to have any output when the laptop is plugged in.
We might wanna consider adding another interpolation that will show the time till fully charged.
@asethwright looping you in on this.
In my status, I have the following:
'#{?battery_icon,, | #{battery_icon}#{battery_percentage}}
which displays correctly on my macbook, but shows | on a remote machine with no battery.
So this means that battery_icon either does not exist or is zero for both environments (note the second alternative is chosen, as per http://man.openbsd.org/OpenBSD-current/man1/tmux.1#FORMATS). Does this make sense?
Hey! Thanks for using the plugin, I am currently planning out some future works for this. I would like to receive your feedback on this.
I became the maintainer for this plugins after some contributions to get the plugin working when upgrading to macOS Sierra (pmset -g batt
output format changed). Thanks to you, we now support ChromeOS. It is also possible to add a changing background color based on the battery percentage.
But, one of the functionalities is adding emoji characters (two byte unicode characters) based on the status (charging/discharging et cetera). However, I encountered multiple issues regarding this problem. And I have been thinking of the importance of this functionality.
As this is an enhancement to the tmux status bar, I prefer not to use emoji characters. So, personally I do not prefer to use it.
With this issue, I want to know what you prefer. Should we keep the battery icon, or is it something we could get rid of?
Hi, this is what started to happen on battery status change after some weeks ago. It made me stop using the plugin:
When I press Enter after that kind of status change, I get:
As can be seen, a caret is shown in the left-bottom corner, not the tmux bar, which got hidden bellow the window canvas.
~ โฏโฏโฏ tmux -V
tmux 2.3
~ โฏโฏโฏ xfce4-terminal --version
Copyright (c) 2003-2016
The Xfce development team. All rights reserved.
set -g status-right "CPU: #{cpu_icon} #{cpu_percentage} Batt: #{battery_icon} #{battery_percentage} #{battery_remain} | %a %h-%d %H:%M"
CPU: โ 12.85% Batt: | Tue Jun-28 01:12
No data for Battery.
Status line print the decimal points of the percentage of the remaining battery. And it seems to print incorrect status icon due to this behavior. This behavior was appeared on my Arch Linux that has upower.
OS: Arch Linux
Versions of upower: UPower client version 0.99.10, UPower daemon version 0.99.10
Right know, the setting of custom and background colors is the same, in the sense that if I set @batt_color_high_charge
, it will be the same for fg
and bg
. It would be good to be able to set those to separately, as to generate some cool combinations.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.