How to get KDE to update settings once config file has been changed
I am updating a kde config file (~/.config/kaccessrc
) using a script.
My script makes the required change to the file but the settings are not updated on the system. I assume I have to tell KDE to re-read the config file but I don't know how.
After a bit of research I've tried using kwriteconfig5
to modify the file, which it does, but the system still retains its old behaviour. I was hoping kwriteconfig5
would have triggered KDE to use the new configuration. kwriteconfig5
doesn't appear to have a man page and it's default help page doesn't mention anything about this:
Usage: kwriteconfig5 [options] value
Options:
-h, --help Displays this help.
--file <file> Use <file> instead of global config
--group <group> Group to look in. Use repeatedly for nested groups.
--key <key> Key to look for
--type <type> Type of variable. Use "bool" for a boolean, otherwise it is
treated as a string
Arguments:
value The value to write. Mandatory, on a shell use '' for empty
The required change does take place if I log out and back in again, but I need the change to happen as soon as I run the command.
I've tried searching online but can't find a directly relevant scenario.
What am I missing?
Update: Background of what I'm trying to achieve
I would like to have a script that toggles 'keyboard navigation' a.k.a. 'MouseKeys'. Once I have the script, I want to bind it a key on my keyboard so I can turn it on and off at will. At the moment, I do it through the system settings dialog a number of times a day.
The reason I use it so often is that some websites I use have very position-dependent on mouseover()
events. For example, on Meteociel, which displays weather forecast model runs, you change the time you are looking at by moving your mouse over the timestamps.
I find using the keypad to move the mouse very helpful on these websites as it means I can keep my eye on the chart and know the mouse will be moving vertically, but annoying the rest of the time.
I would like a keyboard binding to do this to make my workflow more seamless. At the moment, the delay I get by restarting plasma shell upsets my workflow more than using the settings dialog.
Solution 1:
Mousekeys functionality is provided by the xkeyboard driver, and the easiest way to activate and deactivate mousekeys from the terminal or scripts is to use a program dedicated to that task, such as xkbset
.
sudo apt install xkbset
xkbset mousekeys # enable mousekeys
xkbset -mousekeys # disable mousekeys
Another utility, xdotool
, provides functions to control mouse movement programmatically. This may be useful if you need to control the mouse cursor without any user involvement.
As far as I can tell, kwriteconfig5
activates or deactivates most changed settings immediately. In cases where that doesn't happen, it's usually sufficient to reload whichever program uses the config file in question.
Usually, the problematic programs are plasmashell
or kwin
, but in this case, reloading either is not helpful because neither uses kaccessrc
nor provides the functions you desire.
Reloading kaccess
also appears to not work. Normally, the xkeyboard driver is handled by other processes during startup/login. Since there is usually no need, kaccess
does not alter xkeyboard settings when loaded.