个人工具
登录
查看“UbuntuHelp:EjectCDLauncher”的源代码 - Ubuntu中文
UbuntuHelp
讨论
查看源代码
历史
搜索
导航
首页
最近更改
随机页面
页面分类
帮助
编辑
编辑指南
沙盒
新闻动态
字词处理
工具
链入页面
相关更改
特殊页面
页面信息
查看“UbuntuHelp:EjectCDLauncher”的源代码
来自Ubuntu中文
←
UbuntuHelp:EjectCDLauncher
跳转至:
导航
,
搜索
因为以下原因,你没有权限编辑本页:
您所请求的操作仅限于该用户组的用户使用:
用户
您可以查看与复制此页面的源代码。
{{From|https://help.ubuntu.com/community/EjectCDLauncher}} {{Languages|UbuntuHelp:EjectCDLauncher}} You will get an icon on your panel and when you click on it, the cdrom gets unmounted and ejected. Create a new file: <pre><nowiki> gksudo gedit /usr/local/bin/eject_cd </nowiki></pre> Paste the following lines: <pre><nowiki> DEVICE="$1" ZENITY_BIN="/usr/bin/zenity" trap ctrlc INT ctrlc() { echo -e "\nAborted by user." rm -rf $TMP_DIR exit 2 } show_dialog() { if [ "$use_zenity" -gt "0" ] ; then zenity --error --title "CD-Rom eject" --info-text "$1" fi } if [ "$1" === "-h" ] || [ "$1" === "--help" ] ; then echo "Usage: eject_cdrom [-q] DEVICE" echo -e "Try to unmount DEVICE then eject it if successful.\n" echo "Possible parameters:" echo -e "-h, --help\tdisplay this help and exit." echo -e "-z, --zenity\tuse zenity to displays errors in dialog windows." exit 0 fi if [ "$1" === "-z" ] || [ "$1" === "--zenity" ] ; then if [ ! -x "$ZENITY_BIN" ] ; then echo "You must install zenity before that." exit 1 fi use_zenity="1" device="$2" else use_zenity="0" device="$1" fi if [ ! -e "$device" ] ; then echo "Parameter DEVICE is not a file." exit 1 fi echo "Trying to eject CD-Rom..." umount "$device" 2>/dev/null last_err="$?" if [ "$last_err" -eq "1" ] ; then msg="Cannot unmount device $device (busy)." echo "$msg" show_dialog "$msg" exit 1 fi eject "$device" last_err="$?" if [ "$last_err" -ne "0" ] ; then msg="Cannot eject device." echo "$msg" show_dialog "$msg" exit 1 fi exit 0 </nowiki></pre> Make the script executable: <pre><nowiki> sudo chmod +x /usr/local/bin/eject_cd </nowiki></pre> Create a new launcher on a panel (or wherever you want): <pre><nowiki> Right-click on the panel 'Add to Panel' 'Custom Application Launcher' </nowiki></pre> Type this (replace /dev/cdrom with your CD-Rom device): <pre><nowiki> Name: Eject CD-Rom Comment: Unmount and eject the CD-Rom /dev/cdrom Command: /usr/local/bin/eject_cd -z /dev/cdrom Icon: /usr/share/icons/gnome/24x24/devices/gnome-dev-removable.png </nowiki></pre> Click 'Close' Note: This script uses zenity to display errors. However if you don't want this feature, remove the '-z' parameter. To install zenity: <pre><nowiki> sudo apt-get install zenity </nowiki></pre> Credits: [http://ubuntuforums.org/showthread.php?t=52768 Sam] ---- [http://wiki.ubuntu.org.cn/EjectCDLauncher A Chinese translation] of this article. ---- [[category:CategoryDocumentation]] [[category:UbuntuHelp]]
该页面使用的模板:
模板:From
(
查看源代码
)
模板:Languages
(
查看源代码
)(受保护)
模板:Languages/Lang
(
查看源代码
)(受保护)
返回至
UbuntuHelp:EjectCDLauncher
。