Cleaner async, music-client aliased to go trough awesome

This commit is contained in:
Thomas Forgione 2017-10-20 11:38:23 +02:00
parent 052e945250
commit f082d6c5a5
No known key found for this signature in database
GPG Key ID: C75CD416BD1FFCE1
2 changed files with 31 additions and 15 deletions

View File

@ -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 =

View File

@ -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