特殊:Badtitle/NS100:EjectCDLauncher:修订间差异
小 New page: {{From|https://help.ubuntu.com/community/EjectCDLauncher}} {{Languages|php5}} You will get an icon on your panel and when you click on it, the cdrom gets unmounted and ejected. Create a n... |
小无编辑摘要 |
||
第6行: | 第6行: | ||
<pre><nowiki> | <pre><nowiki> | ||
gksudo gedit /usr/local/bin/eject_cd | gksudo gedit /usr/local/bin/eject_cd | ||
</nowiki></ | </nowiki></pre> | ||
Paste the following lines: | Paste the following lines: | ||
第97行: | 第97行: | ||
exit 0 | exit 0 | ||
</nowiki></ | </nowiki></pre> | ||
Make the script executable: | Make the script executable: | ||
<pre><nowiki> | <pre><nowiki> | ||
sudo chmod +x /usr/local/bin/eject_cd | sudo chmod +x /usr/local/bin/eject_cd | ||
</nowiki></ | </nowiki></pre> | ||
Create a new launcher on a panel (or wherever you want): | Create a new launcher on a panel (or wherever you want): | ||
第109行: | 第109行: | ||
'Add to Panel' | 'Add to Panel' | ||
'Custom Application Launcher' | 'Custom Application Launcher' | ||
</nowiki></ | </nowiki></pre> | ||
Type this (replace /dev/cdrom with your CD-Rom device): | Type this (replace /dev/cdrom with your CD-Rom device): | ||
第117行: | 第117行: | ||
Command: /usr/local/bin/eject_cd -z /dev/cdrom | Command: /usr/local/bin/eject_cd -z /dev/cdrom | ||
Icon: /usr/share/icons/gnome/24x24/devices/gnome-dev-removable.png | Icon: /usr/share/icons/gnome/24x24/devices/gnome-dev-removable.png | ||
</nowiki></ | </nowiki></pre> | ||
Click 'Close' | Click 'Close' | ||
第127行: | 第127行: | ||
<pre><nowiki> | <pre><nowiki> | ||
sudo apt-get install zenity | sudo apt-get install zenity | ||
</nowiki></ | </nowiki></pre> | ||
Credits: [http://ubuntuforums.org/showthread.php?t=52768 Sam] | Credits: [http://ubuntuforums.org/showthread.php?t=52768 Sam] |
2007年5月13日 (日) 12:46的版本
文章出处: |
{{#if: | {{{2}}} | https://help.ubuntu.com/community/EjectCDLauncher }} |
点击翻译: |
English {{#ifexist: {{#if: php5 | php5 | {{#if: | :}}EjectCDLauncher}}/af | • {{#if: php5|Afrikaans| [[::EjectCDLauncher/af|Afrikaans]]}}|}} {{#ifexist: {{#if: php5 | php5 | {{#if: | :}}EjectCDLauncher}}/ar | • {{#if: php5|العربية| [[::EjectCDLauncher/ar|العربية]]}}|}} {{#ifexist: {{#if: php5 | php5 | {{#if: | :}}EjectCDLauncher}}/az | • {{#if: php5|azərbaycanca| [[::EjectCDLauncher/az|azərbaycanca]]}}|}} {{#ifexist: {{#if: php5 | php5 | {{#if: | :}}EjectCDLauncher}}/bcc | • {{#if: php5|جهلسری بلوچی| [[::EjectCDLauncher/bcc|جهلسری بلوچی]]}}|}} {{#ifexist: {{#if: php5 | php5 | {{#if: | :}}EjectCDLauncher}}/bg | • {{#if: php5|български| [[::EjectCDLauncher/bg|български]]}}|}} {{#ifexist: {{#if: php5 | php5 | {{#if: | :}}EjectCDLauncher}}/br | • {{#if: php5|brezhoneg| [[::EjectCDLauncher/br|brezhoneg]]}}|}} {{#ifexist: {{#if: php5 | php5 | {{#if: | :}}EjectCDLauncher}}/ca | • {{#if: php5|català| [[::EjectCDLauncher/ca|català]]}}|}} {{#ifexist: {{#if: php5 | php5 | {{#if: | :}}EjectCDLauncher}}/cs | • {{#if: php5|čeština| [[::EjectCDLauncher/cs|čeština]]}}|}} {{#ifexist: {{#if: php5 | php5 | {{#if: | :}}EjectCDLauncher}}/de | • {{#if: php5|Deutsch| [[::EjectCDLauncher/de|Deutsch]]}}|}} {{#ifexist: {{#if: php5 | php5 | {{#if: | :}}EjectCDLauncher}}/el | • {{#if: php5|Ελληνικά| [[::EjectCDLauncher/el|Ελληνικά]]}}|}} {{#ifexist: {{#if: php5 | php5 | {{#if: | :}}EjectCDLauncher}}/es | • {{#if: php5|español| [[::EjectCDLauncher/es|español]]}}|}} {{#ifexist: {{#if: php5 | php5 | {{#if: | :}}EjectCDLauncher}}/fa | • {{#if: php5|فارسی| [[::EjectCDLauncher/fa|فارسی]]}}|}} {{#ifexist: {{#if: php5 | php5 | {{#if: | :}}EjectCDLauncher}}/fi | • {{#if: php5|suomi| [[::EjectCDLauncher/fi|suomi]]}}|}} {{#ifexist: {{#if: php5 | php5 | {{#if: | :}}EjectCDLauncher}}/fr | • {{#if: php5|français| [[::EjectCDLauncher/fr|français]]}}|}} {{#ifexist: {{#if: php5 | php5 | {{#if: | :}}EjectCDLauncher}}/gu | • {{#if: php5|ગુજરાતી| [[::EjectCDLauncher/gu|ગુજરાતી]]}}|}} {{#ifexist: {{#if: php5 | php5 | {{#if: | :}}EjectCDLauncher}}/he | • {{#if: php5|עברית| [[::EjectCDLauncher/he|עברית]]}}|}} {{#ifexist: {{#if: php5 | php5 | {{#if: | :}}EjectCDLauncher}}/hu | • {{#if: php5|magyar| [[::EjectCDLauncher/hu|magyar]]}}|}} {{#ifexist: {{#if: php5 | php5 | {{#if: | :}}EjectCDLauncher}}/id | • {{#if: php5|Bahasa Indonesia| [[::EjectCDLauncher/id|Bahasa Indonesia]]}}|}} {{#ifexist: {{#if: php5 | php5 | {{#if: | :}}EjectCDLauncher}}/it | • {{#if: php5|italiano| [[::EjectCDLauncher/it|italiano]]}}|}} {{#ifexist: {{#if: php5 | php5 | {{#if: | :}}EjectCDLauncher}}/ja | • {{#if: php5|日本語| [[::EjectCDLauncher/ja|日本語]]}}|}} {{#ifexist: {{#if: php5 | php5 | {{#if: | :}}EjectCDLauncher}}/ko | • {{#if: php5|한국어| [[::EjectCDLauncher/ko|한국어]]}}|}} {{#ifexist: {{#if: php5 | php5 | {{#if: | :}}EjectCDLauncher}}/ksh | • {{#if: php5|Ripoarisch| [[::EjectCDLauncher/ksh|Ripoarisch]]}}|}} {{#ifexist: {{#if: php5 | php5 | {{#if: | :}}EjectCDLauncher}}/mr | • {{#if: php5|मराठी| [[::EjectCDLauncher/mr|मराठी]]}}|}} {{#ifexist: {{#if: php5 | php5 | {{#if: | :}}EjectCDLauncher}}/ms | • {{#if: php5|Bahasa Melayu| [[::EjectCDLauncher/ms|Bahasa Melayu]]}}|}} {{#ifexist: {{#if: php5 | php5 | {{#if: | :}}EjectCDLauncher}}/nl | • {{#if: php5|Nederlands| [[::EjectCDLauncher/nl|Nederlands]]}}|}} {{#ifexist: {{#if: php5 | php5 | {{#if: | :}}EjectCDLauncher}}/no | • {{#if: php5|norsk| [[::EjectCDLauncher/no|norsk]]}}|}} {{#ifexist: {{#if: php5 | php5 | {{#if: | :}}EjectCDLauncher}}/oc | • {{#if: php5|occitan| [[::EjectCDLauncher/oc|occitan]]}}|}} {{#ifexist: {{#if: php5 | php5 | {{#if: | :}}EjectCDLauncher}}/pl | • {{#if: php5|polski| [[::EjectCDLauncher/pl|polski]]}}|}} {{#ifexist: {{#if: php5 | php5 | {{#if: | :}}EjectCDLauncher}}/pt | • {{#if: php5|português| [[::EjectCDLauncher/pt|português]]}}|}} {{#ifexist: {{#if: php5 | php5 | {{#if: | :}}EjectCDLauncher}}/ro | • {{#if: php5|română| [[::EjectCDLauncher/ro|română]]}}|}} {{#ifexist: {{#if: php5 | php5 | {{#if: | :}}EjectCDLauncher}}/ru | • {{#if: php5|русский| [[::EjectCDLauncher/ru|русский]]}}|}} {{#ifexist: {{#if: php5 | php5 | {{#if: | :}}EjectCDLauncher}}/si | • {{#if: php5|සිංහල| [[::EjectCDLauncher/si|සිංහල]]}}|}} {{#ifexist: {{#if: php5 | php5 | {{#if: | :}}EjectCDLauncher}}/sq | • {{#if: php5|shqip| [[::EjectCDLauncher/sq|shqip]]}}|}} {{#ifexist: {{#if: php5 | php5 | {{#if: | :}}EjectCDLauncher}}/sr | • {{#if: php5|српски / srpski| [[::EjectCDLauncher/sr|српски / srpski]]}}|}} {{#ifexist: {{#if: php5 | php5 | {{#if: | :}}EjectCDLauncher}}/sv | • {{#if: php5|svenska| [[::EjectCDLauncher/sv|svenska]]}}|}} {{#ifexist: {{#if: php5 | php5 | {{#if: | :}}EjectCDLauncher}}/th | • {{#if: php5|ไทย| [[::EjectCDLauncher/th|ไทย]]}}|}} {{#ifexist: {{#if: php5 | php5 | {{#if: | :}}EjectCDLauncher}}/tr | • {{#if: php5|Türkçe| [[::EjectCDLauncher/tr|Türkçe]]}}|}} {{#ifexist: {{#if: php5 | php5 | {{#if: | :}}EjectCDLauncher}}/vi | • {{#if: php5|Tiếng Việt| [[::EjectCDLauncher/vi|Tiếng Việt]]}}|}} {{#ifexist: {{#if: php5 | php5 | {{#if: | :}}EjectCDLauncher}}/yue | • {{#if: php5|粵語| [[::EjectCDLauncher/yue|粵語]]}}|}} {{#ifexist: {{#if: php5 | php5 | {{#if: | :}}EjectCDLauncher}}/zh | • {{#if: php5|中文| [[::EjectCDLauncher/zh|中文]]}}|}} {{#ifexist: {{#if: php5 | php5 | {{#if: | :}}EjectCDLauncher}}/zh-hans | • {{#if: php5|中文(简体)| [[::EjectCDLauncher/zh-hans|中文(简体)]]}}|}} {{#ifexist: {{#if: php5 | php5 | {{#if: | :}}EjectCDLauncher}}/zh-hant | • {{#if: php5|中文(繁體)| [[::EjectCDLauncher/zh-hant|中文(繁體)]]}}|}} |
{{#ifeq:php5|:EjectCDLauncher|请不要直接编辑翻译本页,本页将定期与来源同步。}} |
{{#ifexist: :EjectCDLauncher/zh | | {{#ifexist: EjectCDLauncher/zh | | {{#ifeq: {{#titleparts:EjectCDLauncher|1|-1|}} | zh | | }} }} }} {{#ifeq: {{#titleparts:EjectCDLauncher|1|-1|}} | zh | | }}
You will get an icon on your panel and when you click on it, the cdrom gets unmounted and ejected.
Create a new file:
gksudo gedit /usr/local/bin/eject_cd
Paste the following lines:
#! /bin/sh # # Try to unmount a CD-Rom device, then eject it. # DEVICE="$1" ZENITY_BIN="/usr/bin/zenity" #Ctrl-C trapping trap ctrlc INT ctrlc() { echo -e "\nAborted by user." rm -rf $TMP_DIR exit 2 } #Show a dialog with zenity #@param string The text to display show_dialog() { if [ "$use_zenity" -gt "0" ] ; then zenity --error --title "CD-Rom eject" --info-text "$1" fi } #Get parameters 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 #Device check #TODO: Check if DEVICE is truly a device. if [ ! -e "$device" ] ; then echo "Parameter DEVICE is not a file." exit 1 fi echo "Trying to eject CD-Rom..." #Unmount 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 eject "$device" last_err="$?" if [ "$last_err" -ne "0" ] ; then msg="Cannot eject device." echo "$msg" show_dialog "$msg" exit 1 fi exit 0
Make the script executable:
sudo chmod +x /usr/local/bin/eject_cd
Create a new launcher on a panel (or wherever you want):
Right-click on the panel 'Add to Panel' 'Custom Application Launcher'
Type this (replace /dev/cdrom with your CD-Rom device):
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
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:
sudo apt-get install zenity
Credits: Sam
A Chinese translation of this article.
CategoryDocumentation