@@ -173,15 +173,53 @@ function buffer {
173173# #########
174174
175175
176+ function _program_running {
177+ pgrep -f " $BASENAME " | fgrep -v $$ > /dev/null 2>&1
178+ }
179+
180+
176181# verbosely show comfortable-swipe status
177182function status {
178- # TODO: show configuration status as well
183+ # show autostart status
179184 echo " Autostart is $( " $BASENAME " autostart status) "
180- if pgrep -f " $BASENAME " | fgrep -v $$ > /dev/null 2>&1 ; then
185+ # show program status
186+ if _program_running; then
181187 echo " Program is RUNNING"
182188 else
183189 echo " Program is STOPPED"
184190 fi
191+ # show configuration status
192+ echo --------------------
193+ echo " Configuration: $( config path) "
194+ mouse3=" $( config get mouse3) "
195+ mouse4=" $( config get mouse4) "
196+ for key in $( config keys) ; do
197+ value=" $( config get " $key " ) "
198+ if [[ -z " $value " ]]; then
199+ vstatus=" NOTSET"
200+ else
201+ vstatus=" VALID"
202+ if [[ " $key " != mouse* ]]; then
203+ if [[ " $key " == * 3 && -n " $mouse3 " ]]; then
204+ vstatus=" IGNORED"
205+ elif [[ " $key " == * 4 && -n " $mouse4 " ]]; then
206+ vstatus=" IGNORED"
207+ fi
208+ fi
209+ if [[ " $key " == threshold ]]; then
210+ if ! [[ " $value " =~ ^[+-]? [0-9]+\. ? [0-9]* $ ]]; then
211+ # not a float
212+ vstatus=" INVALID"
213+ fi
214+ fi
215+ fi
216+ echo " $key $vstatus " | awk ' {printf "%9s is %7s", $1, $2}'
217+ if [[ ! -z " $value " ]]; then
218+ echo " ($value )"
219+ else
220+ echo
221+ fi
222+ done
185223}
186224
187225
@@ -291,8 +329,7 @@ function config {
291329 local RESULT=" $( egrep -v " ^\\ s*($( echo " $DELETE " | awk ' {print $1}' | paste -s -d ' |' ) )\\ s*=" " $CONFIG " ) "
292330 echo " $RESULT " > " $CONFIG "
293331 # restart comfortable-swipe if it is running
294- if [[ " $( status) " == ON ]]; then
295- stop > /dev/null 2>&1
332+ if _program_running; then
296333 start > /dev/null
297334 fi
298335 fi
@@ -378,8 +415,7 @@ function config {
378415 # show newly set value
379416 echo " $KEY = $( get " $KEY " ) "
380417 # restart comfortable-swipe if it is running
381- if [[ " $( status) " == ON ]]; then
382- stop > /dev/null 2>&1
418+ if _program_running; then
383419 start > /dev/null
384420 fi
385421 }
@@ -451,7 +487,7 @@ function autostart {
451487 # ####################################
452488 # toggle to opposite autostart status
453489 function toggle {
454- [[ $( status) = ON ]] && off || on
490+ [[ $( status) == ON ]] && off || on
455491 }
456492
457493 # #####################
495531 # try to invoke config set / get depending on number of arguments
496532 if [[ $# -eq 1 ]]; then
497533 # one argument, use shorthand get
498- " $BASENAME " config get " $1 " || abort
534+ config get " $1 " || abort
499535 else
500536 # multiple arguments, use shorthand set
501- " $BASENAME " config set " $@ " 2> /dev/null || abort
537+ config set " $@ " 2> /dev/null || abort
502538 fi
503539fi
0 commit comments