-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtiger-osd.sh
More file actions
114 lines (88 loc) · 4.68 KB
/
tiger-osd.sh
File metadata and controls
114 lines (88 loc) · 4.68 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
#!/usr/bin/env bash
function input() {
local undecorated="--undecorated"
[ "${TIGER_DIALOG_SHOW_TITLE}" = "1" ] && undecorated=""
local field="--field=:ldl"
[ ! -z "${4}" ] && field="--field=:${4}"
local window_icon="dialog-messages"
[ ! -z "${5}" ] && window_icon="${5}"
yad --center --borders=32 --width=400 --window-icon="${window_icon}" --title="${TIGER_DIALOG_TITLE}" ${undecorated} --fixed \
--text="<big><b>${1}</b></big>\n${2}\n" --form ${field} --field=" ":lbl --separator="" --image-on-top \
--button=gtk-ok:0 --button=gtk-cancel:1
return ${?}
}
function message() {
local undecorated="--undecorated"
[ "${TIGER_DIALOG_SHOW_TITLE}" = "1" ] && undecorated=""
local autoclose="--close-on-unfocus"
[ "${TIGER_DIALOG_AUTOCLOSE}" = "0" ] && autoclose=""
local icon=""
[ ! -z "${3}" ] && icon="--image=${3}"
local window_icon="--window-icon=dialog-messages"
[ ! -z "${3}" ] && window_icon="--window-icon=${3}"
local buttons="--button=gtk-ok:0"
[ "${4}" = "yes-no" ] && buttons="--button=gtk-yes:1 --button=gtk-no:0"
[ "${4}" = "no-yes" ] && buttons="--button=gtk-no:0 --button=gtk-yes:1"
[ "${4}" = "cancel-ok" ] && buttons=""
[ "${4}" = "close" ] && buttons="--button=gtk-close:0 "
[ "${4}" = "ok" ] && buttons="--button=gtk-ok:0 "
[ "${4}" = "cancel" ] && buttons="--button=gtk-cancel:0 "
[ "${4}" = "none" ] && {
buttons="--no-buttons"
[ ! "${TIGER_DIALOG_SHOW_TITLE}" = "1" ] && {
autoclose="--close-on-unfocus"
}
}
yad --center --borders=32 --width=400 "${window_icon}" --title="${TIGER_DIALOG_TITLE}" ${undecorated} --fixed "${icon}" ${autoclose} \
--text="<big><b>${1}</b></big>\n${2}" --form ${field} --field=" ":lbl --separator="" ${buttons} --image-on-top
return ${?}
}
function display-text() {
local undecorated="--undecorated"
[ "${TIGER_DIALOG_SHOW_TITLE}" = "1" ] && undecorated=""
local autoclose="--close-on-unfocus"
[ "${TIGER_DIALOG_AUTOCLOSE}" = "0" ] && autoclose=""
local window_icon="--window-icon=text-x-generic"
[ "${TIGER_DIALOG_ICON}" = "0" ] && window_icon="--window-icon=${TIGER_DIALOG_ICON}"
local description_spacer=""
[ ! -z "${2}" ] && description_spacer="\n"
local buttons="--button=gtk-ok:0"
[ "${4}" = "yes-no" ] && buttons="--button=gtk-yes:1 --button=gtk-no:0"
[ "${4}" = "no-yes" ] && buttons="--button=gtk-no:0 --button=gtk-yes:1"
[ "${4}" = "cancel-ok" ] && buttons=""
[ "${4}" = "close" ] && buttons="--button=gtk-close:0 "
[ "${4}" = "ok" ] && buttons="--button=gtk-ok:0 "
[ "${4}" = "cancel" ] && buttons="--button=gtk-cancel:0 "
[ "${4}" = "none" ] && {
buttons="--no-buttons"
[ ! "${TIGER_DIALOG_SHOW_TITLE}" = "1" ] && {
autoclose="--close-on-unfocus"
}
}
sed '1s/.*/\n&/' "${3}" | \
yad --center --borders=32 --width=800 --height=480 "${window_icon}" --title="${TIGER_DIALOG_TITLE}" ${undecorated} \
--text="<big><b>${1}</b></big>\n${2}${description_spacer}" --fixed ${autoclose} --margins=32 --wrap ${buttons} --listen \
--text-info --image-on-top
return ${?};
}
function pulsate-progress() {
while read -t 1 -r data; do echo "$data"; done | \
yad --center --borders=32 --width=480 --undecorated --no-buttons --auto-close \
--text="${1}" --progress --pulsate --progress-text=""
}
function progress() {
while read -t 1 -r data; do echo "$data"; done | \
yad --center --borders=32 --width=480 --undecorated --no-buttons --auto-close \
--text="${1}" --progress --progress-text=""
}
# -----------------------------------------------------------------------------------------------------
function password() { input "${1}" "${2}" "${3}" "H" "dialog-password" ; return ${?}; }
function directory-picker() { input "${1}" "${2}" "${3}" "DIR" "file-manager" ; return ${?}; }
function file-picker() { input "${1}" "${2}" "${3}" "FL" "file-manager" ; return ${?}; }
function multi-file-picker() { input "${1}" "${2}" "${3}" "MFL" "file-manager" ; return ${?}; }
# -----------------------------------------------------------------------------------------------------
function show-message() { message "${1}" "${2}" "" "ok" ; return ${?}; }
function show-warning() { message "${1}" "${2}" "dialog-warning" "ok" ; return ${?}; }
function show-error() { message "${1}" "${2}" "dialog-error" "close" ; exit ${?}; }
function ask() { message "${1}" "${2}" "dialog-question" "no-yes" ; return ${?}; }
# -----------------------------------------------------------------------------------------------------