Support animated GIF wallpapers via awww
swaybg only ever renders one frame, so an animated GIF (detected by its magic bytes, not the .gif extension - the active wallpaper file is always literally named wallpaper.png regardless of real format) now goes through awww instead, which was already installed. Found that awww img's --transition-type none - the obvious flag for an instant switch - silently kills the render loop that also drives GIF frame advancement; --transition-step 255 gives the same instant switch without that side effect. New `wallpaper.py start` picks the right backend for whatever's currently active and replaces the hardcoded swaybg autostart line in hyprland.lua, so a GIF wallpaper survives a restart correctly too. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Dujsk9jYfxUVLtb5B8eC94
This commit is contained in:
@@ -81,7 +81,7 @@ Theming used to go through a third-party app called aether; it's gone now (it di
|
||||
- Thunar's grid is `ExoIconView`, an old widget that fetches its selection color as a named symbolic color (`gtk_style_context_lookup_color("theme_selected_bg_color")`) instead of through normal `:selected` CSS matching — `.view:selected` and even a blanket `*:selected` do nothing for it. The fix is redefining `@define-color theme_selected_bg_color`/`theme_selected_fg_color` (+ the `unfocused_` pair) in `gtk.css`, which is what `gtk_selection_color`/`gtk_selection_opacity` actually drive
|
||||
- Folder icon *colors* aren't CSS at all — they're baked into the icon theme's SVGs. [`theme/icon_theme.py`](theme/icon_theme.py) generates a small icon theme at `~/.local/share/icons/AetherRice` (inheriting Papirus-Dark for everything else) by taking Papirus-Dark's own "blue" folder SVGs and substituting their two fixed colors for the accent and a darkened variant — no sudo needed, and it matches the accent exactly rather than snapping to one of `papirus-folders`' fixed presets
|
||||
- [`theme/render.py`](theme/render.py) renders every template to its destination and reloads the affected apps (`hyprctl reload`, `makoctl reload`, kitty via `SIGUSR1`, a best-effort `dbus-send` KGlobalSettings ping for KDE apps). Qt/GTK apps only read their palette/CSS at startup, and not every app listens for the `dbus-send` ping either — an already-open window generally keeps its old colors until it's restarted, a freshly launched one picks up a palette change immediately. It also pings the running shell over Quickshell's two IPC targets (`theme` for the bar, `theme-widget` for the widget itself — two separate top-level QML components) so the bar's own accent/border/pill colors and all four opacities, which live in QML rather than a config file another app reads, pick up changes immediately too — no restart. Run it after editing a template by hand, or use `--set KEY VALUE` to change one color (`#rrggbb`) or opacity (`0`-`1`) from a terminal, `--get KEY` / `--dump` to read the palette back out
|
||||
- [`theme/wallpaper.py`](theme/wallpaper.py) swaps the wallpaper: `apply <path>` archives the current one (deduped by hash) into `~/.local/share/quickshell/wallpapers/` and copies the new one to [`hypr/wallpaper.png`](hypr/wallpaper.png) (loaded via `swaybg` in `hyprland.lua`), `pick` does the same via a native file picker, `list` feeds the widget's gallery of past wallpapers
|
||||
- [`theme/wallpaper.py`](theme/wallpaper.py) swaps the wallpaper: `apply <path>` archives the current one (deduped by hash) into `~/.local/share/quickshell/wallpapers/` and copies the new one to [`hypr/wallpaper.png`](hypr/wallpaper.png) (still that filename regardless of the real format inside - `swaybg`/Qt image loading both sniff content, not the extension), `pick` does the same via a native file picker, `list` feeds the widget's gallery of past wallpapers, `start` (re)starts whichever backend the current wallpaper needs without touching it (called on Hyprland startup). A static image goes through `swaybg` as before; an animated GIF (detected by its magic bytes, not `.gif`) goes through [`awww`](https://codeberg.org/LGFae/awww) instead, since `swaybg` only ever shows one frame - `awww img`'s `--transition-type none` looked like the right flag for an instant switch but silently kills the render loop that also drives GIF frame advancement, so `--transition-step 255` is used instead for the same effect
|
||||
- [`theme/presets.py`](theme/presets.py) saves/loads/deletes named snapshots of the *entire* palette (every color and opacity value) as JSON files in `~/.local/share/quickshell/theme-presets/` — per-machine user data, not project config, so it's never tracked by this repo, same reasoning as the wallpaper history above. A built-in `Default` entry (the palette below) is always available, can't be saved over or deleted, and doesn't live in that folder — it's hardcoded in both `presets.py` and the widget
|
||||
|
||||
mako's per-urgency border colors (normal = accent, low = muted, critical = red) work the same way as Hyprland's border colors: edit the template at `theme/templates/mako/colors.ini`, not `mako/colors.ini` itself — that gets overwritten on the next render.
|
||||
@@ -160,7 +160,7 @@ It's a blue theme (`#1793d1` accent on a dark `#1a1b26` background) built around
|
||||
|
||||
## Requirements
|
||||
|
||||
Beyond Hyprland itself, the bar's scripts expect: `quickshell`, `nmcli`, `wpctl`, `nvidia-smi` (GPU stats — no-ops gracefully if absent), `sensors` (lm_sensors, for CPU temperature), `python3`, and `curl` (for the network widget's public-IP lookup). The theme widget's wallpaper picker additionally needs `zenity` (native file picker) and `swaybg`.
|
||||
Beyond Hyprland itself, the bar's scripts expect: `quickshell`, `nmcli`, `wpctl`, `nvidia-smi` (GPU stats — no-ops gracefully if absent), `sensors` (lm_sensors, for CPU temperature), `python3`, and `curl` (for the network widget's public-IP lookup). The theme widget's wallpaper picker additionally needs `zenity` (native file picker) and `swaybg`; an animated GIF wallpaper additionally needs `awww` (optional - only touched when the active wallpaper is a GIF).
|
||||
|
||||
This is an Arch + Hyprland rice through and through, so the list below is Arch-authoritative — everything in the pacman column is a plain `extra`/`multilib` package on current Arch, nothing needs an AUR helper. `apt`/`dnf` columns are best-effort: Hyprland and its ecosystem (Hyprland itself, `quickshell`, `hyprcursor`) move fast and generally aren't in Debian/Ubuntu's or Fedora's stock repos, so those need a third-party repo (Fedora: the [`solopasha/hyprland` COPR](https://copr.fedorainfracloud.org/coprs/solopasha/hyprland/) covers most of it) or building from source — a blank cell means "no known repo package, check the project's own install docs". Snap has essentially no coverage here (this is all system/Wayland-level tooling, not the kind of app snap packages); where an optional app happens to have one, it's noted below the table instead.
|
||||
|
||||
@@ -174,7 +174,8 @@ This is an Arch + Hyprland rice through and through, so the list below is Arch-a
|
||||
| `rofi` | Launcher | `rofi` | `rofi` | `rofi` |
|
||||
| `mako` | Notifications | `mako` | `mako-notifier` | `mako` |
|
||||
| `thunar` (+ `thunar-volman`, `thunar-archive-plugin`, `tumbler`, `gvfs`) | File manager, mounting, archives, thumbnails | `thunar thunar-volman thunar-archive-plugin tumbler gvfs` | `thunar thunar-volman thunar-archive-plugin tumbler gvfs` | `thunar thunar-volman thunar-archive-plugin tumbler gvfs` |
|
||||
| `swaybg` | Wallpaper | `swaybg` | `swaybg` | `swaybg` |
|
||||
| `swaybg` | Wallpaper (static) | `swaybg` | `swaybg` | `swaybg` |
|
||||
| `awww` | Wallpaper (animated GIF only, optional) | `awww` | build from [source](https://codeberg.org/LGFae/awww) | build from [source](https://codeberg.org/LGFae/awww) |
|
||||
| `hyprcursor` (`hyprcursor-util`) | Cursor theme build | `hyprcursor` | — | `hyprcursor` (COPR) |
|
||||
| `librsvg` (`rsvg-convert`) | Cursor theme build | `librsvg` | `librsvg2-bin` | `librsvg2-tools` |
|
||||
| `grim` + `slurp` | Screenshots | `grim slurp` | `grim slurp` | `grim slurp` |
|
||||
@@ -202,7 +203,7 @@ This is an Arch + Hyprland rice through and through, so the list below is Arch-a
|
||||
# enabled by default, no AUR helper needed)
|
||||
sudo pacman -S --needed hyprland sddm xdg-desktop-portal-hyprland quickshell kitty rofi \
|
||||
mako thunar thunar-volman thunar-archive-plugin tumbler gvfs gvfs-mtp gvfs-smb \
|
||||
xarchiver swaybg hyprcursor librsvg grim slurp wl-clipboard cliphist zenity \
|
||||
xarchiver swaybg awww hyprcursor librsvg grim slurp wl-clipboard cliphist zenity \
|
||||
networkmanager network-manager-applet wireplumber pavucontrol blueman brightnessctl \
|
||||
playerctl lm_sensors nvidia-utils curl python qt5ct qt6ct nwg-look materia-gtk-theme \
|
||||
papirus-icon-theme ttf-jetbrains-mono-nerd
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
; thunar GtkAccelMap rc-file -*- scheme -*-
|
||||
; this file is an automated accelerator map dump
|
||||
;
|
||||
; (gtk_accel_path "<Actions>/ThunarDetailsView/expandable-folders" "")
|
||||
; (gtk_accel_path "<Actions>/ThunarStandardView/sort-by-type" "")
|
||||
; (gtk_accel_path "<Actions>/ThunarStatusBar/toggle-last-modified" "")
|
||||
; (gtk_accel_path "<Actions>/Thunarwindow/menu" "")
|
||||
@@ -88,6 +89,7 @@
|
||||
; (gtk_accel_path "<Actions>/ThunarWindow/view-as-icons" "<Primary>1")
|
||||
; (gtk_accel_path "<Actions>/ThunarActionManager/delete-2" "<Shift>Delete")
|
||||
; (gtk_accel_path "<Actions>/ThunarWindow/zoom-in" "<Primary>plus")
|
||||
; (gtk_accel_path "<Actions>/ThunarStandardView/configure-columns" "")
|
||||
; (gtk_accel_path "<Actions>/ThunarStandardView/rename" "F2")
|
||||
; (gtk_accel_path "<Actions>/ThunarWindow/open-location" "<Primary>l")
|
||||
; (gtk_accel_path "<Actions>/ThunarWindow/view-as-compact-list" "<Primary>3")
|
||||
|
||||
@@ -616,7 +616,7 @@ hl.on("hyprland.start", function()
|
||||
hl.exec_cmd("quickshell -c default")
|
||||
hl.exec_cmd("mako")
|
||||
hl.exec_cmd("nm-applet --indicator")
|
||||
hl.exec_cmd("swaybg -i ~/.config/hypr/wallpaper.png -m fill")
|
||||
hl.exec_cmd("python3 ~/.config/theme/wallpaper.py start")
|
||||
hl.exec_cmd("wl-paste --type text --watch cliphist store")
|
||||
hl.exec_cmd("wl-paste --type image --watch cliphist store")
|
||||
end)
|
||||
|
||||
@@ -82,7 +82,7 @@ if [ "$INSTALL_DEPS" = 1 ]; then
|
||||
echo "Installing dependencies via pacman (see README.md for apt/dnf equivalents)..."
|
||||
sudo pacman -S --needed hyprland sddm xdg-desktop-portal-hyprland quickshell kitty rofi \
|
||||
mako thunar thunar-volman thunar-archive-plugin tumbler gvfs gvfs-mtp gvfs-smb \
|
||||
xarchiver swaybg hyprcursor librsvg grim slurp wl-clipboard cliphist zenity \
|
||||
xarchiver swaybg awww hyprcursor librsvg grim slurp wl-clipboard cliphist zenity \
|
||||
networkmanager network-manager-applet wireplumber pavucontrol blueman brightnessctl \
|
||||
playerctl lm_sensors nvidia-utils curl python qt5ct qt6ct nwg-look materia-gtk-theme \
|
||||
papirus-icon-theme ttf-jetbrains-mono-nerd
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
#!/usr/bin/env python3
|
||||
"""Manages the desktop wallpaper (~/.config/hypr/wallpaper.png, loaded by swaybg).
|
||||
"""Manages the desktop wallpaper (~/.config/hypr/wallpaper.png, loaded by swaybg/awww).
|
||||
|
||||
wallpaper.py list JSON array of previously used wallpapers (newest first),
|
||||
each {id, path, added, current}; "path" is directly usable
|
||||
@@ -7,9 +7,19 @@
|
||||
wallpaper.py apply <path> archive the current wallpaper, make <path> the new one
|
||||
wallpaper.py pick open a native file picker, then apply the chosen file
|
||||
wallpaper.py remove <id> delete one archived wallpaper (refuses the current one)
|
||||
wallpaper.py start (re)start whichever daemon the current wallpaper needs,
|
||||
without touching it - called on Hyprland startup
|
||||
|
||||
The picker button in the ThemeWidget calls "list" to fill its gallery of recommendations,
|
||||
"pick" for "choose a new file", and "apply" again when a gallery entry is clicked.
|
||||
|
||||
Static images go through swaybg, same as always. An animated GIF needs an actual
|
||||
compositing daemon instead - swaybg only ever shows one frame - so those go through
|
||||
awww (already installed; a swww-like wlroots wallpaper daemon that also does gifs).
|
||||
Which one applies is decided by sniffing the file's magic bytes, not its extension:
|
||||
ACTIVE is always literally named wallpaper.png regardless of the real format inside
|
||||
(pre-existing, swaybg/Qt image loading both sniff content anyway), so a fixed ".gif"
|
||||
check on that path would never match.
|
||||
"""
|
||||
import hashlib
|
||||
import json
|
||||
@@ -24,6 +34,14 @@ ARCHIVE = os.path.expanduser("~/.local/share/quickshell/wallpapers")
|
||||
MANIFEST = os.path.join(ARCHIVE, "manifest.json")
|
||||
|
||||
|
||||
def is_gif(path):
|
||||
try:
|
||||
with open(path, "rb") as f:
|
||||
return f.read(6) in (b"GIF87a", b"GIF89a")
|
||||
except OSError:
|
||||
return False
|
||||
|
||||
|
||||
def load_manifest():
|
||||
try:
|
||||
return json.load(open(MANIFEST))
|
||||
@@ -53,18 +71,35 @@ def archive_current(entries):
|
||||
return
|
||||
os.makedirs(ARCHIVE, exist_ok=True)
|
||||
next_id = max([e["id"] for e in entries], default=0) + 1
|
||||
ext = os.path.splitext(ACTIVE)[1] or ".png"
|
||||
ext = ".gif" if is_gif(ACTIVE) else (os.path.splitext(ACTIVE)[1] or ".png")
|
||||
dest = os.path.join(ARCHIVE, f"{next_id:04d}{ext}")
|
||||
shutil.copy2(ACTIVE, dest)
|
||||
entries.append({"id": next_id, "file": os.path.basename(dest), "sha256": digest,
|
||||
"added": time.strftime("%Y-%m-%d %H:%M")})
|
||||
|
||||
|
||||
def restart_swaybg():
|
||||
subprocess.run(["pkill", "-x", "swaybg"], check=False, capture_output=True)
|
||||
subprocess.Popen(["swaybg", "-i", ACTIVE, "-m", "fill"],
|
||||
stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL,
|
||||
start_new_session=True)
|
||||
def restart_wallpaper_daemon():
|
||||
if is_gif(ACTIVE):
|
||||
subprocess.run(["pkill", "-x", "swaybg"], check=False, capture_output=True)
|
||||
if subprocess.run(["awww", "query"], capture_output=True, timeout=2).returncode != 0:
|
||||
subprocess.Popen(["awww-daemon"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL,
|
||||
start_new_session=True)
|
||||
for _ in range(20): # wait for the daemon's socket, up to ~2s
|
||||
time.sleep(0.1)
|
||||
if subprocess.run(["awww", "query"], capture_output=True, timeout=2).returncode == 0:
|
||||
break
|
||||
time.sleep(0.3) # query succeeding doesn't mean it's ready for `img` yet
|
||||
# --transition-step 255 for an instant switch, same end result as
|
||||
# --transition-type none - but "none" takes a code path in awww that also kills
|
||||
# the render loop driving GIF frame advancement, leaving it stuck on one frame.
|
||||
subprocess.run(["awww", "img", ACTIVE, "--resize", "crop", "--transition-step", "255"],
|
||||
check=False, capture_output=True, timeout=10)
|
||||
else:
|
||||
subprocess.run(["pkill", "-x", "awww-daemon"], check=False, capture_output=True)
|
||||
subprocess.run(["pkill", "-x", "swaybg"], check=False, capture_output=True)
|
||||
subprocess.Popen(["swaybg", "-i", ACTIVE, "-m", "fill"],
|
||||
stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL,
|
||||
start_new_session=True)
|
||||
|
||||
|
||||
def cmd_list():
|
||||
@@ -84,13 +119,13 @@ def cmd_apply(path):
|
||||
archive_current(entries)
|
||||
shutil.copy2(path, ACTIVE)
|
||||
save_manifest(entries)
|
||||
restart_swaybg()
|
||||
restart_wallpaper_daemon()
|
||||
|
||||
|
||||
def cmd_pick():
|
||||
result = subprocess.run(
|
||||
["zenity", "--file-selection", "--title=Wallpaper wählen",
|
||||
"--file-filter=Images | *.png *.jpg *.jpeg *.webp *.bmp"],
|
||||
"--file-filter=Images | *.png *.jpg *.jpeg *.webp *.bmp *.gif"],
|
||||
capture_output=True, text=True)
|
||||
path = result.stdout.strip()
|
||||
if result.returncode != 0 or not path:
|
||||
@@ -111,6 +146,11 @@ def cmd_remove(id_str):
|
||||
save_manifest([e for e in entries if e["id"] != wanted])
|
||||
|
||||
|
||||
def cmd_start():
|
||||
if os.path.isfile(ACTIVE):
|
||||
restart_wallpaper_daemon()
|
||||
|
||||
|
||||
def main():
|
||||
args = sys.argv[1:]
|
||||
if args[:1] == ["list"]:
|
||||
@@ -121,6 +161,8 @@ def main():
|
||||
cmd_pick()
|
||||
elif args[:1] == ["remove"] and len(args) == 2:
|
||||
cmd_remove(args[1])
|
||||
elif args[:1] == ["start"]:
|
||||
cmd_start()
|
||||
else:
|
||||
sys.exit(__doc__)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user