Reimplementing a GUI Mouse configuration tool in antiX 23

Forum Forums Official Releases antiX-23 “Arditi del Popolo Reimplementing a GUI Mouse configuration tool in antiX 23

  • This topic has 103 replies, 8 voices, and was last updated Mar 30-10:59 pm by Brian Masinick.
Viewing 15 posts - 1 through 15 (of 104 total)
  • Author
    Posts
  • #135084
    Member
    PPC

      An user recently reported that some of the mouse configuration tool, available in the Control Centre do not work in antiX 23+.
      As always, the community was fast to point out that it was because antiX 23 does not use the old software package that was used to perform that management up until antiX 22, replacing that package with “xinput”. The problem is that the current GUI that manages mouse and touchpad configuration was not updated to use that new package.

      What currently works: you can use the current GUI to configure your pointing device (mouse or touchpad) to work with either the right or the left hand.
      What does not work, but has a work around: The touchpad toggle option present on the GUI does not work at all. If you require that feature, you can use alternative scripts to toggle the touchpad on/off. I developed a script that uses xinput to do just that:
      -First: make sure the xinput package is installed and up to date. You can do it using the Package Manager, synaptic or the terminal:
      sudo apt update && sudo apt install xinput
      -Second: download the attached .zip file, extract the script that’s inside it and then you can run that script to toggle the touchpad on/off. The script provides a on screen notification of the state your touchpad is in (on/off/not present).

      This takes care of that missing feature about the touchpad, for now. A command similar to what the script uses has to be edited into the ds-mouse script that the Program that controls the mouse, from the Control Centre uses…

      Now, everything else I’ll talk about is to try to help developing an updated ds-mouse script…

      *Finding out the current mouse id:
      (this step is required for all other commands I show here)

      #Get the mouse id:
      mouse1=$(xinput list | grep Mouse|cut -d "=" -f 2)
      first_word="${mouse1:0:3}"
      mouse=$(echo "$first_word" | tr -dc '0-9')
      echo Your mouse is device nr "$mouse".

      Listing every feature of the current mouse that can be configured (after running the above command):

      xinput list-props $mouse

      In my case I get this output:

      Device 'PixArt USB Optical Mouse':
      	Device Enabled (124):	1
      	Coordinate Transformation Matrix (126):	1.000000, 0.000000, 0.000000, 0.000000, 1.000000, 0.000000, 0.000000, 0.000000, 1.000000
      	libinput Natural Scrolling Enabled (263):	0
      	libinput Natural Scrolling Enabled Default (264):	0
      	libinput Scroll Methods Available (268):	0, 0, 1
      	libinput Scroll Method Enabled (269):	0, 0, 0
      	libinput Scroll Method Enabled Default (270):	0, 0, 0
      	libinput Button Scrolling Button (271):	2
      	libinput Button Scrolling Button Default (272):	2
      	libinput Button Scrolling Button Lock Enabled (273):	0
      	libinput Button Scrolling Button Lock Enabled Default (274):	0
      	libinput Middle Emulation Enabled (275):	0
      	libinput Middle Emulation Enabled Default (276):	0
      	libinput Accel Speed (277):	0.000000
      	libinput Accel Speed Default (278):	0.000000
      	libinput Accel Profiles Available (279):	1, 1
      	libinput Accel Profile Enabled (280):	1, 0
      	libinput Accel Profile Enabled Default (281):	1, 0
      	libinput Left Handed Enabled (282):	0
      	libinput Left Handed Enabled Default (283):	0
      	libinput Send Events Modes Available (248):	1, 0
      	libinput Send Events Mode Enabled (249):	0, 0
      	libinput Send Events Mode Enabled Default (250):	0, 0
      	Device Node (251):	"/dev/input/event3"
      	Device Product ID (252):	2362, 9488
      	libinput Drag Lock Buttons (265):	<no items>
      	libinput Horizontal Scroll Enabled (266):	1
      	libinput Scrolling Pixel Distance (284):	15
      	libinput Scrolling Pixel Distance Default (285):	15
      	libinput High Resolution Wheel Scroll Enabled (267):	1

      *Changing “Mouse acceleration”:
      As you can see, “mouse acceleration” is mentioned here: libinput Accel Speed (277): 0.000000
      That value ranges from 0 to 1. 0 is “no acceleration”, 1 is “full acceleration”.
      Let’s try to set it to half acceleration (i.e. 0.5) (note: “accel speed is value number 277, so we can refere to that value and then use the contents we want for it):
      xinput set-prop $mouse 277 0.5

      This works.

      I’ll now try to figure how to manager other relevant values, that ds-mouse managed via GUI. All help is welcomed…

      *Reverse (or “Natural”) Scroll:
      To enable it:
      xinput set-prop $mouse 263 1

      To disable it:
      xinput set-prop $mouse 263 0

      P-

      • This topic was modified 1 month, 3 weeks ago by PPC.
      • This topic was modified 1 month, 3 weeks ago by PPC.
      • This topic was modified 1 month, 3 weeks ago by PPC.
      Attachments:
      #135093
      Member
      PPC

        I don’t want to celebrate too early, but it seems that ds-mouse will be easier to edit so it works with xinput than I originaly though.
        It seems that all that requires changing is the bash script, not the python script.
        I already edited my ds-mouse script so it enables/disables Reverse scrolling using xinput, so all other features should be also relatively easy to implement too.
        What need to be edited in ds-mouse:
        -As far as I could tell, synaptics worked universally, for mouse and touchpad settings, xinput works on a per device basis. This means that if we wish to implement configurations universally, we’ll have to check for mouse and touchpad and if each one of those devices is present, then edit the setting that the user want to edit for each of the devices (or both, if they are both connected).
        -The only feature that does not require this complexity are touchpad specific ones, like toggling the touchpad on/off. etc.
        -So we require, on the start of the script a routine that checks for mouse and touchpad device ids (I implemented one that just checks for mouse, because I’m testing this in a desktop, without a touchpad)
        -Each function requires, instead of the synaptic command to check it’s setting, the corresponding xinput command (once for the mouse, once for the touchpad) and also the corresponding xinput to change the required setting (again once for the mouse, once for the touchpad)

        I attach AN EXAMPLE TEST ds-mouse script, that enables/disables reverse scrolling using xinput. It requires xinput to be installed. It works just for mouse, not for touchpad, for now.
        Anyone wishing to test this, please backup ds-mouse and replace it’s contents with the ones on the attached file.

        P.

        • This reply was modified 1 month, 3 weeks ago by PPC.
        Attachments:
        #135113
        Moderator
        caprea

          Tested the touchy-yad-231 on my lenovo t440 laptop, I get “no touchpad found”. Guessing that’s because touchy-yad is looking for touchpad|glidepoint
          Here’s mine , touchpad is ID 12

          $ xinput list
          ⎡ Virtual core pointer                    	id=2	[master pointer  (3)]
          ⎜   ↳ Virtual core XTEST pointer              	id=4	[slave  pointer  (2)]
          ⎜   ↳ PixArt USB Optical Mouse                	id=9	[slave  pointer  (2)]
          ⎜   ↳ Synaptics tm2964-001                    	id=12	[slave  pointer  (2)]
          ⎜   ↳ TPPS/2 IBM TrackPoint                   	id=13	[slave  pointer  (2)]
          ⎣ Virtual core keyboard                   	id=3	[master keyboard (2)]
              ↳ Virtual core XTEST keyboard             	id=5	[slave  keyboard (3)]
              ↳ Power Button                            	id=6	[slave  keyboard (3)]
              ↳ Video Bus                               	id=7	[slave  keyboard (3)]
              ↳ Sleep Button                            	id=8	[slave  keyboard (3)]
              ↳ AT Translated Set 2 keyboard            	id=10	[slave  keyboard (3)]
              ↳ ThinkPad Extra Buttons                  	id=11	[slave  keyboard (3)]

          Thanks.

          #135116
          Member
          PPC

            @Caprea – many thanks for testing! Hum… The fact that it seems that touchpads don’t have a uniform name may cause problem on some devices, since I can’t figure out a way to check the id of all possible touchpad devices…
            I have 2 ideas:
            1- excluding, from the result of the xinput list command all entries that include “Mouse” or “Virtual”, etc… and the ones that are left would be assumed to be a touchpad?
            2- add “synaptics” to the grep command and keep my fingers crossed that there is no other “names” for touchpad devices… Since this is what seems less prone to error, I’ll try that- please download and test the attached revised script…

            P.

            #135128
            Moderator
            caprea

              There’s a typo in touchy-yad-231-b, (touchpad|glidepoint|ynaptics), but even when correcting it to (touchpad|glidepoint|synaptics). I still get “no touchpad detected”.

              • This reply was modified 1 month, 3 weeks ago by caprea.
              #135134
              Member
              PPC

                It wasn’t a typo: I wrote it that way, hoping that the grep command got both “Synaptics” and “synaptics”- it’s an old trick I use, always ommit the first character, so the command works when the first letter is a capital one or not… Please notice that you output has “Synaptics”, you edited the command to include “synaptics”.

                Anyway, I assume that you tried the original and the edited version of the script… I’ll only be able to debut it once I’m home, where I have my netbook and laptop…
                I’m trying blind, where in my desktop with a mouse…

                P.

                #135139
                Moderator
                Brian Masinick

                  @PPC you already wrote this script some time ago!

                  cat ppc-yad-touchpad.bash 
                  #!/usr/bin/env bash
                  # Project: antix-dwm
                  # Location: /usr/local/bin/toggle-touchpad.sh
                  # Dependencies: xinput libnotify-bin dunst
                  # Description: Simple script to enable or disable touchpad and
                  #   send a desktop notification using libnotify.
                  # Usage: dwm calls on use of XF86XK_TouchpadToggle. If your laptop
                  #   does not have a touchpad toggle key, assign to a key combo
                  #   using dwm's config.h file.
                  TOUCHPAD=<code>xinput list | grep -Eio &#039;(touchpad|glidepoint)\s*id\=[0-9]{1,2}&#039;</code>
                  if test "$TOUCHPAD" = "" ; then
                      #notify-send "Touchpad undetected" -t 3000
                      yad  --borders=10 --image="/usr/share/icons/papirus-antix/48x48/emblems/emblem-important.png" --undecorated --geometry=280x50-40-50 --window-icon=/usr/share/icons/Adwaita/48x48/devices/input-touchpad-symbolic.symbolic.png --title="Touchpad Toggle" --text=$"No touchpad detected" --button=" x "  --timeout=3  --timeout-indicator=bottom --on-top --skip-taskbar
                      exit
                  fi
                  ID=<code>grep -Eo &#039;[0-9]{1,2}&#039; <<< &quot;$TOUCHPAD&quot;</code>
                  STATE=<code>xinput list-props $ID|grep &#039;Device Enabled&#039;|awk &#039;{print $4}&#039;</code>
                  if test $STATE -eq 0 ; then
                      xinput enable $ID
                      #notify-send "Touchpad enabled" -t 3000
                      yad --undecorated --geometry=50x50-50-50 --title="Touchpad Toggle" --timeout=3  --skip-taskbar --on-top --button="!/usr/share/icons/papirus-antix/48x48/status/input-touchpad-on.png":1
                  else test $STATE -eq 1 
                      xinput disable $ID
                      #notify-send "Touchpad disabled" -t 3000
                      yad --undecorated --geometry=50x50-50-50 --title="Touchpad Toggle" --timeout=3  --skip-taskbar --on-top --button="!/usr/share/icons/papirus-antix/48x48/status/input-touchpad-off.png":1
                  fi

                  All I did in my personal Touchpad script was to remove the yad stuff, but I have both scripts, and I now have at LEAST THREE scripts that essentially do the same thing – WITH xinput!

                  --
                  Brian Masinick

                  #135140
                  Moderator
                  Brian Masinick

                    Oh yes, even though the tool above mentions dwm, it works just fine with IceWM too!

                    --
                    Brian Masinick

                    #135141
                    Member
                    Robin

                      @PPC, when designing the new script, please take into account:
                      What happens, if user has connected an additional touchpad, so there are two of them in the listing? There are USB- or even wireless touchpads out in the wild:

                      External Touchpad
                      External Touchpad
                      Image source: KKPCW, CC BY-SA 4.0, via Wikimedia Commons

                      Proposal for a solution: Just loop through all matches for touchpad devices, fill them into a pulldown, and let user decide in a dialog which one he wants to have changed.

                      Windows is like a submarine. Open a window and serious problems will start.

                      #135142
                      Moderator
                      Brian Masinick

                        That’s a worthwhile thought too @robin. For the user who is willing to use plain tools, we’ve already provided several of them.

                        The fact is we could probably look for synaptics or xinput, and based on what’s there, handle either one of them.
                        “It’s just code”, after all! 🙂

                        --
                        Brian Masinick

                        #135146
                        Moderator
                        Brian Masinick

                          Pseudo code:

                          Setup: establish parameters to search for and store values for either synaptics or xinput/libinput peripherals.

                          Logic Blocks:
                          1) Manage the traditional scenarios for synaptics; these exist in the current ds-mouse/ds-mouse.py code.
                          2) Manage the scenarios for xinput/libinput; these need to be added as another conditional branch.
                          3) If there are STILL other alternatives that do not show up for either synaptics or the xinput style, list and identify them; if there are any others, this becomes information to add to additional conditions and logic blocks.
                          4) If all fails, note it in either a log or the output; based on the “alarm” we get when users see “unexpected information”, perhaps a well-documented log configuration is preferable to “scaring” users with warnings or errors; this is left to the discretion of design and code implmentation; these are simply logic ideas.

                          --
                          Brian Masinick

                          #135147
                          Member
                          PPC

                            Yes, Mr Masinick- I’m currently trying to update that older script. Like Caprea noticed, unfortunatly, it fails to work for everyone.
                            For now, I edited the original script (after testing it against a file that had Caprea’s output from his post above, so it can work for him. One step at a time… later, we’ll take care of giving user’s the option to choose, if there’s are more than 1 touchpad: there’s the possibility of having multiple pointing devices connected at the same time, but I think the most usual situation is just a touchpad and a mouse, right?

                            @Caprea- when possible, please retest the updated script… it *should* work…

                            P.

                            #135152
                            Member
                            Robin

                              but I think the most usual situation is just a touchpad and a mouse, right?

                              On the contrary. If a user is tired of flipping the cursor around fiercely on screen when just typing on his notebook, and has acquired an external touchpad, he surely wants to do two things: Disable the internal touchpad, and setting up the external one according to his needs, concerning sensivity, acceleration etc. And now already you have two of them in the listing…

                              Windows is like a submarine. Open a window and serious problems will start.

                              #135153
                              Member
                              PPC

                                I just edit my test “revised” version of ds-mouse: that I ask folks to test: as above, back-up the original ds-mouse script, replace it’s contents with the ones from this file, launch ds-mouse.

                                What *should* work:
                                – enable/disable the touchpad
                                – enable/disable reverse scrolling

                                What probably won’t be easy to re-implement:
                                – the touchpad lockout, since xinput does not include a daemon (there are several available on-line, I checked, but I did not test anyone of them).

                                What’s missing from my end, that I can try to implement in xinput:
                                – mouse acceleration.

                                Attachments:
                                #135155
                                Member
                                PPC

                                  @Robin – on my own, I tried to reimplement what I could in xinput. The result of my work is here on this thread. Any change of you lending a hand on this??? (Plea extended to anyone that can code, mainly @Dave)

                                  P.

                                Viewing 15 posts - 1 through 15 (of 104 total)
                                • You must be logged in to reply to this topic.