#!/usr/bin/env fish
# Changes the wallpaper to the given image and updates the updates the desktop according to the wallpaper's colors.

set img (readlink -f "$argv[1]")
if not test -f "$img"
    echo "Error: '$argv[1]' is not a valid file" >&2
    exit 1
end

set pid (pidof wbg)
swaybg --mode fill --output '*' --image "$img" &
if test -n "$pid"
    kill $pid
end

ln -sf "$img" ~/.cache/current_background # link to cache so that other apps can reference it
ron-theme-generate
