summaryrefslogtreecommitdiffstats
path: root/clerk_fzf/clerk_starter
blob: db1577f5e3d909314853d3a0e3127c491f969802 (plain)
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
#!/bin/bash

# default tmux config
tmux_config="/etc/clerk/tmux.conf"

# read global config
if [[ -f "/etc/clerk_fzf.conf" ]]; then
  source /etc/clerk_fzf.conf
fi
 
# create config dir, if needed
if [[ ! -d $HOME/.config/clerk ]]; then
  mkdir $HOME/.config/clerk
fi
 
# read user config
if [[ -f "$HOME/.config/clerk/clerk_fzf.conf" ]]; then
  source $HOME/.config/clerk/clerk_fzf.conf
fi

# export MPD_HOST
if [[ -n $mpd_host ]]; then
  if [[ -n $mpd_password ]]; then
    export MPD_HOST="${mpd_password}@${mpd_host}"
  else
    export MPD_HOST="${mpd_host}"
  fi
fi
 
if [[ -n $mpd_port ]]; then
  ┆ export MPD_PORT="${mpd_port}"
fi


export TMUX_TMPDIR="/tmp/clerk/tmux"

if [[ ! -d "${TMUX_TMPDIR}" ]]; then
  mkdir -p "${TMUX_TMPDIR}"
fi

main() {
  tmux has-session -t music
  if [ $? != 0 ]; then
    tmux -f "${tmux_config}" new-session -s music -n albums -d 'clerk_fzf --albums'
    tmux new-window -t music -n tracks 'clerk_fzf --tracks'
    tmux new-window -t music -n latest 'clerk_fzf --latest'
    tmux new-window -t music -n queue 'ncmpcpp'
  fi
  tmux attach -t music
}


if [[ $1 == "--help" || $1 == "-h" ]]; then
  echo "clerk: MPD Interface using fzf and tmux"
  echo "Copyright © 2016 Rasmus Steinke"
  echo ""
  echo "--help, -h    this help message"
  echo "--kill        kill running clerk sessions"
elif [[ $1 == "--kill" ]]; then
  tmux kill-session -t music
else
  main
fi