Folder emblems
Various KDE Extensions
Score 68%
Description:


Folder Emblems 0.6
(c) 2010 JCC
http://blog.lilaetleloup.com
License: GPL

This is a hack to:
* add sort of an "emblem" feature to the folders in KDE4.
* simulate the "folder.jpg" functionnality of Windows XP (i.e. assign as icon to
the directory an image present within itself)

Both functionnalities are available through a "service menu", i.e. you can
right-click a folder, then choose "Actions", then one of the four menu entries
created by the installation of the .desktop file:
* Add emblem
* Add emblem (recursive)
* Apply folder image
* Apply folder image (recursive)

You can also right click on any image within a folder, then choose the action
"Set as folder icon" in order to apply the selected image as the folder icon.

Pre requisites
--------------

This software requires ImageMagick (package imagemagick in Mandriva, or
the equivalent for your distro)

If you want to turn on size optimization of the generated folder icons (see
below) then you will need one of advpng (package advancecomp), pngcrush or
optipng.

Emblem feature
--------------
It allows you to select an icon, and add it to the normal icon folder of the
selected folder. New folder icons are generated and assigned to the directory.

It works through the use of a KDE Service menu (right click on the directory,
then choose "Actions", then "Add emblem"). It can do it recursively.

"folder.jpg" feature (folder image)
-----------------------------------
It allows you to assign to a directory (and its sub-directories if called
recursively) an image which is stored within, as an icon.
Despite its name, any image name will do it.

If the folder image is not square, then applying it as a folder icon would
strech it. In order not to stretch the image, a new image (square, with a
transparent background) will be generated in the directory. The resulting
image will be named after the original image. For example, if the image is
folder.jpg, folder.jcc.png will be generated.
Of course if the image is square it will be used as is.

Note 1: due to a bug in KDE (at least in 4.4.3), you cannot use hidden images as
folder icons (for example .folder.png would be nice, but won't work).

Note 2: if you want to turn on size optimization of the generated folder.jcc.png
then you will need one of advpng (package advancecomp), pngcrush or optipng

Command line
------------
The software comes with emblem.sh, a program that can also be called from the
command line.

Usage
-----
Show this help text and exit:
emblem.sh --help

1. Add an emblem to a directory
emblem.sh [--nodialog] [[--recursive] [--progressbar]] [--local] [--notify]
<target folder> [icon file name]

when the icon file name is not provided, it will be asked to the user
interactively.

2. Apply to a directory one of its images as icon:
emblem.sh [--nodialog]
[[--recursive] [--progressbar]]
--folderimg (<image file name>|--ask)
[--defaultfolderimg <default image name>]
[--optimize]
[--notify]
<target folder>

3. Apply an image as icon to its directory
emblem.sh --setasfoldericon <image file name>

Options:
--help show this help text and exit
--nodialog do not fire kdialog in case of an error
--recursive perform the action on the folder <target folder>
and all of the folders contained witin
--local save the generated icon as <target folder>/folder.png
instead of creating it ~/.config/jcc/emblems
(useful to move directories between machines without
losing their icon)
--folderimg use <image file name> as the icon to be set
(e.g. folder.jpg)
if used with --ask, the user will be asked interactively
--defaultfolderimg default image name to be used in the dialog box when
asking the user. Implies --folderimg --ask.
--optimize optimize generated images for non square folder icons
--setasfoldericon allows to set the image given as a parameter as its
containing directory icon
--notify send notifications to the desktop so that passive popups
can be displayed when the job is over (the error
messages are also displayed this way instead of dialogs)
Install
-------
To install, copy the .desktop files to the kde4 service menus directory
(e.g. /usr/share/kde4/services/ServiceMenus/emblem.desktop
or better ~/.kde4/share/kde4/services/)

and copy emblem.sh to your bin directory
(e.g. ~/bin/emblem.sh)
Note: if /home/<user>/bin does not exist, then create it.

emblem.sh needs the "composite" command from ImageMagick. This package must be
installed on your machine.

To configure the parameters, please edit directly emblem.sh.
In particular, you should edit BASE_FOLDER_ICON to point to the default
folder icon you are using.

You can also change the location of emblem.sh, but you'll have to modify
the emblem.desktop file to point to the right place.

Note: the generated folder emblem icons are stored in ~/.config/jcc/emblems/

Last changelog:

7 years ago

0.6 22/11/2010 new functionnality: the generated icons when the directory
image is not square are now optimized (requires advpng
(package advancecomp), pngcrush or optipng).
bug fix: 0.5 introduced a regresion for directories with two
adjacent spaces in their names (folder icon functionality).
bug fix: now always exits with a return code 0 on success
(it was possible to exit with a different return code if qdbus
had problems with ghost dolphins)
new functionnality: --progressbar displays a dialog box with a
progress bar, when using --recursive
new funcitonnality: --notify uses desktop notifications instead
of dialog boxes for error messages, plus notifies the end of
the job.
new functionnality: whenever it applies, make use of the icon
preferences-desktop-icons (notifications, dialog boxes)
new functionnality: --setasfoldericon, also accessible by right
click (through new desktop file emblem2.desktop)

0.5 15/11/2010 bug fix: "folder.jpg" was hardcoded instead of using the user
defined filename (when not using --recursive). Fixed.
new functionality: when "folder.jpg" (or the like) is not square
then generate a square icon, so that it will not be stretched
when applied as a folder's icon

0.4 14/11/2010 bug fix: did not work when the target directory was not an
absolute path. Fixed.
bug fix: did not work when the best folder.png resolution was
less than 3 digits
(e.g. was searching in 064x064 instead of 64x64)
bug fix: now use the correct tmp directory (use ~/tmp if it
exists, else use $TMP, else $TMPDIR, else/tmp)

0.3 12/11/2010 bug fix: fix the --help text
bug fix: fix the --recursive implementations (now supports any
characters in the directory names - single or double quotes,
multiple spaces, or whatever)
bug fix: fix --folderimg (was case sensitive when --recursive
was not used)

0.2 07/11/2010 new functionality: add "folder.jpg" feature
code rewrite/cleanup
new functionality: autodetection of the default folder icon
new functionality: add all "--" options

0.1 10/10/2010 creation

steveke

6 years ago

Hello! I just wondered if it would be possible to modify the script to add the emblems to the bottom right corner of the base folder to match the emblems in the new oxygen icons in KDE 4.7.

Report

C

jice

6 years ago

You can edit the script to change the position and size of the emblem. Sorry it is not configurable more easily.

Report

steveke

6 years ago

OK Great. Thanks.

Just a matter of changing GRAVITY to southeast then.

Report

lunimare

7 years ago

Good job. but I wish I could also change the icons of files within folders. For example putting the covers of films in the archives

Report

C

jice

6 years ago

I'd like that too, unfortunately, this is not currently supported by KDE

Report

karapuz

7 years ago

./emblem.sh folderemblems-0.3 /usr/share/icons/oxygen/22x22/actions/acrobat.png
folderemblems-0.3/emblem.sh: line 92: printf: scalable: недопустимое число
Using default kde theme icon for folder.png
mktemp: failed to create file via template `/home/jura/tmp/tmp.XXXXXXXXXX': Нет такого файла или каталога
composite: unable to open image `/usr/share/icons/default.kde4/064x064/places/folder.png': /usr/lib/ImageMagick-6.6.1/modules-Q16/coders/png.la @ error/blob.c/OpenBlob/2489.
composite: unable to open image `/usr/share/icons/default.kde4/064x064/places/folder.png': @ error/blob.c/OpenBlob/2489.
composite: unable to open file `/usr/share/icons/default.kde4/064x064/places/folder.png' @ error/png.c/ReadPNGImage/3014.
composite: missing an image filename `' @ error/composite.c/CompositeImageCommand/1607.
Error creating the icon

Report

C

jice

7 years ago

thanks for the report.
version 0.4 will fix these problems.

Report

TheStarLion

7 years ago

Will this work with Dropbox or Kfilebox, and show the sync-ing/ed emblems as Gnome's Nautilus does?

Report

C

jice

7 years ago

It won't. First it works only on directories, then it is more a hack than a real emblem support. In fact icons are generated for the folder when you assign it an "emblem".
I don't know/use dropbox, so do not know how the emblems are generated there.

Report

XandarKablandar

7 years ago

This is great! This should be a standard part of the KDE SC distros.

Report

C

jice

7 years ago

thanks a lot!

Report

musonio

7 years ago

This is a great addition!!!!
It works perfectly well.
Thanks a lot.

Report

musonio

7 years ago

I forgot:
Would it be possible to add an option to set an emblem recursively?
That would allow me to differentiate the different partitions which each folder belongs to.

Report

C

jice

7 years ago

thanks!
indeed this would be a good idea. to keep it simple, I could add a second menu entry "add emblem recursively", what do you think?

Report

musonio

7 years ago

That's exactly what I thought.

Report

C

jice

7 years ago

published today!

Report

7 years ago

0.6 22/11/2010 new functionnality: the generated icons when the directory
image is not square are now optimized (requires advpng
(package advancecomp), pngcrush or optipng).
bug fix: 0.5 introduced a regresion for directories with two
adjacent spaces in their names (folder icon functionality).
bug fix: now always exits with a return code 0 on success
(it was possible to exit with a different return code if qdbus
had problems with ghost dolphins)
new functionnality: --progressbar displays a dialog box with a
progress bar, when using --recursive
new funcitonnality: --notify uses desktop notifications instead
of dialog boxes for error messages, plus notifies the end of
the job.
new functionnality: whenever it applies, make use of the icon
preferences-desktop-icons (notifications, dialog boxes)
new functionnality: --setasfoldericon, also accessible by right
click (through new desktop file emblem2.desktop)

0.5 15/11/2010 bug fix: "folder.jpg" was hardcoded instead of using the user
defined filename (when not using --recursive). Fixed.
new functionality: when "folder.jpg" (or the like) is not square
then generate a square icon, so that it will not be stretched
when applied as a folder's icon

0.4 14/11/2010 bug fix: did not work when the target directory was not an
absolute path. Fixed.
bug fix: did not work when the best folder.png resolution was
less than 3 digits
(e.g. was searching in 064x064 instead of 64x64)
bug fix: now use the correct tmp directory (use ~/tmp if it
exists, else use $TMP, else $TMPDIR, else/tmp)

0.3 12/11/2010 bug fix: fix the --help text
bug fix: fix the --recursive implementations (now supports any
characters in the directory names - single or double quotes,
multiple spaces, or whatever)
bug fix: fix --folderimg (was case sensitive when --recursive
was not used)

0.2 07/11/2010 new functionality: add "folder.jpg" feature
code rewrite/cleanup
new functionality: autodetection of the default folder icon
new functionality: add all "--" options

0.1 10/10/2010 creation

File (click to download) Version Description Filetype Packagetype License Downloads Date Filesize OCS-Install DL
Details
version
0.6
updated Nov 22 2010
added Oct 11 2010
downloads today
0
page views today 0