1

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.

  • When using the graphical 'System Settings' the behaviour I want feel instantaneous when you click the 'Apply' button. I am looking for a way to call the equivalent of 'Apply' from a shell script. – Mehmet Jul 17 '20 at 7:25
  • I found that this post mentions that the ctrl + shift + numlock combo seems to be on X. Are you using Wayland? – Dzinic Jul 26 '20 at 17:40
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.

0

Try restarting your plasmashell

kquitapp5 plasmashell && kstart5 plasmashell &

this will restart your shell and update with new settings

  • Thank you for taking the time to respond. The solution sounded promising, but I'm afraid when plasmashell restarts the new behaviour isn't loaded. I also found that the loading of plasmashell takes longer that I would ideally like, but that is a minor issue. – Mehmet Jul 17 '20 at 7:22
  • When i restart it takes about 6-7 seconds,it reloads all the Kde related programs with new data,if any. I use this to create a script that switches theme on time change so i notice it everyday. And make sure you type exactly as provided,if not plasma will be tied to the terminal you are running,so when you close it,plasma closes too. – AnonymousT Jul 17 '20 at 10:55
  • Yes, that is about how long it took mine to load as well. I also understand about running a process in the background using the final &, but I agree it's worth highlighting in the answer. Unfortunately. it doesn't seem to load the latest settings in ~/.config/kaccessrc. I don't know why. – Mehmet Jul 17 '20 at 12:43
  • I tried this in my terminal, The value changed instantly,but to be used by the plasma environment will take a restart or logout, that i do not know, kwriteconfig5 --file ~/.config/kaccessrc --group Keyboard --key Gestures 'false', Try this,report with what happens.Again what is the behavior you are trying to create. – AnonymousT Jul 21 '20 at 10:24
  • Yes, that is very similar to the line of code I'm using to update ~/.config/kaccessrc. The problem is the next step, which as you say needs a restart of plasmashell. – Mehmet Jul 24 '20 at 11:16

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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