Skip to content

Instantly share code, notes, and snippets.

@Hayao0819
Created January 18, 2020 05:53
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Hayao0819/56d83599c9c07cdb99baba53d823881f to your computer and use it in GitHub Desktop.
Save Hayao0819/56d83599c9c07cdb99baba53d823881f to your computer and use it in GitHub Desktop.
#!/usr/bin/env bash
#-- CUI --#
# 赤(エラー時)
function echo_r () {
echo -e "\033[1;31m$@\033[0;39m" >&2
return 0
}
# 青(通常のログ)
function echo_b () {
if [[ ! $log = 1 ]]; then
echo -e "\033[1;36m$@\033[0;39m"
fi
return 0
}
# 黄(注意、デバッグ)
function echo_y () {
if [[ ! $log = 1 ]]; then
echo -e "\033[0;33m$@\033[0;39m" >&2
fi
return 0
}
#-- GUI --#
# ウィンドウの基本型
function window () {
zenity \
--title="$window_text" \
--window-icon="$window_icon" \
$@
}
# 読み込みウィンドウ
function loading () {
window \
--progress \
--auto-close \
--pulsate \
--width="$1" \
--height="$2" \
--text="$3"
}
# エラーウィンドウ
function error () {
window \
--error \
--width="$1" \
--height="$2" \
--text="$3"
}
# 警告ウィンドウ
function warning () {
window \
--warning \
--width="$1" \
--height="$2" \
--text="$3"
}
# 情報ウィンドウ
function info () {
window \
--info \
--width="$1" \
--height="$2" \
--text="$3"
}
#-- その他 --#
# ユーザーが存在するか(oなら存在している、1ならしていない)
function user_check () {
if [[ $(getent passwd $1 > /dev/null ; printf $?) = 0 ]]; then
printf 0
return 0
else
printf 1
return 1
fi
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment