Skip to content

Commit c7d6eb2

Browse files
authored
Fix XFCE wallpaper scripts for missing backdrop properties (varietywalls#815)
On fresh XFCE installs or systems where wallpaper was never set via XFCE, the backdrop properties (e.g., /backdrop/screen0/monitor0/workspace0/last-image) don't exist. This causes both scripts to fail silently or with errors. Changes to set_wallpaper: - Check if existing backdrop properties exist first - If none exist, detect connected monitors via xrandr and create properties - Use xfconf-query --create (-n) flag to initialize missing properties - Set a sensible default image-style (zoomed) Changes to get_wallpaper: - Dynamically find the first existing backdrop property instead of hardcoding monitor0 - Handle missing properties gracefully by returning nothing Fixes varietywalls#164
1 parent be5ae11 commit c7d6eb2

File tree

2 files changed

+34
-6
lines changed

2 files changed

+34
-6
lines changed

variety/data/scripts/get_wallpaper

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,12 @@ if [ "$desktop" == "ubuntu" ] || [ "$XDG_CURRENT_DESKTOP" == "Unity" ] || [ "$XD
1212

1313
# XFCE
1414
elif [ "$desktop" == "xubuntu" ] || [ "$XDG_CURRENT_DESKTOP" == "XFCE" ]; then
15-
xfconf-query -c xfce4-desktop -p /backdrop/screen0/monitor0/workspace0/last-image
15+
# Find first existing backdrop property (monitor names vary by setup)
16+
# See: https://github.com/varietywalls/variety/issues/164
17+
prop=$(xfconf-query -c xfce4-desktop -p /backdrop -l 2>/dev/null | grep -E -e "screen.*/monitor.*/last-image$" -e "screen.*/monitor.*image-path$" | head -1)
18+
if [ -n "$prop" ]; then
19+
xfconf-query -c xfce4-desktop -p "$prop" 2>/dev/null
20+
fi
1621

1722
# Lingmo OS
1823
elif [ "$XDG_CURRENT_DESKTOP" == "Lingmo" ]; then

variety/data/scripts/set_wallpaper

Lines changed: 28 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -198,11 +198,34 @@ elif [ "$DE" == "xfce" ]; then
198198
command -v xfconf-query >/dev/null 2>&1
199199
rc=$?
200200
if [[ $rc = 0 ]]; then
201-
for i in $(xfconf-query -c xfce4-desktop -p /backdrop -l | grep -E -e "screen.*/monitor.*image-path$" -e "screen.*/monitor.*/last-image$"); do
202-
xfconf-query -c xfce4-desktop -p "$i" -n -t string -s "" 2>/dev/null
203-
xfconf-query -c xfce4-desktop -p "$i" -s "" 2>/dev/null
204-
xfconf-query -c xfce4-desktop -p "$i" -s "$WP" 2>/dev/null
205-
done
201+
# First, try existing properties
202+
existing_props=$(xfconf-query -c xfce4-desktop -p /backdrop -l 2>/dev/null | grep -E -e "screen.*/monitor.*image-path$" -e "screen.*/monitor.*/last-image$")
203+
204+
if [ -n "$existing_props" ]; then
205+
# Set wallpaper on existing properties
206+
for i in $existing_props; do
207+
xfconf-query -c xfce4-desktop -p "$i" -n -t string -s "" 2>/dev/null
208+
xfconf-query -c xfce4-desktop -p "$i" -s "" 2>/dev/null
209+
xfconf-query -c xfce4-desktop -p "$i" -s "$WP" 2>/dev/null
210+
done
211+
else
212+
# No existing properties - create them for each connected monitor
213+
# This handles fresh XFCE installs where backdrop properties don't exist yet
214+
# See: https://github.com/varietywalls/variety/issues/164
215+
if command -v xrandr >/dev/null 2>&1; then
216+
for monitor in $(xrandr --query | grep " connected" | cut -d' ' -f1); do
217+
prop="/backdrop/screen0/monitor${monitor}/workspace0/last-image"
218+
style_prop="/backdrop/screen0/monitor${monitor}/workspace0/image-style"
219+
# Create and set the wallpaper property
220+
xfconf-query -c xfce4-desktop -p "$prop" -n -t string -s "$WP" 2>/dev/null
221+
# Set image style to 5 (zoomed) if not already set
222+
xfconf-query -c xfce4-desktop -p "$style_prop" -n -t int -s 5 2>/dev/null
223+
done
224+
else
225+
# Fallback: try common property path with --create flag
226+
xfconf-query -c xfce4-desktop -p "/backdrop/screen0/monitor0/workspace0/last-image" -n -t string -s "$WP" 2>/dev/null
227+
fi
228+
fi
206229
fi
207230

208231
elif [ "$DE" == "lingmo" ]; then

0 commit comments

Comments
 (0)