Hello,
I've been working on desktop2dt some more, and have a version that
works much better.
It can handle icons in subdirectories, installing files (to $DESTDIR/etc/dt
or ~/.dt), and terminal applications.
There are still some missing features:
-line-wrapped entries
-adding entries to the app manager
-file types and associations
Unless we use libmagic, this will be a real pain.
-multiple locales ( for example, Comment[de]= could make an entry in the
right locale).
Currently, it's hard-coded to output action databases in the C locale.
Usage is similar to the last version, except -i installs everything:
desktop2dt -i /usr/share/applications/nedit.desktop \
/usr/share/applications/xephem.desktop
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
If you can test it, that will be a great help. I've tried to stick to POSIX,
but I only tested on Squeeze.
Thanks,
Isaac Dunham
#!/bin/sh
# Copyright 2013, Isaac Dunham
#
# Permission is hereby granted, free of charge, to any person obtaining a
# copy of this software and associated documentation files (the "Software"),
# to deal in the Software without restriction, including without limitation
# the rights to use, copy, modify, merge, publish, distribute, sublicense,
# and/or sell copies of the Software, and to permit persons to whom the
# Software is furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in
# all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
# THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
# DEALINGS IN THE SOFTWARE.
# 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=`{ find /usr/share/pixmaps /usr/share/icons \
/usr/local/share/pixmaps /usr/local/share/icons \
-type f -name "$1" -o -name "$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" "$ICONDIR$NEWICON.l.pm"
convert -resize 32x32 "$ICON" "$NEWICON.m.xpm" && \
mv "$NEWICON.m.xpm" "$ICONDIR$NEWICON.m.pm"
convert -resize 16x16 "$ICON" "$NEWICON.t.xpm" && \
mv "$NEWICON.t.xpm" "$ICONDIR$NEWICON.t.pm"
echo "$NEWICON"
}
# usage: process_desktop /path/to/some.desktop >some.dt
# Writes a CDE action equivalent to some.desktop to stdout.
process_desktop(){
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 '}'
}
unset INSTALLDIR; export INSTALLDIR="./" ICONDIR="./"
while [[ -n "$1" ]]
do
case "$1" in
*.desktop)
process_desktop "$1" >"$INSTALLDIR"`basename "$1" .desktop`.dt
;;
-i*)
mkdir -p "$DESTDIR/etc/dt/appconfig/types/C" && \
rm -f "$DESTDIR/etc/dt/appconfig/types/C/aaa.xyz.test" && \
touch "$DESTDIR/etc/dt/appconfig/types/C/aaa.xyz.test" && \
test -w "$DESTDIR/etc/dt/appconfig/types/C/aaa.xyz.test" && \
rm -f "$DESTDIR/etc/dt/appconfig/types/C/aaa.xyz.test" && \
export INSTALLDIR="$DESTDIR/etc/dt/appconfig/types/C/" \
ICONDIR="$DESTDIR/etc/dt/appconfig/icons/C/" || \
export INSTALLDIR="$HOME/.dt/types/" ICONDIR="$HOME/.dt/icons/"
mkdir -p "$ICONDIR" "$INSTALLDIR"
;;
*)
echo "Usage: $0 [-i] some.desktop ..."
echo "generates some.dt and the appropriate icons"
echo "If -i is specified, some.dt and the icons are installed"
echo '(in $DESTDIR/etc/dt if possible, otherwise in ~/.dt)'
;;
esac
shift
done
------------------------------------------------------------------------------
Subversion Kills Productivity. Get off Subversion & Make the Move to Perforce.
With Perforce, you get hassle-free workflows. Merge that actually works.
Faster operations. Version large binaries. Built-in WAN optimization and the
freedom to use Git, Perforce or both. Make the move to Perforce.
http://pubads.g.doubleclick.net/gampad/clk?id=122218951&iu=/4140/ostg.clktrk
_______________________________________________
cdesktopenv-devel mailing list
cdesktopenv-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/cdesktopenv-devel