#!/bin/env bash if [ -f "$HOME/.profile" ]; then source "$HOME/.profile" fi # Note: In the future, when multi-monitor support is added, the monitor offset could be retrieved from xrandr # here and fed into feh using --geometry monitor=($(xrandr | grep " connected" | head -n 1 | awk '{ split($4, a, /[+x]/); print $1 " " a[1] " " a[2]; }')) monitor_name="${monitor[0]}" monitor_width="${monitor[1]}" monitor_height="${monitor[2]}" prop="/backdrop/screen0/monitor${monitor_name}/workspace0/last-image" path="$1" wallpaper_dir="$HOME/.local/share/le_wallpaper" wallpaper_path="${wallpaper_dir}/wallpaper.png" wallpaper_store="${wallpaper_dir}/source_path" mkdir -p "$wallpaper_dir" if [ -z "$path" ]; then path="$(xfconf-query -c xfce4-desktop -p "$prop")" if [[ ! "$path" = /* ]]; then path="${HOME}/${path}" fi fi if [ "$path" == "$wallpaper_path" ]; then path=$(cat "$wallpaper_store") fi # path="$(readlink -f "$path")" if [ ! -f "$path" ]; then echo "No wallpaper source" exit 0 fi filename=$(basename -- "$path") ext="${filename##*.}" # The following always assumes the monitor is landscape if [ "$ext" == "svg" ] && command -v inkscape; then tmp="$(mktemp).png" inkscape -h "$monitor_height" "$path" -o "$tmp" path="$tmp" fi export SCHEME shchemes create_theme imagemagick \ | convert "$path" -colorspace srgb -dither FloydSteinberg -geometry "${monitor_width}x" -remap txt:- "$wallpaper_path" echo "Setting wallpaper: $path" xfconf-query -c xfce4-desktop -p "$prop" -s "$wallpaper_path" echo "$path" > "$wallpaper_store" feh --bg-center "$wallpaper_path"