From 061c25f4fcde6c86eafa9e3aa7693e327ef31265 Mon Sep 17 00:00:00 2001 From: Henrik Lissner Date: Sun, 25 Dec 2016 19:08:06 -0500 Subject: [PATCH] shell/mpd: fix + move scripts + fix (z)sh PATH --- scripts/README.md | 3 --- scripts/notify-song.sh | 14 ---------- shell/env.sh | 2 +- shell/mpd/.config/mpd/mpd-linux.conf | 25 +++++++++++++++++ shell/mpd/.config/mpd/mpd-osx.conf | 27 +++++++++++++++++++ shell/mpd/.gitignore | 1 + shell/mpd/.ncmpcpp/config | 6 ++--- shell/mpd/README.md | 3 +++ shell/mpd/aliases.zsh | 12 +++++++++ .../mpd/bin/cleanup-music | 0 shell/mpd/bin/notify-song | 21 +++++++++++++++ shell/mpd/install | 5 ++-- shell/zsh/.zshenv | 2 -- 13 files changed, 96 insertions(+), 25 deletions(-) delete mode 100644 scripts/README.md delete mode 100755 scripts/notify-song.sh create mode 100644 shell/mpd/.config/mpd/mpd-linux.conf create mode 100644 shell/mpd/.config/mpd/mpd-osx.conf create mode 100644 shell/mpd/.gitignore create mode 100644 shell/mpd/README.md create mode 100644 shell/mpd/aliases.zsh rename scripts/cleanup-music.sh => shell/mpd/bin/cleanup-music (100%) create mode 100755 shell/mpd/bin/notify-song diff --git a/scripts/README.md b/scripts/README.md deleted file mode 100644 index 5eb4fe18..00000000 --- a/scripts/README.md +++ /dev/null @@ -1,3 +0,0 @@ -# Scripts - -A collection of personal scripts. diff --git a/scripts/notify-song.sh b/scripts/notify-song.sh deleted file mode 100755 index 06b72a01..00000000 --- a/scripts/notify-song.sh +++ /dev/null @@ -1,14 +0,0 @@ -#!/usr/bin/env bash - -if ! pgrep mpd >/dev/null; then - >&2 echo "mpd isn't running." - exit 1 -fi - -info=$(mpc current) -if [[ -z $info ]]; then - >&2 echo "nothing is playing." - exit -fi - -notify-send --icon="media-playback-start" --app-name="ncmpcpp" "Now playing" "$info" diff --git a/shell/env.sh b/shell/env.sh index 89879d9e..93d3394f 100644 --- a/shell/env.sh +++ b/shell/env.sh @@ -1,6 +1,6 @@ # Loaded at the end of the initialization process -export PATH="$DOTFILES/bin:$DOTFILES/scripts:$HOME/bin:$PATH" +export PATH="$HOME/.bin:$DOTFILES/bin:$PATH" # export EDITOR=$(is-callable nvim && echo 'nvim' || echo 'vim') diff --git a/shell/mpd/.config/mpd/mpd-linux.conf b/shell/mpd/.config/mpd/mpd-linux.conf new file mode 100644 index 00000000..b2c42562 --- /dev/null +++ b/shell/mpd/.config/mpd/mpd-linux.conf @@ -0,0 +1,25 @@ +music_directory "~/music" +playlist_directory "~/music/.db/playlists" +db_file "~/music/.db/db" + +log_file "~/.config/mpd/mpd.log" +pid_file "~/.config/mpd/mpd.pid" +state_file "~/.config/mpd/mpdstate" + +gapless_mp3_playback "yes" +restore_paused "yes" + +bind_to_address "127.0.0.1" +port "6600" + +audio_output { + type "alsa" + name "my_alsa" +} +audio_output { + enabled "no" + type "fifo" + name "my_fifo" + path "/tmp/mpd.fifo" + format "44100:16:2" +} diff --git a/shell/mpd/.config/mpd/mpd-osx.conf b/shell/mpd/.config/mpd/mpd-osx.conf new file mode 100644 index 00000000..17eb2ca2 --- /dev/null +++ b/shell/mpd/.config/mpd/mpd-osx.conf @@ -0,0 +1,27 @@ +music_directory "~/Music/" +playlist_directory "~/Music/.db/playlists" +db_file "~/Music/.db/db" + +log_file "~/.config/mpd/mpd.log" +pid_file "~/.config/mpd/mpd.pid" +state_file "~/.config/mpd/mpdstate" + +gapless_mp3_playback "yes" +restore_paused "yes" + +bind_to_address "127.0.0.1" +port "6600" +user "hlissner" + +audio_output { + type "osx" + name "CoreAudio" + mixer_type "software" +} +audio_output { + enabled "no" + type "fifo" + name "my_fifo" + path "/tmp/mpd.fifo" + format "44100:16:2" +} diff --git a/shell/mpd/.gitignore b/shell/mpd/.gitignore new file mode 100644 index 00000000..8c420106 --- /dev/null +++ b/shell/mpd/.gitignore @@ -0,0 +1 @@ +.config/mpd/mpd.conf diff --git a/shell/mpd/.ncmpcpp/config b/shell/mpd/.ncmpcpp/config index cbed989f..e6c5c86e 100644 --- a/shell/mpd/.ncmpcpp/config +++ b/shell/mpd/.ncmpcpp/config @@ -2,7 +2,7 @@ ncmpcpp_directory = ~/.ncmpcpp ## Directory for storing downloaded lyrics. -#lyrics_directory = ~/.lyrics +lyrics_directory = ~/music/.db/lyrics ##### connection settings ##### #mpd_host = localhost @@ -241,7 +241,7 @@ selected_item_prefix = +$6 ## tag and then composer and performer if previous ones are ## not available. ## -song_columns_list_format = (5f)[green]{NEr} (45)[white]{t|f:Title} (8f)[magenta]{lr} (20)[]{a|A:Artist} (25)[cyan]{b} +song_columns_list_format = (2f)[green]{CEr:_} (3f)[green]{NEr:#} (45)[white]{t|f:Title} (8f)[magenta]{lr} (20)[]{a|A:Artist} (25)[cyan]{b} # ##### various settings ##### # @@ -249,7 +249,7 @@ song_columns_list_format = (5f)[green]{NEr} (45)[white]{t|f:Title} (8f)[magenta] ## Note: Custom command that will be executed each ## time song changes. Useful for notifications etc. ## -execute_on_song_change = "notify-song.sh" +execute_on_song_change = "notify-song" #playlist_show_mpd_host = no playlist_show_remaining_time = yes playlist_shorten_total_times = yes diff --git a/shell/mpd/README.md b/shell/mpd/README.md new file mode 100644 index 00000000..df6fba53 --- /dev/null +++ b/shell/mpd/README.md @@ -0,0 +1,3 @@ +# mpd + mpc + ncmpcpp + +My music player stack, fit for Arch and MacOS. diff --git a/shell/mpd/aliases.zsh b/shell/mpd/aliases.zsh new file mode 100644 index 00000000..24e01109 --- /dev/null +++ b/shell/mpd/aliases.zsh @@ -0,0 +1,12 @@ + +if [[ $OSTYPE == darwin* ]]; then + alias mpdi='mpd ~/.config/mpd/mpd.conf' +fi + +mpca() { + local files=() + for file in $@; do + files+="$(realpath --relative-to="$HOME/music" "$file")" + done + mpc add ${files[@]} +} diff --git a/scripts/cleanup-music.sh b/shell/mpd/bin/cleanup-music similarity index 100% rename from scripts/cleanup-music.sh rename to shell/mpd/bin/cleanup-music diff --git a/shell/mpd/bin/notify-song b/shell/mpd/bin/notify-song new file mode 100755 index 00000000..2d28f485 --- /dev/null +++ b/shell/mpd/bin/notify-song @@ -0,0 +1,21 @@ +#!/usr/bin/env bash + +if ! pgrep mpd >/dev/null; then + >&2 echo "mpd isn't running." + exit 1 +fi + +info=$(mpc current) +if [[ -z $info ]]; then + >&2 echo "nothing is playing." + exit +fi + +case $OSTYPE in + darwin*) + terminal-notifier -title "Now playing" -message "$info" -appIcon "/Applications/iTunes.app/Contents/Resources/iTunes.icns" + ;; + linux*) + notify-send --icon="media-playback-start" --app-name="ncmpcpp" "Now playing" "$info" + ;; +esac diff --git a/shell/mpd/install b/shell/mpd/install index 3fd32355..a38029cc 100755 --- a/shell/mpd/install +++ b/shell/mpd/install @@ -3,8 +3,8 @@ case $OSTYPE in darwin*) brew install mpd mpc - brew install ncmpcpp --with-clock --with-visualizer - brew services start mpd + brew install ncmpcpp --with-clock --with-visualizer --with-outputs + ln -sfv $HOME/.config/mpd/mpd-osx.conf $HOME/.config/mpd/mpd.conf ;; linux*) if [[ -f /etc/arch-version ]]; then @@ -12,5 +12,6 @@ case $OSTYPE in systemctl enable --user mpd.service systemctl start --user mpd.service fi + ln -sfv $HOME/.config/mpd/mpd-linux.conf $HOME/.config/mpd/mpd.conf ;; esac diff --git a/shell/zsh/.zshenv b/shell/zsh/.zshenv index 6115efe9..3e0fe9cd 100644 --- a/shell/zsh/.zshenv +++ b/shell/zsh/.zshenv @@ -8,8 +8,6 @@ path=( /usr/local/{,s}bin $path ) load shell/zsh/config.zsh loadall env.zsh -path=( $HOME/.bin $DOTFILES/bin $path ) - fpath=( $DOTFILES/shell/zsh/{completions,functions} $fpath