Netcfg Archlinux


 

 

Utilité : Affiche un icône de notification en fonction de l'état de la connection Wifi ( pour le filaire, il n' y a qu'un icone ) à l'aide de genmon-plugin.

 Dépendances : xfce4, xfce4-genmon-plugin, ifconfig,iwconfig ( et Netcfg pour la connexion wifi )
 

Attention: Le script est vide, sans images. Vous pouvez recuperer les icones de network-manager par exemple

( ou ceux ci )  et adapter leurs tailles à celles de votre panel. 

N'oubliez pas d'apdapter les chemins dans le scripts.

 

Telechargement : Script + Icones ( basé sur le super thème Dropline Neu! )

 

 Script seul :

 #!/bin/bash

## Parametres ##
ETHERNET="eth0"
WIFI="eth1"
DOSSIER="/home/$USER/.scripts/wifi"

if [ -n "`ifconfig "$WIFI" | awk '/inet addr/{print $2}' | cut -f2 -d:`" ] ; then INTERFACE="$WIFI"
elif [ -n "`ifconfig "$ETHERNET" | awk '/inet addr/{print $2}' | cut -f2 -d:`" ] ; then INTERFACE="$ETHERNET"
fi

case "$INTERFACE" in

"$WIFI")
    QUALITY=`iwconfig "$INTERFACE" | awk '/Link Quality/{print $2}' | cut -f2 -d= | cut -f1 -d/`
    case "$QUALITY" in
    100|9[0-9]|8[0-9]) ICON="100.png";;
    7[0-9]|6[0-9]) ICON="75.png";;
    5[0-9]|4[0-9]) ICON="50.png";;
    3[0-9]2[0-9]) ICON="25.png";;
    1[0-9]|9|8|7|6|5|4|3|2|1) ICON="00.png";;
    esac
    if [ "$QUALITY" == "Quality:0" ] ; then ICON="00.png" ; fi
    ICON_48="100-48.png" ; MESSAGE="Connecté sur $WIFI" ; SIGNAL="Signal $QUALITY %"
;;

"$ETHERNET") ICON="network.png" ; ICON_48="network-48.png" ; MESSAGE="Connecté sur $ETHERNET"
;;

*) MESSAGE="Connexion..."
   if [ -n "`ifconfig "$ETHERNET" | awk '/BROADCAST RUNNING/'`" ] ; then ICON="network.gif" ; ICON_48="network-con.png"
   elif [ "`ifconfig "$WIFI" | awk '/BROADCAST RUNNING/'`" ] ; then ICON="00.gif" ; ICON_48="100-con.png"
   else ICON="error.png" ; ICON_48="error-48.png" ; MESSAGE="Deconnecté"
   fi
;;
esac

if [ -n "$INTERFACE" ] ; then IP=`ifconfig "$INTERFACE" | awk '/inet addr/{print $2}' | cut -f2 -d:` ;
elif [ -z "$INTERFACE" ] ; then IP="$MESSAGE" ;fi

## Notification ##
if [ "`cat "$DOSSIER/Notif"`" != "$MESSAGE" ] ; then rm "$DOSSIER/Notif"; fi
if [ ! -e "$DOSSIER/Notif" ] ; then notify-send "$MESSAGE" -i "$DOSSIER/Icones/$ICON_48" ; echo "$MESSAGE" > "$DOSSIER/Notif" ; fi

## Affichage genmonplugin ##
echo "<img>$DOSSIER/Icones/$ICON</img>"
echo "<tool>$IP
    $SIGNAL</tool>"
#echo    "<click>/home/$USER/.scripts/wifi/netcfg</click>"

exit 0

 

 


Plan du site Version imprimable Envoyer un mailLivre d'or


Flux Rss