Skip to content

Commit

Permalink
feat(args): ability to override play on add config
Browse files Browse the repository at this point in the history
New CLI arguments `--play` and `--noplay` allow the config `play_on_add` setting to be overriden per run.
  • Loading branch information
JakeStanger committed Apr 5, 2020
1 parent 76cc551 commit bd35187
Showing 1 changed file with 15 additions and 3 deletions.
18 changes: 15 additions & 3 deletions rofi_mpd/rofi_mpd.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,11 @@
parser.add_argument('-c', '--host', help='Use the specified MPD host')
parser.add_argument('-p', '--port', help='Use the specified MPD port')

parser.add_argument('--play', action='store_true', help='Start playback on add (overrides config)', dest='play_on_add',
default=None)
parser.add_argument('--noplay', action='store_false', help='Do not start playback on add (overrides config)',
dest='play_on_add', default=None)

parser.add_argument('-i', '--case-sensitive', action='store_true', help='Enable case sensitivity')

parser.add_argument('-r', '--args', nargs=argparse.REMAINDER, help='Command line arguments for rofi. '
Expand Down Expand Up @@ -236,6 +241,13 @@ def run():
else:
client.add(track['file'])

if 'play_on_add' in config and config['play_on_add']:
if client.status()['state'] != 'play':
client.play()
play_on_add = None
if 'play_on_add' in config:
play_on_add = config['play_on_add']

if args.play_on_add is not None:
play_on_add = args.play_on_add

if play_on_add:
if client.status()['state'] != 'play':
client.play()

0 comments on commit bd35187

Please sign in to comment.