aboutsummaryrefslogtreecommitdiff
path: root/i3blocks
diff options
context:
space:
mode:
Diffstat (limited to 'i3blocks')
-rwxr-xr-xi3blocks/i3internet.sh31
-rwxr-xr-xi3blocks/i3music.sh7
2 files changed, 23 insertions, 15 deletions
diff --git a/i3blocks/i3internet.sh b/i3blocks/i3internet.sh
index 2f55fd2..4065a31 100755
--- a/i3blocks/i3internet.sh
+++ b/i3blocks/i3internet.sh
@@ -8,30 +8,37 @@ case $BLOCK_BUTTON in
esac
wifiDev="wlp2s0"
-ethDev="enp3s0"
-wstatus=$(cat /sys/class/net/$wifiDev/operstate)
-estatus=$(cat /sys/class/net/$ethDev/operstate)
+ethDev=""
+wstatus="$(cat /sys/class/net/$wifiDev/operstate)"
+estatus="$(cat /sys/class/net/$ethDev/operstate)"
+tick=✅
+wifiSymbol="📶"
+ethSymbol="🌐"
if [ "$wstatus" = "down" ]; then
wifi="❌"
-elif [ "$(nmcli | grep "$wifiDev: connecting ")" ]; then
- step="$(nmcli | grep "$wifiDev: connecting " | sed 's/^.*(/(/;s/).*$/)/')"
- wifi="⚙️ <span color='#fabd2f'>$(nmcli | grep "$wifiDev: " | cut -d' ' -f5-) $step</span>"
+elif [ "$(nmcli | fgrep "$wifiDev: connecting ")" ]; then
+ step="$(nmcli | fgrep "$wifiDev: connecting " | sed 's/^.*(/(/;s/).*$/)/')"
+ wifi="$tick <span color='#fabd2f'>$(nmcli | fgrep "$wifiDev: " | cut -d' ' -f5-) $step</span>"
else
# with IP
- #wifi="✔️$(nmcli | grep "$wifiDev: connected to " | cut -d' ' -f4-) ($(ip addr show $wifiDev | grep "inet " | cut -d' ' -f6)) ($(grep "^\s*w" /proc/net/wireless | awk '{print int($3 * 100 / 70)"%"}'))"
+ #wifi="$tick$(nmcli | fgrep "$wifiDev: connected to " | cut -d' ' -f4-) ($(ip addr show $wifiDev | fgrep "inet " | cut -d' ' -f6)) ($(egrep "^\s*w" /proc/net/wireless | awk '{print int($3 * 100 / 70)"%"}'))"
# with name
- wifi="✔️ <span color='#79ff79'>$(nmcli | grep "$wifiDev: connected to " | cut -d' ' -f4-) ($(grep "^\s*w" /proc/net/wireless | awk '{print int($3 * 100 / 70)"%"}'))</span>"
+ wifi="$tick <span color='#79ff79'>$(nmcli | fgrep "$wifiDev: connected to " | cut -d' ' -f4-) ($(egrep '^\s*w' /proc/net/wireless | awk '{print int($3 * 100 / 70)"%"}'))</span>"
fi
-if [ -z "$(nmcli | grep $ethDev)" ]; then
+
+[ -z "$ethDev" ] && echo "$wifiSymbol$wifi" && exit 0
+
+if [ -z "$(nmcli | fgrep "$ethDev")" ]; then
en="❌❗ No $ethDev"
elif [ "$estatus" = "down" ]; then
en="❌"
else
# with IP
- #en=$(ip addr show $ethDev | grep "inet " | cut -d' ' -f6)
+ #en=$(ip addr show $ethDev | fgrep "inet " | cut -d' ' -f6)
# no IP
- en=✔️
+ en=$tick
fi
-echo "📶$wifi 🌐$en"
+echo "$wifiSymbol$wifi $ethSymbol$en"
+exit 0
diff --git a/i3blocks/i3music.sh b/i3blocks/i3music.sh
index cad0b66..d446b50 100755
--- a/i3blocks/i3music.sh
+++ b/i3blocks/i3music.sh
@@ -7,18 +7,19 @@ case $BLOCK_BUTTON in
esac
symbol=🎵
-ampersand="I"
+ampersand='and' # & in echo messes up script
pgrep -x cmus >/dev/null || exit 0
stat="$(cmus-remote -Q | grep "^status " | awk '{print $2}' | sed "s/&/$ampersand/")"
artist="$(cmus-remote -Q | grep "^tag artist " | cut -d' ' -f3- | sed "s/&/$ampersand/")"
title="$(cmus-remote -Q | grep "^tag title " | cut -d' ' -f3- | sed "s/&/$ampersand/")"
[ -z "$artist" ] && artist="(unknown)"
-[ -z "$title" ] && title="$(basename "$(cmus-remote -Q | grep "^file" | cut -d' ' -f2- | sed "s/&/$ampersand/")")" # sed to fix & in title messing up script
+[ -z "$title" ] && title="$(basename "$(cmus-remote -Q | grep "^file" | cut -d' ' -f2- | sed "s/&/$ampersand/")")"
if [ "$stat" = "playing" ]; then
- #echo "$symbol $artist ─ $title"
echo "$symbol $artist ─ $title"
+ echo "$symbol ...$title"
elif [ "$stat" = "paused" ]; then
echo "$symbol ( $artist ─ $title )"
+ echo "$symbol ( ...$title )"
else
echo "$symbol $stat"
fi