Skip to content

Commit

Permalink
add option to detach spotify from blockify if it is automatically sta…
Browse files Browse the repository at this point in the history
…rted
  • Loading branch information
gmdfalk committed Mar 25, 2016
1 parent 95f4270 commit 002403b
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 7 deletions.
7 changes: 5 additions & 2 deletions blockify/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
from gi import require_version

require_version('Gtk', '3.0')

from gi.repository import Gtk
from gi.repository import GObject

Expand All @@ -29,7 +30,6 @@
from blockify import interludeplayer
from blockify import util


log = logging.getLogger("cli")


Expand Down Expand Up @@ -165,7 +165,10 @@ def check_for_spotify_process(self):
def start_spotify(self):
if util.CONFIG["general"]["start_spotify"]:
log.info("Starting Spotify ...")
subprocess.Popen(['/usr/bin/spotify'])
spotify_command = "spotify"
if util.CONFIG["general"]["detach_spotify"]:
spotify_command += " &"
os.system(spotify_command)
for _ in range(20):
time.sleep(1)
spotify_is_running = self.check_for_spotify_process()
Expand Down
7 changes: 5 additions & 2 deletions blockify/data/example_blockify.ini
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,10 @@ autoplay = True
# "Gangnam Style" would be blocked, too. Which might not be that bad, actually.
substring_search = False
# When starting Blockify, should it start Spotify if it isn't running?
start_spotify = true
start_spotify = True
# Whether to detach spotify from blockify, if Spotify is automatically started by blockify.
# If it is not detached, closing blockify will also close Spotify.
detach_spotify = False

[cli]
# Update frequency for the CLI in seconds. Lower means quicker detection
Expand All @@ -36,7 +39,7 @@ use_cover_art = True
# Whether to automatically hide the cover art whenever a commercial is playing.
autohide_cover = False
# Whether to minimize blockify-ui at startup.
start_minimized = False
start_minimized = True

[interlude]
# Whether to play songs from a playlist instead of (muted) silence during
Expand Down
5 changes: 3 additions & 2 deletions blockify/gui.py
Original file line number Diff line number Diff line change
Expand Up @@ -210,8 +210,9 @@ def __init__(self, blockify):
# "Trap" the exit.
self.connect("destroy", self.stop)

if not util.CONFIG["gui"]["start_minimized"]:
self.show_all()
self.show_all()
if util.CONFIG["gui"]["start_minimized"]:
self.hide()
self.set_states()

self.play_interlude_button_active = self.pause_img == self.play_interlude_btn.get_image()
Expand Down
3 changes: 2 additions & 1 deletion blockify/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,8 @@ def get_default_options():
"automute": True,
"autoplay": True,
"substring_search": False,
"start_spotify": True
"start_spotify": True,
"detach_spotify": False
},
"cli": {
"update_interval": 200,
Expand Down

0 comments on commit 002403b

Please sign in to comment.