3
\$\begingroup\$

This sequence properly shows whether the TouchpadOff option for synclient is on or not (outputs either a 0 or a 1):

synclient | grep 'TouchpadOff' | tail -n 1 | awk '{print substr(3,ドル 1)}'

Trying to make a keyboard shortcut to toggle the touchpad with a basic script based on that line, I wrote this:

#!/bin/bash
PADOFF=$(synclient | grep 'TouchpadOff' | tail -n 1 | awk '{print substr(3,ドル 1)}')
if [ "$PADOFF" == "0" ]
then
 synclient TouchpadOff=1
else
 synclient TouchpadOff=0
fi.
asked Mar 18, 2015 at 11:51
\$\endgroup\$
0

1 Answer 1

3
\$\begingroup\$

I don't understand the purpose of substr(3,ドル 1) — isn't that the same as 3ドル?

AWK alone can do the work of grep, tail, and negation. I would write it this way:

synclient TouchpadOff=$(synclient | awk '/TouchpadOff/ { off=int(3ドル) }
 END { print !off }')
answered Mar 18, 2015 at 13:01
\$\endgroup\$

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.