Page 3 of 3 FirstFirst 123
Results 21 to 22 of 22

Thread: Writing a script and running into permissions issues.

  1. #21
    Join Date
    Mar 2007
    Location
    TN, US
    Beans
    607
    Distro
    Ubuntu

    Smile Re: Writing a script and running into permissions issues.

    Working script and config file below, as well as the command I used to launch it successfully!

    Command:
    Code:
    halevt -c /home/brendon/.halevt.xml
    Config file (.halevt.xml):
    Code:
    <?xml version="1.0" encoding="UTF-8"?>
    <halevt:Configuration version="0.1" xmlns:halevt="http://www.environnement.ens.fr/perso/dumas/halevt.html">
    	<halevt:Device match="hal.info.udi = /org/freedesktop/Hal/devices/usb_device_46d_c70e_00076142E023">
    		<halevt:Insertion exec="/home/brendon/bin/toggleTouchpad off"/>
    		<halevt:Removal exec="/home/brendon/bin/toggleTouchpad on"/>
    	</halevt:Device>
    </halevt:Configuration>
    toggleTouchpad:
    Code:
    # toggleTouchpad by Brendon Dugan
    # Toggles a touchpad on or off depending on it's current state or CLI argument
    #
    # To configure, run the command 'xinput list' in terminal and identify your touch pad.
    # Using the output of the above command, change the touchpadString variable to a substring
    # of your touchpad's description that is unique to that device.
    #
    # To run, simply type 'toggleTouchpad' to toggle your touchpad on or off, or
    # 'toggleTouchpad on' to explicitly turn your touchpad on, or
    # 'toggleTouchpad off' to explicitly turn it off.
    #
    # Enjoy!
    touchpadString="TouchPad"
    touchpadID=$(xinput list | grep $touchpadString | awk -F " " '{print $6}' | awk -F "=" '{print $2}')
    touchpadEnabled=$(xinput list-props $touchpadID | grep "Device Enabled" | awk -F ":" '{print $2}')
    sleeptime=1
    
    
    # Check for arguments on the command line
    if test $# -eq 1
    then
    	# Change the argument to lowercase
    	arg1=$(echo $1 | tr [:upper:] [:lower:])
    	cliArg=1
    else
    	# There is no argument.
    	cliArg=0
    fi
    
    if [ $cliArg -eq 1 ]
    then
    	# If there's an argument, check to see whether it is on, off, or junk
    	if [ $arg1 = 'on' ]
    	then
    		# The argument was 'on', so turn the touchpad on 
    		sleep $sleeptime
    		xinput --set-prop $touchpadID "Device Enabled" 1
    	elif [ $arg1 = 'off' ]
    	then
    		# The argument was 'off', so turn the touchpad off 
    		sleep $sleeptime
    		xinput --set-prop $touchpadID "Device Enabled" 0
    	else
    		# The argument was junk, so do nothing 
    		echo $arg1
    		sleep 1
    	fi
    else
    	# There was no argument, so just toggle the touchpad to the opposite
    	# of the state it has now.
    	if [ $touchpadEnabled -eq 1 ]
    	then
    		xinput --set-prop $touchpadID "Device Enabled" 0
    	else
    		xinput --set-prop $touchpadID "Device Enabled" 1
    	fi
    fi
    Thanks for the help!
    Registered Linux user 446122 , Registered Machine 352936.

  2. #22
    Join Date
    Apr 2007
    Beans
    116

    Re: Writing a script and running into permissions issues.

    Thanks for sharing your script.

    I'm compelled to do a similar script to do something when I plugin my mobile phone.

    1. On mobile phone plugged in, trigger script.
    2. Script to synchronise certain files.

    This would make it much easier to keep my mobile phone and my notebook/netbook synced up.

    Ah, Palm ... why did you collapse?

    Thanks again!

Page 3 of 3 FirstFirst 123

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •