From 02f553eeb6f869256cf14e8bf5e4c1c136e945bf Mon Sep 17 00:00:00 2001 From: Breizh Date: Sat, 10 Nov 2018 05:22:08 +0100 Subject: [PATCH] Modifs i3blocks --- .i3blocks/battery | 6 +++--- .i3blocks/batterybar | 31 +++++++++++++++++++------------ .i3blocks/mocp | 12 ++++++++---- 3 files changed, 30 insertions(+), 19 deletions(-) diff --git a/.i3blocks/battery b/.i3blocks/battery index 1800c26..d6fe416 100755 --- a/.i3blocks/battery +++ b/.i3blocks/battery @@ -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" diff --git a/.i3blocks/batterybar b/.i3blocks/batterybar index 9491b6f..224eab1 100755 --- a/.i3blocks/batterybar +++ b/.i3blocks/batterybar @@ -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="?$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]} ${percentages[$i]}%${remainings[i]} " + message="$message${statuses[$i]/Not/Not charging} ${percentages[$i]}%${remainings[$i]} " + shortmessage="$shortmessage${statuses[$i]/Not/Not charging} ${remainings[$i]} " fi - message="$message$squares" + message="bat $message$squares" + shortmessage="bat $shortmessage${percentages[$i]}%" done echo "$message" +echo "$shortmessage" diff --git a/.i3blocks/mocp b/.i3blocks/mocp index 9c96cb7..ba81acf 100755 --- a/.i3blocks/mocp +++ b/.i3blocks/mocp @@ -10,9 +10,9 @@ esac status=$(mocp -Q "%state") case $status in - STOP ) status="[]" ;; - PAUSE ) status="||" ;; - PLAY ) status=" >" ;; + STOP ) status="" ;; + PAUSE ) status="" ;; + PLAY ) status="" ;; 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")"