diff --git a/awesome/music.lua b/awesome/music.lua index df09fdf..f401276 100644 --- a/awesome/music.lua +++ b/awesome/music.lua @@ -27,9 +27,9 @@ local function set_text(text) end end -ret.execute_command = function(command) +ret.execute_command = function(command, arg) - awful.spawn.easy_async('music-client ' .. command, function(stdout, stderr, reason, code) + awful.spawn.easy_async({'music-client', command, arg}, function(stdout, stderr, reason, code) local text = su.split(stdout, '\n') local active_command = diff --git a/zsh/functions.zsh b/zsh/functions.zsh index 08aef02..680f73d 100644 --- a/zsh/functions.zsh +++ b/zsh/functions.zsh @@ -112,17 +112,33 @@ if [ -d "$GCLONE_PATH" ]; then fi # Music things -# command -v music-server > /dev/null 2>&1 -# if [ $? -eq 0 ]; then -# mplayer() { -# ps -e | grep music-server > /dev/null 2>&1 -# if [ $? -ne 0 ]; then -# nohup music-server > /dev/null 2>&1 & -# disown -# sleep 0.2s -# fi -# filename=$(echo `realpath $1` | sed 's/ /\\\\ /g' | sed "s/'/\\\\\\\\'/g") -# awesome-client "require('music').execute_command('file ' .. \"$filename\")" -# } -# fi +command -v music-server > /dev/null 2>&1 +if [ $? -eq 0 ]; then + + # If music-server is installed, check if awesome is running with screenfetch + command -v screenfetch > /dev/null 2>&1 + + if [ $? -eq 0 ]; then + + screenfetch -d wm -nN | grep "Awesome" > /dev/null 2>&1 + + if [ $? -eq 0 ]; then + + # User is running awesome, music-client will go through awesome-client + music-client() { + command=$1 + if [ $# -eq 1 ]; then + echo "require('music').execute_command(\"$command\")" + else + library_path=$(realpath $2 | rev | cut -d '/' -f -3 | rev) + awesome_command="require('music').execute_command(\"$command\",\"$library_path\")" + echo $awesome_command | awesome-client + fi + } + + fi + + fi + +fi