Xfce4-terminal: Enable "Disable all menu access keys" in all qubes

Something that really bothered me is that in Xfce Terminal Emulator, by default, Alt+f opens the File menu. I am expecting Alt+f to make the cursor move forward by one word. This configuration option is written in the home directory, so I needed a way to set the option on all the qubes.

I am a newbie to Salt and also Qubes, so if someone can tell me any improvements, do let me know.

To set up, in dom0, make sure /srv/user_salt exists. If not, follow the setup steps at Qubes Salt Beginner's Guide.

In dom0 /srv/user_salt/xfceterminalsettings.sls, put:

Code
Merge config:
  cmd.script:
    - name: xfceterminalsettings.sh
    - source: salt://xfceterminalsettings.py

In dom0 /srv/user_salt/xfceterminalsettings.py, put:

Code
#!/usr/bin/env python3

from pathlib import Path
import configparser

def get_config_path() -> Path:
    # Hard code the user because I think salt runs as a different user
    return Path("/home/user/.config/xfce4/terminal/terminalrc")

def config_path_mkdirp():
    p = get_config_path()
    if not p.parent.exists():
        p.parent.mkdir(parents=True)

def main():
    config = configparser.ConfigParser()
    config.optionxform = str # xfce4-terminal requires the option to be case sensitive
    config.read(get_config_path())

    CONFIGURATION = 'Configuration'
    if CONFIGURATION not in config:
        config[CONFIGURATION] = {}

    configurationSection = config[CONFIGURATION]

    SHORTCUTSNOMNEMONICS = 'ShortcutsNoMnemonics'

    if (SHORTCUTSNOMNEMONICS in configurationSection and
        configurationSection[SHORTCUTSNOMNEMONICS] == 'TRUE'):
        print("No work needed.")
        return

    configurationSection[SHORTCUTSNOMNEMONICS] = 'TRUE'

    config_path_mkdirp()
    with open(get_config_path(), "w") as f:
        config.write(f)
        print("Updated.")

if __name__ == "__main__":
    main()

After you have the files in place, you can apply the configuration by running in dom0:

sudo qubesctl --show-output --skip-dom0 --targets vault,personal state.sls xfceterminalsettings saltenv=user

You can specify which target qubes to apply the settings to by modifying the command. You can also omit --skip-dom0 to apply the setting to dom0 also.

1 Like

I didn’t know about cmd.script, quite useful!

But then, I was wondering if salt really hasn’t anything more concise to manage a config file… What about this?

{% set config_path = "/home/user/.config/xfce4/terminal/terminalrc" %}

Check {{config_path}}:
    file.managed:
        - name: {{ config_path }} 
        - makedirs: true
        - user: user
        - group: user
    ini.options_present:
        - name: {{ config_path }} 
        - sections:
            Configuration:
                ShortcutsNoMnemonics: "TRUE"

Edit: forgot to set user and group ownership. I don’t know if the default permissions are correct.

That is a better solution. Thanks. The permissions looks the same as when Xfce4 Terminal makes the file.