|
| 1 | +#!/bin/bash |
| 2 | +# Copyright (C) 2014 Alexander Keller <[email protected]> |
| 3 | + |
| 4 | +# This program is free software: you can redistribute it and/or modify |
| 5 | +# it under the terms of the GNU General Public License as published by |
| 6 | +# the Free Software Foundation, either version 3 of the License, or |
| 7 | +# (at your option) any later version. |
| 8 | + |
| 9 | +# This program is distributed in the hope that it will be useful, |
| 10 | +# but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 11 | +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 12 | +# GNU General Public License for more details. |
| 13 | + |
| 14 | +# You should have received a copy of the GNU General Public License |
| 15 | +# along with this program. If not, see <http://www.gnu.org/licenses/>. |
| 16 | + |
| 17 | +#------------------------------------------------------------------------ |
| 18 | +if [[ -z "$INTERFACE" ]] ; then |
| 19 | + INTERFACE="${BLOCK_INSTANCE:-wlan0}" |
| 20 | +fi |
| 21 | +#------------------------------------------------------------------------ |
| 22 | + |
| 23 | +# As per #36 -- It is transparent: e.g. if the machine has no battery or wireless |
| 24 | +# connection (think desktop), the corresponding block should not be displayed. |
| 25 | +# Similarly, if the wifi interface exists but no connection is active, show |
| 26 | +# nothing |
| 27 | +[[ ! -d /sys/class/net/"${INTERFACE}"/wireless || \ |
| 28 | + "$(cat /sys/class/net/"$INTERFACE"/operstate)" = 'down' ]] && exit |
| 29 | + |
| 30 | +#------------------------------------------------------------------------ |
| 31 | + |
| 32 | +SSID=$(iw "$INTERFACE" info | awk '/ssid/ {print $2}') |
| 33 | + |
| 34 | +#------------------------------------------------------------------------ |
| 35 | + |
| 36 | +echo "$SSID" # full text |
| 37 | +echo "$SSID" # short text |
| 38 | +echo "#00FF00" # color |
0 commit comments