From 5041cb2a907ecb42d11ac228044bf9d07ed31c3b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Hannes=20K=C3=B6rber?= Date: Mon, 9 Nov 2015 17:39:01 +0100 Subject: [PATCH] Switch from i3status+conky to i3blocks. --- i3/i3/config | 2 +- i3/i3/conky/statusbar.conkyrc | 44 --------------------------- i3/i3/i3blocks.conf | 29 ++++++++++++++++++ i3/i3/scripts/battery.bash | 51 ++++++++++---------------------- i3/i3/scripts/i3bar_wrapper.bash | 24 --------------- i3/i3/scripts/update-status.bash | 3 +- 6 files changed, 47 insertions(+), 106 deletions(-) delete mode 100644 i3/i3/conky/statusbar.conkyrc create mode 100644 i3/i3/i3blocks.conf delete mode 100755 i3/i3/scripts/i3bar_wrapper.bash diff --git a/i3/i3/config b/i3/i3/config index d5f9c22..444f58a 100644 --- a/i3/i3/config +++ b/i3/i3/config @@ -367,5 +367,5 @@ bar { } i3bar_command i3bar - status_command bash ~/.i3/scripts/i3bar_wrapper.bash ~/.i3/conky/statusbar.conkyrc + status_command i3blocks -c ~/.i3/i3blocks.conf } diff --git a/i3/i3/conky/statusbar.conkyrc b/i3/i3/conky/statusbar.conkyrc deleted file mode 100644 index 3565970..0000000 --- a/i3/i3/conky/statusbar.conkyrc +++ /dev/null @@ -1,44 +0,0 @@ -# vim:set filetype=conkyrc: -out_to_console yes -out_to_ncurses no -out_to_stderr no -out_to_x no - -short_units yes - -double_buffer yes - -update_interval 1.0 -update_interval_on_battery 1.0 - -# pad_percents is useless without use_spacer, but the latter leads to some ugly gaps -#pad_percents 2 -#use_spacer left - -#${mpd_artist} - ${mpd_title} ${mpd_elapsed}/${mpd_length}\ -TEXT -[\ -{ "full_text" : "  \ -${texeci 5 bash $HOME/.i3/scripts/pa-volume.bash status} " , "color" : "\#FFFFFF" , "name" : "volume" },\ -\ -\ -\ -${texeci 10 bash $HOME/.i3/scripts/battery.bash conky}\ -\ -\ -\ -{ "full_text" : "  ${kernel} " , "color" : "\#FFFFFF" , "name" : "sysinfo" },\ -\ -\ -\ -{ "full_text" : "  $uptime_short " , "color" : "\#FFFFFF" , "name" : "sysinfo" },\ -\ -\ -\ -{ "full_text" : "  ${time %a %F %T} " , "color" : "\#FFFFFF" , "name" : "time" },\ -\ -\ -\ -{ "full_text" : "" }\ -], - diff --git a/i3/i3/i3blocks.conf b/i3/i3/i3blocks.conf new file mode 100644 index 0000000..43b57d2 --- /dev/null +++ b/i3/i3/i3blocks.conf @@ -0,0 +1,29 @@ +separator_block_width=33 + +[volume] +command=$HOME/.i3/scripts/pa-volume.bash status +signal=1 +label= +interval=once + +[battery] +command=$HOME/.i3/scripts/battery.bash i3blocks +label= +interval=30 + +[kernel] +command=uname -r +label= +interval=once + +[time] +command=date "+%a %d.%m.%Y %H:%M:%S" +label= +interval=1 +separator=false +separator_block_width=12 + +[empty] +full_text= +color=#e16b40 +separator=false diff --git a/i3/i3/scripts/battery.bash b/i3/i3/scripts/battery.bash index 701c3f6..db8febe 100755 --- a/i3/i3/scripts/battery.bash +++ b/i3/i3/scripts/battery.bash @@ -18,13 +18,12 @@ THRESHOLD2=5 acpi_output=$(acpi -b) if [[ -n "$acpi_output" ]] ; then has_battery=1 - percent="$(echo "$acpi_output" | cut -d "," -f 2 | cut -d " " -f 2 | cut -d "%" -f 1)" + percent="$(echo "$acpi_output" | grep -oP '\d+(?=%)')" if [[ $percent == 100 ]] ; then status="Full" else - status="$(echo "$acpi_output" | cut -d "," -f 1 | cut -d " " -f 3)" + status="$(echo "$acpi_output" | grep -oP '(?<=: )\w+(?=,)' )" fi - time="$(echo "$acpi_output" | cut -d "," -f 3 | cut -d " " -f 2)" shortstatus="$(echo $status | cut -c 1)" else has_battery=0 @@ -34,19 +33,6 @@ log() { echo [$(date +%FT%T)] "$*" >> $logfile } - -pretty() { - if (( has_battery )) ; then - ( - echo "Status:|$status" - echo "Charge:|${percent}%" - if [[ $percent != 100 ]] ; then - echo "Time left:|$time" - fi - ) | column -t --separator="|" - fi -} - charging() { [[ "$shortstatus" == "C" ]] } @@ -56,14 +42,14 @@ discharging() { } threshold1() { - [[ $percent -le $THRESHOLD1 ]] + (( $percent <= $THRESHOLD1 )) } threshold2() { - [[ $percent -le $THRESHOLD2 ]] + (( $percent <= $THRESHOLD2 )) } -conky() { +short() { if (( has_battery )) ; then if discharging ; then if threshold2 ; then @@ -87,34 +73,27 @@ conky() { rm "$PATH_WARN_1" fi [[ -f "$PATH_WARN_2" ]] && rm "$PATH_WARN_2" - #if [[ $percent -gt 25 ]] ; then - # [[ -f "$PATH_WARN_1" ]] && rm "$PATH_WARN_1" - #elif [[ $percent -gt 5 ]] ; then - # [[ -f "$PATH_WARN_2" ]] && rm "$PATH_WARN_2" - #fi - fi if threshold2 ; then color="#FF0000" # red + urgent=1 elif threshold1 ; then color="#FFFF00" # yellow + urgent=0 else color="#FFFFFF" # white + urgent=0 fi - - - echo "{ \"full_text\" : \"  ${shortstatus} ${percent}% \" , \"color\" : \"$color\" , \"name\" : \"battery\" }," + echo "${shortstatus} ${percent}%" + echo + echo $color + (( $urgent )) && exit 33 + exit 0 else - echo "{ \"full_text\" : \"  no battery \" , \"color\" : \"#FFFFFF\" , \"name\" : \"battery\" }," + echo "no battery" fi } -if [[ "$1" == "conky" ]] ; then - conky -else - pretty -fi - - +short diff --git a/i3/i3/scripts/i3bar_wrapper.bash b/i3/i3/scripts/i3bar_wrapper.bash deleted file mode 100755 index 3afe0c3..0000000 --- a/i3/i3/scripts/i3bar_wrapper.bash +++ /dev/null @@ -1,24 +0,0 @@ -#!/usr/bin/env bash -# paths to scripts used. -path_conkyrc="$1" - -_PIDFILE="$RUNDIR/i3/conky.pid" - - -# end the header so that i3bar knows we want to use JSON: -echo '{ "version" : 1 , "click_events" : true }' - -# Begin the endless array. -echo '[' - -# We send an empty first array of blocks to make the loop simpler: -echo '[],' - -# Now send blocks with information forever: -conky -c "$path_conkyrc" & - -pid=$! - -printf '%s' $pid > "$_PIDFILE" - -wait $pid diff --git a/i3/i3/scripts/update-status.bash b/i3/i3/scripts/update-status.bash index 71e7d01..f5ade82 100755 --- a/i3/i3/scripts/update-status.bash +++ b/i3/i3/scripts/update-status.bash @@ -1 +1,2 @@ -kill -USR1 $(cat $RUNDIR/i3/conky.pid) +#!/usr/bin/env bash +pkill --signal SIGRTMIN+1 i3blocks