Injecting configuration files into appVM when it's created/started for the first time

11 views
Skip to first unread message

Qubes

unread,
Apr 29, 2023, 1:36:06 PM4/29/23
to qubes...@googlegroups.com
I am sure I have read this somewhere here on the list or in the
[documentation](https://www.qubes-os.org/doc/) 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.

Rusty Bird

unread,
Apr 30, 2023, 7:20:23 AM4/30/23
to Qubes, qubes...@googlegroups.com
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA512

Qubes:
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
-----BEGIN PGP SIGNATURE-----

iQKTBAEBCgB9FiEEhLWbz8YrEp/hsG0ERp149HqvKt8FAmROTJhfFIAAAAAALgAo
aXNzdWVyLWZwckBub3RhdGlvbnMub3BlbnBncC5maWZ0aGhvcnNlbWFuLm5ldDg0
QjU5QkNGQzYyQjEyOUZFMUIwNkQwNDQ2OUQ3OEY0N0FBRjJBREYACgkQRp149Hqv
Kt9e6RAAiExsUJl9d7xyaLd/m7gVX3HuZAVAAVkFDhTU1SU/o0uVs3rhcuMDAmqx
/gftDBulJnS6pz30TUN/+C7Qd8GcE2VZ37z6tIsP+VMVVA+cUlNIi8VSsCl7+2ho
2ETt12WjHaGQ3tfhEs9G4ixt3hA7EzXL3qI8ItqE68Yel1oi77R21oAqQbFvPOgy
ogAfjIQhmX30esZ9ym5oJZWprzUpPyX3SF1OtgZ5SC84yhPqy1/jOdpxvDNrni3+
ACAMYTBz34nYWS5ioQ6tLEJthFlsswoiKL3R72HRyLhs1gCnVDW/4LNJ0gjJS7jn
zJ958zuRw9pnfFobYqk4359tEpEct7GEMuA/DFaiYf5gO3G3iPkuopr1Iu6p3QV9
SulyaL2a32I5cuIuqa4/ryRsF8aPMrtSQbRJFltDmnOWjh58Kf8rYwY6el2aBmMh
OQGgg7OODTIS24wRX43VXq51SYRi7d/prB0P/fK9s4twijSZ8yXxbOrulco5Kdgp
2aULUnq2TDQ3ZDh0e/ONWx7Q3S3iR7QiM8W6psTsWBaHw+A7GPYQfHvabvYIyYOI
Xh6oRp7PmR9cT0Ojz7QqmAOUB4b6rtjZHXFd3L8oTD+ofmZlHyBXBaFQ+Acbot7n
rz49u7CIqoVDrcTc+rFcL20LhM8iSiBeoqzSkF1S7fb7TYKNn7I=
=wYrE
-----END PGP SIGNATURE-----

Vít Šesták

unread,
May 1, 2023, 10:59:08 AM5/1/23
to qubes-users
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'

Qubes

unread,
May 1, 2023, 2:01:01 PM5/1/23
to qubes...@googlegroups.com
> 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

unread,
May 1, 2023, 2:06:47 PM5/1/23
to qubes...@googlegroups.com
> 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

Vít Šesták

unread,
May 1, 2023, 2:12:15 PM5/1/23
to qubes-users
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'

Qubes

unread,
May 1, 2023, 4:03:14 PM5/1/23
to qubes...@googlegroups.com
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?

Cristian Margine

unread,
May 2, 2023, 1:33:31 AM5/2/23
to qube...@ak47.co.za, qubes...@googlegroups.com
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.
-------- Original Message --------
On May 1, 2023, 11:03 PM, Qubes < qube...@ak47.co.za> wrote:

> 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? -- You received this message because you are subscribed to the Google Groups "qubes-users" group. To unsubscribe from this group and stop receiving emails from it, send an email to qubes-users...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/qubes-users/0d57fe08-5556-cf45-7ab1-6fdc376281ef%40ak47.co.za.
publickey - EmailAddress(s=cristiioan@cristiioan.me) - 0xDAC92D89.asc
signature.asc

Qubes

unread,
May 2, 2023, 1:52:33 AM5/2/23
to qubes...@googlegroups.com
> 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

unread,
May 2, 2023, 2:18:29 AM5/2/23
to qubes...@googlegroups.com
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`.

Qubes

unread,
May 3, 2023, 11:57:21 AM5/3/23
to qubes...@googlegroups.com
> 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?

Cristian Margine

unread,
May 3, 2023, 12:04:51 PM5/3/23
to Qubes, qubes...@googlegroups.com
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/.


------- Original Message -------
> --
> You received this message because you are subscribed to the Google Groups "qubes-users" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to qubes-users...@googlegroups.com.
> To view this discussion on the web visit https://groups.google.com/d/msgid/qubes-users/0cf4e184-f257-6937-84b9-dbcf62ba74af%40ak47.co.za.
publickey - cristiioan@cristiioan.me - 0xDAC92D89.asc
signature.asc

unman

unread,
May 3, 2023, 12:36:44 PM5/3/23
to Qubes, qubes...@googlegroups.com
On Wed, May 03, 2023 at 12:53:00PM +0000, Qubes wrote:

> Is there a sane way to update existing `*.conf` files on VMs that are
> already running?
> Is there a not-so-labour-intensive way to solve this problem?

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.

Qubes

unread,
May 3, 2023, 3:04:45 PM5/3/23
to qubes...@googlegroups.com
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?

unman

unread,
May 3, 2023, 10:48:27 PM5/3/23
to qubes...@googlegroups.com
I have some notes at https://github.com/unman/notes which take you
through simple steps with many examples of using salt in Qubes.

Qubes

unread,
May 4, 2023, 8:09:36 AM5/4/23
to qubes...@googlegroups.com
> 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]:
https://wiki.archlinux.org/title/Qt#Configuration_of_Qt_5_applications_under_environments_other_than_KDE_Plasma
[2]: https://wiki.archlinux.org/title/Qt#Styles_in_Qt_4
[3]:
https://wiki.archlinux.org/title/Uniform_look_for_Qt_and_GTK_applications#Adwaita
[4]:
https://wiki.archlinux.org/title/Uniform_look_for_Qt_and_GTK_applications#Kvantum

Vít Šesták

unread,
May 4, 2023, 8:26:56 AM5/4/23
to qubes-users
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.

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_'

Regards,
Vít Šesták 'v6ak'

Qubes

unread,
May 4, 2023, 8:31:52 AM5/4/23
to qubes...@googlegroups.com
> 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.

Vít Šesták

unread,
May 4, 2023, 8:42:14 AM5/4/23
to qubes-users
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'

Qubes

unread,
May 4, 2023, 8:55:05 AM5/4/23
to qubes...@googlegroups.com
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.

Qubes

unread,
May 4, 2023, 10:19:37 AM5/4/23
to qubes...@googlegroups.com
> Qubes wrote:
>> 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.
>
Ok so just to provide feedback, I have tried this again. The default is
in fact located at `/etc/xdg/qt5ct/qt5ct.conf`, but it is only applied
if `~/.config/qt5ct/qt5ct.conf` does not exist, with caveats. In fact
what happens is if `~/.config/qt5ct/qt5ct.conf` does not exist
`/etc/xdg/qt5ct/qt5ct.conf` is copied to `~/.config/qt5ct/`. Which kind
of solves the problem.

If the file exists you can delete it and just close all of you Qt
applications and open them again. With the first one that you open it
will check if `~/.config/qt5ct/qt5ct.conf` exists and if not make a copy
of `/etc/xdg/qt5ct/qt5ct.conf`.

This still does not allow a seamless edit to `/etc/xdg/qt5ct/qt5ct.conf`
(in the Template) that will just apply to all VMs, but it does make it
easier.

I had a look at `strings /usr/lib64/libQt5Gui.so.5.15.9|grep '^QT_'` but
I don't see a variable name that indicates to me it has anything to do
with the path of `qt5ct.conf`. Thank you for the suggestion I have
learnt something new today.

Qubes

unread,
May 4, 2023, 10:28:20 AM5/4/23
to qubes...@googlegroups.com
I checked this now. This not the case, it was because of a test I was
doing with another thread "Injecting configuration files into appVM when
it's created/started for the first time". The test I was doing did
something unexpected that made it appear as if `/etc/skel` was copied to
a VM when the Template changes when in fact it does not.
Reply all
Reply to author
Forward
0 new messages