\$\begingroup\$
\$\endgroup\$
0
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.
1 Answer 1
\$\begingroup\$
\$\endgroup\$
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
lang-bash