-
-
Notifications
You must be signed in to change notification settings - Fork 1
/
now-playing.tmux
executable file
·54 lines (42 loc) · 1.58 KB
/
now-playing.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
#!/usr/bin/env bash
CURRENT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
source "$CURRENT_DIR/scripts/helpers.sh"
status_key="\#{now_playing}"
do_interpolation() {
local interpolated_text="$1"
local value="#($CURRENT_DIR/scripts/music.sh)"
echo "${interpolated_text//${status_key}/${value}}"
}
update_tmux_option() {
local option=$1
local option_value=$(get_tmux_option "$option")
local 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"
local keytable="$(get_tmux_option "@now-playing-keytable" "prefix")"
local keys="$(get_tmux_option "@now-playing-play-pause-key" ",")"
local key
for key in $keys; do
tmux unbind -T "$keytable" "$key"
tmux bind-key -T "$keytable" "$key" run-shell -b "bash $CURRENT_DIR/scripts/music.sh --cmd pause"
done
keys="$(get_tmux_option "@now-playing-stop-key" ".")"
for key in $keys; do
tmux unbind -T "$keytable" "$key"
tmux bind-key -T "$keytable" "$key" run-shell -b "bash $CURRENT_DIR/scripts/music.sh --cmd stop"
done
keys="$(get_tmux_option "@now-playing-previous-key" "\\;")"
for key in $keys; do
tmux unbind -T "$keytable" "$key"
tmux bind-key -T "$keytable" "$key" run-shell -b "bash $CURRENT_DIR/scripts/music.sh --cmd previous"
done
keys="$(get_tmux_option "@now-playing-next-key" "'")"
for key in $keys; do
tmux unbind -T "$keytable" "$key"
tmux bind-key -T "$keytable" "$key" run-shell -b "bash $CURRENT_DIR/scripts/music.sh --cmd next"
done
}
main