Hello,
Earlier I noticed that *.dt files contain much the same information as
*.desktop files, so I thought I'd see about automatically converting
from *.desktop to *.dt.
Here's a first try, in the form of a shell script.
It reads one or more desktop files, listed on the command line,
to generate as many .dt files and the corresponding icons.
Each .dt file contains only the action that would start the command.
This does NOT handle quite a few things:
-multiple locales ( for example, Comment[de]= could make an entry in the
right locale).
-putting anything in the right place
-line-wrapped entries
-adding entries to the app manager
-file types and associations
-most sanity checks
That said, this works for me:
cd emptydir
desktop2dt /usr/share/applications/nedit.desktop \
/usr/share/applications/xephem.desktop
mv *.dt ~/.dt/types/
mv *.pm ~/.dt/icons/
touch ~/.dt/appmanager/Desktop_Apps/nedit
touch ~/.dt/appmanager/Desktop_Apps/xephem
chmod +x ~/.dt/appmanager/Desktop_Apps/nedit
chmod +x ~/.dt/appmanager/Desktop_Apps/xephem
and then go to Desktop_Tools > Reload Applications
I'd like to hear any comments you have.
Thanks,
Isaac Dunham
#!/bin/sh
# Name= -> LABEL ...
# Icon= -> ICON ...
# (use imagemagick/gm convert to resize and change format?)
# Comment= -> DESCRIPTION
# Exec= -> EXEC_STRING
# (note: %F means "file name"; = "%(File)Arg_1%" )
# Terminal=false/0 -> WINDOW_TYPE NO_STDIO
# Terminal=true/1 -> WINDOW_TYPE PERM_TERMINAL
# or maybe something else is a little better than PERM_TERMINAL
# Note that the component of an ACTION MUST be in the right order!
# for example, EXEC_STRING must be before ICON, or you will not
# get the right icon or command.
#
#
#find_convert icon | /path/to/icon.png
# Find icon and convert it to an xpm of suitable size; t/m/l = 16/32/48
find_convert(){
ICON=""
case "$1" in
/*)
ICON="$1"
;;
*)
ICON=`{ ls /usr/share/pixmaps/$1.* /usr/share/pixmaps/$1 || \
ls /usr/local/share/pixmaps/$1.* /usr/local/share/pixmaps $1 ;
} |head -n 1`
;;
esac
export ICON
NEWICON=`basename $ICON|sed -e 's/\.xpm$//' -e 's/\.png$//' -e 's/\.svg$//' -e
's/\.jpe*g$//'`
convert -resize 48x48 "$ICON" "$NEWICON.l.xpm" && mv "$NEWICON.l.xpm"
"$NEWICON.l.pm"
convert -resize 32x32 "$ICON" "$NEWICON.m.xpm" && mv "$NEWICON.m.xpm"
"$NEWICON.m.pm"
convert -resize 16x16 "$ICON" "$NEWICON.t.xpm" && mv "$NEWICON.t.xpm"
"$NEWICON.t.pm"
echo "$NEWICON"
}
#usage: process_desktop /path/to/some.desktop >`basename some.desktop desktop`dt
process_desktop(){
#extracting from Name= line would be nice...
echo "ACTION `basename $1 .desktop`"
echo '{'
LABEL="`sed -ne 's/^Name=//p' $1`"
[[ -n "$LABEL" ]] && echo " LABEL $LABEL"
echo ' TYPE COMMAND'
sed -ne 's/^Exec=/ EXEC_STRING /p' "$1" | sed -e 's/%F/%(File)Arg_1%/g'
ICON="`sed -ne 's:^Icon=::p' $1`"
[[ -n "$ICON" ]] && ICON=`find_convert $ICON`
echo " ICON $ICON"
INTERM=`sed -ne 's/^Terminal=//gp' "$1"`
case "$INTERM" in
0 | f* ) echo " WINDOW_TYPE NO_STDIO"
;;
*) echo " WINDOW_TYPE PERM_TERMINAL"
;;
esac
sed -ne 's/^Comment=/ DESCRIPTION /p' "$1"
echo '}'
}
while [[ -n "$1" ]]
do
case "$1" in
*.desktop)
process_desktop "$1" >`basename "$1" .desktop`.dt
;;
*)
echo "Usage: $0 some.desktop ..."
echo "generates some.dt and the appropriate icons in the current
directory"
;;
esac
shift
done
------------------------------------------------------------------------------
Flow-based real-time traffic analytics software. Cisco certified tool.
Monitor traffic, SLAs, QoS, Medianet, WAAS etc. with NetFlow Analyzer
Customize your own dashboards, set traffic alerts and generate reports.
Network behavioral analysis & security monitoring. All-in-one tool.
http://pubads.g.doubleclick.net/gampad/clk?id=126839071&iu=/4140/ostg.clktrk
_______________________________________________
cdesktopenv-devel mailing list
cdesktopenv-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/cdesktopenv-devel