Containing spotify listener launch to local configs; get_pid in spotify listener; Only sending spotify hooks to top bars instead of all bars
This commit is contained in:
parent
ebe8fb1657
commit
de2a59ab19
@ -1,5 +1,3 @@
|
|||||||
Status Bar(s)
|
Status Bar(s)
|
||||||
|
|
||||||
https://github.com/polybar/polybar
|
https://github.com/polybar/polybar
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -4,6 +4,7 @@
|
|||||||
|
|
||||||
# Terminate already running bar instances
|
# Terminate already running bar instances
|
||||||
killall -q polybar
|
killall -q polybar
|
||||||
|
#killall -q py_spotify_listener.py
|
||||||
|
|
||||||
# Wait until the processes have been shut down
|
# Wait until the processes have been shut down
|
||||||
while pgrep -u $UID -x polybar >/dev/null; do sleep 1; done
|
while pgrep -u $UID -x polybar >/dev/null; do sleep 1; done
|
||||||
@ -12,6 +13,7 @@ for m in $(polybar --list-monitors | cut -d":" -f1); do
|
|||||||
MONITOR=$m polybar top -c ~/.config/polybar/config-top.ini > ~/.config/polybar/top.log &
|
MONITOR=$m polybar top -c ~/.config/polybar/config-top.ini > ~/.config/polybar/top.log &
|
||||||
MONITOR=$m polybar bottom -c ~/.config/polybar/config-bottom.ini > ~/.config/polybar/bottom.log &
|
MONITOR=$m polybar bottom -c ~/.config/polybar/config-bottom.ini > ~/.config/polybar/bottom.log &
|
||||||
done
|
done
|
||||||
|
/usr/bin/env python3 ~/.config/polybar/spotify/py_spotify_listener.py > ~/.config/polybar/spotify/listener.log &
|
||||||
|
|
||||||
exit 0
|
exit 0
|
||||||
|
|
||||||
|
|||||||
36
polybar/spotify/listener.log
Normal file
36
polybar/spotify/listener.log
Normal file
@ -0,0 +1,36 @@
|
|||||||
|
Successfully wrote action '#playpause.hook.1' to PID 924
|
||||||
|
Successfully wrote action '#playpause.hook.1' to PID 926
|
||||||
|
Successfully wrote action '#playpause.hook.1' to PID 928
|
||||||
|
Successfully wrote action '#spotify.hook.1' to PID 924
|
||||||
|
Successfully wrote action '#spotify.hook.1' to PID 926
|
||||||
|
Successfully wrote action '#spotify.hook.1' to PID 928
|
||||||
|
Successfully wrote action '#spotify.hook.1' to PID 924
|
||||||
|
Successfully wrote action '#spotify.hook.1' to PID 926
|
||||||
|
Successfully wrote action '#spotify.hook.1' to PID 928
|
||||||
|
Successfully wrote action '#playpause.hook.2' to PID 924
|
||||||
|
Successfully wrote action '#playpause.hook.2' to PID 926
|
||||||
|
Successfully wrote action '#playpause.hook.2' to PID 928
|
||||||
|
Successfully wrote action '#spotify.hook.1' to PID 924
|
||||||
|
Successfully wrote action '#spotify.hook.1' to PID 926
|
||||||
|
Successfully wrote action '#spotify.hook.1' to PID 928
|
||||||
|
Successfully wrote action '#playpause.hook.1' to PID 924
|
||||||
|
Successfully wrote action '#playpause.hook.1' to PID 926
|
||||||
|
Successfully wrote action '#playpause.hook.1' to PID 928
|
||||||
|
Successfully wrote action '#spotify.hook.1' to PID 924
|
||||||
|
Successfully wrote action '#spotify.hook.1' to PID 926
|
||||||
|
Successfully wrote action '#spotify.hook.1' to PID 928
|
||||||
|
Successfully wrote action '#spotify.hook.1' to PID 924
|
||||||
|
Successfully wrote action '#spotify.hook.1' to PID 926
|
||||||
|
Successfully wrote action '#spotify.hook.1' to PID 928
|
||||||
|
Successfully wrote action '#playpause.hook.2' to PID 924
|
||||||
|
Successfully wrote action '#playpause.hook.2' to PID 926
|
||||||
|
Successfully wrote action '#playpause.hook.2' to PID 928
|
||||||
|
Successfully wrote action '#spotify.hook.1' to PID 924
|
||||||
|
Successfully wrote action '#spotify.hook.1' to PID 926
|
||||||
|
Successfully wrote action '#spotify.hook.1' to PID 928
|
||||||
|
Successfully wrote action '#playpause.hook.1' to PID 924
|
||||||
|
Successfully wrote action '#playpause.hook.1' to PID 926
|
||||||
|
Successfully wrote action '#playpause.hook.1' to PID 928
|
||||||
|
Successfully wrote action '#spotify.hook.1' to PID 924
|
||||||
|
Successfully wrote action '#spotify.hook.1' to PID 926
|
||||||
|
Successfully wrote action '#spotify.hook.1' to PID 928
|
||||||
@ -5,6 +5,7 @@
|
|||||||
import dbus.service
|
import dbus.service
|
||||||
from dbus.mainloop.glib import DBusGMainLoop
|
from dbus.mainloop.glib import DBusGMainLoop
|
||||||
from os import system
|
from os import system
|
||||||
|
from os import popen
|
||||||
from gi.repository import GLib
|
from gi.repository import GLib
|
||||||
import dbus
|
import dbus
|
||||||
|
|
||||||
@ -39,6 +40,12 @@ class Test(dbus.service.Object):
|
|||||||
raise Exception('FAIL!')
|
raise Exception('FAIL!')
|
||||||
|
|
||||||
|
|
||||||
|
def get_top_pid():
|
||||||
|
pids = popen("pgrep -f 'polybar top'").read().split('\n')
|
||||||
|
while('') in pids:
|
||||||
|
pids.remove('')
|
||||||
|
return pids
|
||||||
|
|
||||||
def catchall_handler(*args, **kwargs):
|
def catchall_handler(*args, **kwargs):
|
||||||
"""Catch all handler.
|
"""Catch all handler.
|
||||||
Catch and print information about all singals.
|
Catch and print information about all singals.
|
||||||
@ -58,21 +65,30 @@ def event_handler(*args, **kwargs):
|
|||||||
"""arg[1] contains metadata"""
|
"""arg[1] contains metadata"""
|
||||||
"""arg[1][1] contains PlaybackStatus"""
|
"""arg[1][1] contains PlaybackStatus"""
|
||||||
data = unwrap(args)
|
data = unwrap(args)
|
||||||
|
pids = get_top_pid()
|
||||||
|
print("Top Bar PIDs:", pids)
|
||||||
#if 'spotify' in data[1]['Metadata']['mpris:trackid']:
|
#if 'spotify' in data[1]['Metadata']['mpris:trackid']:
|
||||||
if 'PlaybackStatus' in data[1]:
|
if 'PlaybackStatus' in data[1]:
|
||||||
if data[1]['PlaybackStatus'] == "Playing":
|
if data[1]['PlaybackStatus'] == "Playing":
|
||||||
print("Music is playing")
|
print("Music is playing")
|
||||||
""" Send IPC hook 2 to all bars for module playpause """
|
""" Send IPC hook 2 to top bars for module playpause """
|
||||||
#system("polybar-msg hook playpause 2")
|
for pid in pids:
|
||||||
system("polybar-msg action '#playpause.hook.1'")
|
#system("polybar-msg hook playpause 2")
|
||||||
|
cmd = "polybar-msg -p " + pid + " action '#playpause.hook.1'"
|
||||||
|
system(cmd)
|
||||||
if data[1]['PlaybackStatus'] == "Paused":
|
if data[1]['PlaybackStatus'] == "Paused":
|
||||||
print("Music is paused.")
|
print("Music is paused.")
|
||||||
""" Send IPC hook 3 to all bars module playpause """
|
""" Send IPC hook 3 to all bars module playpause """
|
||||||
#system("polybar-msg hook playpause 3")
|
#system("polybar-msg hook playpause 3")
|
||||||
system("polybar-msg action '#playpause.hook.2'")
|
for pid in pids:
|
||||||
|
cmd = "polybar-msg -p " + pid + " action '#playpause.hook.2'"
|
||||||
|
system(cmd)
|
||||||
""" Send IPC hook 2 to all bars for module spotify """
|
""" Send IPC hook 2 to all bars for module spotify """
|
||||||
#system("polybar-msg hook spotify 2")
|
#system("polybar-msg hook spotify 2")
|
||||||
system("polybar-msg action '#spotify.hook.1'")
|
for pid in pids:
|
||||||
|
cmd = "polybar-msg -p " + pid + " action '#spotify.hook.1'"
|
||||||
|
#system("polybar-msg action '#spotify.hook.1'")
|
||||||
|
system(cmd)
|
||||||
|
|
||||||
def unwrap(val):
|
def unwrap(val):
|
||||||
if isinstance(val, dbus.ByteArray):
|
if isinstance(val, dbus.ByteArray):
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user