gpakosz / .tmux

🇫🇷 Oh my tmux! My self-contained, pretty & versatile tmux configuration made with ❤️
MIT License
21.83k stars 3.36k forks source link

battery disappeared #108

Closed Artem-Schander closed 7 years ago

Artem-Schander commented 7 years ago

Since today the battery output disappeared on my computers (at work and at home) Here is how my statusbar config looks like: #{prefix} | #{username}#{root} | %R , %d %b ,#{pairing}#{?battery_status, #{battery_status},}#{?battery_bar, #{battery_bar},}#{?battery_percentage, #{battery_percentage},} |

And this is the result: bildschirmfoto 2017-09-19 um 23 32 19

What could lead to the loss?

EDIT Here are both files: my dotfiles

gpakosz commented 7 years ago

Honestly @Artem-Schander, this repository hasn't changed in a month and I just can't dig through your dot files and guess what you might have changed around my tmux configuration ☹️

Artem-Schander commented 7 years ago

I think It has nothing to do with the changes (BTW. there are none in the tmux.conf) At least the issue was not fixed by fully cloning your repo ;)

Maybe it's the tmux version 2.5 ?! I run my installer and it installed the latest version.

gpakosz commented 7 years ago

You can try looking at the output of

$ cut -c3- ~/.tmux.conf | sh -sx _battery

This should end with something that ressembles

...
+ tmux set -g @battery_status '🔋 ' ';' set -g @battery_bar '#[bg=none]#[fg=colour196]◼#[fg=colour202]◼#[fg=colour208]◼#[fg=colour214]◼#[fg=colour220]◼#[fg=colour226]◼#[fg=colour190]◼#[fg=colour154]◼#[fg=colour118]◼#[fg=colour82]◼#[fg=colour82]' ';' set -g @battery_hbar '#[fg=colour82]█' ';' set -g @battery_vbar '#[fg=colour82]█' ';' set -g @battery_percentage 100%
Artem-Schander commented 7 years ago

After i've done that, it showed up im my statusbar. Thanks for the help.

gpakosz commented 7 years ago

But will never update

Artem-Schander commented 7 years ago

oh .. but the output was tmux set -g @battery_status $'232' ';' set -g @battery_bar '#[bg=#e4e4e4]#[fg=#000000]◼◼◼◼◼◼◼◼◼◼' ';' set -g @battery_hbar '#[fg=colour82]█' ';' set -g @battery_vbar '#[fg=colour82]█' ';' set -g @battery_percentage 100%

gpakosz commented 7 years ago

Yes that sets variables once. With the values measures at the time you launched $ cut -c3- ~/.tmux.conf | sh -sx _battery.

But cut -c3- ~/.tmux.conf | sh -s _battery is supposed to be invoked regularly as part of updating the status line.

If you do tmux show -gv status-right you will see it's invoking it. Here's the output on my laptop:

$ tmux show -gv status-right
#(cut -c3- ~/.tmux.conf | sh -s _uptime)#(cut -c3- ~/.tmux.conf | sh -s _battery)#[fg=#080808,bg=default,none]#[fg=#8a8a8a,bg=#080808,none]#[fg=none]#[bg=none]#[none]#{?client_prefix,⌨ ,}#[fg=none]#[bg=none]#[none]#{?session_many_attached,👓 ,} #(ping -t 1 -c 1 google.com >/dev/null 2>&1 && printf ✔ || printf ✘) #{?@battery_status, #{@battery_status},}#{?@battery_vbar, #{@battery_vbar},}#{?@battery_percentage, #{@battery_percentage},} #[fg=#8a8a8a,bg=#080808,none]| %R #[fg=#8a8a8a,bg=#080808,none]| %d %b #[fg=#d70000,bg=#080808,none]#[fg=#e4e4e4,bg=#d70000,none] #(cut -c3- ~/.tmux.conf | sh -s _username #{pane_tty} true #D)#[fg=none]#[bg=none]#[bold,blink]#(cut -c3- ~/.tmux.conf | sh -s _root #{pane_tty} #D)#[default]#[fg=#e4e4e4,bg=#d70000,none] #[fg=#e4e4e4,bg=#d70000,none]#[fg=#000000,bg=#e4e4e4,bold] #(cut -c3- ~/.tmux.conf | sh -s _hostname #{pane_tty} true #D)
Artem-Schander commented 7 years ago

looks similar in my case

tmux show -gv status-right
#(cut -c3- ~/.tmux.conf | sh -s _uptime)#(cut -c3- ~/.tmux.conf | sh -s _battery)#[fg=#080808,bg=default,none]#[fg=#8a8a8a,bg=#080808,none]#[fg=none]#[bg=none]#[none]#{?client_prefix,⌨,} #[fg=#333333,bg=#080808,none]#[fg=#e4e4e4,bg=#333333,none] #(cut -c3- ~/.tmux.conf | sh -s _username #{pane_tty} false #D)#[fg=none]#[bg=none]#[bold,blink]#(cut -c3- ~/.tmux.conf | sh -s _root #{pane_tty} #D)#[default]#[fg=#e4e4e4,bg=#333333,none] #[fg=#e4e4e4,bg=#333333,none]#[fg=#000000,bg=#e4e4e4,bold] %R #[fg=#000000,bg=#e4e4e4,bold] %d %b #[fg=#000000,bg=#e4e4e4,bold]#[fg=none]#[bg=none]#[none]#{?session_many_attached,👓,}#{?@battery_status, #{@battery_status},}#{?@battery_bar, #{@battery_bar},}#{?@battery_percentage, #{@battery_percentage},} #[fg=#080808,bg=#e4e4e4,none]#[fg=#8a8a8a,bg=#080808,none]
gpakosz commented 7 years ago

Then I don't know.

You can try debugging whether tmux updates the status line by doing

$ tmux set status-right '#(date >> /tmp/test.txt)'
$ tail -f /tmp/test.txt
Artem-Schander commented 7 years ago

it seems like it is updating .. there are constantly entries like Mi 20 Sep 2017 09:30:52 CEST getting added

gpakosz commented 7 years ago

Then I have no idea why the variables set when invoking cut -c3- ~/.tmux.conf | sh -s _battery were not updated (which is likely the cause for the battery indicators not showing).

Artem-Schander commented 7 years ago

sorry to bother you again .. i've cloned your repo, so there are no changes. if i fire cut -c3- ~/.tmux.conf | sh -sx _battery the last lines of the output looks like this:

...

+ battery_bg=none
+ '[' xgradient = xgradient ']'
+ palette='196 202 208 214 220 226 190 154 118 82 46'
+ '[' xgradient = xheat ']'
++ echo '196 202 208 214 220 226 190 154 118 82 46'
++ awk -v n=10 '{ for (i = 0; i < n; ++i) printf $(1 + (i * NF / n))" " }'
+ palette='196 202 208 214 220 226 190 154 118 82 '
+ eval set -- '196 202 208 214 220 226 190 154 118 82 '
++ set -- 196 202 208 214 220 226 190 154 118 82
++ awk 'BEGIN { printf "%.0f", (0,7) * 10 }'
awk: syntax error at source line 1
 context is
        BEGIN { printf "%.0f", (0,7) >>>  * <<<  10 }
awk: illegal statement at source line 1
+ full=

it must be in line 357 full=$(awk "BEGIN { printf \"%.0f\", ($charge) * $battery_bar_length }")

UPDATE It was the calculation of floats - the separator was a comma. The solution was to put export LC_NUMERIC="C" into my .zshrc

gpakosz commented 7 years ago

Hmm that's interesting after all!

Can you please instead leave your .zshrc unchanged and edit .tmux.conf?

# # exit the script if any statement returns a non-true return value
# set -e
#
# export LC_ALL=C
Artem-Schander commented 7 years ago

yapp, that solves the issue too. BTW you can reproduce by running

$ export LC_NUMERIC="de_DE.UTF-8"
mmarchand commented 6 years ago

export LC_ALL=C fixed it for me too, it should probably be merged ;)

gpakosz commented 6 years ago

it should probably be merged

done

mmarchand commented 6 years ago

indeed, my bad, I was not up to date, thanks !