diff --git a/README.md b/README.md index bff828e..8aee500 100644 --- a/README.md +++ b/README.md @@ -23,6 +23,7 @@ A modular statusbar for dwm - [dwm_transmission](#dwm_transmission) - [dwm_backlight](#dwm_backlight) - [dwm_connman](#dwm_connman) + - [dwm_loadavg](#dwm_loadavg) - [Installation](#installation) - [Reccomendations](#reccomendations) - [Usage](#usage) @@ -147,6 +148,11 @@ Shows network information IP, SSID, WLan strength (if connected to WLan) using c [🌐 192.169.189.12 HomeNetworkName 53%] ``` Dependencies: ```connman``` +### dwm_loadavg +Displays the average system load +``` +[⏱ 0.14 0.17 0.18] +``` ## Installation 1. Clone and enter the repository: ``` diff --git a/bar-functions/dwm_loadavg.sh b/bar-functions/dwm_loadavg.sh new file mode 100644 index 0000000..145d5d8 --- /dev/null +++ b/bar-functions/dwm_loadavg.sh @@ -0,0 +1,26 @@ +#!/bin/sh + +# A dwm_bar function to read the average system load +# Alvar Penning +# GNU GPLv3 + +dwm_loadavg () { + # LOAD_FIELDS specifies the load average values to be displayed. Values + # within 1-3 are allowed, passed as a range (-) or comma-separated. + # - 1: load average within the last minute + # - 2: load average within the last five minutes + # - 3: load average within the last fifteen minutes + LOAD_FIELDS=1,2,3 + + LOAD_AVG=$(cut -d " " -f ${LOAD_FIELDS} /proc/loadavg) + + printf "%s" "$SEP1" + if [ "$IDENTIFIER" = "unicode" ]; then + printf "⏱ %s" "$LOAD_AVG" + else + printf "AVG %s" "$LOAD_AVG" + fi + printf "%s\n" "$SEP2" +} + +dwm_loadavg diff --git a/dwm_bar.sh b/dwm_bar.sh index 0088c27..01141e8 100755 --- a/dwm_bar.sh +++ b/dwm_bar.sh @@ -41,10 +41,12 @@ export SEP2="]" . "$DIR/bar-functions/dwm_ccurse.sh" . "$DIR/bar-functions/dwm_date.sh" . "$DIR/bar-functions/dwm_connman.sh" +. "$DIR/bar-functions/dwm_loadavg.sh" # Update dwm status bar every second while true do xsetroot -name "$(dwm_connman)$(dwm_countdown)$(dwm_alarm.sh)$(dwm_transmission)$(dwm_cmus)$(dwm_mpc)$(dwm_spotify)$(dwm_resources)$(dwm_battery)$(dwm_mail)$(dwm_backlight)$(dwm_alsa)$(dwm_pulse)$(dwm_weather)$(dwm_vpn)$(dwm_networkmanager)$(dwm_keyboard)$(dwm_ccurse)$(dwm_date)" + xsetroot -name "$(dwm_countdown)$(dwm_alarm.sh)$(dwm_transmission)$(dwm_cmus)$(dwm_mpc)$(dwm_spotify)$(dwm_resources)$(dwm_battery)$(dwm_mail)$(dwm_backlight)$(dwm_alsa)$(dwm_pulse)$(dwm_weather)$(dwm_vpn)$(dwm_networkmanager)$(dwm_keyboard)$(dwm_ccurse)$(dwm_date)$(dwm_loadavg)" sleep 1 done