summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Stapelberg <stapelberg@users.noreply.github.com>2015-04-12 09:12:22 -0700
committerMichael Stapelberg <stapelberg@users.noreply.github.com>2015-04-12 09:12:22 -0700
commitdedea6266bb3771c51493d690f8835beb9520c24 (patch)
tree22949db2e22c71cdf2c097313132eac14eac0223
parentab89f73656d92ccf8fd8119318b50eca0529c207 (diff)
parent5e8303ef17beee56a03b41a7ded46f983ac1efc6 (diff)
Merge pull request #23 from Deiz/net-speed
Basic XDG support and minor tweaks to the net-speed script
-rwxr-xr-xcontrib/net-speed14
1 files changed, 12 insertions, 2 deletions
diff --git a/contrib/net-speed b/contrib/net-speed
index 3b7b30b..ca0a850 100755
--- a/contrib/net-speed
+++ b/contrib/net-speed
@@ -44,13 +44,23 @@ ifaces=$(ls /sys/class/net | grep -E '^(eth|wlan)')
# Interval must be the same as in i3status.conf
#interval=5
+if [ -z "$XDG_CONFIG_HOME" ]; then
+ XDG_CONFIG_HOME="${HOME}/.config"
+fi
+
# Auto detect
-if [ -f ~/.i3status.conf ]; then
+if [ -f "${XDG_CONFIG_HOME}/i3status/config" ]; then
+ i3status_conf="${XDG_CONFIG_HOME}/i3status/config"
+elif [ -f ~/.i3status.conf ]; then
i3status_conf=~/.i3status.conf
else
i3status_conf="/etc/i3status.conf"
fi
-interval=$(grep -o '^[[:space:]]*interval[[:space:]]*=[[:space:]]*[[:digit:]]\+' $i3status_conf | grep -o '[[:digit:]]\+')
+
+if [ -f "$i3status_conf" ]; then
+ interval=$(grep -o '^[[:space:]]*interval[[:space:]]*=[[:space:]]*[[:digit:]]\+' $i3status_conf | grep -o '[[:digit:]]\+')
+fi
+
if [ x"$interval" = x ]; then
interval=5
fi