#!/bin/sh

DESTDIR=share/desktop-base/kali-theme/
DESKTOP_BACKGROUND=$1
LOGIN_BACKGROUND=$2

# login/lockscreen
ln -sfv ../../../backgrounds/kali/$LOGIN_BACKGROUND.xml ${DESTDIR}lockscreen/gnome-background.xml
ln -sfv ../../../backgrounds/kali/$LOGIN_BACKGROUND-16x9.png ${DESTDIR}login/background

# desktop background
kde_wallpaper=$(echo $DESKTOP_BACKGROUND | sed -E 's/(^|-)([a-z])/\U\2/g')
ln -sfv ../../../backgrounds/kali/$DESKTOP_BACKGROUND.xml ${DESTDIR}wallpaper/gnome-background.xml
ln -nsfv ../../../wallpapers/$kde_wallpaper/contents ${DESTDIR}wallpaper/contents

sed -i "s/defaultWallpaperTheme=.*/defaultWallpaperTheme=${kde_wallpaper}/" share/plasma/desktoptheme/kali/metadata.desktop

# default background symlink for XFCE
mkdir -p share/backgrounds/kali-16x9
ln -sf $DESKTOP_BACKGROUND.png share/backgrounds/kali-16x9/default
