--progress
オプションの使用

This work is licensed under a GNU Free Documentation License Version 1.1 or any later version.

Permission is granted to copy, distribute and/or modify this document under the terms of the GNU Free Documentation License (GFDL), Version 1.1 or any later version published by the Free Software Foundation with no Invariant Sections, no Front-Cover Texts, and no Back-Cover Texts. You can find a copy of the GFDL at this link.

This manual is part of a collection of GNOME manuals distributed under the GFDL. If you want to distribute this manual separately from the collection, you can do so by adding a copy of the license to the manual, as described in section 6 of the license.

Many of the names used by companies to distinguish their products and services are claimed as trademarks. Where those names appear in any GNOME documentation, and the members of the GNOME Documentation Project are made aware of those trademarks, then the names are in capital letters or initial capital letters.

DOCUMENT AND MODIFIED VERSIONS OF THE DOCUMENT ARE PROVIDED UNDER THE TERMS OF THE GNU FREE DOCUMENTATION LICENSE WITH THE FURTHER UNDERSTANDING THAT:

DOCUMENT IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, WITHOUT LIMITATION, WARRANTIES THAT THE DOCUMENT OR MODIFIED VERSION OF THE DOCUMENT IS FREE OF DEFECTS MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE OR NON-INFRINGING. THE ENTIRE RISK AS TO THE QUALITY, ACCURACY, AND PERFORMANCE OF THE DOCUMENT OR MODIFIED VERSION OF THE DOCUMENT IS WITH YOU. SHOULD ANY DOCUMENT OR MODIFIED VERSION PROVE DEFECTIVE IN ANY RESPECT, YOU (NOT THE INITIAL WRITER, AUTHOR OR ANY CONTRIBUTOR) ASSUME THE COST OF ANY NECESSARY SERVICING, REPAIR OR CORRECTION. THIS DISCLAIMER OF WARRANTY CONSTITUTES AN ESSENTIAL PART OF THIS LICENSE. NO USE OF ANY DOCUMENT OR MODIFIED VERSION OF THE DOCUMENT IS AUTHORIZED HEREUNDER EXCEPT UNDER THIS DISCLAIMER; AND

UNDER NO CIRCUMSTANCES AND UNDER NO LEGAL THEORY, WHETHER IN TORT (INCLUDING NEGLIGENCE), CONTRACT, OR OTHERWISE, SHALL THE AUTHOR, INITIAL WRITER, ANY CONTRIBUTOR, OR ANY DISTRIBUTOR OF THE DOCUMENT OR MODIFIED VERSION OF THE DOCUMENT, OR ANY SUPPLIER OF ANY OF SUCH PARTIES, BE LIABLE TO ANY PERSON FOR ANY DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES OF ANY CHARACTER INCLUDING, WITHOUT LIMITATION, DAMAGES FOR LOSS OF GOODWILL, WORK STOPPAGE, COMPUTER FAILURE OR MALFUNCTION, OR ANY AND ALL OTHER DAMAGES OR LOSSES ARISING OUT OF OR RELATING TO USE OF THE DOCUMENT AND MODIFIED VERSIONS OF THE DOCUMENT, EVEN IF SUCH PARTY SHALL HAVE BEEN INFORMED OF THE POSSIBILITY OF SUCH DAMAGES.

赤星　柔充
yasumichi@vinelinux.org 2011,2012

# 進捗表示ダイアログ

進捗表示ダイアログを作成するには、--progress というオプションを使ってください。

Zenity は、標準入力から 1 行ごとにデータを読み込みます。行が # で始まっている場合、進捗表示ダイアログに表示しているテキストを更新します。行が数値のみを含んでいる場合、進捗状況のパーセンテージをその数値で更新します。

進捗表示ダイアログは、以下のオプションをサポートしています。

# --text=テキスト

進捗表示ダイアログに表示するテキストを指定します。

# --percentage=パーセンテージ

進捗表示ダイアログに設定する初期のパーセンテージを指定します。

# --auto-close

100% に到達した際に進捗表示ダイアログを閉じます。

# --pulsate

標準入力から EOF 文字を読み込むまで進捗表示バーを振動させたい場合に指定します。

以下のスクリプトの例で進捗表示ダイアログの作成方法を示します。

#!/bin/sh ( echo "10" ; sleep 1 echo "# メールログの更新" ; sleep 1 echo "20" ; sleep 1 echo "# cron ジョブの再設定" ; sleep 1 echo "50" ; sleep 1 echo "この行は無視されます" ; sleep 1 echo "75" ; sleep 1 echo "# システムの再起動" ; sleep 1 echo "100" ; sleep 1 ) | zenity --progress \ --title="システムログの更新" \ --text="メールログを走査中..." \ --percentage=0

if [ "$?" = -1 ] ; then zenity --error \ --text="更新がキャンセルされました。" fi

# 進捗表示ダイアログの例

Zenity
進捗表示ダイアログの例