Repository 32bit  Forum
Repository 64bit  Wiki

Rox-filer: automount e icona dispositivo sul desktop

Da Slacky.eu.
Versione delle 20:15, 23 feb 2010, autore: Wikijimmy (Discussione | contributi)

(diff) ← Versione meno recente | Versione attuale (diff) | Versione più recente → (diff)


Creare il file ~/.halevt/HalevtConfigActions.xml (nella home directory si intende) con dentro:

<!DOCTYPE halevt:Configuration [
 
<!-- this entity corresponds with mountable devices, which have
 volume.policy.should_mount true or don't have
 volume.policy.should_mount false and are block devices hotpluggable or
 removable.
--> 
<!ENTITY MOUNTABLE "hal.block.device & hal.block.is_volume = true & (hal.volume.policy.should_mount = true | ((! hal.volume.policy.should_mount = false) & (hal.block.storage_device.hal.storage.policy.should_mount = true | ((! hal.block.storage_device.hal.storage.policy.should_mount = false)  & (hal.block.storage_device.hal.storage.hotpluggable = true | hal.block.storage_device.hal.storage.removable = true)))))"> 
]>
<halevt:Configuration version="0.1" xmlns:halevt="http://www.environnement.ens.fr/perso/dumas/halevt.html"> 
 
   <!-- audio CD --> 
   <halevt:Device match="hal.block.is_volume & hal.volume.disc.type=cd_rom & hal.volume.disc.has_audio=true & hal.volume.disc.has_data=false"> 
      <halevt:Insertion exec="grip"/> 
   </halevt:Device> 
 
   <!-- blank CD/DVD --> 
   <halevt:Device match="hal.block.is_volume & hal.volume.is_disc=true & hal.volume.disc.is_blank=true"> 
      <halevt:Insertion exec="k3b"/> 
   </halevt:Device> 
   
   <!--
   This rule matches removable devices which have volume.policy.should_mount true
   or don't have volume.policy.should_mount false.
   Upon insertion, they are mounted and recorded by halevt-mount.
   -m 002 sets the umask of mount to 002 when pmount is used system-wide
   to mount the device. This allows regular users to read the device.
      <halevt:Insertion exec='halevt-mount -u $hal.udi$ -m 002 ; /usr/local/bin/rox.panelput.pl Add "$hal.volume.mount_point$" "$hal.volume.label$"'/>
   !--> 
   <halevt:Device match="&MOUNTABLE; & (!hal.volume.is_disc | hal.volume.is_disc=false)"> 
      <halevt:Insertion exec='halevt-mount -u $hal.udi$ -m 002'/> 
   </halevt:Device> 
   <halevt:Device match="&MOUNTABLE; & hal.volume.is_disc=true"> 
      <halevt:Insertion exec="halevt-mount -u $hal.udi$ -m 002"/> 
   </halevt:Device> 
 
   <!--
   When a device get a mount point, it is passed to halevt-mount which can
   record it. The property that changes is volume.is_mounted, and the action is
   executed when the value of volume.is_mounted becomes true.
         <halevt:Action value="true" exec="halevt-mount -s"/>
   !--> 
<!--USB--> 
   <halevt:Device match="hal.block.device & hal.block.is_volume = true & hal.volume.mount_point & hal.volume.is_disc = false"> 
      <halevt:Property name="hal.volume.is_mounted"> 
         <halevt:Action value="true" exec='/usr/local/bin/rox.panelput.pl Add "$hal.volume.mount_point$" "$hal.volume.label$"'/> 
      </halevt:Property> 
   </halevt:Device> 
   
<!--cdroms--> 
    <halevt:Device match="hal.block.device & hal.block.is_volume = true  & hal.volume.is_disc = true & hal.volume.disc.has_data = true"> 
      <halevt:Property name="hal.volume.is_mounted"> 
         <halevt:Action value="true" exec='/usr/local/bin/rox.panelput.pl Add "$hal.volume.mount_point$" "$hal.volume.label$"'/> 
      </halevt:Property> 
   </halevt:Device> 
 
   <!--
   When a device is unmounted, it is recorded by halevt-mount.
   !--> 
   <halevt:Device match="hal.block.device & hal.block.is_volume = true"> 
      <halevt:Property name="hal.volume.is_mounted"> 
         <halevt:Action value="false" exec="halevt-mount -s"/> 
      </halevt:Property> 
   </halevt:Device> 
 
   <!--
   When a device is removed, it is recorded by halevt-mount.
   Note that at that point the device is already out of hal, so we use
   * which matches any device in the match attribute, and only pass the
   udi to the command.
   !--> 
   <halevt:Device match="hal.*"> 
      <halevt:Removal exec="halevt-umount -u $hal.udi$; halevt-umount -s"/> 
   </halevt:Device> 
 
 
   <!--
   Example of a use of OnInit. At startup all the devices are matched and the exec
   comand is run for those that match. Here we match all the removable devices
   that aren't already mounted and mount and register them.
      <halevt:OnInit exec="halevt-mount -u $hal.udi$ -m 002"/>
 
   !--> 
   <halevt:Device match="&MOUNTABLE; & (!hal.volume.is_disc | hal.volume.is_disc=false)"> 
      <halevt:OnInit exec='halevt-mount -u $hal.udi$ -m 002 ; /usr/local/bin/rox.panelput.pl Add "$hal.volume.mount_point$" "$hal.volume.label$"'/> 
   </halevt:Device> 
   <halevt:Device match="&MOUNTABLE; & hal.volume.is_disc=true"> 
      <halevt:OnInit exec='halevt-mount -u $hal.udi$ -m 002 ; /usr/local/bin/rox.panelput.pl Add "$hal.volume.mount_point$" "$hal.volume.label$"'/> 
   </halevt:Device> 
   <halevt:Device match="hal.storage.drive_type = cdrom"> 
      <halevt:Condition name="EjectPressed" exec='eject.hal $hal.block.device$'/> 
   </halevt:Device> 
 
</halevt:Configuration> 

Fatto ciò, creare da root il file /usr/bin/eject.hal

#!/bin/bash
if [ -z $1 ]; then
    echo "Usage: eject.hal <device>"
    exit
else
  echo "$1" | egrep "^/dev"
  if [ "$?" == "0" ]; then
    #echo "Device First, find mount point"
    TOSCAN=`echo "$1" | sed -e 's/ /\\\\\\\\040/g'`
    TOUMOUNT=`grep "$TOSCAN" /proc/mounts | cut -d" " -f2`
    UDI=`hal-find-by-property --key volume.mount_point --string "$TOUMOUNT"`
    DISC=`hal-get-property --udi "$UDI" --key volume.is_disc`
    /usr/local/bin/rox.panelput.pl Remove "$TOUMOUNT"
    halevt-umount "$1"
    halevt-umount -s
    if [ "$DISC" == "true" ]; then
        /usr/bin/eject -p "$1" &>/dev/null
    fi
  else
    #echo "Mount Point First, find device"
    UDI=`hal-find-by-property --key volume.mount_point --string "$1"`
    DISC=`hal-get-property --udi "$UDI" --key volume.is_disc`
    TOSCAN=`echo "$1" | sed -e 's/ /\\\\\\\\040/g'`
    TOUMOUNT=`grep "$TOSCAN" /proc/mounts | cut -d" " -f1`
    /usr/local/bin/rox.panelput.pl Remove "$1" nowait
    halevt-umount "$1"
    halevt-umount -s
    if [ "$DISC" == "true" ]; then
        /usr/bin/eject -p "$TOUMOUNT" &>/dev/null
    fi
  fi
fi
</device>

e renderlo eseguibile con il comando, sempre da root chmod +x /usr/bin/eject.hal

Strumenti personali
Namespace

Varianti