2 # hiddev != hidraw, hiddev does parsing and more, not hidraw
3 effects
='rainbow-shift|breath-fast|breath|breath-slow|steady|rainbow-breath|disco'
7 rainbow-shift
) effect
=00;;
8 breath-fast
) effect
=01;;
10 breath-slow
) effect
=03;;
12 rainbow-breath
) effect
=05;;
15 printf "\nERROR:invalid effect ($effects)\n"
21 # not implemented, because factory default value is ok
22 # set polling rate in Hz:
24 # suffix=00 00 00 00 00 00
29 # 1000 Hz=01 (factory default)
30 USAGE
="Usage: $0 -z1 color(hex 3 bytes rrggbb) -z2 color(hex 3 bytes rrggbb) -z3 color(hex 3 bytes rrggbb) -logo color(hex 3 bytes rrggbb) -s dpi1,dpi2,dpi3,dpi4,dpi5(40-8500/40 increment) -e effect($effects) -save"
31 if test $# -eq 0; then
38 # product_id=0x182c, firmware v0.37.0.0
39 # endpoint index 3 (there are 4 endpoints)
41 for l
in /sys
/class
/hidraw
/*; do
42 if readlink
-f $l |
egrep '1038:1824' >/dev
/null
2>&1; then
43 if test $endpoint -eq 3; then
44 rival3
=/dev
/$
(basename $l)
47 endpoint
=$
(($endpoint + 1))
48 elif readlink
-f $l |
egrep -i '1038:182c' >/dev
/null
2>&1; then
49 if test $endpoint -eq 3; then
50 rival3
=/dev
/$
(basename $l)
53 endpoint
=$
(($endpoint + 1))
57 if test "${rival3-unset}" = unset; then
58 echo ERROR
:unable to
locate a rival3
64 while test $# -ne 0; do
67 if test "$2" = ""; then
75 if test "$2" = ""; then
83 if test "$2" = ""; then
91 if test "$2" = ""; then
99 if test "$2" = ""; then
100 echo missing sensitivities
107 if test "$2" = ""; then
125 # each command is padded to 9 bytes
126 if test "${rgb_hex_z1-unset}" != unset; then
127 echo "rgb_hex_z1=$rgb_hex_z1";
128 cmd_hex
=050001${rgb_hex_z1}64
130 if test "${rgb_hex_z2-unset}" != unset; then
131 echo "rgb_hex_z2=$rgb_hex_z2";
132 cmd_hex
=050002${rgb_hex_z2}64
134 if test "${rgb_hex_z3-unset}" != unset; then
135 echo "rgb_hex_z3=$rgb_hex_z3";
136 cmd_hex
=050003${rgb_hex_z3}64
138 if test "${rgb_hex_logo-unset}" != unset; then
139 echo "rgb_hex_logo=$rgb_hex_logo";
140 cmd_hex
=0500004${rgb_hex_logo}64
142 if test "${sensitivities-unset}" != unset; then
143 printf "sensitivities = $sensitivities"
147 sensitivities_rounded
="/rounded_to ="
148 for dpi
in $sensitivities
150 dpi_step
=$
(printf "$dpi/40" |
bc)
151 dpi_rounded
=$
(printf "$dpi_step * 40" |
bc)
152 sensitivities_rounded
="${sensitivities_rounded} ${dpi_rounded}"
153 if test $dpi_rounded -lt 40; then
154 printf "\n$dpi_rounded from $dpi is below 40\n"
157 if test $dpi_rounded -gt 8500; then
158 printf "\n$dpi_rounded from $dpi is above 8500\n"
161 output
=$
(($dpi_step - 1))
162 output_hex
=$
(printf "%02x" $output)
163 sensitivities_hex
="${sensitivities_hex}$output_hex"
164 dpi_n
=$
(printf "%02x" $
(($dpi_n + 1)))
167 printf "$sensitivities_rounded"
168 if test $dpi_n -gt 5; then
169 printf "\ndpi preset count is above 5\n"
172 echo "/hexcode = ${dpi_n}${sensitivities_hex}"
173 cmd_hex
=${cmd_hex}0b00${dpi_n}01${sensitivities_hex}
175 if test "${effect-unset}" != unset; then
176 printf "effect=$effect"
178 echo "/hexcode=$effect"
179 cmd_hex
=${cmd_hex}0600${effect}
181 # must be last for an obvious reason
182 if test "${save-unset}" != unset; then
183 echo "****will save settings in mouse persistent memory****"
184 cmd_hex
=${cmd_hex}0900
186 printf "00:$cmd_hex\n" | xxd
-r >$rival3