vivien / i3blocks

The hacker-friendly status_command for Sway and i3
https://vivien.github.io/i3blocks/
GNU General Public License v3.0
2.28k stars 181 forks source link

Extending given perl scripts with iconic fonts #130

Closed boolean-is-null closed 9 years ago

boolean-is-null commented 9 years ago

I've tried to customize the given perl scripts to my needs (in this case battery) by adding more descriptive icons from font awesome 4.4.0 (https://fortawesome.github.io/Font-Awesome/icons/)

The altered parts are:

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);
}
}

the used unicodes are: f240 - f244 and f1e6..

Now the problem is that the battery block is now empty, if started in the command line i get:

$ 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

This is the first time I wrote anything in perl, so that might be a problem as well.. The script as I see it: 2015-08-24-115106_388x584_scrot

edit: the problem seems to be with  (< 50% battery left)

kb100 commented 9 years ago

One of the goals of the main scripts is to have as few dependencies as possible. I don't think something depending on font awesome would be appropriate for the core scripts. You may be interested in https://github.com/vivien/i3blocks-contrib which is for user contributed scripts.

See http://perldoc.perl.org/utf8.html for how to use UTF8 in perl. You may also be interested in seeing or forking https://github.com/kb100/i3blocks-battery which does the same thing but in python. I wrote that before the new battery icons came out so it's due for an update.

vivien commented 9 years ago

Hi @boolean-is-null, I agree with @kb100 here. Default scripts will become quite minimal. But if you guys feel the need to share a fancier battery script, feel free to discuss about a new one in the i3blocks-contrib repository. I'm closing this ticket!