[qubes-users] Injecting configuration files into appVM when it's created/started for the first time

I am sure I have read this somewhere here on the list or in the [documentation](Documentation | Qubes OS) that it is possible to inject configuration files into an appVM when it gets created. Can someone maybe remind me how to do it?

For example to enable a default dark theme in a VM one does the following:

mkdir -p .config/gtk-3.0
vi .config/gtk-3.0/settings.ini

Then you add the following lines to settings.ini:

[Settings]
gtk-application-prefer-dark-theme=1

The problem here is if you do it in the template the appVM does not inherit ".config/gtk-3.0/settings.ini" because the appVM gets its own private storage. It is however a pain to have to manually put it in each appVM. This is just an example there are many other cases where this is desirable.

Qubes:

I am sure I have read this somewhere here on the list or in the
[documentation](Documentation | Qubes OS) that it is possible to inject
configuration files into an appVM when it gets created. Can someone maybe
remind me how to do it?

For example to enable a default dark theme in a VM one does the following:

mkdir -p .config/gtk-3.0
vi .config/gtk-3.0/settings.ini

Then you add the following lines to settings.ini:

[Settings]
gtk-application-prefer-dark-theme=1

The problem here is if you do it in the template the appVM does not inherit
".config/gtk-3.0/settings.ini" because the appVM gets its own private
storage. It is however a pain to have to manually put it in each appVM. This
is just an example there are many other cases where this is desirable.

Everything in /etc/skel/ on the TemplateVM is copied to /home/user/ on
VM creation, e.g. /etc/skel/.config/gtk-3.0/settings.ini (although for
this specific case you could just use /etc/gtk-3.0/settings.ini which
would also apply to existing VMs, not just newly created ones).

Rusty

I sometimes need something similar, but I prefer a slightly different approach. I prefer the config files to be in the TemplateVM, so that I can easily update them for all the VMs. There is no general solution for all the cases, but you often can find a global file. For example:

  • /etc/ssh/ssh_known_hosts
  • /etc/ssh/ssh_config.d/something.conf allows you to configure SSH client, e.g., RevokedHostKeys.
  • /etc/xdg/xfce4/terminal/terminalrc for XFCE4 Terminal settings
  • /usr/share/geany/geany.conf
    Regards,
    Vít Šesták ‘v6ak’

Vít Šesták wrote:
I sometimes need something similar, but I prefer a slightly different approach. I prefer the config files to be in the TemplateVM, so that I can easily update them for all the VMs. There is no general solution for all the cases, but you often can find a global file. For example:
* /etc/xdg/xfce4/terminal/terminalrc for XFCE4 Terminal settings

Thank you for the nice tip. Rather using a global config file is in fact more like I want it. I will definitely use the xfce4-terminal settings file global location. What is the best way to find other configuration files' global location. Is it just a matter of searching or is there a more sophisticated approach?

For example I would also like to use global settings locations for,

1. global dark theme, currently I have it configured in `~/.config/gtk-3.0/settings.ini`
2. is there one for `~./.bashrc`
3. `~/.config/dconf/user` (the config file that gets created by executing `gsettings set org.gnome.desktop.interface color-scheme prefer-dark. A necessary setting with newer Gtk applications, like the latest evince, not following the dark theme setting in `~/.config/gtk-3.0/settings.ini` anymore. Some software is changing over to Handy StyleManager for theming.
4. Is there on for Krusader, currently it is in `~/.config/krusaderrc`

Qubes wrote:

Vít Šesták wrote:
I sometimes need something similar, but I prefer a slightly different approach. I prefer the config files to be in the TemplateVM, so that I can easily update them for all the VMs. There is no general solution for all the cases, but you often can find a global file. For example:
* /etc/xdg/xfce4/terminal/terminalrc for XFCE4 Terminal settings

Thank you for the nice tip. Rather using a global config file is in fact more like I want it. I will definitely use the xfce4-terminal settings file global location. What is the best way to find other configuration files' global location. Is it just a matter of searching or is there a more sophisticated approach?

For example I would also like to use global settings locations for,

1. global dark theme, currently I have it configured in `~/.config/gtk-3.0/settings.ini`
2. is there one for `~./.bashrc`

I see in my ~/.bashrc it gives the global location

# Source global definitions
if [ -f /etc/bashrc ]; then
         . /etc/bashrc

I have several ways:

a. Google
b. ChatGPT, e.g. “Can I configure XFCE Terminal for all users?” (real example copied from my history)

c. Try to find a file with the same name (maybe without initial dot) in /usr, /etc, etc. Something like this: sudo find / -xdev -name zshrc

Regards,
Vít Šesták ‘v6ak’

Vít Šesták wrote:
I have several ways:

a. Google
b. ChatGPT, e.g. “Can I configure XFCE Terminal for all users?” (real example copied from my history)
c. Try to find a file with the same name (maybe without initial dot) in /usr, /etc, etc. Something like this: sudo find / -xdev -name zshrc

I have a question that I was hoping someone can shed some light on. I put an alias, now in /etc/bashrc to make it global, to

alias l='ls -Ahl'

This works everywhere but it does not work with sudo,

[user@fedora ~]$ sudo l
sudo: l: command not found
[user@fedora-37-m-default ~]$

Why is that, can I make it comply?

That happens because bash will replace an alias only if it is is the first word. You can set the alias
alias sudo='sudo '. Because it has a space at the end it will also check the parameter(‘l’ in your situation) if it is an alias.

Cristian Margine wrote:
That happens because bash will replace an alias only if it is is the first word. You can set the alias
alias sudo='sudo '. Because it has a space at the end it will also check the parameter('l' in your situation) if it is an alias.

  Thank you kindly that works a treat.

Qubes wrote:

Vít Šesták wrote:
I sometimes need something similar, but I prefer a slightly different approach. I prefer the config files to be in the TemplateVM, so that I can easily update them for all the VMs. There is no general solution for all the cases, but you often can find a global file. For example:
* /etc/xdg/xfce4/terminal/terminalrc for XFCE4 Terminal settings

Thank you for the nice tip. Rather using a global config file is in fact more like I want it. I will definitely use the xfce4-terminal settings file global location. What is the best way to find other configuration files' global location. Is it just a matter of searching or is there a more sophisticated approach?

For example I would also like to use global settings locations for,

1. global dark theme, currently I have it configured in `~/.config/gtk-3.0/settings.ini`

The global path for the dark theme is `/usr/share/gtk-3.0/settings.ini`.

Rusty Bird wrote:

Everything in /etc/skel/ on the TemplateVM is copied to /home/user/ on
VM creation, e.g. /etc/skel/.config/gtk-3.0/settings.ini (although for
this specific case you could just use /etc/gtk-3.0/settings.ini which
would also apply to existing VMs, not just newly created ones).

Is there a sane way to update existing `*.conf` files on VMs that are already running?

For example, I have installed new software in a Template that is used by several VMs. I would like a default look and feel across all of the VMs when I use the new software but the software stores its configuration in `~/.config/.......`

I can put the default configuration in `/etc/skel/.config/.......',which will apply to newly created VMs, but this will not apply to already created and running VMs.

Is there a not-so-labour-intensive way to solve this problem?

Most software has a default config location. You can search it on archwiki(qubes is using fedora, but in general the arch wiki list paths that work on all distros as location where the configuration for a program must be placed), ask chatgpt or search on google for the default config location for that program. It might be in /etc or somewhere in /usr/.

Use salt - it's easy to apply to existing qubes, as well as template.
You can (if you wish) store the config file whole, or just the changes
that you want to make, as part of the install.
It also has the advantage of being self documenting.

I have looked over salt, albeit briefly, but it definitely does not look like something that someone with no knowledge of salt can just jump in and use. You have mentioned this a lot so perhaps the best person here to ask is you. Can you maybe recommend a salt for 'dummies' guide?

I have some notes at GitHub - unman/notes which take you
through simple steps with many examples of using salt in Qubes.

Cristian Margine wrote:
Most software has a default config location. You can search it on archwiki(qubes is using fedora, but in general the arch wiki list paths that work on all distros as location where the configuration for a program must be placed), ask chatgpt or search on google for the default config location for that program. It might be in /etc or somewhere in /usr/.

Perhaps my search terms are just out of whack, but I have had a good look around and I cannot find a system wide location for `~/.config/qt5ct/qt5ct.conf` that controls the Style and Icon Theme for example. I have looked around on Archwiki [1] as well but there is no mention of a global conf file for Qt5. Qt4 on the other hand does support a global conf file [2], `/etc/xdg/Trollech.conf`, which I have tried using but Qt5 does not look at it. Even more frustrating I cannot find a list of the environment variables that I can potentially use. I only know of the `QT_QPA_PLATFORMTHEME=qt5ct` which I currently use and `QT_STYLE_OVERRIDE=` [3][4] which you can set to either `adwaita` or `kvantum` However there may be an environment variable one can use to set the path to the `qt5ct.conf`, but such a list alludes me.

I also canot find a system wide location for Krusader configuration file `~/.config/krusaderrc`.

From there the need arises to inject files into already running VMs. For future VMs this problem is solved with `/etc/skel` but my problem is with running VMs.

[1]: Qt - ArchWiki
[2]: Qt - ArchWiki
[3]: Uniform look for Qt and GTK applications - ArchWiki
[4]: Uniform look for Qt and GTK applications - ArchWiki

Perhaps my search terms are just out of whack, but I have had a good
look around and I cannot find a system wide location for
~/.config/qt5ct/qt5ct.conf that controls the Style and Icon Theme for
example.

It’s easy to find.

  1. Me: Do you know a system-wide file for ~/.config/qt5ct/qt5ct.conf?
    ChatGPT: Yes, the system-wide configuration file for ~/.config/qt5ct/qt5ct.conf is typically located at /etc/xdg/qt5ct/qt5ct.conf. This file contains the default settings for the Qt5 Configuration Tool and is used as a fallback configuration file if no user-specific configuration is found.

Note that the location of the system-wide configuration file may vary depending on your specific Linux distribution or operating system. You can use the locate or find command to search for the file on your system.

  1. Verify by Google by searching “/etc/xdg/qt5ct/qt5ct.conf” (including quotes). It seems that this location is real.

Even more frustrating I cannot
find a list of the environment variables that I can potentially use. I
only know of the QT_QPA_PLATFORMTHEME=qt5ct which I currently use and
QT_STYLE_OVERRIDE= [3][4] which you can set to either adwaita or
kvantum However there may be an environment variable one can use to
set the path to the qt5ct.conf, but such a list alludes me.

  1. Look where it is used:
    sudo grep -rl QT_QPA_PLATFORMTHEME /usr
    /usr/share/doc/qgnomeplatform-qt6/README.md
    /usr/share/doc/gnupg2/NEWS
    /usr/share/doc/qgnomeplatform-qt5/README.md
    /usr/lib64/libQt5Gui.so.5.15.9
    /usr/lib64/libQt6Gui.so.6.4.3

  2. Look in the binary:

strings /usr/lib64/libQt6Gui.so.6.4.3 | grep ‘^QT_’

Regards,
Vít Šesták ‘v6ak’

Vít Šesták wrote:
    Perhaps my search terms are just out of whack, but I have had a good
    look around and I cannot find a system wide location for
    `~/.config/qt5ct/qt5ct.conf` that controls the Style and Icon Theme for
    example.

It's easy to find.

1. Me: Do you know a system-wide file for ~/.config/qt5ct/qt5ct.conf?
ChatGPT: Yes, the system-wide configuration file for ~/.config/qt5ct/qt5ct.conf is typically located at /etc/xdg/qt5ct/qt5ct.conf. This file contains the default settings for

I tried `/etc/xdg/qt5ct/qt5ct.conf` and it didn't work. I also tried `/etc/xdg/qt5ct.conf` (just to try my luck) but it also doesn't work. I will try it again just to double check, maybe my midnight oil lamp was already running out of oil when I did try and I made a mess of it.

the Qt5 Configuration Tool and is used as a fallback configuration file if no user-specific configuration is found.

Note that the location of the system-wide configuration file may vary depending on your specific Linux distribution or operating system. You can use the locate or find command to search for the file on your system.

2. Verify by Google by searching "/etc/xdg/qt5ct/qt5ct.conf" (including quotes). It seems that this location is real.

    Even more frustrating I cannot
    find a list of the environment variables that I can potentially use. I
    only know of the `QT_QPA_PLATFORMTHEME=qt5ct` which I currently use and
    `QT_STYLE_OVERRIDE=` [3][4] which you can set to either `adwaita` or
    `kvantum` However there may be an environment variable one can use to
    set the path to the `qt5ct.conf`, but such a list alludes me.

1. Look where it is used:
sudo grep -rl QT_QPA_PLATFORMTHEME /usr
/usr/share/doc/qgnomeplatform-qt6/README.md
/usr/share/doc/gnupg2/NEWS
/usr/share/doc/qgnomeplatform-qt5/README.md
/usr/lib64/libQt5Gui.so.5.15.9
/usr/lib64/libQt6Gui.so.6.4.3

2. Look in the binary:
strings /usr/lib64/libQt6Gui.so.6.4.3 | grep '^QT_'

Thanks I will check this.

The file location may vary by your distro, at least ChatGPT tells so. Also strace might help you to check what file locations are accessed:

  1. strace -o /tmp/strace.log gnome-terminal
  2. grep settings.ini /tmp/strace.log

You’ll probably want to use a Qt app rather than gnome-terminal, but the way to look for that is the same.

Regards,
Vít Šesták ‘v6ak’

Is this normal/expected behavior?

As has been discussed in this thread, making changes in `/etc/skel` in a template of an existing VM does not propagate to the VM. However, if you change the VMs template to a different template it seems like `/etc/skel` is copied to `/home/user` when the VM boots, even though it is not a new VM. I don't understand the documentation in this way.