Main index > About existing desklets > doityourself

By dessaya (Desklet Author), on Thu Jul 14 15:07:43 2005: doityourself.

I wanted to add some features to doityourself, and then I realized that the code was really, really ugly. So, I mostly rewrote it. The result is a much more feature-rich and flexible generic desklet (in my opinion :D ). Check this out: http://lug.fi.uba.ar/~dessaya/doityourself/doityourself_screen.jpg
Unfortunately, user scripts are not backwards compatible. Sorry.
You can get the darcs repository from here.
I would like to hear your opinions. I will be releasing soon.

Regards,
Diego

By geoSlack (User), on Wed Jul 20 22:21:24 2005, last edited on Thu Jul 21 07:28:04 2005.

Wow!
Great desklet and a nice improvement over the earlier version. Here is a script that displays some wireless network info - the ESSID name and signal strength. I am not sure how tied it is to my peculiar setup, since I am really new to writing bash scripts. But so far it works for me.

Cheers,
geoSlack

Code:

#!/bin/bash

# Display wireless signal strength and essid.

# Exit immediately if any command fails:

set -e

# get signal strength

if [ ! `cat /proc/net/wireless | awk '/eth0/ {print $3}' | cut -d"." -f1 `];
then
SIGNAL="0"
else
SIGNAL="`cat /proc/net/wireless | awk '/eth0/ {print $3}' | cut -d"." -f1 `"
fi

case $1 in
        init)
                echo "<icon 'network.png'/>"
                echo "<never_shrink True/>"
                echo "<background_color None/>"
                echo "<click_on_icon_only False/>"
                echo "<test_delay 10/>"
                echo "<font 'DISTRO__/12'/>"
                ;;

        test | click)
                
                # show signal strength

                echo "<color 'FF6666'/>"
                echo "<hspace -1/><bar_meter 100 10 $SIGNAL 100/> $SIGNAL"
                
                # set text color

                echo "<color 'FF2222'/>"

                # check to see that we are connected
                # if not print "No connection!" if so print ESSID

                
                if [ ! `sudo /sbin/iwconfig eth0 | awk '/IEEE/ {print $1}'` ];
                   then
                   echo "No connection!"
                   else 
                   sudo /sbin/iwconfig eth0 | awk '/ESSID/ {print $4}' | cut -d":" -f2 | cut -d"\"" -f2
 fi
                ;;
        *)
                echo "Usage: $0 [ init | test | click ] test-value"
esac


By dessaya (Desklet Author), on Thu Jul 21 07:15:04 2005.

geoSlack wrote:

Wow!
Great desklet and a nice improvement over the earlier version. Here is a script that displays some wireless network info - the ESSID name and signal strength. I am not sure how tied it is to my peculiar setup, since I am really new to writing bash scripts. But so far it works for me.

I'm not able to try it, because I don't own a wireless card, so, I will trust you :D. Although, to include it in the code repository, I would like to know about the 'network.png' icon and the 'DISTRO__' font. Where did you get them? Are they widely available resources? If not, would you post them as well?

Thanks!
Diego

By geoSlack (User), on Thu Jul 21 07:54:32 2005.

DISTRO__ is not essential it's just a font I use in my desklets and can be substituted for whatever the user wants. Maybe the code should just use the default Vera as in your other scripts. It is available here.

newtork.png is my name for an icon from the Kreski-lines icon set by azazel100.

To see what it looks like, have a look at this screenshot. I use that icon set on the yab bar above as well as the wireless script. And the DISTRO__ font is used throughout.

I have also just edited the script above - it wasn't working when there was no connection, but now it is. If anyone sees other problems (or knows of more elegant ways of doing what it does) please let me know.

Cheers,
George

By foobar (User), on Thu Feb 16 18:52:09 2006: running doityoursel with several scripts.

I would like to use doit with three scripts that I have wrote. How can I do it?

By syfou (Core Developer & Desklet Author), on Thu Feb 16 20:33:04 2006: Re: running doityoursel with several scripts.

foobar wrote:

I would like to use doit with three scripts that I have wrote. How can I do it?

doityourself 0.4.0 comes with a pretty good manual under doc/ ... Yours,

By foobar (User), on Fri Feb 17 13:10:38 2006: Re: running doityoursel with several scripts.

syfou wrote:

doityourself 0.4.0 comes with a pretty good manual under doc/ ... Yours,


Yes, I know, and have read it, I have doityourself running with
one script, but still don't know how to run it with more than
one.

By dessaya (Desklet Author), on Fri Feb 17 17:24:55 2006: Re: running doityoursel with several scripts.

foobar wrote:

syfou wrote:

doityourself 0.4.0 comes with a pretty good manual under doc/ ... Yours,

Yes, I know, and have read it, I have doityourself running with
one script, but still don't know how to run it with more than
one.

To have, for example, three instances of doityourself, you should have, in ~/.adesklets:

Code:

[/home/you/doityourself/doityourself.py] id=0 screen=0 x=0 y=990
[/home/you/doityourself/doityourself.py] id=1 screen=0 x=1007 y=207
[/home/you/doityourself/doityourself.py] id=2 screen=0 x=1006 y=323

And in /home/you/doityourself/config.txt:

Code:

id0 = {'rawmode': False, 'script': 'mboxes.py'}
id1 = {'rawmode': False, 'script': 'agenda.pl'}
id2 = {'rawmode': False, 'script': 'todo.sh'}


Hope it helps,
Diego

By fp2099 (User), on Mon Feb 20 16:57:20 2006, last edited on Tue Feb 21 17:50:29 2006: doityourself borders [SOLVED].

how to remove doityourself boders? I'm using an edonkey based script to grab amule stats.

http://static.flickr.com/36/102263753_c1a937c073_o.png

By dessaya (Desklet Author), on Mon Feb 20 17:35:13 2006: Re: doityourself borders.

fp2099 wrote:

how to remove doityourself boders? I'm using an edonkey based script to grab amule stats.

Cool desktop! :D

IIRC, doityourself doesn't draw a border unless you tell it to. Anyway, the context variable that controls the border is background.border.color. Set it to None to disable the border. If you still can't disable it, post your script and we'll see where the problem is.

By fp2099 (User), on Tue Feb 21 17:40:53 2006: well [SOLVED].

the script has the background.border.color set to none... maybe it has to do with the output being from amule-cmd instead of netcat?
Don't know... the script is an awfull hack of edonkey it doesn't use nc to get edonkey stats but exports amule-cmd stats using my pass and username (it is set to local access only)....

does doityourself use dys for every script?

This is the relevant part.:

Code:

               <background.border 0/>
                <background.border.color None/>
        #       <background.border.color 'A0A0A0'/>
                <background.border.padding 0/>
                <window.click_anywhere False/>
                <test_delay 10/>
                <vpadding 2/>
                <hpadding 2/>


what's wrong here?


[EDIT] The border padding!!!!!!!!!!!!!!!!!!!!arrrgggg i hate myself

By dessaya (Desklet Author), on Wed Feb 22 06:03:15 2006, last edited on Fri Feb 24 19:14:56 2006: Re: well [SOLVED].

Quote:

what's wrong here?
[EDIT] The border padding!!!!!!!!!!!!!!!!!!!!arrrgggg i hate myself

Hmmm... Seems like a bug. The border should never be drawn if you set its color to None, regardless of the padding. I'll check it out. Thanks,
Diego

[EDIT] I have found this is not a bug, but a missing feature :wink:. The problem is here:

Code:

<background.border.color None/>
# <background.border.color 'A0A0A0'/>

The parser does not treat the '#' sign as a comment (comments are not allowed at all -- should I add this efature?). Thus, the command that sets the border color is executed after the one that sets it to None.

By Maybelline (User), on Thu Feb 23 14:26:39 2006: DIY help! (defeats the purpose?).

I've hacked together a script for DIY (DYS?) to show the current xmms2 song, and the image "folder.jpg" from the directory that that song came from.

I have a problem, tho... Some images fail with

Code:

Invalid image attributes: "/mnt/hdb1/mp3/Smashing Pumpkins/Greatest Hits 1/folder.jpg" 128 128


I know the file exists, and gqview can read it, so I'm sure it's valid. I'm no Python developer, so I can't quite make out what image.py is choking on. The image is 512x512 (some are larger, some are smaller), and is 37.3kb. What are the other attributes that could cause a choke? Other folder.jpg files display just fine.

If anyone's interested, you can grab the script from here.

Thanks in advance!

edit: Other files with spaces in the name work, too. Still stumped.
edit2: It seems to happen on images where " x/" is in the path (space number slash), where x is a numeral. For instance, "B-52s/" works, but "7 Mary 3/" does not.

By dessaya (Desklet Author), on Fri Feb 24 18:01:30 2006: Re: DIY help! (defeats the purpose?).

Maybelline wrote:

I've hacked together a script for DIY (DYS?)

Yeah, DYS sounded more natural for me, and I realized too late that DIY is more widely accepted for "Do It Yourself"... Now I'm too lazy to change the icon :D

Maybelline wrote:

I have a problem, tho... Some images fail with

Code:

Invalid image attributes: "/mnt/hdb1/mp3/Smashing Pumpkins/Greatest Hits 1/folder.jpg" 128 128

Maybelline wrote:

edit2: It seems to happen on images where " x/" is in the path (space number slash), where x is a numeral. For instance, "B-52s/" works, but "7 Mary 3/" does not.

Yes, you have found a bug in the parsing routine. I will fix it (and also some other known bugs) and hopefully release a new version today or tomorrow.

Thanks!
Diego

By Maybelline (User), on Fri Feb 24 18:16:21 2006: Re: DIY help! (defeats the purpose?).

dessaya wrote:

I will fix it (and also some other known bugs) and hopefully release a new version today or tomorrow.

Thanks!
Diego


Excellent! Thank you!

By Maybelline (User), on Mon Feb 27 18:23:48 2006: Hate to annoy....

My little xmms2 script is working out much better with your changes, but I'm still running into trouble with files like the following:

Code:

/mnt/hdb1/mp3/Guns 'N Roses/Appetite For Destruction/folder.jpg
/mnt/hdb1/mp3/Chevelle/Point #1/folder.jpg



I'm taking a blind guess that it has something to do with escaping the ' and # characters. Would it be enough to enclose the whole thing in quotes first?

Can you tell me what piece of code I could look at to try & debug this? Or, a way to pass the string in that will parse correctly, but still end up pointing to this file -- like quotes or something?

Thanks!

By dessaya (Desklet Author), on Tue Feb 28 06:02:16 2006: Re: Hate to annoy....

Maybelline wrote:

My little xmms2 script is working out much better with your changes, but I'm still running into trouble with files like the following:

Code:

/mnt/hdb1/mp3/Guns 'N Roses/Appetite For Destruction/folder.jpg
/mnt/hdb1/mp3/Chevelle/Point #1/folder.jpg


Come on, do you really have to use the entire ASCII set on your file names!? :lol:

Quote:

I'm taking a blind guess that it has something to do with escaping the ' and # characters.

The problem with the first one is the ' character. With the second one... I'm not sure.

Quote:

Would it be enough to enclose the whole thing in quotes first?

You mean you are not doing that already? The problem with the ' character should be solved enclosing the whole thing in "s...

Quote:

Can you tell me what piece of code I could look at to try & debug this? Or, a way to pass the string in that will parse correctly, but still end up pointing to this file -- like quotes or something?

The relevant code is in dys/widgets/image.py, in the constructor of the ImageWidget class. Anyway, I will take another look at it as soon as I return home (I'm at work now).

By Maybelline (User), on Tue Feb 28 10:08:52 2006: Re: Hate to annoy....

dessaya wrote:

Come on, do you really have to use the entire ASCII set on your file names!? :lol:

Yeah, I think that's causing me a lot of trouble here. From here on, I'll only buy albums with A-Z in the title!

Quote:

You mean you are not doing that already? The problem with the ' character should be solved enclosing the whole thing in "s...

I am now, and when I pass "/mnt/.../folder.jpg" to DYS, it still chokes & aborts.

Quote:

Quote:

Can you tell me what piece of code I could look at to try & debug this? Or, a way to pass the string in that will parse correctly, but still end up pointing to this file -- like quotes or something?

The relevant code is in dys/widgets/image.py, in the constructor of the ImageWidget class. Anyway, I will take another look at it as soon as I return home (I'm at work now).

OK, I've looked there, and it gets too deep for me in a hurry. I've hacked together a filter... if it can't find an image, it grabs a default image. So, it's working, and only fails on certain albums. So, no hurry -- whenever you get around to it is fine. Thanks, I really appreciate your help!

By dessaya (Desklet Author), on Thu Mar 2 07:48:05 2006: Re: Hate to annoy....

Maybelline wrote:

So, no hurry -- whenever you get around to it is fine. Thanks, I really appreciate your help!

Well, I've been looking at this problem, and I fail to find a solution that doesn't involve a lot of code rewriting :(

The problem is parsing the script's output. Take these examples:

Code:

This is a simple case: <markup True False "text" 'text' 45 -15.8/>
Some special cases:
<image "some \"filename with 'quotes'\""/>
<image 'some \'file with the other "quotes"\''/>
some text including a \< character
<markup "with some text including />"/>
Other special cases I forgot...?

The current simple parser chokes or produces unexpected results when some of these are found.

If I get this right, regular expressions are not enough to solve all these cases. A complete parser should be written, in pure Python, using a parser generator like Yapps, or by some other means.

As I've said previously in this forum, currently I lack the time to do this. Anyone willing to cooperate can get the darcs repository from here, and send me a patch by e-mail. Or, you can suggest a solution involving a simpler mechanism... if it is simple enough, I may find some spare time to implement it.

Thanks!
Diego

By Maybelline (User), on Thu Mar 2 14:29:06 2006: Helpless.

Well, I'm sorry to say that I don't have a clue as to writing a better parser... much less doing so in Perl.

So, as it stands, I'm perfectly content with what I've got... no modifications necessary. Thanks for all you've done already -- and for a great desklet!!

By nine (User), on Wed Jun 21 05:15:37 2006: Doityourself dont like my input ....

I have trying to make one script to doityourself adesklets but something is wrong with the input.

The objective of my desklet is to transform the list todo in a list that cames from an application tomboy (it's a todo with more options).

The aplication tomboy saves their information in xml file where i have extracted what I want and create the file .todo. The file todo it will be open normaly by the script todo, i hope that is clear what i want to do.

The script to transform the data is done but when the script todo try to make cat $TODO this message of error apears :

Code:


Traceback (most recent call last):
  File "./doityourself.py", line 140, in ?
    Events().pause()
  File "./doityourself.py", line 51, in __init__
    adesklets.Events_handler.__init__(self)
  File "/usr/lib/python2.4/site-packages/adesklets/events_handler.py", line 159,
 in __init__
    self._alarm()
  File "/usr/lib/python2.4/site-packages/adesklets/events_handler.py", line 296,
 in _alarm
    timeout=self.alarm()
  File "./doityourself.py", line 82, in alarm
    self.script.test()
  File "/home/nine/Desktop/deskletes/doityourself-0.4.1/dys/script.py", line 178
, in test
    self._call(args)
  File "/home/nine/Desktop/deskletes/doityourself-0.4.1/dys/script.py", line 155
, in _call
    self.render(self.widget_tree)
  File "/home/nine/Desktop/deskletes/doityourself-0.4.1/dys/script.py", line 383
, in render
    adesklets.window_resize(w, h)
  File "/usr/lib/python2.4/site-packages/adesklets/commands.py", line 1437, in w
indow_resize
    return comm.out()
  File "/usr/lib/python2.4/site-packages/adesklets/commands_handler.py", line 10
3, in out
    raise ADESKLETSError(4,message)
adesklets.error_handler.ADESKLETSError: adesklets command error - did not resize
 window



I have added this line to todo script to run my scritp that tranform the data

Code:


perl /home/nine/.tomboy/script.pl > "/home/nine/.todo"



I am using ubuntu 5.10, with version of doityourself-0.4.1
I am using codification utf-8 but using iconv to change it dont resolv the problem.

Any idea is a good idea.

Thank's for the time and sorry for the bad english

By dessaya (Desklet Author), on Wed Jun 21 18:23:42 2006: Re: Doityourself dont like my input ....

nine wrote:

The script to transform the data is done but when the script todo try to make cat $TODO this message of error apears :

Code:


Traceback (most recent call last):
    [...]
    adesklets.window_resize(w, h)
    [...]
adesklets.error_handler.ADESKLETSError: adesklets command error - did not resize
 window


I have added this line to todo script to run my scritp that tranform the data

Code:


perl /home/nine/.tomboy/script.pl > "/home/nine/.todo"


At first glance I can't tell what may be causing this error--probably a bug in doityourself. Please, can you post the contents of the generated .todo file, so I can test it?

Thanks,
Diego

By nine (User), on Thu Jun 22 05:41:01 2006.

My todo script is this, i only have added the line of perl :

Code:


#!/bin/bash

# This is a sample back-end script for doityourself. It shows your To Do List,
# which is taken from a text file. On click, it launches the editor on the
# To Do file.

# Exit immediately if any command fails:
set -e

export EDITOR=${EDITOR:-vi}
TODO="$HOME/.todo"

case $1 in
        init)
                cat <<-EOF
                <window.never_shrink False/>
                <background.color None/>
                <test_delay 3600/>
                EOF
                exit 0
                ;;
        test)
                # Test if the TODO file exists:
                if [ ! -r $TODO ]; then
                        cat <<-EOF
                        <color 'FF0000'/>
                        <col/><image 'error.png' 48 48/><endcol/><col/>
                        This desklet shows your To Do List.
                        The list is taken from the file $TODO.
                        Click to create the To Do file.
                        EOF
                        exit 0
                fi
                ;;
        click)
                # launch editor
                xterm -e $EDITOR $TODO
                ;;
esac

# Show the TODO file:
cat <<-EOF
<font 'Vera/14'/><color 'FF0000'/>
To Do List
<hline 300/>
<font 'Vera/10'/><color 'FFFFFF'/>
EOF
perl /home/nine/.tomboy/script.pl > "/home/nine/.todo"
cat $TODO




My perl script is :

Code:


#!/usr/bin/perl -w

use XML::Simple;
use File::Find;
#use strict;

my $dir= '/home/nine/.tomboy/';

find(\&display_note,$dir);

sub display_note {

        if(/\.note$/){
                my $file = '79200272-9f2f-424c-8781-b4d89ee05670.note';
                my $xsl = XML::Simple->new();
                
                my $doc = $xsl->XMLin($_);

                my $def_title = "<font 'Vera/12'/><color 'FF0000'/>";
                my $def_text = "<font 'Vera/10'/><color 'FFFFFF'/>";


                $texto = $doc->{'text'}->{'note-content'}->{content};

                @linhas = split(/\n/,$texto);

        #       print "$def_title \n";
                print "$linhas[0] \n";
        #       print "$def_text \n";

                $size = @linhas;

                for($cnt = 1; $cnt < $size; $cnt++){
                        print "$linhas[$cnt] \n";
                }
        }
}



If you need anything just ask.

Thanks,
An?bal

By nine (User), on Tue Jul 18 05:13:32 2006: The todo file.

Sorry, i forgot to post the todo file :

PLUG 8-11/07

8,9,10,11
Santo Tirso
Fotos

Imposi??o -> 01972 - 01981
Bonsai
SAD

23/06 9h00-12h00 14h00-16h00

gabinete 021 -> 023
engenharia 2
Estudo de Psicologia

fica para o dia de exame, marcar hora
Ana Daniela ...

By dessaya (Desklet Author), on Sat Jul 22 16:15:44 2006: Re: The todo file.

nine, I tried your .todo file and it was properly displayed (doityourself 0.4.1). So, I'm sorry to tell you that I have no idea what's wrong in your case :( . Maybe Sylvain can help a bit?

Regards,
Diego

By nine (User), on Thu Jul 27 15:37:19 2006: Thanks ....

Thanks for the help.
It don't work but i don't given up so esaly, if i resolve it i post it,

By yabbadabbadont (User), on Fri Sep 8 21:20:44 2006.

I've found what might be a bug in the text parser. Here are three versions of an echo statement used in a script. The first two work, while the third causes an error.

These two work:

Code:

echo "<font 'VeraBd/8'/>Wallpaper: <font 'Vera/8'/><hspace -1/>$FILENAME"
echo "<font 'VeraBd/8'/>Wallpaper:<font 'Vera/8'/><hspace -1/>$FILENAME"

This one causes an error:

Code:

echo "<font 'VeraBd/8'/>Wallpaper:<font 'Vera/8'/> <hspace -1/>$FILENAME"

Code:

/home/bubba/.desklets/doityourself-0.4.1 $ ./doityourself.py 
Do you want to (r)egister this desklet or to (t)est it? t
Now testing...
============================================================
If you do not see anything (or just an initial flicker
in the top left corner of your screen), try `--help',
and see the FAQ: `info adesklets'.
============================================================
Traceback (most recent call last):
  File "./doityourself.py", line 140, in ?
    Events().pause()
  File "./doityourself.py", line 51, in __init__
    adesklets.Events_handler.__init__(self)
  File "/usr/lib/python2.4/site-packages/adesklets/events_handler.py", line 158, in __init__
    self._alarm()
  File "/usr/lib/python2.4/site-packages/adesklets/events_handler.py", line 296, in _alarm
    timeout=self.alarm()
  File "./doityourself.py", line 82, in alarm
    self.script.test()
  File "/home/bubba/.desklets/doityourself-0.4.1/dys/script.py", line 178, in test
    self._call(args)
  File "/home/bubba/.desklets/doityourself-0.4.1/dys/script.py", line 155, in _call
    self.render(self.widget_tree)
  File "/home/bubba/.desklets/doityourself-0.4.1/dys/script.py", line 405, in render
    root_widget.render(x = padding, y = padding)
  File "/home/bubba/.desklets/doityourself-0.4.1/dys/widgets/group.py", line 177, in render
    widget.render(widget_x, widget_y)
  File "/home/bubba/.desklets/doityourself-0.4.1/dys/widgets/group.py", line 130, in render
    widget.render(widget_x, widget_y)
  File "/home/bubba/.desklets/doityourself-0.4.1/dys/widgets/text.py", line 47, in render
    adesklets.text_draw(x + self._initial_spaces_width, y, self.text.strip())
  File "/usr/lib/python2.4/site-packages/adesklets/commands.py", line 536, in text_draw
    return comm.out()
  File "/usr/lib/python2.4/site-packages/adesklets/commands_handler.py", line 103, in out
    raise ADESKLETSError(4,message)
adesklets.error_handler.ADESKLETSError: adesklets command error - text string not given or blank

Does this look like a bug, or have I just misunderstood the documentation?

On an unrelated note, is there a way to force this single line of text to always be a certain width? I tried messing with widget.min_size, but it didn't do what I expected. (didn't do anything at all as far as I could tell) I'm sure I just tried to use it incorrectly.

By dessaya (Desklet Author), on Fri Sep 8 22:04:30 2006.

yabbadabbadont wrote:

This one causes an error:

Code:

echo "<font 'VeraBd/8'/>Wallpaper:<font 'Vera/8'/> <hspace -1/>$FILENAME"

Does this look like a bug, or have I just misunderstood the documentation?

IIRC, it is a problem with the adesklets API, which does not allow to render a text string consisting only of spaces. I think that this issue gave me some serious headache in the past... Sure, doityourself could detect this situation and try to work around it, so you could consider it a bug in doityourself :wink:.

yabbadabbadont wrote:


On an unrelated note, is there a way to force this single line of text to always be a certain width? I tried messing with widget.min_size, but it didn't do what I expected. (didn't do anything at all as far as I could tell) I'm sure I just tried to use it incorrectly.

I'm not sure I get what you want to do.

min_size sets the minimum size for variable size widgets. For example, if min_size is 10, the hspace widget will always be at least 10 pixels wide (at least, it should work this way, unless you have found a real bug). Text widgets are not variable sized (ie, their size is determined by the font, not by the rest of the widgets).

Maybe what you need to do is to enclose some widgets between <col/>...<endcol/>. Please explain in detail the layout you want, and I'll see if I can help. Maybe you can also post your script.

Regards,
Diego

By yabbadabbadont (User), on Fri Sep 8 22:25:46 2006.

Thanks for the information and the quick reply. Coding wouldn't be very much fun if programs didn't have "undocumented features." :D

My script just pulls the name of my current wallpaper (which changes randomly every 10 minutes) from a text file and removes the path portion. It then displays it after the literal text "Wallpaper: ". Because the filenames all vary in length, I would like the display to be a certain fixed width (say 300 pixels) with the "Wallpaper: " left justified and the filename right justified.

Here is the script:

Code:

#!/bin/bash
#

# Exit immediately if any command fails:
set -e

case $1 in
        init)
                echo "<background.color '0000005C'/>"
                echo "<color 'FFFFFFFF'/>"
                echo "<test_delay 5/>"
                ;;
        test | click)
                FULLNAME=$(cat ~/.fluxbox/wallpaper-current)
                FILENAME=$(basename $FULLNAME)
                echo "<font 'VeraBd/8'/>Wallpaper: <font 'Vera/8'/><hspace -1/>$FILENAME"
                ;;
        *)
                echo "Usage: $0 [ init | test | click ] test-value"
esac

By dessaya (Desklet Author), on Fri Sep 8 23:02:24 2006.

yabbadabbadont wrote:

Because the filenames all vary in length, I would like the display to be a certain fixed width (say 300 pixels) with the "Wallpaper: " left justified and the filename right justified.

Ok, now I realize that a 'window.min_size' context variable would come in handy :oops:. However, '<window.never_shrink True/>' helps a bit.
A simple workaround is to create an empty line with a 300 pixels wide hspace. For example:

Code:

        test | click)
                ...
                echo "<hspace 300/>"
                echo "<font 'VeraBd/8'/>Wallpaper: <font 'Vera/8'/><hspace -1/>$FILENAME"

You should also set vpadding to 0 to completely hide that empty line. So, try adding these two lines to the init part:

Code:

        init)
                ...
                <window.never_shrink True/>
                <vpadding 0/>

Hope it helps,
Diego

By yabbadabbadont (User), on Fri Sep 8 23:27:59 2006.

Sweet! Thank you. That did just what I wanted.

Here is the result:

Screenshot

Again, thank you for your quick help.

Offtopic:
Now if I could just figure out how to create a transparent gkrellm theme that was tinted the same way that I have my adesklets...

By yabbadabbadont (User), on Sat Sep 23 03:53:49 2006.

After playing with this some more, I realized that it was stupid to have a doityourself script that just displayed the current wallpaper. It might as well call the wallpaper rotate script too. One thing I've noticed though, when using alpha channel transparency in the background, the value specified isn't used when the background is first drawn on desklet startup. It *is* transparent, it just doesn't seem to use the correct value (it's always darker than specified). If I pull up the control menu and move the desklet, then the background transparency immediately changes to the correct value. It's just wrong on initial startup. I know it isn't adesklets itself as my hacked weatherforecast desklet behaves correctly on startup. I have the background transparency set to the same value for both, so it is easy to see that my doityourself script is incorrect. I would guess that I'm just not doing something correctly in my script. Here is my script for reference:

Code:

/home/bubba/.desklets/doityourself-0.4.1/scripts $ cat rotate-wallpaper.sh 
#!/bin/bash
#
# This script is for use by the doityourself adesklet only
#

# Exit immediately if any command fails:
set -e

case $1 in
        init)
                echo "<background.color '00000080'/>"
                echo "<color 'FFFFFFFF'/>"
                echo "<test_delay 600/>"
                echo "<font 'VeraBd/7'/>"
                ;;
        test | click)
                wallpaper-set-random.sh
                FULLNAME=$(cat ~/.fluxbox/wallpaper-current)
                FILENAME=$(basename $FULLNAME)
                echo "$FILENAME"
                ;;
        *)
                echo "Usage: $0 [ init | test | click ] test-value"
esac


Thanks in advance for any help.

EDIT: After further testing, it appears that the initial background is pure black without any transparency. Once the desklet is moved however, the background has the correct transparency.

By dessaya (Desklet Author), on Sun Sep 24 13:58:32 2006.

yabbadabbadont wrote:

One thing I've noticed though, when using alpha channel transparency in the background, the value specified isn't used when the background is first drawn on desklet startup. It *is* transparent, it just doesn't seem to use the correct value (it's always darker than specified). If I pull up the control menu and move the desklet, then the background transparency immediately changes to the correct value. It's just wrong on initial startup.

I tested it and it seems to be a bug in doityourself. Unfortunately, right now I'm really busy with college and work, and I lack the time to study the problem and make a release.
Meanwhile, you can try this workaround: open the file dys/script.py and comment the following lines:

Code:

        # Render background, if necessary:
        #
        if self.last_background != (
           context['background.image'],
           context['background.color'],
           context['background.border.color']):
           self.render_background()

So that they look like:

Code:

        # Render background, if necessary:
        #
        #if self.last_background != (
        #   context['background.image'],
        #   context['background.color'],
        #   context['background.border.color']):
        #   self.render_background()

Hope it helps,
Diego

By yabbadabbadont (User), on Sun Sep 24 15:10:17 2006.

Thanks. I'll give that a try.

By yabbadabbadont (User), on Sun Sep 24 16:01:09 2006.

That's a no go. However, while testing I found that if I changed:

Code:

                        # Fill with the background color
                        if context['background.color']:
                                context.set_color(context['background.color'])
                                adesklets.image_fill_rectangle(0, 0, w, h)


in render_background to:

Code:

                        # Fill with the background color
                        if context['background.color']:
                                adesklets.context_set_color(0,0,0,64)
                                adesklets.image_fill_rectangle(0, 0, w, h)


it worked correctly. From this I assume that there is an issue with the context.set_color() function in context.py. However, my knowledge of python is limited enough that I am unable to determine what it might be. As far as I can tell, it looks correct to me. I'm going to do some experimenting (and probably end up reading "Dive into python") and see if I can figure it out.

EDIT: I had changed the code back to it's original state while I tried to track this down. Then today, I put the hack back in just so that it would work correctly. Unfortunately, it didn't work this time... <sarcasm>I don't know about you, but I just love problems that come and go on their own.</sarcasm> :x I guess there must be something else going on. I apologize if I sent you off on a wild goose chase.

By yabbadabbadont (User), on Wed Sep 27 13:40:43 2006.

Never mind. I've found an alternative solution without using adesklets at all. It just took the right combination of bash scripts and imagemagick to do what I wanted. Sorry for wasting your time. (although I did find a bug, so I guess it wasn't a total waste :))


adesklets is proud to be hosted on:

SourceForge.net Logo

Back to adesklets.sf.net.