- Как скрыть указатель мыши в Linux / X11?
- 11 ответов
- Как скрыть указатель мыши под Linux / X11?
- 9 ответов
- альтернатива unclutter
- linux — xinit — xset hide cursor
- How do you hide the mouse pointer under Linux/X11? (6)
- an alternative to unclutter
- Cursor themes
- Contents
- Installation
- Packages
- Manually
- Configuration
- XDG specification
- LXAppearance
- Desktop environments
- GNOME
- X resources
- Environment variable
- Display managers
- Troubleshooting
- Create links to missing cursors
- Supplying missing cursors
- rdesktop
- Change X shaped default cursor
- .Xdefaults
- Cursor size does not change on startup
Как скрыть указатель мыши в Linux / X11?
Как скрыть указатель мыши под X11? Я хотел бы использовать для этого встроенные библиотеки, а не что-то вроде SDL (SDL_ShowCursor (0)) или перенасыщения (glutSetCursor (GLUT_CURSOR_NONE)). Кроме того, указатель мыши должен быть скрыт независимо от местоположения указателя, а не только в его собственном окне.
11 ответов
Вы можете создать и установить тему невидимого курсора. Этот трюк используется maemo, потому что иметь курсор на устройстве с сенсорным экраном довольно бессмысленно.
К сожалению, возможность изменения темы глобального курсора во время выполнения неодинакова для приложений и инструментов X11. Вы можете изменить ресурс сервера Xcursor.theme , и никто этого не заметит (обычно он запрашивается только при запуске); вы можете сообщить xsettings, который влияет только на программы Gtk +; KDE использует своего рода связь через свойства в корневом окне; и т.п.
По крайней мере, изменить курсор для вашего собственного приложения так же просто, как XDefineCursor, и если вы сделаете это в корневом окне, некоторые приложения могут последовать их примеру.
Вот описание, как утилита unclutter делает Это.
Unclutter — это программа, которая постоянно работает в фоновом режиме сеанса X11. Он проверяет положение указателя (курсора) X11 каждые несколько секунд и, когда обнаруживает, что он не перемещается (и на мыши не нажимаются никакие кнопки, и курсор не находится в корневом окне), он создает небольшое подокно как дочерний элемент окна, в котором находится курсор. Новое окно устанавливает курсор размером 1×1, но с маской всего 0, то есть невидимым курсором. Это позволяет вам видеть весь текст, например, в xterm или xedit. Толпа, занимающаяся человеческим фактором, согласится, что это должно меньше отвлекать.
После создания программа ожидает, пока указатель покинет окно, а затем уничтожает его, восстанавливая исходную ситуацию. События кнопок прозрачно передаются родительскому окну. Обычно они вызывают повторное появление курсора, потому что активный захват будет выполнен программой, пока кнопка нажата, поэтому указатель, очевидно, покинет окно, даже если его положение x y не изменится.
xinit — -nocursor или startx — -nocursor могут работать.
Источник
Как скрыть указатель мыши под Linux / X11?
Как скрыть указатель мыши под X11? Я хотел бы использовать встроенные библиотеки, чтобы сделать это, а не что-то вроде SDL (SDL_ShowCursor(0)) или glut (glutSetCursor(GLUT_CURSOR_NONE)). Кроме того, указатель мыши должен быть скрыт независимо от местоположения указателя, а не только в собственном окне.
9 ответов
вы можете создать и установить невидимую тему курсора. Этот трюк используется maemo, потому что довольно бессмысленно иметь курсор на сенсорном устройстве.
к сожалению, возможность изменения темы глобального курсора во время выполнения неоднородна в приложениях и наборах инструментов X11. Вы можете изменить ресурс сервера Xcursor.theme , и никто не заметит (обычно это запрашивается только при запуске); вы можете сообщить xsettings который, похоже, влияет только на Gtk+ программы; KDE использует некоторую связь через свойства в корневом окне и т. д.
по крайней мере, изменение курсора для вашего собственного приложения так же просто, как XDefineCursor, и если вы сделаете это на корневом окне, некоторые приложения может следовать вдоль.
здесь описание как unclutter утилита делает это.
Unclutter-это программа, которая постоянно работает в фоновом режиме X11 сессия. Он проверяет положение указателя X11 (курсора) каждые несколько секунды, и когда он находит, что он не переместился (и нет кнопок нажатии на мышь, и курсор находится не в корневом окне) он создает небольшое подокно в качестве дочернего элемента окна, в котором находится курсор. Новое окно устанавливает курсор размера 1×1 но маска все 0, т. е. невидимый курсор. Это позволяет увидеть весь текст в например, xterm или xedit. Толпа людей согласится с этим. следует делать меньше отвлекает.
после создания программа ожидает, пока указатель покинет окно а потом уничтожает его, восстанавливая первоначальную ситуацию. События Button прозрачно передаются в родительское окно. Они обычно заставляют курсор появляться снова, потому что активный захват будет сделано программой пока кнопка вниз, поэтому указатель по-видимому, покинет окно, даже если его положение x y не изменится.
Я бы предпочел использовать более простой метод:
вы почти не видите курсор, все еще он доступен. Чтобы отключить мышь:
или отключить модуль мыши постоянно где-то в /etc/. Обратитесь к руководству по распределению.
альтернатива unclutter
Unclutter не работал для меня, так как он не хорошо играет с аппаратными ускоренными поверхностями (например, теми, которые производятся VA-API intels при декодировании видео). Поэтому я нашел программу, которая спрятала указатель мыши менее окольным путем,hhp, и переписал его в C с минимальными зависимостями, результат hhpc. Я сделал это, чтобы избавить Хаскелла от необходимости скомпилируйте его и потому, что hhp иногда перестает скрывать указатель мыши.
hhpc, полагается только на glibc и xlib , поэтому его легко построить, просто сделайте make release . Вы можете получить код и инструкции от мой репозиторий. Это очень эффективная память и процессор (потому что он почти ничего не делает).
Я закончил с использованием XDefineCursor как ephemient упомянул. Управляющее приложение изменило курсор корневого окна по умолчанию, а другие приложения (которые находятся под моим контролем) унаследовали его.
специфика кода выглядит так:
для того, чтобы скрыть курсор, а затем после того, как я
для восстановления курсора левой руки X (так как это корневое окно, и я не хочу, чтобы он оставался невидимым. Я не уверен, но я также мог бы использовать
есть -no-cursor опция для Xorg 1.7 и более поздних версий. https://www.x.org/wiki/AdvancedTopicsFAQ/
xinit — -nocursor или startx — -nocursor может работать.
используйте xbanish! Это «изгнать курсор мыши при вводе»! Начните с
Источник
linux — xinit — xset hide cursor
How do you hide the mouse pointer under Linux/X11? (6)
an alternative to unclutter
Unclutter didn’t work for me, as it doesn’t play well with hardware accelerated surfaces (such as for example those produced by intels’ VA-API when decoding video). So I found a program that hid the mouse pointer in a less roundabout way, hhp, and rewrote it in C with minimal dependencies, the result is hhpc. I did this to obviate the need to have haskell to compile it and because hhp sometimes stopped hiding the mouse pointer.
hhpc, relies only on glibc and xlib , so it’s easy to build, just do make release . You can get the code and instructions from my repository. It’s very memory and CPU efficient (because it does almost nothing).
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 (glutSetCursor(GLUT_CURSOR_NONE)). Also, the mouse pointer should be hidden no matter the pointer location, not just in its own window.
I guess this post may be getting a little bit old, but if what I’ve found can help some of us, I definitely have to post it here 😉
I found myself a clean and simple solution that works fine, without using «xcb» ( for what I tried to achieve, it was a litte over-engineering (..)
All you need is the «xsetroot» command, with appropriate arguments/params:
-> to hide the mouse cursor, you need an extra little file (I called mine «blnk_ptr.xbm»)
the content of this file:
Then, we can use the two following commands:
-> to hide the mouse pointer cursor:
-> to show the mouse pointer cursor again:
( you can use a mouse pointer cursor other than «left_ptr», but this one seems to be widely available across *nix systems (..)
Btw-> I don’t know yet how to get the name of the pointer currently used by the system using xsetroot —> I guess I’ll [as usual] digg that too, but I’d be happy to have someone who knows the how-to giving me the answer ( It’d be nice 😉 )
I ended up using XDefineCursor like ephemient mentioned. The control application changed the default root window cursor and the other applications (which are under my control) inherited it.
Code specifics look like:
In order to hide the cursor and then after I’m done
To restore X’s left handed cursor (Since it’s the root window and I don’t want it to stay invisible. I’m not sure, but I might also be able to use
I’d rather use simpler method:
You almost do not see cursor, still it is available. To disable mouse:
Or disable mouse module permanently somewhere in /etc/. See your distribution manual.
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 🙂
Use xbanish! It «banish the mouse cursor when typing»! Start it with
Источник
Cursor themes
The display server is accompanied by a cursor theme that helps various aspects of GUI navigation and manipulation. The display server includes a cursor theme, however, other cursor themes can be installed and selected.
Contents
Installation
Installation can be done with a package, or downloaded and extracted to an appropriate directory.
Packages
Cursors themes are available in the:
Manually
If a cursor theme is not available in the official repositories or the AUR, it can be added manually. A number of websites exist where cursor themes can be downloaded. Once downloaded, they need to be put in the icons directory (as cursors have the ability to be bundled with icon themes).
Some websites that have cursor themes:
For user-specific installation, use the
/.icons/ directory. Extract them with this command that will work for most archives:
The cursor theme directory structure is theme-name/cursors , for example:
/.local/share/icons/theme/cursors/ ; make sure the extracted files follow this structure.
Already installed cursor themes can be viewed with the command:
If the package includes an index.theme file, check if there is an «Inherits» line inside. If yes, check whether the inherited theme also exists on the system (rename if needed).
Configuration
There are various ways to set the cursor theme.
XDG specification
This method applies to both X11 and Wayland cursor themes.
For user-specific configuration, create or edit
/.icons/default/index.theme ; for system-wide configuration, one can edit /usr/share/icons/default/index.theme .
The Inherits option in the [icon theme] section must be set to the xcursor theme directory name cursor_theme_name , for example xcursor-breeze-snow :
You should then edit
/.config/gtk-3.0/settings.ini , replacing the cursor_theme_name with the chosen one:
Restart X for the changes to take effect.
If it still does not work, try creating a symlink from
/.icons/default/cursors (assuming user-specific) to .local/share/icons/cursor_theme_name/cursors and restart X again.
LXAppearance
LXAppearance sets the default cursor by creating an
/.icons/default/index.theme file: if you edited that file manually, LXAppearance will overwrite it. Remember to also edit
/.config/gtk-3.0/settings.ini manually as specified in #XDG specification, because applications like Firefox use this setting instead.
Desktop environments
Desktop environments use the XSETTINGS protocol, typically implemented through a settings daemon. While this allows to change the cursor on-the-fly, the applied theme may be inconsistent across applications. See #XDG specification to change the cursor theme manually.
GNOME
To change the theme in GNOME, use gnome-tweaks or set the configuration directly with:
Change the cursor size with (depending on the theme, sizes are 24, 32, 48, 64):
/.local/share/icons . As a workaround, you can add that path to XCURSOR_PATH.
In MATE one can use mate-control-center or gsettings. To change the theme:
To change the size:
To change the xcursor theme, use:
To change the size:
X resources
To locally name a cursor theme, add to the
To have the cursor theme properly loaded it will need to be done so by the window manager; if it does not, it can be forced to load prior the window manager by putting the following command in
/.xinitrc or .xprofile (depending on ones personal setup):
Optionally, add this line to
/.Xresources if your cursor theme supports multiple sizes:
If in doubt over supported cursor sizes, start X without this setting and let it choose the cursor size automatically. (Refer to your window manager documentation for details.)
Environment variable
You can use an environment variable to set a theme for a single application to try it out temporarily, for example:
XCURSOR_SIZE is optional if your cursor theme supports multiple sizes.
If cursor themes are installed in
/.local/share/icons , in order to avoid possible issues, add that path to XCURSOR_PATH. For example:
Display managers
Cursor theme can usually be set within a display manager, but keep in mind the cursor theme may not carry over to the user session.
Troubleshooting
Create links to missing cursors
Applications may keep using the default cursors when a theme lacks some cursors. This can be corrected by adding links to the missing cursors. For example:
If the above does not solve the problem, look in /usr/share/icons/whiteglass/cursors for additional cursors your theme may be missing, and create links for these as well.
Supplying missing cursors
Some programs set their own custom cursors
/.Xresources which you may want to override. A common example of this is rdesktop, which connects to a Microsoft Windows computer and uses the cursors obtained from the remote machine, which can often be difficult to see due to protocol limitations yielding poor conversion quality.
This can be resolved by replacing these cursors with ones from the same (or another) cursor theme. In order to do this, the hash of the image must be obtained. This is done by setting the XCURSOR_DISCOVER environment variable prior to launching the application that sets these cursors:
The first time (and only the first time) the cursor is set, some details will be displayed, like this:
When Xcursor looks for missing cursors, the search path includes
/.icons/default/cursors so this is where an image can be placed for Xcursor to find. First, create this directory if it does not already exist:
Then link the hash to the target image. Here we are using the left_ptr image from the Vanilla-DMZ cursor theme:
The change will be visible as soon as the application is restarted. No special method of launching the application is required.
rdesktop
Here are some common Microsoft Windows cursors that rdesktop uses when connecting to a remote machine running Windows 7. Unfortunately, animated cursors are difficult to override as they are sent frame-by-frame, so one mapping will be needed for every frame!
Change X shaped default cursor
The default X shaped Xcursor appears in window managers that do not set the default cursor to left_ptr or in window managers using XCB (like awesome) instead of Xlib.
To fix this simply add the following to your
/.xinitrc , xsession or window managers startup configuration if possible (for example bspwm’s bspwmrc).
The list of cursor styles is in appendix B of the X protocol.
.Xdefaults
If you have conflicting cursors then it might be because a different cursor has been set in the
Cursor size does not change on startup
If you are trying to change cursor size via
/.Xresources in your
/.xinitrc and it does not work, make sure that xrandr runs before loading
Источник