Check for defined variables in order to populate $status_cmd - statusbar - Shell script to set/print a status bar
(HTM) hg clone https://bitbucket.org/iamleot/statusbar
(DIR) Log
(DIR) Files
(DIR) Refs
(DIR) README
---
(DIR) changeset 4c1af169d594a0dcf07e0c6a55846ad85103e18b
(DIR) parent 7421f516dd3cc748b0e4995aa2ffd550b61b3617
(HTM) Author: Leonardo Taccari <iamleot@gmail.com>
Date: Tue, 27 Feb 2018 23:14:27
Check for defined variables in order to populate $status_cmd
Check for defined variables in order to gradually populate $status_cmd only with
elements that are provided via $STATUSBAR_* environment variables.
Introduce STATUSBAR_UNREAD_EMAILS and STATUSBAR_UNREAD_NEWS while here.
Diffstat:
README | 2 ++
statusbar.sh | 29 ++++++++++++++++++++++++++++-
2 files changed, 30 insertions(+), 1 deletions(-)
---
diff -r 7421f516dd3c -r 4c1af169d594 README
--- a/README Tue Feb 27 20:07:53 2018 +0100
+++ b/README Tue Feb 27 23:14:27 2018 +0100
@@ -13,6 +13,8 @@
setenv STATUSBAR_MIXER_OUTPUT "outputs.master"
setenv STATUSBAR_NETWORK_INTERFACES "alc0 urtwn0"
setenv STATUSBAR_TEMPERATURE_SENSOR "acpitz0:cpu0/cpu1/cpu2/cpu3 temperature"
+ setenv STATUSBAR_UNREAD_EMAILS "yes"
+ setenv STATUSBAR_UNREAD_FEEDS "yes"
It can also be used to print the status bar on the standard output
(`-o'): only one time (`-1' option):
diff -r 7421f516dd3c -r 4c1af169d594 statusbar.sh
--- a/statusbar.sh Tue Feb 27 20:07:53 2018 +0100
+++ b/statusbar.sh Tue Feb 27 23:14:27 2018 +0100
@@ -40,11 +40,38 @@
mixer_output="${STATUSBAR_MIXER_OUTPUT}"
network_interfaces="${STATUSBAR_NETWORK_INTERFACES}"
temperature_sensor="${STATUSBAR_TEMPERATURE_SENSOR}"
+unread_emails="${STATUSBAR_UNREAD_EMAILS}"
+unread_news="${STATUSBAR_UNREAD_NEWS}"
#
# Customizable status command dynamically evaluated every $sleep_time.
#
-status_cmd='status="`network_status` $separator `volume` $separator `cpu_temperature` $separator `battery_status` $separator `unread_mail` $separator `unread_feeds` $separator `what_day_is_it` $separator `what_time_is_it`"'
+status_cmd='status="'
+if [ -n "${network_interfaces}" ]; then
+ status_cmd=$status_cmd' `network_status` $separator'
+fi
+if [ -n "${mixer_mute}" ] && [ -n "${mixer_output}" ]; then
+ status_cmd=$status_cmd' `volume` $separator'
+fi
+if [ -n "${temperature_sensor}" ]; then
+ status_cmd=$status_cmd' `cpu_temperature` $separator'
+fi
+if [ -n "${acad_sensor}" ] && [ -n "${battery_sensor}" ] && [ -n "${battery_charging_sensor}" ]; then
+ status_cmd=$status_cmd' `battery_status` $separator'
+fi
+if [ -n "${unread_emails}" ]; then
+ status_cmd=$status_cmd' `unread_mail` $separator'
+fi
+if [ -n "${unread_news}" ]; then
+ status_cmd=$status_cmd' `unread_feeds` $separator'
+fi
+if [ -n "${date_format}" ]; then
+ status_cmd=$status_cmd' `what_day_is_it` $separator'
+fi
+if [ -n "${clock_format}" ]; then
+ status_cmd=$status_cmd' `what_time_is_it`'
+fi
+status_cmd=$status_cmd'"'
# Sleep time (in seconds) used to refresh the status bar
sleep_time=60