Difference between revisions of "Udiskie"

From ArchWiki
Jump to: navigation, search
(Openbox)
m (use pkg template.)
(35 intermediate revisions by 12 users not shown)
Line 1: Line 1:
[[Category:Auto-mounting (English)]]
+
[[Category:Hardware detection and troubleshooting]]
 
+
{{Out of date|This article still references ConsoleKit, which has been deprecated.}}
== Introduction ==
+
[http://bitbucket.org/byronclark/udiskie Udiskie] is an automatic disk mounting service using {{Pkg|udisks}}. It can be used for mounting CDs, flash drives, and other media. It is simple to use and requires no configuration.
Udiskie is an automatic disk mounting service using [http://www.archlinux.org/packages/?q=udisks udisks]. It can be used for mounting CDs, flash drives, and other media. It is simple to use and requires no configuration.
+
 
+
== Installation ==
+
You can install Udiskie by using the [http://aur.archlinux.org/packages.php?ID=37279 udiskie] package that is found in the [[AUR]].
+
  
 +
==Installation==
 +
You can [[pacman|install]] Udiskie by using the {{pkg|udiskie}} package that is found in the [[Official Repositories]].
 
Start the Udiskie service by adding
 
Start the Udiskie service by adding
  
  udiskie &
+
udiskie &
  
 
to your [[xinitrc]] file, before the [[window manager]] is loaded.
 
to your [[xinitrc]] file, before the [[window manager]] is loaded.
Line 15: Line 13:
 
Once Udiskie is running, all removable media will automatically be mounted under <code>/media</code> under a new directory that matches the device name.
 
Once Udiskie is running, all removable media will automatically be mounted under <code>/media</code> under a new directory that matches the device name.
  
=== Permissions ===
+
===Permissions===
 +
udiskie requires permission for the <code>org.freedesktop.udisks.filesystem-mount</code> action to be granted through [[PolicyKit]]. If you use a display manager that supports [[ConsoleKit]] this will be taken care of for you automatically. If you don't, you'll need to set up consolekit to work with startx/xinit or use the storage group method.
 +
 
 +
====Consolekit ====
 +
{{Note|You may have to start udiskie after your window manager is started. You may have to use the storage group method if your WM doesn't provide this functionality.}}
 +
<!-- if someone has a way to start udiskie after the wm is started as a child process, (sub-shell + sleep) won't work, put it here--->
 +
 
 +
Start your window manager or desktop environment with ck-launch-session, for example, an exec line in ~/.xinitrc:
 +
exec ck-launch-session awesome
  
udiskie requires permission for the <code>org.freedesktop.udisks.filesystem-mount</code> action to be granted through PolicyKit. If you use a desktop manager that supports ConsoleKit this will be taken care of for you automatically. If you are not using a desktop manager that supports ConsoleKit, you'll need to grant the permission manually. This can be done by creating <code>10-udiskie.pkla</code> in <code>/etc/polkit-1/localauthority/50-local.d</code> with these contents:
+
You may need to start udiskie within the Consolekit session -- that seems to be necessary, for example, when launching [[dwm]]:
 +
  exec ck-launch-session bash -c "udiskie & dwm"
  
   [udiskie]
+
====Storage group====
 +
If it doesn't already exist, create the file {{ic|/etc/polkit-1/localauthority/50-local.d/10-udiskie.pkla}} with these contents:
 +
   [Local Users]
 
   Identity=unix-group:storage
 
   Identity=unix-group:storage
   Action=org.freedesktop.udisks.filesystem-mount
+
   Action=org.freedesktop.udisks.*
 
   ResultAny=yes
 
   ResultAny=yes
 +
  ResultInactive=yes
 +
  ResultActive=yes
  
This example configuration allows any member of the <code>storage</code> group to mount and unmount disks with udiskie.
+
This example configuration allows any member of the {{ic|storage}} group to mount and unmount disks with udiskie.
  
 
== Unmounting ==
 
== Unmounting ==
Line 39: Line 50:
 
For convenience, you can add a script to the menu in some window managers to allow for easy access and control of removable media.
 
For convenience, you can add a script to the menu in some window managers to allow for easy access and control of removable media.
  
=== Openbox ===
+
===Openbox===
 
+
 
Here's an openbox menu script that offers a slight variation on the WindowMaker example below:
 
Here's an openbox menu script that offers a slight variation on the WindowMaker example below:
  
Line 60: Line 70:
 
DIR=$(cd $(dirname "$0") && pwd)
 
DIR=$(cd $(dirname "$0") && pwd)
 
SCRIPT=$(basename "$0")
 
SCRIPT=$(basename "$0")
FM_CMD=rox
+
NOTIFY="notify-send"
 +
FM_CMD="rox"
  
 
pipemenu() {
 
pipemenu() {
Line 97: Line 108:
 
case $1 in  
 
case $1 in  
 
     unmount)
 
     unmount)
udiskie-umount $2 && notify-send "Unmounted $2"
+
udiskie-umount $2
 +
if mountpoint -q $2; then
 +
    $NOTIFY "Failed to unmount $2"
 +
else
 +
    $NOTIFY "Unmounted $2"
 +
fi
 
;;
 
;;
 
     remount)
 
     remount)
killall udiskie; udiskie && notify-send "Remounted $2"
+
killall udiskie
 +
udiskie &
 +
$NOTIFY "Mounting removable media..."
 
;;
 
;;
 
     *)
 
     *)
Line 106: Line 124:
 
;;
 
;;
 
esac
 
esac
 
 
</pre>
 
</pre>
  
=== Window Maker ===
+
===Window Maker===
 
Create a "Generated Submenu" entry in the root menu.
 
Create a "Generated Submenu" entry in the root menu.
  
Line 149: Line 166:
 
echo \"Media\" END
 
echo \"Media\" END
 
</pre>
 
</pre>
 
== Links ==
 
* [http://bitbucket.org/byronclark/udiskie Udiskie Homepage]
 
* [http://aur.archlinux.org/packages.php?ID=37279 Udiskie AUR package]
 

Revision as of 14:22, 8 December 2012

Tango-view-refresh-red.pngThis article or section is out of date.Tango-view-refresh-red.png

Reason: This article still references ConsoleKit, which has been deprecated. (Discuss in Talk:Udiskie#)

Udiskie is an automatic disk mounting service using udisks. It can be used for mounting CDs, flash drives, and other media. It is simple to use and requires no configuration.

Installation

You can install Udiskie by using the udiskie package that is found in the Official Repositories. Start the Udiskie service by adding

udiskie &

to your xinitrc file, before the window manager is loaded.

Once Udiskie is running, all removable media will automatically be mounted under /media under a new directory that matches the device name.

Permissions

udiskie requires permission for the org.freedesktop.udisks.filesystem-mount action to be granted through PolicyKit. If you use a display manager that supports ConsoleKit this will be taken care of for you automatically. If you don't, you'll need to set up consolekit to work with startx/xinit or use the storage group method.

Consolekit

Note: You may have to start udiskie after your window manager is started. You may have to use the storage group method if your WM doesn't provide this functionality.

Start your window manager or desktop environment with ck-launch-session, for example, an exec line in ~/.xinitrc:

exec ck-launch-session awesome

You may need to start udiskie within the Consolekit session -- that seems to be necessary, for example, when launching dwm:

exec ck-launch-session bash -c "udiskie & dwm"

Storage group

If it doesn't already exist, create the file /etc/polkit-1/localauthority/50-local.d/10-udiskie.pkla with these contents:

 [Local Users]
 Identity=unix-group:storage
 Action=org.freedesktop.udisks.*
 ResultAny=yes
 ResultInactive=yes
 ResultActive=yes

This example configuration allows any member of the storage group to mount and unmount disks with udiskie.

Unmounting

Use the udiskie-umount command to unmount media. For example, for a device named "MY_USB_DRIVE":

 udiskie-umount /media/MY_USB_DRIVE

Or, you can unmount all media with the command:

 udiskie-umount -a

Window Manager Menu Scripts

For convenience, you can add a script to the menu in some window managers to allow for easy access and control of removable media.

Openbox

Here's an openbox menu script that offers a slight variation on the WindowMaker example below:

#!/bin/bash

# An openbox menu for removable media (requires udiskie).
#
# This script will generate sub-menus for any device mounted
# under /media. You can browse the device in a file manager or
# unmount it.
#
# It will ignore the "cd", "dvd", and "fl" directories and the U3
# containers found on some windows formatted drives
#
# By default, this script uses the rox file manager to browse the
# media.

DIR=$(cd $(dirname "$0") && pwd)
SCRIPT=$(basename "$0")
NOTIFY="notify-send"
FM_CMD="rox"

pipemenu() {

    cd /media
    echo '<openbox_pipe_menu>'

    for i in *
    do
	if [ "$i" != "*" ] && [[ ! "$i" =~ ^U3|cd|dvd|fl ]]; then
	    echo "<item label=\"Browse $i\">"
	    echo "<action name=\"Execute\">"
	    echo "<execute>$FM_CMD /media/$i</execute>"
	    echo "</action></item>"
	    echo "<item label=\"Unmount $i\">"
	    echo "<action name=\"Execute\">"
	    echo "<execute>$DIR/$SCRIPT unmount /media/$i</execute>"
	    echo "</action></item>"
	    echo "<separator/>"
	fi
    done

    echo "<item label=\"Eject CD/DVD\">"
    echo "<action name=\"Execute\">"
    echo "<execute>eject -T</execute>"
    echo "</action></item>"

    echo "<item label=\"Remount all\">"
    echo "<action name=\"Execute\">"
    echo "<execute>$DIR/$SCRIPT remount</execute>"
    echo "</action></item>"

    echo "</openbox_pipe_menu>"
}

case $1 in 
    unmount)
	udiskie-umount $2
	if mountpoint -q $2; then
	    $NOTIFY "Failed to unmount $2"
	else
	    $NOTIFY "Unmounted $2"
	fi
	;;
    remount)
	killall udiskie
	udiskie &
	$NOTIFY "Mounting removable media..."
	;;
    *)
	pipemenu
	;;
esac

Window Maker

Create a "Generated Submenu" entry in the root menu.

#!/bin/bash

# For a Window Maker menu for removable media.
#
# This script will generate sub-menus for any device mounted
# under /media. You can browse the device in a file manager or
# unmount it.
#
# It will ignore the "cd", "dvd", and "fl" directories.
#
# It uses "emelFM2" file manager to browse the media.

cd /media

echo \"Media\" MENU

for i in *
do
  if ["$i" != "*" ] && [ "$i" != "cd" ] && [ "$i" != "dvd" ] && [ "$i" != "fl" ]
  then
    echo \"Browse $i\" EXEC \"emelfm2 -1 \'/media/$i\'\"
  fi
done

for i in *
do
  if ["$i" != "*" ] && [ "$i" != "cd" ] && [ "$i" != "dvd" ] && [ "$i" != "fl" ]
  then
    echo \"Unmount $i\" EXEC \"udiskie-umount \'/media/$i\'\"
  fi
done

echo \"Eject Disc\" EXEC \"eject --traytoggle\"

echo \"Media\" END