Xfce Forum

Sub domains
 

You are not logged in.

#1 2025-05-24 10:05:54

abalfoort
Member
Registered: 2023-02-27
Posts: 6
Website
LinuxFirefox 138.0

Set default backdrop on first run

Hi, I am the maintainer of SolydXK, a Debian derivate, and I struggle getting the desktop to show the SolydX background on Xfce 4.20 (Debian Trixie). This will only run by a new user on first run and the settings for the user's monitor do not yet exist and need to be created.

I now have this logic that seems to work for the majority of monitors:

WALLPAPER='/usr/share/xfce4/backdrops/solydx-light-1920x1080.svg'
WORKSPACECNT=$(xfconf-query --channel xfwm4 --property /general/workspace_count 2>/dev/null)
[ -z "$WORKSPACECNT" ] && WORKSPACECNT=4
for MONITOR in $(xrandr --query | awk '/ connected/{print $1}'); do
    echo "Set wallpaper for $MONITOR"
    for ((I=0; I < $WORKSPACECNT; I++)); do
        xfconf-query --channel xfce4-desktop --property /backdrop/screen0/monitor${MONITOR}/workspace${I}/last-image --create --type string --set "$WALLPAPER"
        xfconf-query --channel xfce4-desktop --property /backdrop/screen0/monitor${MONITOR}/workspace${I}/image-style --create --type int --set 5
    done
done

I've tested this with these monitors:

  • Virtual-1

  • Virtual1

  • DP-3

However, if xrandr returns "eDP-1", the desktop will not show the wallpaper and if you manually change it, the property uses "monitoreDP". In this case the "-1" in "eDP-1" is omitted.

At first, we thought it could be because single-workspace-mode did not exist, but adding that did not change the wallpaper issue.

So, how can I be sure which monitor name is used by Xfce4?
Is eDP the only exception to omit "-1"?

Perhaps, I'm doing it wrong and is there another, more straight forward way of setting the default wallpaper. Please, let me know.

Offline

#2 2025-05-25 21:28:30

ToZ
Administrator
From: Canada
Registered: 2011-06-02
Posts: 12,016
LinuxFirefox 138.0

Re: Set default backdrop on first run

Have a read through a similar issue being experienced by the Xubuntu developers: https://gitlab.xfce.org/xfce/xfdesktop/-/issues/364.

The new recommended approach is to pass the "--default-backdrop-filename=FILENAME" compile-time parameter to set the default wallpaper - assuming of course that you build your own xfdesktop package.

Edit: This might help as well.

Last edited by ToZ (2025-05-25 21:42:02)


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

#3 2025-05-26 10:00:51

abalfoort
Member
Registered: 2023-02-27
Posts: 6
Website
LinuxFirefox 138.0

Re: Set default backdrop on first run

Thanks @ToZ, for the reply.
I agree however with the people in that thread: distributors should not need to compile xfdesktop just to change the default wallpaper.

After a lot of testing and trying I came up with this monstrocity:

#!/usr/bin/env bash

# Purpose: set default SolydX desktop
# Documentation: https://docs.xfce.org/xfce/xfconf/xfconf-query
# Function: set_property [channel] [property] [type] [value] [optional: force_array]
# Separate array items with pipes: "item1|item2|item3"
#                         strings: '"item 1"|"item 2"|"item 3"'

WALLPAPER='/usr/share/images/desktop-base/default'

function set_property {
    BASE="xfconf-query --channel $1 --property $2"

    IFS='|' read -ra VALUES <<< "$4"
    SET=''
    for VALUE in "${VALUES[@]}"; do
        if [ "$3" == string ]; then
            SET="$SET --type $3 --set \"$VALUE\""
        else
            SET="$SET --type $3 --set $VALUE"
        fi
    done
    unset IFS

    # Force an array even if there is only one item
    if [ "$5" == 'true' ]; then
        SET="--force-array $SET"
    fi

    # Create the property if it does not exist
    if ! $BASE >/dev/null 2>&1; then
        SET="--create $SET"
    fi

    eval "$BASE $SET"
}

# Set all workspace wallpapers
SCREENS=$(xfconf-query --channel xfce4-desktop --property /backdrop --list | grep -Eo 'screen[^/]+' | uniq)
MONITORS=$(xrandr --query | awk '/ connected/{print $1}')
WSPCNT=$(xfconf-query --channel xfwm4 --property /general/workspace_count 2>/dev/null)
[ -z "$WSPCNT" ] && WSPCNT=4
for SCR in $SCREENS; do
    for MON in $MONITORS; do
        echo "Set wallpaper for monitor: $MON"
        for ((WSP=0; WSP < $WSPCNT; WSP++)); do
            set_property xfce4-desktop /backdrop/${SCR}/monitor${MON}/workspace${WSP}/last-image string "$WALLPAPER"
            set_property xfce4-desktop /backdrop/${SCR}/monitor${MON}/workspace${WSP}/image-style int 5
            set_property xfce4-desktop /backdrop/${SCR}/monitor${MON}/workspace${WSP}/color-style int 0
            set_property xfce4-desktop /backdrop/${SCR}/monitor${MON}/workspace${WSP}/rgba1 double "0.956863|0.721569|0.498039|1"
        done
    done
done

This is part of a bash script which is run by xdg/autostart and runs once for each new user.

I am not happy with its complexity, but as long as there is no better solution, it'll have to do.

Offline

Registered users online in this topic: 0, guests: 1
[Bot] ClaudeBot

Board footer

Powered by FluxBB
Modified by Visman

[ Generated in 0.010 seconds, 7 queries executed - Memory usage: 540.36 KiB (Peak: 541.2 KiB) ]