Closed skywarth closed 10 months ago
Hello, sry late reply.
There could be a 100 reasons why the batter segment doesn't work on your system. The best way forward is to follow the debugging instructions outlined at https://github.com/erikw/tmux-powerline#debugging
As you said you're on Ubuntu, the relevant code to debug should be https://github.com/erikw/tmux-powerline/blob/4b23381ceca5a52c771d9bec791905f6689437bf/segments/battery.sh#L83-L123
Alright I'll try to debug the corresponding section whenever I have the time. Will update the issue if I find anything strange.
It's been some time since I had a ride with Bash, here we go.
My findings during the debug:
BAT0 folder exists
BAT_FULL=/sys/class/power_supply/BAT0/energy_full
BAT_NOW=/sys/class/power_supply/BAT0/energy_now
[!] Code doesn't go inside the if [ "$1" = `cat $STATUS` -o "$1" = "" ]; then
section, therefore segment is not rendered.
$1
. Not sure where this method is called from, or what $1
could be. But I suppose this is an expected case.cat $STATUS
evals to "not charging"[...]
if conditions are used along empty string comparisons, it provides unexpected results AFAIK, please correct me if I'm wrong. When $1 is an empty string, the test [ "$1" = cat $STATUS -o "$1" = "" ] becomes malformed. This is a quirk of how the single-bracket test [ ... ] works in bash. In other conditions where $1 has a value, the expression would work as expected. The double-bracket [[ ... ]] is a more modern, Bash-specific test construct that behaves in a more intuitive manner in such scenarios. However I can understand if double-bracket is not used here to achieve compability with POSIX-compliant shells like sh
, ash
and dash
. I suppose reasoning behind it was portability, is that right ?PR proposal is at #334
Confirmed to be solved on production release (main branch) after #334 is merged. :+1:
Hi,
I just installed tmux-powerline and was about to customize it. So far all the segments defined in the default configs seems to be working, except for battery segment. It simply doesn't display it at all. I disabled all other segments to test maybe it wasn't able to fit in the stack width, that didn't change anything. Screenshot below, certain fields are hidden:
BTW: default tmux (without tmux-powerline plugin) displays the battery just fine.
My configuration (basically default config):
Theme: my-theme.sh (also copied from default)
My theme and config file is being read, it updates the plugin, I tested it by altering certain lines it was reflected on the tmux display.
BAT0 and BAT1 exists, it contains up to date data about the battery.
I'm on Ubuntu 22.04.
What is wrong, why is it not working? I can provide additional debugging outputs if needed.
Thank you