Talk:Udisks

From ArchWiki
Latest comment: 18 January 2016 by Kynikos in topic Udiskie - Window Manager Menu Scripts

Udiskie - 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)]Reply[reply]

[Moved from Talk:Udiskie because Udiskie now redirects to Udisks and the following scripts might still be relevant. -- Lahwaacz (talk) 11:38, 27 August 2014 (UTC)]Reply[reply]

Assuming this should be kept, doesn't it belong in the respective window manager articles? -- Alad (talk) 00:45, 17 January 2016 (UTC)Reply[reply]
It's always the same dilemma with cross-software content, I think arguments can be brought to support both sides, and I'd be completely neutral; maybe if restored in the respective WM articles, their sections could be linked from here, or vice versa.
Regarding the keep or delete problem, I don't like deleting original work, but since I haven't tested the scripts I won't restore them either. I don't mind if they stay here until somebody tests them and moves them back to an article if working, or deletes them if broken.
— Kynikos (talk) 03:33, 18 January 2016 (UTC)Reply[reply]

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