Modifs i3blocks

This commit is contained in:
Breizh 2018-11-10 05:22:08 +01:00
parent a67dd266b1
commit 02f553eeb6
3 changed files with 30 additions and 19 deletions

View file

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

View file

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

View file

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