LOGIN / SIGN UP

#148 pekwm_themeset.sh doesn't handle empty theme directories properly and produces ugly error message

Reported by: dmoerner Assigned to: ioerror
Phase: release-0.1.11 Component: configuration
Type: bug Status: closed
Priority: 3: Medium
Watchers:

Description

Hi, the code for pekwm_themeset.sh.in has changed a bit from 0.1.9a to 0.1.10 (as I am sure you are well aware!) I apologize for the vague title of this Task report but it's really two issues with the same root.

index e191c0c..cc9339f 100644 --- a/data/scripts/pekwm_themeset.sh.in +++ b/data/scripts/pekwm_themeset.sh.in @@ -1,6 +1,6 @@

 #!<SH>
 #

-# Copyright © 2003-2008 the pekwm development team +# Copyright © 2003-2009 the pekwm development team

 #
 # Add this to your menu to use this script:
 #

@@ -23,13 +23,13 @@ if test -z "${2}"; then

     # Check that theme directory exists, if it does not exist create a
     # dummy entry that says the dir does not exist.
     if test -d "${theme_dir}"; then

- for path in $(find "${theme_dir}" -maxdepth 2 -type f -name theme); do - theme_path="$(dirname "${path}")" - theme_name="$(basename "${theme_path}")" - echo -e "Entry = \"${theme_name}\" { Actions = \"Exec ${0} ${1} ${t - done + ( cd ${theme_dir}; + for theme_name in *; do + theme_path="${theme_dir}/${theme_name}" + echo "Entry = \"${theme_name}\" { Actions = \"Exec ${0} ${1} ${them + done )

     else

- echo -e "Entry = "No such directory ${theme_dir}" { Actions = "NO" }" + echo "Entry = \"No such directory ${theme_dir}\" { Actions = \"None\" }

     fi
     echo "}"

Although this commit does make the "No such directory" error message properly appear, there are two problems:

1) .pekwm/themes is currently not a directory created on the first run of pekwm. This means that a fresh install always produces an ugly "No such directory ~/.pekwm" on the start. It would be nice to make the themes/ directory in .pekwm when the rest of the config files are installed on the first run.

2) The * expansion globbing doesn't work properly when the directory is empty--instead of expanding the * to nothing, it just passes "*" as the name of the theme. The easiest way to fix this is to use another test using "ls -A $DIR" to see if the directory is empty and then just falling through without error if it is empty.

Cheers, Daniel

2009-01-31

00:50:08

Thanks!

00:33:49 changed from open to closed
00:33:43

I applied the patches and pushed to git HEAD.

2009-01-30

01:40:54 changed from release-0.1.10 to release-0.1.11
01:40:54 changed from new to open

2009-01-29

00:02:02

Hi,

The following two patches fix the issues in this Task:

1) http://git.debian.org/?p=collab-maint/pekwm.git;a=blob;f=debian/patches/make-empty-themes-dir-in-home-dir-on-first-run.diff;h=a99ee97db8bd5855cefc2e50af7ede43d37434b2;hb=84214c04919d80a4d6fefcd94838d26a13c318c5

This fixes the first issue by introducing a new boolean "make_themes" (I used make_themes instead of cp_themes since you aren't copying like in the other cases) and then making a .pekwm/themes dir if it doesn't already exist. I didn't put all the tests in that exist for the .pekwm directory, because if you can safely make .pekwm it seems to me that you should be able to make .pekwm/themes.

2) http://git.debian.org/?p=collab-maint/pekwm.git;a=blob;f=debian/patches/properly-handle-nullglob-in-themes-script.diff;h=66dcc6733b8329eba2b6e57d2b0f85298e055f7f;hb=145003d9c2aa9a9d22217a2119f10e05b9b16ae8

This fixes the second issue by introducing another test inside the for loop. It also resolves another issue--if you have any non-directory in a themes dir, it will show up in the menu, even though only directories can be full themes in there.

I have tested these patches myself but there are no guarantees.

2009-01-27

21:52:50 changed from Claes Nästén to Andreas
06:08:55

It appears that it really mangled the diff when I just copy and pasted it. The relevant commit from the git master tree is:

2a637df... Make pekwm_themeset.sh much faster avoiding a lot of forks.