#!/bin/bash## Quick shell script to be initiated by the wireless button on laptop## Will be run with command "gksudo SCRIPTNAME"########################## Defining Variables ##########################statusfile=/etc/wireless-statusversion=TogglEd-0.3########################## Defining Functions ##########################function enablewireless { chmod 777 /proc/acpi/acer/wireless ##gksudo/sudo not necessarily transportable over all systems echo "enabled : 1" > /proc/acpi/acer/wireless}function disablewireless { chmod 777 /proc/acpi/acer/wireless ##gksudo/sudo not necessarily transportable over all systems echo "enabled : 0" > /proc/acpi/acer/wireless}function updatestatuson { echo "Wireless ON" > "$statusfile" zenity --info --title="$version" --text="Wireless has been enabled"}function updatestatusoff { echo "Wireless OFF" > "$statusfile" zenity --info --title="$version" --text="Wireless has been disabled"}function Error { zenity --error --title="$version" --text="Something is wrong with $statusfile"}############ Main #############if no statusfile, turn on wirelessif [ ! -e $statusfile ] ; then zenity --error --title="$version" --text="Something is wrong with $statusfile" enablewireless updatestatusonfi#check status and act accordinglyread line < "$statusfile"if [ "$line" == "Wireless ON" ] ; then DisableWireless updatestatusoffelif [ "$line" == "Wireless OFF" ] ; then enablewireless updatestatusonelse Errorfi