I use font-awesome 4.4.0 and have extended the default i3blocks battery script with the new battery icons.
All seem to work correctly but the fa-battery-half Unicode: f242
, which renders the script useless. The unicode also seems to refer to the character
.
In the terminal it crashes with:
$ perl /usr/share/i3blocks/battery
Wide character in print at /usr/share/i3blocks/battery line 65.
28% (01:02)
Wide character in print at /usr/share/i3blocks/battery line 66.
28%
#000000
The script is default, except of the following few lines:
if ($status eq 'Discharging') {
if ($percent < 10) {
$full_text .= ' ';
} elsif ($percent < 25) {
$full_text .= ' ';
} elsif ($percent < 50) {
$full_text .= ' ';
} elsif ($percent < 75) {
$full_text .= ' ';
} elsif ($percent < 100) {
$full_text .= ' ';
}
} elsif ($status eq 'Charging') {
$full_text .= ' ';
}
and
if ($status eq 'Discharging') {
if ($percent < 25) {
print "#FF003C\n";
} else {
print "#000000\n";
}
if ($percent < 5) {
exit(33);
}
}
In the editor the script looks like:
How may I get the script to work, with the fa-battery-half Unicode: f242
icon.
You have two problems.
Your first problem is a bug that's resulting in the "wide character" warnings and possibly other problems. To solve the error, properly encode your output. Specifically, add the following to your script:
use open ':std', ':encoding(UTF-8)';
This tells Perl to
The warnings indicate that Perl was able to notice your bug, and that it attempted to fix it by encoding the output using UTF-8. That's the correct fix, so your program's output won't change, which brings us to the second problem.
Your second problem is that your terminal's font doesn't have a glyph for U+F242. If you wish to display that character, you'll need to use a different font.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With