De vez en cuando nos piden poner un fondo fijo en el escritorio de todo el personal, con motivo de alguna efeméride o para impedir que los alumnos cambien su fondo de escritorio. La solución mas sencilla es cambiar el escritorio a nivel de máquina y bloquearlo por políticas que impidan su cambio.
Nuestros escritorios usan XFCE, por lo que esta tarea es bastante fácil. Desconozco si será posible para otros tipos de escritorio.
2. Cambio a nivel de máquina.
La configuración global del fondo de escritorio en XFCE se guarda en: /etc/xdg/xfce4/xfconf/xfce-perchannel-xml/xfce4-desktop.xml. La de cada usuario se guarda en $HOME/.config/xfce4/xfconf/xfce-perchannel-xml/xfce4-desktop.xml. Para poner un fondo de escritorio fijo que se imponga a los de los usuarios individuales debemos meter en /etc/xdg/xfce4/xfconf/xfce-perchannel-xml/xfce4-desktop.xml esta configuración:
<?xml version="1.0" encoding="UTF-8"?>
<channel name="xfce4-desktop" version="1.0" locked="*" unlocked="root">
<property name="desktop-icons" type="empty">
<property name="style" type="empty"/>
<property name="file-icons" type="empty">
<property name="show-home" type="empty"/>
<property name="show-filesystem" type="empty"/>
<property name="show-removable" type="empty"/>
<property name="show-trash" type="empty"/>
</property>
</property>
<property name="backdrop" type="empty">
<property name="screen0" type="empty">
<property name="monitor0" type="empty">
<property name="image-path" type="empty"/>
<property name="image-style" type="empty"/>
<property name="image-show" type="empty"/>
<property name="workspace0" type="empty">
<property name="color-style" type="int" value="0"/>
<property name="image-style" type="int" value="4"/>
<property name="last-image" type="string" value="/var/cache/fondo.jpg"/>
<property name="image-path" type="string" value="/var/cache/fondo.jpg"/>
</property>
</property>
<property name="monitor1" type="empty">
<property name="image-path" type="empty"/>
<property name="image-style" type="empty"/>
<property name="image-show" type="empty"/>
<property name="workspace0" type="empty">
<property name="color-style" type="int" value="0"/>
<property name="image-style" type="int" value="4"/>
<property name="last-image" type="string" value="/var/cache/fondo.jpg"/>
<property name="image-path" type="string" value="/var/cache/fondo.jpg"/>
</property>
</property>
<property name="monitoreDP-1" type="empty">
<property name="workspace0" type="empty">
<property name="color-style" type="int" value="0"/>
<property name="image-style" type="int" value="4"/>
<property name="last-image" type="string" value="/var/cache/fondo.jpg"/>
<property name="image-path" type="string" value="/var/cache/fondo.jpg"/>
</property>
</property>
<property name="monitorVGA-0" type="empty">
<property name="workspace0" type="empty">
<property name="color-style" type="int" value="0"/>
<property name="image-style" type="int" value="4"/>
<property name="last-image" type="string" value="/var/cache/fondo.jpg"/>
<property name="image-path" type="string" value="/var/cache/fondo.jpg"/>
</property>
</property>
<property name="monitorHDMI-0" type="empty">
<property name="workspace0" type="empty">
<property name="color-style" type="int" value="0"/>
<property name="image-style" type="int" value="4"/>
<property name="last-image" type="string" value="/var/cache/fondo.jpg"/>
<property name="image-path" type="string" value="/var/cache/fondo.jpg"/>
</property>
</property>
<property name="monitorVGA-1" type="empty">
<property name="workspace0" type="empty">
<property name="color-style" type="int" value="0"/>
<property name="image-style" type="int" value="4"/>
<property name="last-image" type="string" value="/var/cache/fondo.jpg"/>
<property name="image-path" type="string" value="/var/cache/fondo.jpg"/>
</property>
</property>
<property name="monitorDVI-I-0" type="empty">
<property name="workspace0" type="empty">
<property name="color-style" type="int" value="0"/>
<property name="image-style" type="int" value="4"/>
<property name="last-image" type="string" value="/var/cache/fondo.jpg"/>
<property name="image-path" type="string" value="/var/cache/fondo.jpg"/>
</property>
</property>
<property name="monitorHDMI-1" type="empty">
<property name="workspace0" type="empty">
<property name="color-style" type="int" value="0"/>
<property name="image-style" type="int" value="4"/>
<property name="last-image" type="string" value="/var/cache/fondo.jpg"/>
<property name="image-path" type="string" value="/var/cache/fondo.jpg"/>
</property>
</property>
<property name="monitorDP-3" type="empty">
<property name="workspace0" type="empty">
<property name="color-style" type="int" value="0"/>
<property name="image-style" type="int" value="4"/>
<property name="last-image" type="string" value="/var/cache/fondo.jpg"/>
<property name="image-path" type="string" value="/var/cache/fondo.jpg"/>
</property>
</property>
<property name="monitorDP-1" type="empty">
<property name="workspace0" type="empty">
<property name="color-style" type="int" value="0"/>
<property name="image-style" type="int" value="4"/>
<property name="last-image" type="string" value="/var/cache/fondo.jpg"/>
<property name="image-path" type="string" value="/var/cache/fondo.jpg"/>
</property>
</property>
<property name="monitorDisplayPort-0" type="empty">
<property name="workspace0" type="empty">
<property name="color-style" type="int" value="0"/>
<property name="image-style" type="int" value="4"/>
<property name="last-image" type="string" value="/var/cache/fondo.jpg"/>
<property name="image-path" type="string" value="/var/cache/fondo.jpg"/>
</property>
</property>
</property>
</property>
<property name="last" type="empty">
<property name="window-width" type="int" value="664"/>
<property name="window-height" type="int" value="545"/>
</property>
</channel>
La clave está en "locked="*" unlocked="root">", que hace que toda la configuración descrita en ese fichero esté bloqueada de forma general para todo el mundo, excepto para el usuario root. Esta configuración se impone sobre la configuración personal de cada usuario en su carpeta privda.
El fondo elegido se pondría en /var/cache/fondo.jpg, que es una carpeta a la que tienen acceso todas las cuentas y se mantiene entre reinicios.
3. Tarea puppet.
Meter esto a mano equipo a equipo es un poco fastidioso, asi que lo mejor es hacerlo mediante una tarea puppet:
class xubuntu_fondo {
#El fichero .xml tiene entradas repetidas dentro en función de si la salida es VGA, HDMI, DP, etc, etc.
#Si en un ordenador concreto no funciona es porque necesita otra configuración, no queda otra que investigar cual es
#y añadirla al fichero .xml base
file {"/etc/xdg/xfce4/xfconf/xfce-perchannel-xml/xfce4-desktop.xml" :
owner => root , group => root , mode => '0644' ,
source => "puppet:///modules/xubuntu_fondo/xfce4-desktop.xml"
}
file {"/var/cache/fondo.jpg" :
owner => root , group => root , mode => '0644' ,
source => "puppet:///modules/xubuntu_fondo/fondo.jpg
}
}
Simplemente habría que poner xfce4-desktop.xml y fondo.jpg en el directorio files de la tarea puppet y listo, ya funcionaría.
El único contratiempo es el relatado en la tarea puppet: si nos fijamos el fichero .xml tiene entradas repetidas dentro en función de si la salida es VGA, HDMI, DP, etc, etc. Si en un ordenador concreto no funciona es porque necesita otra configuración más para su dispositivo de salida. En ese caso no queda otra que investigar cual es el nombre de dicho dispositivo y añadirla al fichero .xml base.
Para ello el procedimiento es definir manualemente un fondo usando el entorno gráfico y mirar luego como queda el fichero $HOME/.config/xfce4/xfconf/xfce-perchannel-xml/xfce4-desktop.xml del usuario donde hemos definido el escritorio. Allí estará la nomenclatura usada por su dispositivo de salida concreto. Yo mismo empezé con un xml mas pequeño que ha ido creciendo confirme he ido probando en distantas máquinas.
4. Por comandos/scripts.
Otra opción sería copiar un xfce4-desktop.xml al home de los usuarios afectado, machacando $HOME/.config/xfce4/xfconf/xfce-perchannel-xml/xfce4-desktop.xml. Esto se puede hacer una sola vez con un bucle si los homes están en el servidor NFS o bien en cada inicio de sesión, máquina a máquina, si los homes están en local.
Otra alternativa es hacer un script que lo actualice mediante comandos, en lugar de sobreescribir $HOME/.config/xfce4/xfconf/xfce-perchannel-xml/xfce4-desktop.xml. Sería :
#!/bin/bash
FONDO="/var/cache/fondofijo.jpg"
# Aplicar el fondo a todos los monitores
for i in $(xfconf-query -c xfce4-desktop -p /backdrop -l | grep -E "screen.*/monitor.*/(image-path|last-image)$"); do
xfconf-query -c xfce4-desktop -p "$i" -s "$FONDO"
done
# Ajustar el modo de imagen a 'relleno' (expandir para cubrir)
for i in $(xfconf-query -c xfce4-desktop -p /backdrop -l | grep -E "screen.*/monitor.*/image-style$"); do
# Crear la propiedad si no existe
if ! xfconf-query -c xfce4-desktop -p "$i" -l 2>/dev/null; then
xfconf-query -c xfce4-desktop -p "$i" --create -t int -s 4
else
xfconf-query -c xfce4-desktop -p "$i" -s 4
fi
done
# Eliminar configuraciones residuales de monitores no conectados
xfconf-query -c xfce4-desktop -p /backdrop/screen0/monitoreDP-1/workspace0/image-style --reset 2>/dev/null
xfconf-query -c xfce4-desktop -p /backdrop/screen0/monitoreDP/workspace0/image-style --reset 2>/dev/null
# Mostrar las configuraciones actuales de xfce4-desktop : xfconf-query -c xfce4-desktop -lv
# Forzar la recarga del fondo
xfdesktop --reload
exit 0
Este script se debe ejecutar con la sesión iniciada del usuario al que queremos cambiar el fondo, ya que xfconf-query solo funciona con la sesión gráfica XFCE iniciada.
Si queremos ver la configuración de xfce4-desktop aplicada al usuario actual podemos abrir un terminal y escribir:
# xfconf-query -c xfce4-desktop -lv
Como ampliación podemos ver todo lo que se puede bloquear en XFCE en esta otra entrada.
Seguiremos...






