Score:2

How to get value of synclient parameter?

cn flag

synclient enables you to change its parameters' values, e.g.:

synclient TouchpadOff=0

Is there a possibility to access the value, print it, for instance?

I'd like to be able to set a value depending on the current value, e.g.:

synclient TouchpadOff=abs($TouchpadOff.value - 1)
Score:2
ng flag

synclient or synclient -l then cut it from there.

toggle_value=$(synclient -l | awk '$1=="TouchpadOff" {print 2-$(NF)}')
synclient TouchpadOff=$toggle_value
maciejwww avatar
cn flag
Thanks, but there is a mistake somewhere.
user.dz avatar
ng flag
@maciejwww could you add output of `synclient -l` to the question? Do `synclient TouchpadOff=1` & `synclient TouchpadOff=0` works as direct commands?
maciejwww avatar
cn flag
Yes, they work.
user.dz avatar
ng flag
@maciejwww probably missed `echo` in first command, updated the answer
Raffa avatar
jp flag
You probably want `toggle_value=$(echo "1 - $(synclient -l | awk '$1=="TouchpadOff" {printf "%d", $(NF)}')" | bc)` ... Also I think you can do the arithmetic in bash without `bc`
Score:2
cn flag

I found out an answer thank to @user.dz answer:

touchpadoff_value=$(synclient -l | awk '$1=="TouchpadOff" {print $(NF)}'); (( tmp_value =  $touchpadoff_value - 1 )); synclient TouchpadOff=${tmp_value#-}
  • to obtain TouchpadOff value:
$(synclient -l | awk '$1=="TouchpadOff" {print $(NF)}')
  • to get absolute value of tmp_value:
${tmp_value#-}
I sit in a Tesla and translated this thread with Ai:

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.