You are not logged in.


I am developing an app which features a "chameleonic" background color based on the wallpaper. For it, I get the path of the wallpaper, and get the appropriate color using imagemagick.
In GNOME, I can get the path of the wallpaper with `gsettings get org.gnome.desktop.background picture-uri`. Something similar is available for MATE Desktop and Cinnamon.
Is there any similar way (maybe, by looking at the appropriate conf file) I can get the path of the wallpaper in XFCE?
Last edited by archisman (2025-05-25 13:56:43)
Offline


I am developing an app which features a "chameleonic" background color based on the wallpaper. For it, I get the path of the wallpaper, and get the appropriate color using imagemagick.
In GNOME, I can get the path of the wallpaper with `gsettings get org.gnome.desktop.background picture-uri`. Something similar is available for MATE Desktop and Cinnamon.
Is there any similar way (maybe, by looking at the appropriate conf file) I can get the path of the wallpaper in XFCE?
Greetings and welcome!
A while back, I had a similar need, and with ToZ's help, devised the following script run as a launcher's "command" string...
bash -c "backdrop=$(xfconf-query -c xfce4-desktop -p '/backdrop/screen0/monitoreDP-1/workspace0/last-image') && ristretto $backdrop "I use it re-display with image viewer the current background image before it auto-cycles to the next image.
This might give you a starting point. Of course, you'll have to tweak you monitor's setup.
Cheers, m4a
Linux Mint 21.3 -- xfce 4.18 ... Apple iMAC -- Lenovo, Dell, HP Desktops and Laptops -- Family & Community Support
Offline


This might help to identify the currently valid display names, if you're looking for something programmatic.
Mark solved threads as [SOLVED] to make it easier for others to find solutions.
--- How To Ask For Help | FAQ | Developer Wiki | Community | Contribute ---
Offline


bash -c "backdrop=$(xfconf-query -c xfce4-desktop -p '/backdrop/screen0/monitoreDP-1/workspace0/last-image') && ristretto $backdrop "
This is not correct in case when you tick "Apply to all workspaces" on another workspace.
You can check /backdrop/single-workspace-mode and /backdrop/single-workspace-number to find out the right background.
This scipt will do (on X11, because it uses xrandr).
#!/bin/bash
# list_monitors_wallpapers.sh
# Ensure required tools are available
command -v xfconf-query >/dev/null 2>&1 || { echo "Error: xfconf-query is required"; exit 1; }
command -v xrandr >/dev/null 2>&1 || { echo "Error: xrandr is required"; exit 1; }
# Function to validate monitor name (exclude numeric names like "0", "1")
is_valid_monitor_name() {
local name="$1"
[[ -z "$name" ]] && return 1
[[ "$name" =~ ^[0-9]+$ ]] && return 1
return 0
}
# Get monitor information using xrandr
mapfile -t monitors < <(xrandr --current | grep -w connected | awk '{print $1, $2}')
monitor_count=${#monitors[@]}
# Get XFCE desktop channel properties
channel="xfce4-desktop"
# Check single workspace mode
single_workspace_mode=$(xfconf-query -c "$channel" -p "/backdrop/single-workspace-mode" 2>/dev/null || echo "false")
[[ "$single_workspace_mode" == "true" ]] && single_mode=1 || single_mode=0
# Get single workspace number (default to 0 if not set)
single_workspace_number=$(xfconf-query -c "$channel" -p "/backdrop/single-workspace-number" 2>/dev/null || echo "0")
# Get all backdrop properties
props=$(xfconf-query -c "$channel" -p "/backdrop/screen0" -l 2>/dev/null | grep "last-image")
# Initialize associative arrays
declare -A monitor_paths
if [[ $single_mode -eq 0 ]]; then
declare -A workspace_paths
fi
# Parse properties
while IFS= read -r key; do
if [[ "$key" == *"/last-image" ]]; then
# Extract monitor name
monitor_name=$(echo "$key" | grep -oP '(?<=/monitor)[^/]+')
# Extract workspace name
workspace_name=$(echo "$key" | grep -oP '(?<=workspace)[0-9]+')
if [[ -n "$monitor_name" ]] && is_valid_monitor_name "$monitor_name"; then
# Get wallpaper path
value=$(xfconf-query -c "$channel" -p "$key" 2>/dev/null)
if [[ -n "$value" ]]; then
if [[ $single_mode -eq 1 ]]; then
# Single workspace mode: store only the wallpaper for single_workspace_number
if [[ "$workspace_name" == "$single_workspace_number" ]]; then
monitor_paths["$monitor_name"]="$value"
fi
else
# Multi-workspace mode: store all workspaces
workspace_paths["$monitor_name:$workspace_name"]="$value"
fi
fi
fi
fi
done <<< "$props"
# Output monitor and wallpaper info
index=0
while IFS= read -r line; do
monitor_name=$(echo "$line" | awk '{print $1}')
is_primary=$(echo "$line" | grep -q "primary" && echo "Yes" || echo "No")
if is_valid_monitor_name "$monitor_name"; then
printf "Monitor %d: %s [Primary: %s]\n" "$index" "$monitor_name" "$is_primary"
if [[ $single_mode -eq 1 ]]; then
wallpaper="${monitor_paths[$monitor_name]:-<not set>}"
printf " Wallpaper: %s\n" "$wallpaper"
else
# Get all workspaces for this monitor and sort them numerically
mapfile -t workspaces < <(
for key in "${!workspace_paths[@]}"; do
if [[ "$key" == "$monitor_name:"* ]]; then
ws=$(echo "$key" | cut -d':' -f2)
echo "$ws"
fi
done | sort -n
)
if [[ ${#workspaces[@]} -gt 0 ]]; then
for ws in "${workspaces[@]}"; do
wallpaper="${workspace_paths[$monitor_name:$ws]:-<not set>}"
printf " Workspace %s: %s\n" "$ws" "$wallpaper"
done
else
printf " No wallpapers set for this monitor\n"
fi
fi
((index++))
fi
done < <(xrandr --current | grep -w connected)
exit 0Now when you move desktop settings to another workspace,
pick some different wallpaper from that workspace and click "Apply to all workspaces" and this script will print the correct wallpaper.
@ToZ As for C, for 4.18 with a few libraries (gtk+-3.0 libxfconf-0 glib-2.0) this will do:
Last edited by Misko_2083 (2025-05-16 09:04:09)
Do you want to exit the Circus?
https://www.youtube.com/watch?v=ZJwQicZHp_c
Offline


mint4all wrote:bash -c "backdrop=$(xfconf-query -c xfce4-desktop -p '/backdrop/screen0/monitoreDP-1/workspace0/last-image') && ristretto $backdrop "This is not correct in case when you tick "Apply to all workspaces" on another workspace.
You can check /backdrop/single-workspace-mode and /backdrop/single-workspace-number to find out the right background.
This scipt will do (on X11, because it uses xrandr).#!/bin/bash # list_monitors_wallpapers.sh # Ensure required tools are available command -v xfconf-query >/dev/null 2>&1 || { echo "Error: xfconf-query is required"; exit 1; } command -v xrandr >/dev/null 2>&1 || { echo "Error: xrandr is required"; exit 1; } # Function to validate monitor name (exclude numeric names like "0", "1") is_valid_monitor_name() { local name="$1" [[ -z "$name" ]] && return 1 [[ "$name" =~ ^[0-9]+$ ]] && return 1 return 0 } # Get monitor information using xrandr mapfile -t monitors < <(xrandr --current | grep -w connected | awk '{print $1, $2}') monitor_count=${#monitors[@]} # Get XFCE desktop channel properties channel="xfce4-desktop" # Check single workspace mode single_workspace_mode=$(xfconf-query -c "$channel" -p "/backdrop/single-workspace-mode" 2>/dev/null || echo "false") [[ "$single_workspace_mode" == "true" ]] && single_mode=1 || single_mode=0 # Get single workspace number (default to 0 if not set) single_workspace_number=$(xfconf-query -c "$channel" -p "/backdrop/single-workspace-number" 2>/dev/null || echo "0") # Get all backdrop properties props=$(xfconf-query -c "$channel" -p "/backdrop/screen0" -l 2>/dev/null | grep "last-image") # Initialize associative arrays declare -A monitor_paths if [[ $single_mode -eq 0 ]]; then declare -A workspace_paths fi # Parse properties while IFS= read -r key; do if [[ "$key" == *"/last-image" ]]; then # Extract monitor name monitor_name=$(echo "$key" | grep -oP '(?<=/monitor)[^/]+') # Extract workspace name workspace_name=$(echo "$key" | grep -oP '(?<=workspace)[0-9]+') if [[ -n "$monitor_name" ]] && is_valid_monitor_name "$monitor_name"; then # Get wallpaper path value=$(xfconf-query -c "$channel" -p "$key" 2>/dev/null) if [[ -n "$value" ]]; then if [[ $single_mode -eq 1 ]]; then # Single workspace mode: store only the wallpaper for single_workspace_number if [[ "$workspace_name" == "$single_workspace_number" ]]; then monitor_paths["$monitor_name"]="$value" fi else # Multi-workspace mode: store all workspaces workspace_paths["$monitor_name:$workspace_name"]="$value" fi fi fi fi done <<< "$props" # Output monitor and wallpaper info index=0 while IFS= read -r line; do monitor_name=$(echo "$line" | awk '{print $1}') is_primary=$(echo "$line" | grep -q "primary" && echo "Yes" || echo "No") if is_valid_monitor_name "$monitor_name"; then printf "Monitor %d: %s [Primary: %s]\n" "$index" "$monitor_name" "$is_primary" if [[ $single_mode -eq 1 ]]; then wallpaper="${monitor_paths[$monitor_name]:-<not set>}" printf " Wallpaper: %s\n" "$wallpaper" else # Get all workspaces for this monitor and sort them numerically mapfile -t workspaces < <( for key in "${!workspace_paths[@]}"; do if [[ "$key" == "$monitor_name:"* ]]; then ws=$(echo "$key" | cut -d':' -f2) echo "$ws" fi done | sort -n ) if [[ ${#workspaces[@]} -gt 0 ]]; then for ws in "${workspaces[@]}"; do wallpaper="${workspace_paths[$monitor_name:$ws]:-<not set>}" printf " Workspace %s: %s\n" "$ws" "$wallpaper" done else printf " No wallpapers set for this monitor\n" fi fi ((index++)) fi done < <(xrandr --current | grep -w connected) exit 0Now when you move desktop settings to another workspace,
pick some different wallpaper from that workspace and click "Apply to all workspaces" and this script will print the correct wallpaper.@ToZ As for C, for 4.18 with a few libraries (gtk+-3.0 libxfconf-0 glib-2.0) this will do:
▼Hidden text
The bash script worked. That you!
Offline
[ Generated in 0.011 seconds, 7 queries executed - Memory usage: 664.73 KiB (Peak: 698.01 KiB) ]