Just switched to fvwm a few days ago after many months of not being happy about the style and behaviour of any other window manager. Fvwm is perfect for me, configurable to (nearly) the last detail. I’m still on the way to building the perfect set for me. But I’m on my way.
This is a small bash script, a quick’n’dirty hack (well not so quick to be honest). The script is mainly intended for lazy people - like me - who hate generating menu entries by hand.
It reads all *.desktop files found in /usr/share/applications, compares them to a user configuration file and puts all those icons automagically as shortcuts into the TaskBar. It also resizes the icons (uses imagemagick).
The directory structure (create the directories and files by hand, script doesn’t handle this yet):
The script. name it whatever you want to.
stores the generated 16x16 icons
this file has the generated entries for fvwmtaskbar. You do not have to put anything in it, as the script takes care of this file.
this tells the script which programs to include in the generation. The programms listed in this file are the only ones put in the taskbar. You have to edit this file yourself
this tells the script which programms are seen as “excludes”. This - together with includes - is used to determine new programms. You have to edit this file yourself
Syntax of include and exclude files: One program name per line. The program name is the first part of the *.desktop file name.
Example: mozillafirefox.desktop, so the program name is mozillafirefox. If you have programs you haven’t used yet, the script will display the name of the programs.
And here is the script:
[code]#!/bin/bash
iconscript.sh: Automatically build FvwmTaskBar-Shortcuts from .desktop files
Fvwm is a Window Manager for the X11 Windowing System (http://fvwm.org)
Copyright 2005 Stephen Tallowitz
Released under the GNU General Public Licence (GPL)
Licence available from: http://www.gnu.org/licenses/gpl.txt
Version: 2005-04-25
if you do not get this script to work properly, you may have to install these programs:
gnu coreutils (find, cat, sed)
imagemagick (convert)
things I have yet to do:
1. adhere to handling of config- and cache directories. see XDG Base Directory Specification
2. write some initialisation routines for fresh “installations” of this script
information on the desktop-files can be found at: http://standards.freedesktop.org/desktop-entry-spec/desktop-entry-spec-0.9.4.html
set environment
DESKTOP_DIR=“/usr/share/applications”
ICON_DIR=“/usr/share/pixmaps”
USR_CONFIG=“${HOME}/.config/fvwm-iconscript/”
USR_CACHE=“${HOME}/.cache/fvwm-iconscript”
FVWM_CONF=“${HOME}/.fvwm”
DEBUG=1
Initialise empty cache
echo “” > ${FVWM_CONF}/entries.cache
Remove old, generated icons - deactivated: problems when loading fvwm TaskBar
rm ${USR_CACHE}/*
Read user config for includes
for i in cat ${FVWM_CONF}/iconscript/include
; do
for k in find ${DESKTOP_DIR} -name *.desktop | sed -r "s/(.*\/)(.*)(\.desktop)/\2/"
; do
if test $i == $k; then
# echo “Name der Desktop-Datei: $i”
executable=cat \
find ${DESKTOP_DIR} -name $i.desktop` | sed -n -e “/^Exec/p” | sed -r “s/(.)=(\ )(.)/\3/" # strip any arguments off executable=
echo $executable | sed -r "s/(.)\ (.)/\1/" # echo "Name der Exec-Datei: $executable" icon=
cat `find ${DESKTOP_DIR} -name $i.desktop` | sed -n -e “/^Icon/p” | sed -r "s/(.)=(\ )(.)/\3/” # echo "Icon-Eintrag: $icon" iconname=
echo $icon | sed -r “s/^/(./)+(.)$/\2/” iconpath=
echo $icon | sed -r “s/^/(./)+(.){1}$//\1/” echo "Pfad des Icons: $iconpath" echo "Dateiname des Icons: $iconname" if test $iconpath == $iconname; then iconpath="${ICON_DIR}/" fi
convert -geometry 16x16 $iconpath$iconname ${USR_CACHE}/16$iconname`
echo “*FvwmTaskBar: Button Icon 16$iconname, Action Exec $executable” >> ${FVWM_CONF}/entries.cache
fi
done
done
Read includes and excludes and print new desktop-files
for i in find ${DESKTOP_DIR} -name *.desktop | sed -r "s/(.*\/)(.*)(\.desktop)/\2/"
; do
value=“true”
for k in cat ${FVWM_CONF}/iconscript/include ${FVWM_CONF}/iconscript/exclude
; do
if test $i == $k; then
value=“false”
fi
done
if test $value == “true”; then
echo “New Desktop entry file for: $i”
fi
done
[/code]
The things you might want to change in your .fvwm/config (assuming you know the script by ~/.fvwm/iconscript.sh):
ImagePath ${HOME}/.cache/fvwm-iconscript/
AddToFunc InitFunction
+ I Module FvwmTaskBar
+ I Exec exec ${HOME}/.fvwm/iconscript.sh
AddToFunc RestartFunction
+ I Module FvwmTaskBar
+ I Exec exec ${HOME}/.fvwm/iconscript.sh
# Read the file the script produced
Read entries.cache
# Some manual entries that are not handled by the script
*FvwmTaskBar: Button Icon /usr/somewhere/xterm.xpm, Action (Mouse 1) exec xterm
Anyone like this idea?
One small side note: the icon handling from the *.desktop config files is rather simple. Some shortcuts may not display an icon. If they don’t you will mostly find it to be a path / filename problem. I am working on this. Believe me, I’m not happy about it myself. So just wait a little bit longer until I fix it. (fixed on: 2005-05-01)
cheers,
geta