From 318568fb6db4981692d7b2abc5e0a42f0907a2b5 Mon Sep 17 00:00:00 2001
From: Luke Shumaker <LukeShu@sbcglobal.net>
Date: Wed, 10 Oct 2012 01:21:52 -0400
Subject: wmii: use a connected_to_x_server function

---
 .wmii/include.sh   | 5 +++++
 .wmii/rbar_battery | 3 +--
 .wmii/rbar_clock   | 3 +--
 .wmii/rbar_cpu     | 3 +--
 .wmii/rbar_wifi    | 3 +--
 5 files changed, 9 insertions(+), 8 deletions(-)

diff --git a/.wmii/include.sh b/.wmii/include.sh
index 36f8f3e..f4b29b3 100644
--- a/.wmii/include.sh
+++ b/.wmii/include.sh
@@ -68,3 +68,8 @@ Action() {
 		return 1
 	fi
 }
+
+connected_to_x_server() {
+        xdpyinfo &>/dev/null
+        return $?
+}
diff --git a/.wmii/rbar_battery b/.wmii/rbar_battery
index 7a7f24f..0e70799 100755
--- a/.wmii/rbar_battery
+++ b/.wmii/rbar_battery
@@ -3,8 +3,7 @@
 
 priority=$1
 
-set -e
-while true; do
+while connected_to_x_server; do
 	acpi -b |a "$WMII_DIR/rbar/${priority}_battery"
 	sleep 1
 done
diff --git a/.wmii/rbar_clock b/.wmii/rbar_clock
index 8e7d2a4..86bf14d 100755
--- a/.wmii/rbar_clock
+++ b/.wmii/rbar_clock
@@ -3,8 +3,7 @@
 
 priority=$1
 
-set -e
-while true; do
+while connected_to_x_server; do
 	date |a "$WMII_DIR/rbar/${priority}_clock"
 	sleep .5
 done
diff --git a/.wmii/rbar_cpu b/.wmii/rbar_cpu
index 7f891da..d3bdd88 100755
--- a/.wmii/rbar_cpu
+++ b/.wmii/rbar_cpu
@@ -3,8 +3,7 @@
 
 priority=$1
 
-set -e
-while true; do
+while connected_to_x_server; do
 	# This doesn't work for me, it shows capacity
 	#echo -n 'Core MHz:' $(cat /proc/cpuinfo | grep 'cpu MHz' | sed 's/.*: //g; s/\..*//g;') |a "$WMII_DIR/rbar/${priority}_cpu"
 	# This actually displays %idle
diff --git a/.wmii/rbar_wifi b/.wmii/rbar_wifi
index 608b164..2ea84a3 100755
--- a/.wmii/rbar_wifi
+++ b/.wmii/rbar_wifi
@@ -3,8 +3,7 @@
 
 priority=$1
 
-set -e
-while true; do
+while connected_to_x_server; do
 	echo 'Wlan0:' $(iwconfig wlan0 | sed 's/ /\n/g' | grep Quality) |a "$WMII_DIR/rbar/${priority}_wifi"
 	sleep 1
 done
-- 
cgit v1.2.3-2-g168b