Skip to content

Commit

Permalink
Merge pull request #8 from o-nikolas/onikolas/default_format_with_ico…
Browse files Browse the repository at this point in the history
…n_overrides

Support overrideing icons with the default format
  • Loading branch information
imwally authored Mar 27, 2024
2 parents 924c328 + ea22aac commit f9f8ae3
Showing 1 changed file with 25 additions and 18 deletions.
43 changes: 25 additions & 18 deletions battstat
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
#!/usr/bin/env sh

charging_icon="" # U+26A1 - Thunderbolt
charging_icon="" # U+26A1 - Thunderbolt
discharging_icon="🔋" # U+1F50B - Battery
format=false # Track whether formatting was supplied from the user

print_help() {
echo "usage: battstat [options] format"
Expand Down Expand Up @@ -169,11 +170,6 @@ case $(uname) in
;;
esac

if [ $# -eq 0 ]; then
print_time
print_percent
print_icon
fi

while test $# -gt 0; do
case "$1" in
Expand All @@ -192,22 +188,33 @@ while test $# -gt 0; do
shift
;;
{i})
print_icon
shift
;;
format=true
print_icon
shift
;;
{t})
print_time
shift
;;
format=true
print_time
shift
;;
{p})
print_percent
shift
;;
format=true
print_percent
shift
;;
*)
print_help
break
;;
print_help
break
;;
esac
done

if [ "$format" = false ]
then
# No format was provided by the user, so print the default format
print_time
print_percent
print_icon
fi

printf "\n"

0 comments on commit f9f8ae3

Please sign in to comment.