-
Notifications
You must be signed in to change notification settings - Fork 0
/
tmux-connection-status.tmux
executable file
·71 lines (64 loc) · 1.94 KB
/
tmux-connection-status.tmux
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
CURRENT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
source "$CURRENT_DIR/scripts/helpers.sh"
interpolation=(
"\#{wifi_device}"
"\#{wifi_status}"
"\#{wifi_ssid}"
"\#{wifi_icon}"
"\#{wifi_bg_color}"
"\#{wifi_fg_color}"
"\#{ethernet_device}"
"\#{ethernet_status}"
"\#{ethernet_icon}"
"\#{ethernet_bg_color}"
"\#{ethernet_fg_color}"
"\#{vpn_device}"
"\#{vpn_status}"
"\#{vpn_icon}"
"\#{vpn_bg_color}"
"\#{vpn_fg_color}"
)
commands=(
"#($CURRENT_DIR/scripts/connection.sh wifi device)"
"#($CURRENT_DIR/scripts/connection.sh wifi status)"
"#($CURRENT_DIR/scripts/connection.sh wifi ssid)"
"#($CURRENT_DIR/scripts/connection.sh wifi icon)"
"#($CURRENT_DIR/scripts/connection.sh wifi bg_color)"
"#($CURRENT_DIR/scripts/connection.sh wifi fg_color)"
"#($CURRENT_DIR/scripts/connection.sh ethernet device)"
"#($CURRENT_DIR/scripts/connection.sh ethernet status)"
"#($CURRENT_DIR/scripts/connection.sh ethernet icon)"
"#($CURRENT_DIR/scripts/connection.sh ethernet bg_color)"
"#($CURRENT_DIR/scripts/connection.sh ethernet fg_color)"
"#($CURRENT_DIR/scripts/connection.sh vpn device)"
"#($CURRENT_DIR/scripts/connection.sh vpn status)"
"#($CURRENT_DIR/scripts/connection.sh vpn icon)"
"#($CURRENT_DIR/scripts/connection.sh vpn bg_color)"
"#($CURRENT_DIR/scripts/connection.sh vpn fg_color)"
)
set_tmux_option() {
local option=$1
local value=$2
tmux set-option -gq "$option" "$value"
}
do_interpolation() {
local interpolated="$1"
for ((i = 0; i < ${#commands[@]}; i++)); do
interpolated=${interpolated//${interpolation[$i]}/${commands[$i]}}
done
echo "$interpolated"
}
update_tmux_option() {
local option
local option_value
local new_option_value
option=$1
option_value=$(get_tmux_option "$option")
new_option_value=$(do_interpolation "$option_value")
set_tmux_option "$option" "$new_option_value"
}
main() {
update_tmux_option "status-right"
update_tmux_option "status-left"
}
main