#!/bin/bash

NEW_THEME=$2

function wallpaper() {
  /usr/libexec/PlistBuddy -c "set AllSpacesAndDisplays:Desktop:Content:Choices:0:Files:0:relative file:///$1" ~/Library/Application\ Support/com.apple.wallpaper/Store/Index.plist && \
    killall WallpaperAgent
}

wp=$(find $HOME/Wallpapers/$NEW_THEME/* | shuf -n1)
wallpaper $wp
