Set dark mode wallpaper as well on Ubuntu

This gets it working on my machine! And the last of the big three!
This commit is contained in:
Isaiah Odhner 2023-07-17 22:43:36 -04:00
parent 5fd214182c
commit 00e6dd70b0
2 changed files with 9 additions and 1 deletions

View File

@ -197,7 +197,7 @@ To preview ANSI art files in file managers like Nautilus, Thunar, Nemo, or Caja,
- Free-Form Select stamping/finalizing is incorrect when the selection is off-screen to the left or top.
- Status bar description can be left blank when selecting a menu item. (I think the `Leave` event can come after closing, once the mouse moves.)
- Menu items like Copy/Cut/Paste are not grayed out when inapplicable. Only unimplemented items are grayed out.
- Set As Wallpaper may not work on your system. It works for me on Windows 10, and macOS 10.14, but on Ubuntu 22, the wallpaper setting is updated but the picture is not, unless I manually pick it. There is also untested support for many other platforms.
- Set As Wallpaper (Tiled) acts the same as Set As Wallpaper (Centered).
- ANSI files (.ans) are treated as UTF-8 when saving and loading, rather than CP437 or Windows-1252 or any other encodings. Unicode is nice and modern terminals support it, but it's not the standard for ANSI files. There isn't really a standard for ANSI files.
- ANSI files are loaded with a white background. This may make sense as a default for text files, but ANSI files either draw a background or assume a black background, being designed for terminals.
- Hitting Enter in View Bitmap mode exits the mode but may also trigger a menu item. Menu items ought to be disabled when hidden, and View Bitmap should prevent the key event from taking other actions if possible.

View File

@ -93,13 +93,21 @@ def set_wallpaper(file_loc: str, first_run: bool = True):
uri = "'file://%s'" % file_loc
SCHEMA = "org.gnome.desktop.background"
KEY = "picture-uri"
# Needed for Ubuntu 22 in dark mode
# Might be better to set only one or the other, depending on the current theme
# In the settings it will say "This background selection only applies to the dark style"
# even if it's set for both, arguably referring to the selection that you can make on that page.
KEY_DARK = "picture-uri-dark"
try:
from gi.repository import Gio # type: ignore
gsettings = Gio.Settings.new(SCHEMA) # type: ignore
gsettings.set_string(KEY, uri)
gsettings.set_string(KEY_DARK, uri)
except Exception:
args = ["gsettings", "set", SCHEMA, KEY, uri]
subprocess.Popen(args)
args = ["gsettings", "set", SCHEMA, KEY_DARK, uri]
subprocess.Popen(args)
elif desktop_env=="mate":
try: # MATE >= 1.6
# info from http://wiki.mate-desktop.org/docs:gsettings