10

One the most difficult things for visually impaired people is locating the mouse looking up to the screen.

Therefore enabling locate mouseor locate pointer give some extra visual attention (flashing orange circle/waves) after pressing CTRL. (difficult to catch in screenshot: on the left)

Locate mouse in Ubuntu

Xubuntu doesn't have this invaluable tool, and Ubuntu is too heavy for the 1GB, dual core old hardware. Gnome has it, Unity has it, Compiz has it, Mint has it. Xubuntu/XFCE doesn't have it.

It is not about a bigger mouse, that helps a bit. Some flashing attention is needed.

Using high contrast theme.

If Lubuntu has it, I consider switching from Xu to Lu.

3
  • Have you looked in Synaptic package manager for Big Cursor? It may solve your problem.
    – Rex
    Jan 5, 2015 at 22:45
  • This was for Xubuntu, then the title was changed to Lubuntu but paragraphs still talks about Xubuntu. Are you sure it's not a duplicate for your other question Locate mouse helper in Xubuntu for visually impaired
    – user.dz
    Jan 27, 2015 at 12:57
  • No, I don't think the title changed, maybe you confuse it with the screenshot. I asked before about Xubuntu in another question, this one is about Lubuntu, but generating tips about Xubuntu and Lubuntu.
    – Janghou
    Feb 9, 2015 at 9:08

3 Answers 3

5
  • In Xubuntu go to Settings Manager - Mouse and Touchpad - Theme. There you can make mouse cursor size bigger.

    Xubuntu mouse & touchpad csettings

  • Also you can download additional themes for your mouse that make viewing the mouse easier. See xfce-look.org. You may choose the theme by your tastes.

    I think this one best suits your needs: DMZ with Yellow Background Multisized.

    As for Lubuntu: According to its wiki site, PCManFM and LxPanel don't use the cursor theme, you will have to change the cursor manually. See here for more details: https://wiki.archlinux.org/index.php/LXDE#Cursors

  • And one more option: Install MATE environment on your Ubuntu, it is lightweight running on 512-MB RAM machine and has the mouse flash option you are searching.

    sudo apt-add-repository ppa:ubuntu-mate-dev/ppa 
    sudo apt-add-repository ppa:ubuntu-mate-dev/trusty-mate 
    
    sudo apt-get update && sudo apt-get upgrade 
    sudo apt-get install ubuntu-mate-core ubuntu-mate-desktop
    

    If you want to have only one environment you can even download and install Ubuntu Mate version as a single OS (But note that is is not officially supported by Canonical).

    https://ubuntu-mate.org/longterm/

    After you have installed MATE environment you can set mouse flash:

    1. Go to Menu and select PreferencesMouse and Touchpad.
    2. Enable the tick mark next to “Show position of pointer when the Control key is pressed”.

    See the link for details: Quickly Locate Mouse Pointer In Linux Mint / Ubuntu | I Have A PC.

2
  • Thx, I will give that a try, I will also try Treepata theme.
    – Janghou
    Jan 6, 2015 at 15:22
  • The DMZ/yellow mouse theme is fine. This together with the Treepata theme (e.g. improved high/contrast) offers an appropriate type of assistance for Xubuntu. Thx
    – Janghou
    Jan 18, 2015 at 17:03
5
  1. Download locate-pointer.c

    wget https://gist.githubusercontent.com/sneetsher/d6d35b6181aa70c27a85/raw/dd874ac535d511c675724fa30d9e12ba5b810c37/locate-pointer.c
    
  2. Install build requirements

    sudo apt-get install build-essential libx11-dev libcairo2-dev
    
  3. Build it

    gcc `pkg-config --cflags x11 cairo` locate-pointer.c -o locate-pointer `pkg-config --libs x11 cairo` -lm
    
  4. Copy it to the system bin/

    sudo cp locate-pointer /usr/local/bin/
    
  5. Create a shortcut to launch it

  6. Enable Composite

    Lubuntu

    1. Install a composite manager

      sudo apt-get install xcompmgr
      
    2. Add a line for it in

      ~/.config/lxsession/Lubuntu/autostart
      

    Xubuntu

    1. Run xfwm4-tweaks-settings → Compositor → Check Enable Display Compositing

Notes

  • You gonna get a black background without composite. If you couldn't get it to work, try other composite manager like: compton, cairo-compmgr.

locate-pointer in Lubuntu with xcompmgr

locate-pointer in Xubuntu session

Here is the complete code of locate-pointer.c, just in case link broke.

/*
 * locate-pointer.c
 * Some windows manager missing option to locate mouse pointer as accessibity feature.
 * To get transparent window need to activate `composite` service for wm.
 * Coded in c / xlib so it can work in most wm's.
 * 
 * Coded by:    Abdellah Chelli
 * Date:    January 2015
 *
 * Original code by:    Bernhard R. Fischer <[email protected]>
 *          Cairo graphics and X11/Xlib motion example.
 *          https://www.cypherpunk.at/2014/11/cairo-graphics-and-x11xlib/
 *
 * gcc `pkg-config --cflags x11 cairo` locate-pointer.c -o locate-pointer `pkg-config --libs x11 cairo` -lm
 */

#include <X11/Xlib.h>
#include <X11/Xatom.h>
#include <X11/Xutil.h>
#include <cairo.h>
#include <cairo-xlib.h>

#include <stdio.h>
#include <stdlib.h>
#include <time.h>
#include <math.h>

int cairo_check_event(cairo_surface_t *sfc, int block, double *mx, double *my)
{
   char keybuf[8];
   KeySym key;
   XEvent e;
   XSync(cairo_xlib_surface_get_display(sfc),False);
   for (;;)
   {
      if (block || XPending(cairo_xlib_surface_get_display(sfc)))
         XNextEvent(cairo_xlib_surface_get_display(sfc), &e);
      else 
         return 0;

      switch (e.type)
      {
         case ButtonPress:
            return -e.xbutton.button;
         case KeyPress:
            XLookupString(&e.xkey, keybuf, sizeof(keybuf), &key, NULL);
            return key;
         case  MotionNotify:
            *mx = e.xmotion.x;
            *my = e.xmotion.y;

         default:
            //fprintf(stderr, "Dropping unhandled XEevent.type = %d.\n", e.type);
            return 0;
      }
   }
}


static void fullscreen(Display* dpy, Window win)
{
  Atom atoms[2] = { XInternAtom(dpy, "_NET_WM_STATE_FULLSCREEN", False), None };
  XChangeProperty(dpy, win, XInternAtom(dpy, "_NET_WM_STATE", False),
                  XA_ATOM, 32, PropModeReplace, (unsigned char*) atoms, 1);
}


cairo_surface_t *cairo_create_x11_surface(int *x, int *y, double* mx, double *my)
{
   Display *dsp;
   Drawable da;
   Screen *scr;
   int screen;
   cairo_surface_t *sfc;

   XVisualInfo vinfo;
   XSetWindowAttributes win_attr;
   int mousex, mousey;

   if ((dsp = XOpenDisplay(NULL)) == NULL)
      exit(1);
   //XSynchronize(dsp,True);
   screen = DefaultScreen(dsp);
   scr = DefaultScreenOfDisplay(dsp);

   XMatchVisualInfo(dsp, screen, 32, TrueColor, &vinfo);
   win_attr.colormap = XCreateColormap(dsp, DefaultRootWindow(dsp), vinfo.visual, AllocNone);
   win_attr.background_pixel = 0;
   win_attr.border_pixel = 0;

   *x = WidthOfScreen(scr), *y = HeightOfScreen(scr);

   da = XCreateWindow(dsp, DefaultRootWindow(dsp),
           0, 0, *x, *y, 0, vinfo.depth, InputOutput,
           vinfo.visual,
           CWColormap | CWBorderPixel | CWBackPixel, &win_attr);

   fullscreen (dsp, da);

   XSelectInput(dsp, da, PointerMotionMask | ButtonPressMask | KeyPressMask);
   XMapWindow(dsp, da);

   sfc = cairo_xlib_surface_create(dsp, da, vinfo.visual, *x, *y);
   cairo_xlib_surface_set_size(sfc, *x, *y);

   Window rw=DefaultRootWindow(dsp);
   Window cw=da;
   int rx, ry;
   unsigned int mr;
   XQueryPointer(dsp, da, &rw, &cw, &rx , &ry, &mousex, &mousey, &mr);
   *mx = mousex;
   *my = mousey;

   return sfc;
}


void cairo_close_x11_surface(cairo_surface_t *sfc)
{
   Display *dsp = cairo_xlib_surface_get_display(sfc);

   cairo_surface_destroy(sfc);
   XCloseDisplay(dsp);
}

int main(int argc, char **argv)
{
   cairo_surface_t *sfc;
   cairo_t *ctx;
   int x, y;
   struct timespec ts = {0, 5000000};

   double mx, my;
   int c = 0;
   double dr0, dr1, dr2, a;

   int running;

   x = y = 0;

   sfc = cairo_create_x11_surface(&x, &y, &mx, &my);
   ctx = cairo_create(sfc);

   for (running = 1; running;)
   {

      dr0 = 20 * sin(c*M_PI/180.0);
      dr1 = 20 * sin((c+45)*M_PI/180.0);
      dr2 = 20 * sin((c+90)*M_PI/180.0);
      a = c*M_PI/720.0;

      cairo_save (ctx);
      //cairo_set_source_rgba (ctx, 0, 0, 0, 1);
      //cairo_set_operator (ctx, CAIRO_OPERATOR_SOURCE);
      cairo_set_operator (ctx, CAIRO_OPERATOR_CLEAR);
      cairo_paint (ctx); 
      cairo_restore (ctx);

      cairo_push_group(ctx);
      cairo_translate(ctx, mx, my);
      cairo_rotate(ctx,a);
      cairo_translate(ctx, -mx, -my);
      cairo_set_source_rgba(ctx, 0, 0, 0, 0.1);
      cairo_paint(ctx);

      cairo_set_line_join (ctx, CAIRO_LINE_JOIN_MITER);
      cairo_set_source_rgba(ctx, 1, 0, 0, 1);
      cairo_set_line_width (ctx, 30);
      cairo_move_to (ctx, mx-50, my-100-dr0);
      cairo_rel_line_to (ctx, 50, 30);
      cairo_rel_line_to (ctx, 50, -30);
      cairo_move_to (ctx, mx+100+dr0, my-50);
      cairo_rel_line_to (ctx, -30, 50);
      cairo_rel_line_to (ctx, 30, 50);
      cairo_move_to (ctx, mx+50, my+100+dr0);
      cairo_rel_line_to (ctx, -50, -30);
      cairo_rel_line_to (ctx, -50, 30);
      cairo_move_to (ctx, mx-100-dr0, my+50);
      cairo_rel_line_to (ctx, 30, -50);
      cairo_rel_line_to (ctx, -30, -50);
      cairo_stroke(ctx);
      cairo_set_source_rgba(ctx, 1, 0, 0, 0.5);
      cairo_move_to (ctx, mx-50, my-150-dr1);
      cairo_rel_line_to (ctx, 50, 30);
      cairo_rel_line_to (ctx, 50, -30);
      cairo_move_to (ctx, mx+150+dr1, my-50);
      cairo_rel_line_to (ctx, -30, 50);
      cairo_rel_line_to (ctx, 30, 50);
      cairo_move_to (ctx, mx+50, my+150+dr1);
      cairo_rel_line_to (ctx, -50, -30);
      cairo_rel_line_to (ctx, -50, 30);
      cairo_move_to (ctx, mx-150-dr1, my+50);
      cairo_rel_line_to (ctx, 30, -50);
      cairo_rel_line_to (ctx, -30, -50);
      cairo_stroke(ctx);
      cairo_set_source_rgba(ctx, 1, 0, 0, 0.3);
      cairo_move_to (ctx, mx-50, my-200-dr2);
      cairo_rel_line_to (ctx, 50, 30);
      cairo_rel_line_to (ctx, 50, -30);
      cairo_move_to (ctx, mx+200+dr2, my-50);
      cairo_rel_line_to (ctx, -30, 50);
      cairo_rel_line_to (ctx, 30, 50);
      cairo_move_to (ctx, mx+50, my+200+dr2);
      cairo_rel_line_to (ctx, -50, -30);
      cairo_rel_line_to (ctx, -50, 30);
      cairo_move_to (ctx, mx-200-dr2, my+50);
      cairo_rel_line_to (ctx, 30, -50);
      cairo_rel_line_to (ctx, -30, -50);
      cairo_stroke(ctx);
      cairo_pop_group_to_source(ctx);
      cairo_paint(ctx);
      cairo_surface_flush(sfc);

      switch (cairo_check_event(sfc, 0, &mx, &my))
      {
         case 0xff1b:   // Esc
         case -1:       // left mouse button
            running = 0;
            break;
      }

      c++;
      nanosleep(&ts, NULL);
   }

   cairo_destroy(ctx);
   cairo_close_x11_surface(sfc);
   return 0;
}
2
  • 1
    It's a little disconcerting the To-Do list was written almost 5 years ago and hasn't been tackled yet. I'm bad that way too but at least I get some of it done after a year or two max. Oct 20, 2019 at 22:59
  • @WinEunuuchs2Unix , Que Sera Sera. I always write my brain storming ideas, issues (BugR ,feedback, testing results) in same script. It is hard to remember when switching projects (mind context), working 5w/5w rotation on different domain. In the end, I don't come back, if it doesn't have much user base and it just work enough (public interest or just waste of resources I have, BTW I'm not a direct user of my script). So now the tech moving fast: x11 replaced, this script died, unity dropped, xkbmod-indicator died, x11 replaced, keyboard_modifiers, todo rewriting for updated gtk , ..:D
    – user.dz
    Oct 21, 2019 at 7:58
3

There is a simple and dirty trick using "yad", which is a tool for generating relatively simple windows. ( It is a fork from zenity )

So, if you create an script on your, let's say $HOME/bin, with the following content:

yad --picture  --width=68 --height=68 --no-buttons --size=fit --filename=ANY_PICTURE_YOU_LIKE --timeout=1 --mouse --undecorated  --on-top  > /dev/null 2>&1 

The value of width and height should be 4 pixels more than the actual size of the picture.

It will overlay the picture, for a second, at the position of the mouse, if the picture is an animated gif, you get something quite similar to what your where asking for.

You just have to map a keyboard shortcut to your new app.

There are some nice animations at preloader.net (I have not checked copyright issues)

Hope it helps.

3
  • Doesn't work with i3 ):
    – Jezor
    Jan 29, 2018 at 14:49
  • This is really cool. Is there a way to make it follow the mouse?
    – Michael
    Jun 29, 2018 at 8:33
  • 1
    Nice trick! @Jezor, it works in i3 too. You just need to make the window floating using for_window [class="Yad"] floating enable in your i3 config.
    – Gautam
    Feb 24, 2020 at 20:51

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .