2

I was thinking about writing a script that toggles my desktop between regular use and screencasting mode. As part of that I would like to be able to programmatically set the my cursor to a different theme (bigger and higher visibility).

Is there any way I can do this from bash/python?

Edit:

I would prefer to be able to set this without having to change the systemwide X.org configuration (just like KDE's systemsettings does). Looking into this a bit myself I found that you can actually update the corresponding KDE config file through kwriteconfig5:

kwriteconfig5 --file ~/.config/kcminputrc --group Mouse --key cursorTheme "Large Mouse Cursors"

The only problem is that the setting does not seem to be applied. The config file does update, but not the cursor. So there probably must be some kind of command that will cause KDE to reload the file and apply the new cursor theme (maybe something through dbus?). Sadly I haven't had any success in tracking that down, yet.

1
+50

After some searching, I found out a few things that you may be able to do. Note that the following solutions only works under X11, I have no idea how to make it work with Wayland.

  1. sudo update-alternatives --config x-cursor-theme as a bash command, and then restart your computer/KWin and plasma shell (original answer for Gnome: https://askubuntu.com/a/73736/661239)
  2. Using the python Xlib (https://github.com/python-xlib/python-xlib) and adapting the following C++ code: https://stackoverflow.com/a/16848981/7520341
  3. There is this great ArchWiki page with which you may be able to see what you may be able to do: https://wiki.archlinux.org/index.php/Cursor_themes
  • Appreciate the answer, thanks! That archwiki entry was very insightful. Unfortunately it seems like there is no information specific to KDE, and the global update-alternatives sadly seems to require root. Given how you can change the cursors from KDE's systemsettings menu as a user, I was hoping that I'd be able to do the same through a script. I've actually just updated my question with some promising discoveries I stumbled on recently. Hopefully someone will be able to use that to put together the final pieces of the puzzle. – Glutanimate Apr 21 '18 at 16:37
0

I don't have enough reputation to add a comment. So I'll just put this here.

You didn't mention this on your post. Have you try to refresh the shell after you change the config?

  • Well, that's one of the first things I tried, it seems to work but it's fairly buggy as some shell parts are not updated with the new cursor and some applications aren't (even KDE's ones) – Ad5001 Apr 23 '18 at 7:30

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.