gcmd-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [gcmd-dev] archive browser plugin


From: Magnus Stålnacke
Subject: Re: [gcmd-dev] archive browser plugin
Date: Wed, 22 Mar 2006 11:33:00 +0100
User-agent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.7.12) Gecko/20051003

Micha wrote:

Folks, as a sidenote, you can view

[cut ...]

As another sidenote.

I have started to develop a shellscript for managing
mime types, attached is what i have done so far...

The script takes a filename (works fine in gcmd rightclick
menu), investigates its mime type, asks for app. name
and command and then writes/modifies the files in
~/.local/share/applications and updates the mimeinfo.chache

Many possible features are missing, now it just does the
very basics.


//Magnus S.
#!/bin/bash
#
# TODO
# Fix handling of defaults.list
# Add "runs in terminal" option
#
export LANG=en_US.utf8 
ME=`whoami`
XDG_DATA_DIRS=/home/$ME/.local/share
MTPE=`file -i $1 | awk '{print $2}'`
#
echo "Name of application that can handle the mimetype $MTPE:"
read NME
echo "Command to run the $NME application:"
read APP
#
# Write/modify .desktop file
#
function modmime(){
GLOB_USER=`cat $XDG_DATA_DIRS/applications/mimeinfo.cache 
/usr/share/applications/mimeinfo.cache`
EXT=usercreated.desktop
USER_APP="$XDG_DATA_DIRS/applications/$APP.$EXT"

if echo "$GLOB_USER" | grep "$MTPE" | grep -q "$APP"
then
  echo "The mime type: $MTPE is allredy assigned to: $APP"
else
  if [ -e "$USER_APP" ]
  then
    cat $USER_APP | sed "s|MimeType=|MimeType=$MTPE;|g" > $USER_APP
    echo "The mime type: $MTPE is now added to: $APP"
  else
    echo "[Desktop Entry]" > $USER_APP
    echo "Encoding=UTF-8" >> $USER_APP
    echo "Name=$NME" >> $USER_APP
    echo "MimeType=$MTPE;" >> $USER_APP
    echo "Exec='$CMD'" >> $USER_APP
    echo "Type=Application" >> $USER_APP
    echo "Terminal=false" >> $USER_APP
    echo "NoDisplay=true" >> $USER_APP
    echo "The application: $APP is now registered to handle: $MTPE"
  fi
export XDG_DATA_DIRS
update-desktop-database -q
fi
}
if which $APP >&/dev/null
then
CMD=`which $APP`
modmime
else
echo "No such command in path, try assign command with full path"
fi

reply via email to

[Prev in Thread] Current Thread [Next in Thread]