
Estoy creando un paquete instantáneo para mi aplicación que está basado en Java y descarga fondos de pantalla de Internet. Hasta ahora todo bien, pero ahora estoy agregando una nueva función para configurar el fondo de pantalla seleccionado y no funciona. Esta función se implementa para los escritorios Unity y Gnome 3, que proporcionan una forma sencilla de configurar el fondo de escritorio mediante la herramienta de línea de comandos gsettings.
De esta manera, ejecutandogsettings set org.gnome.desktop.background imagen-uri archivo://blablabla.jpgpuede cambiar el fondo de pantalla del escritorio directamente y mi aplicación basada en Java utiliza esta herramienta y este comando para lograr este objetivo.
Primero, cuando probé wallpaperdownloader dentro de un paquete instantáneo, se quejó porque no encontró el binario gsettings dentro del complemento. Ahora está arreglado, porque he incluidolibglib2.0-bincomo paquete escénico. Sin embargo, no funciona. Supongo que gsettings dentro del paquete snap no puede manipular archivos fuera del snap, y necesito modificar directamente esos archivos dentro del directorio de inicio del usuario. ¿Puedo lograr esto o está restringido?
Estos son los archivos snapcraft.yaml y el script que se ejecuta cuando se inicia wallpaperdownloaded.
snapcraft.yml
name: wallpaperdownloader
version: "2.2"
summary: Download and manage your favorite wallpapers from the Internet
description: WallpaperDownloader is a simple GUI Java based application for downloading and managing wallpapers from the Internet
confinement: strict
apps:
wallpaperdownloader:
command: wallpaperdownloader.sh
plugs: [x11, network-bind, home]
parts:
# Pulls the code from the original source (master branch)
wallpaperdownloader:
plugin: maven
source: .
stage-packages:
- libglib2.0-bin
# It will copy wallpaperdownloader script into /bin/
# This script contains all the commands needed (sets env variables, launches the jar file...) to
# execute the application
exec:
plugin: copy
files:
wallpaperdownloader.sh: bin/wallpaperdownloader.sh
wallpaperdownloader.sh
#!/bin/sh
# Only for packaging!
# Script for snap packaging wallpaperdownloader application. It is not related to the code itself
# Not good, needed for fontconfig
export XDG_DATA_HOME=$SNAP/usr/share
# Font Config
export FONTCONFIG_PATH=$SNAP/etc/fonts/config.d
export FONTCONFIG_FILE=$SNAP/etc/fonts/fonts.conf
export HOME=$SNAP_USER_DATA
java -jar -Duser.home=$SNAP_USER_DATA $SNAP/jar/wallpaperdownloader.jar
PD: Probé los complementos gsettings y unity7, pero no funcionaron aunque solo los incluí en el archivo snapcraft.yaml y no apliqué ningún ajuste/configuración.
Muchas gracias,
eloy
Respuesta1
Finalmente, resolví este problema. El truco consiste en utilizarconfiguracióninterfaz y snapcraft-desktop-helpers parte de la Wiki (escritorio/gtk3). Estos son los archivos principales. Los publiqué por si acaso son útiles para que otros resuelvan un problema similar.
snapcraft.yaml
name: wallpaperdownloader
version: "2.2"
summary: Download and manage your favorite wallpapers from the Internet
description: WallpaperDownloader is a simple GUI Java based application for downloading and managing wallpapers from the Internet
grade: stable
confinement: strict
apps:
wallpaperdownloader:
command: wallpaperdownloader.sh
plugs: [x11, network-bind, home, gsettings]
parts:
# Pulls the code from the original source (master branch)
# desktop/gtk3 is a snapcraft part (snapcraft-desktop-helpers) from the Wiki: https://wiki.ubuntu.com/snapcraft/parts
# It enables desktop integration and gsettings manipulation from the confined application
# It is necessary to use gsettings interface (see above) in order to have a fully functional
# desktop/gtk3 part
# Github repository for snapcraft-desktop-helpers: https://github.com/ubuntu/snapcraft-desktop-helpers
wallpaperdownloader:
plugin: maven
source: ..
after: [desktop/gtk3]
# It will copy wallpaperdownloader script into /bin/
# This script contains all the commands needed (sets env variables, launches the jar file...) to
# execute the application
exec:
plugin: dump
source: scripts
wallpaperdownloader.sh
#!/bin/sh
# Only for packaging!
# Script for snap packaging wallpaperdownloader application. It is not related to the code itself
# Not good, needed for fontconfig
export XDG_DATA_HOME=$SNAP/usr/share
# Font Config
export FONTCONFIG_PATH=$SNAP/etc/fonts/config.d
export FONTCONFIG_FILE=$SNAP/etc/fonts/fonts.conf
export HOME=$SNAP_USER_DATA
desktop-launch java -jar -Duser.home=$SNAP_USER_DATA $SNAP/jar/wallpaperdownloader.jar