How do you hide the mouse pointer under Linux/X11?

前端 未结 10 2090
小蘑菇
小蘑菇 2020-12-05 00:44

How do I hide the mouse pointer under X11? I would like to use the built in libraries in order to do this and not something like SDL (SDL_ShowCursor(0)) or glut (glutSetCur

10条回答
  •  既然无缘
    2020-12-05 01:00

    This is my solution. It places the cursor where you can't see it (in my case, in the bottom-left corner) - then, it disables the mouse, so you can't move it.

    Note You could parse data from xrandr, or put that data in an environmental on login, and then use it; that way, you won't have to have it hard coded. But, as for me, I never change my screen resolution, so 768 is OK :)

    setmouse () {
       DISPLAY=":0" xinput $1 `DISPLAY=":0" xinput | grep Mouse |
               tr -d " " | tr "\t" " " |
               cut -d" " -f2 | cut -d"=" -f2`
    }
    
    offmouse () {
       DISPLAY=":0" xdotool mousemove 0 768 # use xrandr to find out
       setmouse disable
    }
    
    onmouse () {
       setmouse enable
    }
    

提交回复
热议问题