Difference between revisions of "Talk:Udisks"

From ArchWiki
Jump to: navigation, search
m (Out of date: rm closed discussion)
(2 intermediate revisions by one other user not shown)
Line 1: Line 1:
Ernestas: This article should be edited as ConsoleKit was replaced by logind.
+
== Window Manager Menu Scripts ==
 +
 
 +
''[Restoring here the scripts deleted with https://wiki.archlinux.org/index.php?title=Udiskie&diff=next&oldid=248036 without an appropriate discussion. -- [[User:Kynikos|Kynikos]] ([[User talk:Kynikos|talk]]) 07:00, 14 April 2013 (UTC)]''
 +
 
 +
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:
 +
 
 +
<pre>
 +
#!/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
 +
</pre>
 +
 
 +
===Window Maker===
 +
Create a "Generated Submenu" entry in the root menu.
 +
 
 +
<pre>
 +
#!/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
 +
</pre>

Revision as of 11:32, 30 November 2013

Window Manager Menu Scripts

[Restoring here the scripts deleted with https://wiki.archlinux.org/index.php?title=Udiskie&diff=next&oldid=248036 without an appropriate discussion. -- Kynikos (talk) 07:00, 14 April 2013 (UTC)]

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