Modifs i3blocks

This commit is contained in:
Breizh 2018-11-10 05:22:08 +01:00
parent 7200b37828
commit 928c0dac33
3 changed files with 30 additions and 19 deletions

View file

@ -24,7 +24,7 @@
output=$(acpi battery)
percentage=$(echo "$output" | grep -o -m1 '[0-9]\{1,3\}%' | tr -d '%')
status=$(echo "$output" | egrep -o -m1 'Discharging|Charging|AC|Full|Unknown')
status=$(echo "$output" | egrep -o -m1 'Discharging|Charging|AC|Full|Unknown|Not charging')
remaining=$( echo "$output" | egrep -o -m1 '[0-9][0-9]:[0-9][0-9]')
[[ -n $remaining ]] && remaining_formatted=" ($remaining)"
icon=""
@ -114,9 +114,9 @@ case "$status" in
color="${dis_colors[7]}"
fi
;;
"Full")
"Full"|"Not charging")
color="$full_color"
icon="=$icon"
icon="$icon"
;;
"AC")
color="$ac_color"

View file

@ -25,7 +25,7 @@ battery_count=${#output[@]}
for line in "${output[@]}";
do
percentages+=($(echo "$line" | grep -o -m1 '[0-9]\{1,3\}%' | tr -d '%'))
statuses+=($(echo "$line" | egrep -o -m1 'Discharging|Charging|AC|Full|Unknown'))
statuses+=($(echo "$line" | egrep -o -m1 'Not|Discharging|Charging|AC|Full|Unknown'))
remaining=$(echo "$line" | egrep -o -m1 '[0-9][0-9]:[0-9][0-9]')
if [[ -n $remaining ]]; then
remainings+=(" ($remaining)")
@ -34,6 +34,8 @@ do
fi
done
echo $statuses >&2
#There are 8 colors that reflect the current battery percentage when
#discharging
dis_colors=("#F2777A" "#F2777A" "#F99157" "#F99157" "#FFCC66" "#FFCC66"
@ -95,35 +97,35 @@ do
if [[ $(( percents[$i] - ( _full_squares * 8 ) )) -eq 7 ]]
then
squares+="▉"
#squares+="▇"
shortsquares+="▇"
elif [[ $(( percents[$i] - ( _full_squares * 8 ) )) -eq 6 ]]
then
squares+="▊"
#squares+="▆"
shortsquares+="▆"
elif [[ $(( percents[$i] - ( _full_squares * 8 ) )) -eq 5 ]]
then
squares+="▋"
#squares+="▅"
shortsquares+="▅"
elif [[ $(( percents[$i] - ( _full_squares * 8 ) )) -eq 4 ]]
then
squares+="▌"
#squares+="▄"
shortsquares+="▄"
elif [[ $(( percents[$i] - ( _full_squares * 8 ) )) -eq 3 ]]
then
squares+="▍"
#squares+="▃"
shortsquares+="▃"
elif [[ $(( percents[$i] - ( _full_squares * 8 ) )) -eq 2 ]]
then
squares+="▎"
#squares+="▂"
shortsquares+="▂"
elif [[ $(( percents[$i] - ( _full_squares * 8 ) )) -eq 1 ]]
then
squares+="▏"
#squares+="▁"
shortsquares+="▁"
fi
if [[ "${statuses[$i]}" = "Unknown" ]]; then
squares="<sup>?</sup>$squares"
squares="? $squares"
fi
case "${statuses[$i]}" in
@ -136,7 +138,7 @@ do
"Full")
color="$full_color"
;;
"AC")
"AC"|"Not")
color="$ac_color"
;;
"Discharging"|"Unknown")
@ -171,10 +173,15 @@ do
message="$message$(($i + 1)): "
fi
shortmessage="$message"
if [[ "$BLOCK_BUTTON" -eq 1 ]]; then
message="$message${statuses[$i]} <span foreground=\"$color\">${percentages[$i]}%${remainings[i]}</span> "
message="$message${statuses[$i]/Not/Not charging} <span foreground=\"$color\">${percentages[$i]}%${remainings[$i]}</span> "
shortmessage="$shortmessage${statuses[$i]/Not/Not charging} <span foreground=\"$color\">${remainings[$i]}</span> "
fi
message="$message<span foreground=\"$color\" background=\"#515151\">$squares</span>"
message="bat $message<span foreground=\"$color\" background=\"#515151\">$squares</span>"
shortmessage="bat $shortmessage<span foreground=\"$color\">${percentages[$i]}%</span>"
done
echo "$message"
echo "$shortmessage"

View file

@ -10,9 +10,9 @@ esac
status=$(mocp -Q "%state")
case $status in
STOP ) status="[]" ;;
PAUSE ) status="||" ;;
PLAY ) status=" >" ;;
STOP ) status="<span foreground=\"#F2777A\">⏹</span>" ;;
PAUSE ) status="<span foreground=\"#FFCC66\">⏸</span>" ;;
PLAY ) status="<span foreground=\"#99CC99\">⏵</span>" ;;
esac
dots=
@ -23,6 +23,10 @@ song=$(mocp -Q "%song")
if [ ${#song} -gt 30 ]
then
dots="…"
elif [ ${#song} -gt 15 ]
then
shortdots="…"
fi
echo $status ${song:0:30}$dots $(mocp -Q "%ct %tt %tl")
echo "$status ${song:0:30}$dots $(mocp -Q "[%ct %tl %tt]")"
echo "$status ${song:0:15}$shortdots $(mocp -Q "%ct %tl")"