implemented next and prev, added pkill command for i3blocks on toggle
This commit is contained in:
parent
e7f3cf6170
commit
675e7c10ab
|
@ -8,12 +8,13 @@ from mpd import MPDClient
|
|||
import mpd_playback
|
||||
import mpd_state
|
||||
|
||||
signal_id = 11
|
||||
cover_art_temp = '/tmp/mpd_cover_art_temp.jpg'
|
||||
|
||||
arguments = sys.argv
|
||||
|
||||
if len(arguments) == 1:
|
||||
mpc_command = None
|
||||
mpc_command = 'state'
|
||||
elif len(arguments) == 2:
|
||||
mpc_command = arguments[1]
|
||||
|
||||
|
@ -28,13 +29,18 @@ def main():
|
|||
return
|
||||
# follow mpc_command
|
||||
if mpc_command == 'toggle':
|
||||
mpd_playback.toggle(client)
|
||||
# show status
|
||||
mpd_state.get_state(client, cover_art_temp)
|
||||
mpd_playback.toggle(client, signal_id)
|
||||
elif mpc_command == 'next':
|
||||
mpd_playback.play_next(client)
|
||||
elif mpc_command == 'prev':
|
||||
mpd_playback.play_prev(client)
|
||||
elif mpc_command == 'state':
|
||||
mpd_state.get_state(client, cover_art_temp)
|
||||
# close connection
|
||||
client.close()
|
||||
client.disconnect()
|
||||
|
||||
|
||||
# lunch from here
|
||||
if __name__ == '__main__':
|
||||
main()
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
from time import sleep
|
||||
import subprocess
|
||||
|
||||
def fade(way, current_vol, client):
|
||||
""" gracefull fading """
|
||||
|
@ -13,7 +14,7 @@ def fade(way, current_vol, client):
|
|||
sleep(0.03)
|
||||
|
||||
|
||||
def toggle(client):
|
||||
def toggle(client, signal_id):
|
||||
""" toggles play status """
|
||||
# setup
|
||||
client_status = client.status()
|
||||
|
@ -26,4 +27,26 @@ def toggle(client):
|
|||
client.setvol(0)
|
||||
client.play()
|
||||
fade('in', current_vol, client)
|
||||
# call pkill to refresh status bar
|
||||
subprocess.call(["pkill", "-RTMIN+" + str(signal_id), "i3blocks"])
|
||||
|
||||
|
||||
def play_next(client):
|
||||
""" skip to next in playlist """
|
||||
client_status = client.status()
|
||||
current_vol = int(client_status['volume'])
|
||||
fade('out', current_vol, client)
|
||||
client.pause()
|
||||
client.setvol(current_vol)
|
||||
client.next()
|
||||
|
||||
|
||||
def play_prev(client):
|
||||
""" skip to previous in playlist """
|
||||
client_status = client.status()
|
||||
current_vol = int(client_status['volume'])
|
||||
fade('out', current_vol, client)
|
||||
client.pause()
|
||||
client.setvol(current_vol)
|
||||
client.previous()
|
||||
|
||||
|
|
|
@ -47,7 +47,7 @@ def get_state(client, cover_art_temp):
|
|||
print_state(artist, album, song_title, mpd_status)
|
||||
# send message
|
||||
title = icon + '\t' + artist
|
||||
message = album + "-" + song_title
|
||||
message = album + " - " + song_title
|
||||
subprocess.call(['notify-send', title, message, '-i', cover_art_temp])
|
||||
return
|
||||
|
||||
|
|
Loading…
Reference in New Issue