Wiki de Mancomunwikiconselleria

Scripts de instalación

Instalación/Desinstalación Background

O ficheiro establece os valores na configuración da base de datos Gconf por defecto: /etc/gconf/gconf.xml.defaults Tamén modifica o ficheiro XML coas referencias as fondo de escritorio /usr/share/gnome-background-properties/ubuntu-wallpapers.xml ~/.gnome2/backgrounds.xml

TODO

  • Asistente de instalación
  • Modificar as configuracións por perfís de usuario en función das escollas no asistente
  • Mellorar as modificacións e procuras nos ficheiros XML

postinst

Script de postinstalación

#!/usr/bin/env python
import gconf
import os,stat
from xml.dom.minidom import parse

GCONF_DEFAULTS_SOURCE='xml:readwrite:/etc/gconf/gconf.xml.defaults'
DEBIAN_DEFAULTS_SOURCE='xml:readwrite:/var/lib/gconf/debian.defaults'
UBUNTU_WALLPAPERS='/usr/share/gnome-background-properties/ubuntu-wallpapers.xml'

NAME_BACKGROUND='araOS'
COLOR_SHADING_TYPE='solid'
DRAW_BACKGROUND=True
PICTURE_FILENAME='/usr/share/backgrounds/background-araos.png'
PICTURE_OPACITY=100
PICTURE_OPTIONS='stretched'
PRIMARY_COLOR='#333366669999'
SECONDARY_COLOR='#333366669999'

def set_gconf_values(source) :
    """ Modificar as entradas do gconf    
        para modificar o fondo de pantalla """
    
    engine = gconf.engine_get_for_address( source )
    client = gconf.client_get_for_engine( engine )    
        
    client.set_string('/desktop/gnome/background/color_shading_type', COLOR_SHADING_TYPE)
    client.set_bool('/desktop/gnome/background/draw_background', DRAW_BACKGROUND)
    client.set_string('/desktop/gnome/background/picture_filename', PICTURE_FILENAME)
    client.set_int('/desktop/gnome/background/picture_opacity', PICTURE_OPACITY)
    client.set_string('/desktop/gnome/background/picture_options', PICTURE_OPTIONS)
    client.set_string('/desktop/gnome/background/primary_color', PRIMARY_COLOR)
    client.set_string('/desktop/gnome/background/secondary_color', SECONDARY_COLOR)

def set_background_xml(path):
    """ Crear unha entrada en ficheiros xml de backgrounds de ubuntu
        path - ruta ao ficheiro a modificar
        /usr/share/gnome-background-properties/ubuntu-wallpapers.xml
        ~/.gnome2/backgrounds.xml """
        
    bg_dom = parse(path)
    wallpaper = bg_dom.createElement('wallpaper')
    
    name = bg_dom.createElement('name')
    name_text = bg_dom.createTextNode( NAME_BACKGROUND )
    name.appendChild( name_text )
    wallpaper.appendChild( name )
    
    filename = bg_dom.createElement('filename')
    filename_text = bg_dom.createTextNode( PICTURE_FILENAME )
    filename.appendChild( filename_text )
    wallpaper.appendChild( filename )
    
    options = bg_dom.createElement('options')
    options_text = bg_dom.createTextNode( PICTURE_OPTIONS )
    options.appendChild( options_text )
    wallpaper.appendChild( options )
    
    shade_type = bg_dom.createElement('shade_type')
    shade_type_text = bg_dom.createTextNode( COLOR_SHADING_TYPE )
    shade_type.appendChild( shade_type_text )
    wallpaper.appendChild( shade_type )    
    
    pcolor = bg_dom.createElement('pcolor')
    pcolor_text = bg_dom.createTextNode( PRIMARY_COLOR )
    pcolor.appendChild( pcolor_text )
    wallpaper.appendChild( pcolor )
        
    scolor = bg_dom.createElement('scolor')
    scolor_text = bg_dom.createTextNode( SECONDARY_COLOR )
    scolor.appendChild( scolor_text )
    wallpaper.appendChild( scolor )    
    
    wallpapers = bg_dom.getElementsByTagName('wallpapers')[0]
    wallpapers.appendChild( wallpaper )     
    
    xml_string = bg_dom.toxml()
    
    xml_file = open(path, "w")
    xml_file.writelines( xml_string )
    
    xml_file.close()

# Establecer os valores do fondo para GCONF_DEFAULTS_SOURCE
set_gconf_values( GCONF_DEFAULTS_SOURCE )
# Establecer os valores do fondo para DEBIAN_DEFAULTS_SOURCE
set_gconf_values( DEBIAN_DEFAULTS_SOURCE )

# Establecer o background para que se poida seleccionar
set_background_xml( UBUNTU_WALLPAPERS )

prerm

Script que se executa ao desinstalar o paquete:

#!/usr/bin/env python
import gconf
import os,stat
from xml.dom.minidom import parse

GCONF_DEFAULTS_SOURCE='xml:readwrite:/etc/gconf/gconf.xml.defaults'
DEBIAN_DEFAULTS_SOURCE='xml:readwrite:/var/lib/gconf/debian.defaults'
UBUNTU_WALLPAPERS='/usr/share/gnome-background-properties/ubuntu-wallpapers.xml'

NAME_BACKGROUND='Ubuntu'
COLOR_SHADING_TYPE='solid'
DRAW_BACKGROUND=True
PICTURE_FILENAME='/usr/share/backgrounds/warty-final-ubuntu.png'
PICTURE_OPACITY=100
PICTURE_OPTIONS='zoom'
PRIMARY_COLOR='#8f4a1c'
SECONDARY_COLOR='#8f4a1c'

def set_gconf_values(source) :
    """ Modificar as entradas do gconf    
        para modificar o fondo de pantalla """
    
    engine = gconf.engine_get_for_address( source )
    client = gconf.client_get_for_engine( engine )    
        
    client.set_string('/desktop/gnome/background/color_shading_type', COLOR_SHADING_TYPE)
    client.set_bool('/desktop/gnome/background/draw_background', DRAW_BACKGROUND)
    client.set_string('/desktop/gnome/background/picture_filename', PICTURE_FILENAME)
    client.set_int('/desktop/gnome/background/picture_opacity', PICTURE_OPACITY)
    client.set_string('/desktop/gnome/background/picture_options', PICTURE_OPTIONS)
    client.set_string('/desktop/gnome/background/primary_color', PRIMARY_COLOR)
    client.set_string('/desktop/gnome/background/secondary_color', SECONDARY_COLOR)

def del_backgrounds_xml(path):
    """ Eliminar unha entrada nos ficheiros xml de backgrounds de ubuntu:
        /usr/share/gnome-background-properties/ubuntu-wallpapers.xml
        ~/.gnome2/backgrounds.xml """
        
    bg_dom = parse(path)
    wallpapers = bg_dom.getElementsByTagName('wallpapers')[0]
    wallpaper_list = bg_dom.getElementsByTagName('name')    
    
    for w in wallpaper_list:
        if w.firstChild.nodeValue.strip() == NAME_BACKGROUND:
            wallpapers.removeChild( w.parentNode )            
    
    xml_string = bg_dom.toxml()
    
    xml_file = open(path, "w")
    xml_file.writelines( xml_string )
    
    xml_file.close()

# Establecer os valores do fondo para GCONF_DEFAULTS_SOURCE
set_gconf_values( GCONF_DEFAULTS_SOURCE )
# Establecer os valores do fondo para DEBIAN_DEFAULTS_SOURCE
set_gconf_values( DEBIAN_DEFAULTS_SOURCE )

# Establecer o background para que se poida seleccionar
del_backgrounds_xml( UBUNTU_WALLPAPERS )
Ferramentas personais


MediaWiki