From 1cc17efec280a56e8c6e2c3eb1d99a6185c7eb7d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vladim=C3=ADr=20Dudr?= Date: Wed, 15 Feb 2023 16:52:26 +0100 Subject: [PATCH] hlwm: add df to statusbar --- .../herbstluftwm/executable_panel-generator | 12 ++++++++++++ .../herbstluftwm/executable_panel-handler | 19 ++++++++++++++----- 2 files changed, 26 insertions(+), 5 deletions(-) diff --git a/dot_config/herbstluftwm/executable_panel-generator b/dot_config/herbstluftwm/executable_panel-generator index b90a1ae..58ed355 100644 --- a/dot_config/herbstluftwm/executable_panel-generator +++ b/dot_config/herbstluftwm/executable_panel-generator @@ -44,6 +44,17 @@ do done ) & +root_dev="$(stat --printf %Hd,%Ld /)" +home_dev="$(stat --printf %Hd,%Ld "$HOME")" +check_df() { + df="" + df="/:$(df --output=pcent / | tail -n+2 | xargs)" + + [[ "$root_dev" = "$home_dev" ]] || df+="\t$USER:$(df --output pcent "$HOME" | tail -n+2 | xargs)" + + update df "$df" +} + while : do # shellcheck source=/sys/class/power_supply/BAT0/uevent # most likely @@ -68,6 +79,7 @@ do which iwctl &>/dev/null && update wifi "$(iwctl station wlan0 show |grep 'Connected network' | sed 's/ */ /g' | cut -d ' ' -f 4-)" + check_df #if [ -e /run/user/1000/cmus-socket ] #then #update player "$(printf '%s\t%s \t%s' "$(playerctl metadata artist | tr -d "'" )" "$(playerctl metadata xesam:comment)" "$(playerctl metadata title)")" diff --git a/dot_config/herbstluftwm/executable_panel-handler b/dot_config/herbstluftwm/executable_panel-handler index b951318..4a8a568 100644 --- a/dot_config/herbstluftwm/executable_panel-handler +++ b/dot_config/herbstluftwm/executable_panel-handler @@ -117,7 +117,7 @@ hc --idle | { ### center #echo -n "%{c}%{U${colors[bright_orange]}}${windowtitle:0:150}%{U-}" ### print the right - res+="%{r}$playing $separator $volume $separator $wifi $separator $network $separator $temperature $separator $load $separator $date $separator %{U#f2f229}$charge%{U-} $separator" + res+="%{r}$df $separator $playing $separator $volume $separator $wifi $separator $network $separator $temperature $separator $load $separator $date $separator %{U#f2f229}$charge%{U-} $separator" #echo -en "%{r}$right $separator %{U#f2f229}$charge%{U-} $separator" done @@ -194,16 +194,16 @@ hc --idle | { charging) batt_sym="%{F#00aa00}$batt_sym%{F-}" ac="+" - notify "Power" "Battery charging" + notify "Power" "Battery charging" ;; discharging) ac="-" batt_sym="%{F#ffdb00}$batt_sym%{F-}" - notify "Power" "Battery discharging" + notify "Power" "Battery discharging" ;; idle) ac="=" - notify "Power" "Fully charged" + notify "Power" "Fully charged" ;; esac ;; @@ -230,7 +230,16 @@ hc --idle | { charge="$batt_sym ${batt_perc}%%" - [ "$batt_perc" -le 15 ] && [ "$ac" != '+' ] && notify -u critical "Power" "Battery has only ${batt_perc}%" + [ "$batt_perc" -le 15 ] && [ "$ac" != '+' ] && notify -u critical "Power" "Battery has only ${batt_perc}%" + ;; + df) + df="" + for f in "${cmd[@]:1}" + do + IFS=: read -r name perc <<<"$f" + [[ "${perc%%%}" -lt 80 ]] && continue + df+=" $name $perc" + done ;; temperature) temperature=" ${cmd[1]}°C"