#!/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-status version=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 wireless if [ ! -e $statusfile ] ; then zenity --error --title="$version" --text="Something is wrong with $statusfile" enablewireless updatestatuson fi #check status and act accordingly read line < "$statusfile" if [ "$line" == "Wireless ON" ] ; then DisableWireless updatestatusoff elif [ "$line" == "Wireless OFF" ] ; then enablewireless updatestatuson else Error fi