-
Notifications
You must be signed in to change notification settings - Fork 1
/
i3term
executable file
·113 lines (86 loc) · 2.97 KB
/
i3term
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
#!/bin/bash
# SPDX-FileCopyrightText: 2022 budRich af budlabs
# SPDX-License-Identifier: 0BSD
: "${XDG_CONFIG_HOME:=$HOME/.config}"
main(){
declare -A conf
declare -a terminal_command
declare -g _terminal_class _base_command
# in makefile sed will expand DATA_DIR (/usr/share/i3term)
# before installation
if [[ -d @@DATA_DIR@@ ]]; then
_data_dir='@@DATA_DIR@@'
elif [[ -d $__dir ]]; then #bashbud
_data_dir="$__dir/data" #bashbud
fi
[[ -d $_data_dir && -f "$_data_dir/config" ]] \
|| ERX "no default config files. Consider reinstalling i3term."
if [[ ${_o[list-palettes]} ]]; then
if [[ -d "$_data_dir"/palettes ]]
then ls -1 "$_data_dir"/palettes
else ERM "could not find palettes directory.."
fi
exit
elif [[ ${_o[palette-menu]} ]]; then
theme_menu
exit
fi
parse_config
[[ $_base_command =~ (xterm|urxvtc|xfce4-terminal|st) ]] \
|| ERX "'$_base_command' is not a supported terminal." \
"set 'terminal' option in $XDG_CONFIG_HOME/i3term/config"
# --role is added as a convenience since it is the
# actual criteria used for xfce4-terminal
: "${_o[instance]:=${_o[role]}}"
if [[ $_base_command = xfce4-terminal ]]
then criteria='--role'
else criteria='--instance'
fi
if [[ ${_o[autotile]} ]]; then
_o[instance]=auto
auto_large_font
else
(($# == 1)) && : "${_o[instance]:=$1}"
[[ ${_o[instance]} ]] \
|| : "${_o[instance]:=${1:-${conf[default_instance]:-i3term}}}"
conid=$(i3get "$criteria" "${_o[instance]}" -c "$_terminal_class")
fi
# if i3get finds a windows (conid) we focus the existing
# window with i3run instead of starting a new terminal
[[ $conid && ! ${_o[dryrun]} ]] && {
i3run_flags=(hide mouse nohide summon verbose)
for o in "${i3run_flags[@]}"; do
[[ ${_o[$o]} ]] && i3run_args+=("--$o")
done
i3run --conid "$conid" "${i3run_args[@]}"
messy "[con_id=$conid] title_format ${_o[instance]}"
exit
}
terminal_command+=("$_base_command")
case "$_base_command" in
st ) terminal_command+=(-n "${_o[instance]}") ;;
xterm|urxvtc ) terminal_command+=(-name "${_o[instance]}") ;;
xfce4-terminal ) terminal_command+=(--role "${_o[instance]}") ;;
esac
set_font
set_options
create_script_file "$@"
[[ ${_o[verbose]} || $BASHBUD_VERBOSE ]] && {
sed 's/^/ /g' "$_temp_file"
printf '\n%s\n' "${terminal_command[*]}"
} >&2
[[ ${_o[dryrun]} ]] || {
launch_terminal
# TODO: add --timeout when we know latest i3ass
# builds successfully..
conid=$(i3get --class "$_terminal_class" \
--synk \
"$criteria" "${_o[instance]}"
)
[[ $conid && ! ${_o[autotile]} ]] \
&& messy "[con_id=$conid] title_format ${_o[instance]}"
[[ $conid ]] && echo "$conid"
}
}
__dir=$(dirname "$(readlink -f "${BASH_SOURCE[0]}")") #bashbud
source "$__dir/_init.sh" #bashbud