Skip to content

Commit

Permalink
Remove #58 fix.
Browse files Browse the repository at this point in the history
  • Loading branch information
Max Falk committed Oct 5, 2015
1 parent 1160996 commit ac01e4f
Showing 1 changed file with 5 additions and 22 deletions.
27 changes: 5 additions & 22 deletions blockify/blockify.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,10 +44,8 @@ def __init__(self, blocklist):
self._autodetect = util.CONFIG["general"]["autodetect"]
self._automute = util.CONFIG["general"]["automute"]
self.autoplay = util.CONFIG["general"]["autoplay"]
self.unmute_delay = util.CONFIG["cli"]["unmute_delay"]
self.update_interval = util.CONFIG["cli"]["update_interval"]
self.spotify_refresh_interval = 5000
self.suspend_blockify = False
self.unmute_delay = util.CONFIG["cli"]["unmute_delay"]
self.pulse_unmuted_value = ""
self.found = False
self.current_song = ""
Expand Down Expand Up @@ -168,19 +166,14 @@ def check_for_spotify_process(self):
def start_spotify(self):
if util.CONFIG["general"]["start_spotify"]:
log.info("Starting Spotify ...")
null = open('/dev/null', 'w')
spid = subprocess.Popen(['/usr/bin/spotify'], stdout=null, stderr=null) # .pid
spid = subprocess.Popen(['/usr/bin/spotify'])
for i in range(20):
time.sleep(1)
spotify_is_running = self.check_for_spotify_process()
if spotify_is_running:
log.info("Spotify launched!")
break

# if spid:
# log.info("Spotify launched!")
# time.sleep(10)


def init_channels(self):
channel_list = ["Master"]
Expand All @@ -200,21 +193,12 @@ def init_dbus(self):
log.error("Cannot connect to DBus. Exiting.\n ({}).".format(e))
sys.exit()

def refresh_spotify_process_state(self):
"""Check if Spotify is running periodically. If it's not, suspend blockify."""
if not self.check_for_spotify_process():
self.suspend_blockify = True
else:
self.suspend_blockify = False

return True

def start(self):
self.bind_signals()
# Force unmute to properly initialize unmuted state
self.toggle_mute()

gtk.timeout_add(self.spotify_refresh_interval, self.refresh_spotify_process_state)
gtk.timeout_add(self.update_interval, self.update)
if self.autoplay:
# Delay autoplayback until self.spotify_is_playing was called at least once.
Expand Down Expand Up @@ -244,11 +228,10 @@ def spotify_is_playing(self):

def update(self):
"Main update routine, looped every self.update_interval milliseconds."
if not self.suspend_blockify:
# Determine if a commercial is running and act accordingly.
self.found = self.find_ad()
# Determine if a commercial is running and act accordingly.
self.found = self.find_ad()

self.adjust_interlude()
self.adjust_interlude()

# Always return True to keep looping this method.
return True
Expand Down

0 comments on commit ac01e4f

Please sign in to comment.