varietywalls / variety

Wallpaper downloader and manager for Linux systems
http://peterlevi.com/variety
GNU General Public License v3.0
1.12k stars 137 forks source link

Support in-memory options changing with a read-only config file #667

Open Nemo157 opened 6 months ago

Nemo157 commented 6 months ago

Version of Variety you are using variety 0.8.10

Is your feature request related to a problem? Please describe.

When using home-manager to configure my system it creates read-only config files for services. If I then try to set an option on a running variety instance (e.g. in a script that updates the system color scheme) this succeeds:

> variety --set-option icon Dark
Variety is already running. Sending the command to the running instance.

but the background service logs an error when it attempts to write this to the config file, and doesn't actually apply the change:

ERROR: 2023-12-09 14:46:27,113: process_command() 'Could not read/write configuration:'
Traceback (most recent call last):
  File "/nix/store/49ywz2z7zmkgxisph4pz8hdcf996pq5q-variety-0.8.10/lib/python3.11/site-packages/variety/VarietyWindow.py", line 2477, in process_command
    Options.set_options(options.set_options)
  File "/nix/store/49ywz2z7zmkgxisph4pz8hdcf996pq5q-variety-0.8.10/lib/python3.11/site-packages/variety/Options.py", line 851, in set_options
    config.write()
  File "/nix/store/wr530732f2m8lfj0m9vmkk0gykpsnc3n-python3.11-configobj-5.0.8/lib/python3.11/site-packages/configobj/__init__.py", line 2128, in write
    with open(self.filename, 'wb') as h:
         ^^^^^^^^^^^^^^^^^^^^^^^^^
OSError: [Errno 30] Read-only file system: '/home/nemo157/.config/variety/variety.conf'

Describe the solution you'd like If the config file is not writeable, changing options programmatically should still work and just not be saved.