Zane C. Bowers-Hadley > ZConf-BGSet > ZConf::BGSet

Download:
ZConf-BGSet-1.0.0.tar.gz

Dependencies

Annotate this POD

View/Report Bugs
Module Version: 1.0.0   Source  

NAME ^

ZConf::BGSet - A perl module for background management.

VERSION ^

Version 1.0.0

SYNOPSIS ^

    use ZConf::BGSet;

    my $zbg = ZConf::BGSet->new();
    ...

METHODES ^

new

This initializes it.

One arguement is taken and that is a hash value.

If this it fails, $zbg->{perror} is set and the other methods will always error as a permanent error has been set.

hash values

zconf

If this key is defined, this hash will be passed to ZConf->new().

    my $zbg=ZConf::Runner->new();
    if($zbg->{error}){
        print "Error!\n";
    }

addToLast

This adds an item to the history.

args hash

hostname

This specifies the hostname to use. If this is not defined, the hostname of the machine it is currently running on will be used.

display

This is the X display the BG was set on. If it is not set, the enviromental variable 'DISPLAY' is used.

filltype

This is the fill type that was used.

image

This is the image the background was set to.

    $zbg->addToLast({image=>'/tmp/something.jpg', filltype=>'full'});
    if($zbg->{error}){
        print "Error!\n";
    }

createPath

This creates a path. If a path already exists, it will error.

Two arguements are required. The first is the name of the path and the second is a array containing the various paths.

    $zbg->setPath('somepath', @paths);
    if($zbg->{error}){
        print "Error!\n";
    }

delPath

This removes a specified path.

One arguement is taken and that is the name of the path to remove.

    $zbg->delPath('somepath');
    if($zbg->{error}){
        print "Error!\n";
    }

getDefaultPath

This fetches the default path.

    my $path=$zbg->getDefaultPath;
    if($zbg->{error}){
        print "Error!\n";
    }

getLast

This fetches information on the last file set.

It also does not have to be checked for errors as it will never set an error.

No arguements are taken.

    my %last=$zbg->getLast;
    if(!defined($last{file})){
        print "No previous last.\n";
    }else{
        print 'file: '.$last{file}."\n".
              'filltype: '.$last{filltype}."\n".
              'display: '.$last{display}."\n".
              'hostname: '.$last{hostname}."\n";
    }

getLastRaw

Gets the last variable in it's raw form.

No arguements are taken.

It also does not have to be checked for errors as it will never set an error.

For a description of it's formatting, please see

    my $rawlast=$zbg->getLastRaw();
    print $rawlast;

getPath

This fetches a specified path.

One arguement is taken and that is the path name.

The returned value is an array

    my @paths=$zbg->getPath('somepath');
    if($zbg->{error}){
        print "Error!\n";
    }

getSet

This gets what the current set is.

    my $set=$zbg->getSet;
    if($zcr->{error}){
        print "Error!\n";
    }

getSetter

This fetches a setter.

The only image accepted is the name of the setter to fetch.

    my $setter=$zbg->getSetter('full');
    if($zbg->{error}){
        print "Error!\n";
    }

    #escapes the image
    my $image='/tmp/something.jpg';
    $image=~s/(["`\$\\ ])/\\$1/g;
    $image=~qq($image);

    #replaces %%%THEFILE%%% in the setter with the filename
    $setterr=~s/\%\%\%THEFILE\%\%\%/$image/g;

init

This initializes it or a new set.

If the specified set already exists, it will be reset.

One arguement is required and it is the name of the set. If it is not defined, ZConf will use the default one.

    #creates a new set named foo
    $zbg->init('foo');
    if($zbg->{error}){
        print "Error!\n";
    }

    #creates a new set with ZConf choosing it's name
    $zbg->init();
    if($zbg->{error}){
        print "Error!\n";
    }

listPaths

This gets a lists of configured paths.

    my @paths=$zbg->listPaths();
    if($zbg->{error}){
        print "Error!\n";
    }

listSets

This lists the available sets.

    my @sets=$zbg->listSets;
    if($zcr->{error}){
        print "Error!";
    }

pathExists

This verifies a path exists.

Only one arguement is taken and that is the name of the path.

    my $returned=$zbg->pathExists('foo');
    if($zbg->{error}){
        print "Error!\n";
    }else{
        if(!$returned){
            print "The path 'foo' does not exist.\n";
        }
    }

readSet

This reads a specific set. If the set specified is undef, the default set is read.

    #read the default set
    $zbg->readSet();
    if($zbg->{error}){
        print "Error!\n";
    }

    #read the set 'someSet'
    $zbg->readSet('someSet');
    if($zbg->{error}){
        print "Error!\n";
    }

setBG

args hash

image

The picture to set the background to.

filltype

The fill type to use. If this is not defined, the default one will be used.

dontSave

If this is set to true, it will not be added to the last list.

    $zbg->setBG({image='/tmp/something.jpg', filltype=>'auto'});
    if($zbg->{error}){
        print "Error!\n";
    }

    #the same as the above, but not saved to the last list
    $zbg->setBG({image='/tmp/something.jpg', filltype=>'auto', dontSave='0'});
    if($zbg->{error}){
        print "Error!\n";
    }

setLast

This sets the background image to last. It will also not re-append th e image to the last list.

No arguements are accepted.

    $zbg->setLast();
    if($zbg->{error}){

    }

setRand

This sets a random background.

One option is accepted and that is the path to use. If it is note specified, 'default' will be used.

    #set one from the default path
    $zbg->setRand();
    if($zbg->{error}){
        print "Error!\n";
    }
    
    #set one from the default path
    $self->setRand('somepath');
    if($zbg->{error}){
        print "Error!\n";
    }

setPath

This sets a sets/creates a path. If it is set, it will be overwritten.

Two arguements are required. The first is the name of the path and the second is a array ref containing the various paths.

    $zbg->setPath('somepath', \@paths);
    if($zbg->{error}){
        print "Error!\n";
    }

setterExists

This verifies a path exists.

Only one arguement is taken and that is the name of the setter.

    my $returned=$zbg->setterExists('foo');
    if($zbg->{error}){
        print "Error!\n";
    }else{
        if(!$returned){
            print "The setter 'foo' does not exist.\n";
        }
    }

setSetter

Sets the setter to be used for a specific fill type.

Two arguements are required. The first is the setter name and the second is setter.

    $zbg->setSetter('full', 'hsetroot -full %%%THEFILE%%%');
    if($zbg->{error}){
        print "Error!\n";
    }

validSetterName

Checks if a name specified for a setter is valid or not.

There is no reason to check for an error on this as it does not set any. It just checks that the specified name is valid. If it is not set, it will also return false.

    if(!$zbg->validSetterName('monkey')){
        print "No valid.\n";
    }

    if(!$zbg->validSetterName('full')){
        print "No valid.\n";
    }

errorblank

This blanks the error storage and is only meant for internal usage.

It does the following.

    $self->{error}=undef;
    $self->{errorString}="";

FILL TYPES ^

full

The setter to use for setting fill the screen and keep the same aspect ratio.

fill

The setter to use for setting the image to fill the screen.

center

The setter to use to center the image.

tile

The setter to use to tile the image.

auto

This will automatically choose between fill and full. The variable 'maxdiff' is used to determine what it should be set to.

^ft/

Any thing matching the regex /^ft\// can also be used as a setter.

ZConf Keys ^

center

This contains the setter that will be used for when setting a centered image. '%%%THEFILE%%%' is replaced at runtime with the name of the file.

        center=hsetroot -center %%%THEFILE%%%

fill

This key contains setter to be used for fill the background with a resized image. '%%%THEFILE%%%' is replaced at runtime with the name of the file.

        fill=hsetroot -fill %%%THEFILE%%%

full

This key contains setter to be used for fill the background with a scaled image. '%%%THEFILE%%%' is replaced at runtime with the name of the file.

        full=hsetroot -full %%%THEFILE%%%

last

This contains the last several images set. There is one entry per line. The format is as below.

        <hostname>:<display>:<fill type>:<image>

maxdiff

This contains the maximum difference for between any two any two sides when choosing between fill and full.

        maxdiff=.2

numberoflast

The number of last entries to save.

path

This is the path to use for when selecting a random image.

paths/<path>

This is a path. Each path have multiple paths. Each path is seperated by a new line.

postSetRefresh

Wether or not it should run something after it has been set. This is a perl boolean value.

        postSetRefresh=0

postSetRefresher

If 'postSetRefresh' is set to true, this is ran.

tile

This key contains setter to be used for tiling. '%%%THEFILE%%%' is replaced at runtime with the name of the file.

        tile=hsetroot -tile %%%THEFILE%%%

ERROR CODES ^

1

Could not initialize ZConf.

2

ZConf error.

3

Failed to create the ZConf config 'zbgset'.

4

Autoinit errored.

5

Undefined arguement.

6

Invalid setter name.

7

Setter does not exist.

8

Could not determine the display.

9

Invalid hostname.

10

Invalid display name.

11

Image::Size::FillFullSelect->select failed.

12

The file does not exist.

13

The file does not exist.

14

The path does not exist.

15

No default path defined.

16

The path already exists.

AUTHOR ^

Zane C. Bowers, <vvelox at vvelox.net>

BUGS ^

Please report any bugs or feature requests to bug-zconf-bgset at rt.cpan.org, or through the web interface at http://rt.cpan.org/NoAuth/ReportBug.html?Queue=ZConf-BGSet. I will be notified, and then you'll automatically be notified of progress on your bug as I make changes.

SUPPORT ^

You can find documentation for this module with the perldoc command.

    perldoc ZConf::BGSet

You can also look for information at:

ACKNOWLEDGEMENTS ^

COPYRIGHT & LICENSE ^

Copyright 2009 Zane C. Bowers, all rights reserved.

This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.

syntax highlighting: