#!/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 --notification --title="$version" --text="Wireless has been enabled" } function UpdateStatusOFF { echo "Wireless OFF" > "$statusfile" zenity --notification --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 [ -z $statusfile ] ; then # zenity --error --title="$version" --text="Something is wrong with $statusfile" # EnableWireless # UpdateStatusOn fi #check status and act accordingly if [ $(cat $statusfile) == "Wireless ON" ] ; then DisableWireless UpdateStatusOFF elif [ $(cat $statusfile) == "Wireless OFF" ] ; then EnableWireless UpdateStatusON else Error fi