WelcomeWelcome | FAQFAQ | DownloadsDownloads | WikiWiki

Author Topic: AutoCursor extension submitted  (Read 15249 times)

Offline Rich

  • Administrator
  • Hero Member
  • *****
  • Posts: 11694
AutoCursor extension submitted
« on: January 31, 2021, 01:18:41 AM »
I recently came across this:
... On Ubuntu (on Unity desktop), you can even have a touchscreen and a mouse connected simultaneously and when moving the mouse, the cursor appears and when touching the touchscreen, the cursor disappears, and it reappears again when using the mouse (and so on), so the cursor is being dynamically hidden or shown depending on what kind of input device is currently in use.

That being said: Any idea how this could also be achieved in Tiny Core Linux?
That piqued my interest, so I decided to take a crack at it.

AutoCursor has been added to the TC10 x86 and x86_64 repositories. It's only dependency is libXfixes. Here's the .info file:
http://tinycorelinux.net/10.x/x86/tcz/AutoCursor.tcz.info

This is the usage message:
Code: [Select]
tc@E310:~/C_Programs/AutoCursor$ ./AutoCursor

AutoCursor version 0.10 Jan 30 2021 22:13:00
Copyright Richard A. Rost Jan 25,2021

AutoCursor controls cursor visibility based on device
events, such as mouse, keyboard, touch screen, etc.

Usage: AutoCursor [-sN] [-hN] [-i] [-e] [-S file] [-L file]

        -s N    Show cursor when event N occurs.
        -h N    Hide cursor when event N occurs.
        -i      Initial state of cursor is hidden.
        -e      Display list of available events.
        -S file Save event settings to file.
        -L file Load event settings from file.

Example: AutoCursor -i -s5 -h1 -h3 -s2 -S ~/.cursor.conf

Starts with cursor hidden.
Shows cursor when events 5 or 2 occur.
Hides cursor when events 1 or 3 occur.
Saves the event settings (but not -i) to a file.

tc@E310:~/C_Programs/AutoCursor$

The first thing to do is scan the  /dev/input/  directory and get a list of events and their descriptions:
Code: [Select]
tc@E310:~/C_Programs/AutoCursor$ sudo ./AutoCursor -e
Event#  Input device name
0:      "Power Button"
1:      "Power Button"
2:      "Logitech USB-PS/2 Optical Mouse"
3:      "PC Speaker"
4:      "DELL DELL USB Keyboard"
5:      "HDA Intel Mic"
6:      "HDA Intel Line"
7:      "HDA Intel Line Out"
8:      "HDA Intel Front Headphone"
tc@E310:~/C_Programs/AutoCursor$

To hide the cursor when typing, show the cursor when using the mouse, and create a settings file:
Code: [Select]
sudo ./AutoCursor -h4 -s2 -S ~/.cursor.conf &
This is what the settings file looks like:
Code: [Select]
tc@E310:~/C_Programs/AutoCursor$ cat ~/.cursor.conf
s:"Logitech USB-PS/2 Optical Mouse"
h:"DELL DELL USB Keyboard"
tc@E310:~/C_Programs/AutoCursor$

Although I haven't tried it under TC11 or higher, I have no reason to believe it won't work. I did copy the 32 bit binary to
my TC4 machine and it ran without any issues.
« Last Edit: January 31, 2021, 09:07:57 AM by Rich »

Offline jazzbiker

  • Hero Member
  • *****
  • Posts: 934
Re: AutoCursor extension submitted
« Reply #1 on: January 31, 2021, 01:46:14 AM »
Hi, Rich!

Your AutoCursor is just a tasty candy! May I take one more, please? :)

Offline jazzbiker

  • Hero Member
  • *****
  • Posts: 934
Re: AutoCursor extension submitted
« Reply #2 on: January 31, 2021, 09:00:43 AM »
Hi, Rich!

AutoCursor is overwhelmingly convenient. I vote for updating Xorg-7.7.tcz.info and adding
Code: [Select]
        Recommended: AutoCursor.tcz
line to the Comments section.

This bothering cursor made me avoid X, now I feel it's fun :)

Best regards!

PS

there is typo in http://tinycorelinux.net/10.x/x86/tcz/AutoCursor.tcz..info - doubled point, and You didn't mentioned in the info file, were we can obtain the sources. Isn't it GPLv2 ;) ?
« Last Edit: January 31, 2021, 09:04:35 AM by jazzbiker »

Offline Rich

  • Administrator
  • Hero Member
  • *****
  • Posts: 11694
Re: AutoCursor extension submitted
« Reply #3 on: January 31, 2021, 09:16:40 AM »
Hi jazzbiker
... AutoCursor is overwhelmingly convenient. ...
Glad you like it.

Quote
... there is typo in http://tinycorelinux.net/10.x/x86/tcz/AutoCursor.tcz..info - doubled point ...
Oops. :-[ Thanks, fixed. :)

Quote
... You didn't mentioned in the info file, were we can obtain the sources. ...
The source package can be found here:
http://tinycorelinux.net/10.x/x86/tcz/src/AutoCursor/


Offline Rich

  • Administrator
  • Hero Member
  • *****
  • Posts: 11694
Re: AutoCursor extension submitted
« Reply #4 on: January 31, 2021, 09:43:24 AM »
If there are any Raspberry Pi users running a GUI who are interested in this, here are the build instructions:

Code: [Select]
wget http://tinycorelinux.net/10.x/x86/tcz/src/AutoCursor/AutoCursor-source-v0.31.tar.gz
tar xf AutoCursor-source-v0.1.tar.gz
cd AutoCursor
./CompileAutoCursor

The  CompileAutoCursor  script will download and install extensions that are required to build this package.
The  CompileAutoCursor  script will not alter your  onboot.lst  file.

When it completes, copy  AutoCursor.tcz, AutoCursor.tcz.dep, and AutoCursor.tcz.md5.txt  to your  tce/optional  directory. Then:
Code: [Select]
tce-load -i AutoCursor
You will also find an  AutoCursor-armv.tar.gz.bfe  or  AutoCursor-aarch64.tar.gz.bfe  file has been created. It contains
all the extension files and a source package.

Now you can submit it to the repository. Attach the  AutoCursor  file with the  .bfe  extension  it to a brief email that says:
Quote
Attached is AutoCursor for TC12.
AutoCursor-armv.tar.gz.bfe contains the extension and the source tarball.
Adjust the TC version and filename as required.

The instructions for emailing the extension are here:
http://wiki.tinycorelinux.net/doku.php?id=wiki:creating_extensions#submitting
Use the  tcesubmit  email address, not the  picoresubmit  address.
« Last Edit: October 27, 2022, 10:34:39 PM by Rich »

Offline jazzbiker

  • Hero Member
  • *****
  • Posts: 934
Re: AutoCursor extension submitted
« Reply #5 on: January 31, 2021, 10:15:23 AM »
Events are named - that's great for nomadic TinyCore install! Thanks again!

Offline Rich

  • Administrator
  • Hero Member
  • *****
  • Posts: 11694
Re: AutoCursor extension submitted
« Reply #6 on: January 31, 2021, 10:18:12 AM »
Hi jazzbiker
Those event names come from peripherals, so they will differ from machine to machine.

Offline jazzbiker

  • Hero Member
  • *****
  • Posts: 934
Re: AutoCursor extension submitted
« Reply #7 on: January 31, 2021, 10:44:05 AM »
Quote from: Rich link=http://tinycorelinux.net/10.x/x86/tcz/AutoCursor.tcz.info
      If a mouse was included in your saved settings and is not present
      when you boot, we just move on to the next setting in the file.
On the new machine:
Code: [Select]
AutoCursor -hX -sY -S AutoCursor.conf.new; cat AutoCursor.conf.new >> ~/.config/AutoCursor.conf
Voila! all birds are trapped in our cages.
« Last Edit: January 31, 2021, 10:48:41 AM by jazzbiker »

Offline Rich

  • Administrator
  • Hero Member
  • *****
  • Posts: 11694
Re: AutoCursor extension submitted
« Reply #8 on: January 31, 2021, 11:28:10 AM »
Hi jazzbiker
The  -s  and  -h  can be used multiple times. So you can us multiple events to hide (keyboard, touchscreen) and multiple
events to show (mouse, touchpad).

If you just want to hide the cursor:
Code: [Select]
sudo AutoCursor -i
I don't know why someone would want to do this, but I figured eventually someone will try to use  -S  and  -L  in the
same command. So rather than testing for it and throwing an error, it was easier to just make it so it works:
Code: [Select]
sudo AutoCursor -hX -sY -sZ -hW -S AutoCursor.conf.new -L ~/.config/AutoCursor.confThis says hide the cursor for events  X  and  W , show the cursor for events  Y  and  Z , save the settings in
AutoCursor.conf.new , but run using the settings from  ~/.config/AutoCursor.conf.

Offline jazzbiker

  • Hero Member
  • *****
  • Posts: 934
Re: AutoCursor extension submitted
« Reply #9 on: January 31, 2021, 11:54:53 AM »
Hi, Rich!
I meant that if AutoCursor.conf includes descriptions of all the devices on all possible host machines, on one particular machine only devices actually present will be enqued. Is this wrong statement?

Offline Rich

  • Administrator
  • Hero Member
  • *****
  • Posts: 11694
Re: AutoCursor extension submitted
« Reply #10 on: January 31, 2021, 12:15:59 PM »
Hi jazzbiker
... Voila! all birds are trapped in our cages.

Here's an explanation of how the settings work that may prove useful.

These are the events listed on one of my machines:
Code: [Select]
tc@E310:~/C_Programs/AutoCursor$ sudo ./AutoCursor -e
Event#  Input device name
0:      "Power Button"
1:      "Power Button"
2:      "Logitech USB-PS/2 Optical Mouse"
3:      "PC Speaker"
4:      "DELL DELL USB Keyboard"
5:      "HDA Intel Mic"
6:      "HDA Intel Line"
7:      "HDA Intel Line Out"
8:      "HDA Intel Front Headphone"
tc@E310:~/C_Programs/AutoCursor$

This is the settings file from that machine:
Code: [Select]
tc@E310:~/C_Programs/AutoCursor$ cat cursor.conf
s:"Logitech USB-PS/2 Optical Mouse"
h:"DELL DELL USB Keyboard"
tc@E310:~/C_Programs/AutoCursor$

The program does a case sensitive substring search for the  settings string  in the  events string.
Any copy and paste section of the event string will work. In other words, this would work too:
Code: [Select]
s:"Mouse"
h:"Keyboard"

If all of your machines report  Mouse  and  Keyboard , That is all you would need. If one of your machines reports
keyboard , you could do this:
Code: [Select]
s:"Mouse"
h:"Keyboard"
h:"keyboard"

If I did this:
Code: [Select]
h:"HDA"My cursor would disappear anytime one of those 4 audio devices generated an event.

Summary:
You only need enough of the string to uniquely identify the event of interest.
You need the quotation marks.

...  on one particular machine only devices actually present will be enqued. ...
Correct.

Offline jazzbiker

  • Hero Member
  • *****
  • Posts: 934
Re: AutoCursor extension submitted
« Reply #11 on: January 31, 2021, 12:52:00 PM »
Hi, Rich!

Seems, that trick with substrings doesn't works.
Code: [Select]
tc@box:/tmp$ sudo AutoCursor -e
Event#  Input device name
0:      "Lid Switch"
1:      "Sleep Button"
2:      "Power Button"
3:      "AT Translated Set 2 keyboard"
4:      "YSPRINGTECH USB OPTICAL MOUSE"
5:      "PC Speaker"
6:      "Video Bus"
7:      "HDA Intel MID Mic"
8:      "HDA Intel MID Headphone"

This config works:
Code: [Select]
tc@box:/tmp$ cat ~/.config/autocursor.conf
h:"AT Translated Set 2 keyboard"
s:"YSPRINGTECH USB OPTICAL MOUSE"

while this don't:
Code: [Select]
tc@box:/tmp$ cat ~/.config/autocursor.conf.test
h:"keyboard"
s:"MOUSE"

You really use
Code: [Select]
       {       // Only return entries starting with EVENTstr.
                if(strncmp(EVENTstr, entity->d_name, EVENTstrlen) == 0)
in  BuildEventlist(void).

It's absolutely ok to use full names, as they are written by AutoCursor.

Offline Rich

  • Administrator
  • Hero Member
  • *****
  • Posts: 11694
Re: AutoCursor extension submitted
« Reply #12 on: January 31, 2021, 02:28:44 PM »
Hi jazzbiker
Seems, that trick with substrings doesn't works. ...
You are correct. I use the quote mark for locating the description but neglected to omit it as a search term. Updated
extensions posted to TC10 x86 and x86_64. It now works as described in reply #10. Please update your copy.

Quote
... You really use
Code: [Select]
       {       // Only return entries starting with EVENTstr.
                if(strncmp(EVENTstr, entity->d_name, EVENTstrlen) == 0)
in  BuildEventlist(void). ...
That section of code searches  /dev/input/  for  event*.  We don't care about other entries (mice. mouse0, etc.).
The search for a match is done in  LoadSettings(char *fullname, int *fdmax)

Quote
... It's absolutely ok to use full names, as they are written by AutoCursor.
Yes, it is. But I also wanted to allow for a little more flexibility if required.

Offline jazzbiker

  • Hero Member
  • *****
  • Posts: 934
Re: AutoCursor extension submitted
« Reply #13 on: January 31, 2021, 03:38:01 PM »
Hi, Rich!

Yes, works great!
Code: [Select]
tc@box:~$ cat ~/.autocursor.conf
h:"keyboard"
h:"Keyboard"
h:"KEYBOARD"
s:"mouse"
s:"Mouse"
s:"MOUSE"

Thanks for update!

Offline Rich

  • Administrator
  • Hero Member
  • *****
  • Posts: 11694
Re: AutoCursor extension submitted
« Reply #14 on: January 31, 2021, 04:56:18 PM »
Hi jazzbiker
Here's the output from an ASUS netbook with touchscreen, touchpad, and Bluetooth keyboard. In addidtion, there is a USB
mouse and keyboard plugged in:
Code: [Select]
Event# Input device name
0: "Lid Switch"
1: "Sleep Button"
2: "PC Speaker"
3: "SYNA7508:00 06CB:11E5 Pen"
4: "SYNA7508:00 06CB:11E5"
5: "Asus WMI hotkeys"
6: "PixArt HP USB Optical Mouse"
7: "Chicony HP Elite USB Keyboard"
8: "Chicony HP Elite USB Keyboard System Control"
9: "Chicony HP Elite USB Keyboard Consumer Control"
10: "Video Bus"
11: "bytcr-rt5640 Headset"
12: "Intel HDMI/DP LPE Audio HDMI/DP,pcm=0"
13: "Intel HDMI/DP LPE Audio HDMI/DP,pcm=1"
14: "Broadcom Bluetooth Wireless  Keyboard                        "
15: "Broadcom Bluetooth Wireless  Keyboard                        "
16: "Broadcom Bluetooth Wireless  Keyboard                        "
17: "Asus TouchPad"
18: "Broadcom Bluetooth Wireless  Keyboard                        "
19: "Broadcom Bluetooth Wireless  Keyboard                        "

This hides for the touchscreen and 2 keyboards, and shows for the mouse and touchpad:
Code: [Select]
sudo ./AutoCursor -s6 -h4 -s17 -h14 -h7