-
-
Notifications
You must be signed in to change notification settings - Fork 3
/
roon
executable file
·2855 lines (2785 loc) · 98.7 KB
/
roon
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
#!/usr/bin/env bash
#
# roon - frontend script to issue commands to Roon via the Python Roon API
#
# Copyright 2021-2024, Ronald Joe Record
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
# shellcheck disable=SC1090,SC2001,SC2002,SC2016,SC2006,SC2086,SC2181,SC2129,SC2059,SC2076,SC2029,SC2207
#
# Edit these two settings if necessary
#
# Both of these should have been set correctly during
# installation of the RoonCommandLine package. Manual
# setting of these variables is uncommon and only necessary
# if the Python Roon API is installed on another system
#
# The IP address of the system on which the Python Roon API is installed
#
server="XX.X.X.XXX"
#
# The username with public key authorized SSH access to the system on
# which the Python Roon API is installed
#
user="SSH_USERNAME"
# Set defaults
album= artist= composer= comm= albumlist= artistlist= artalbumlist=
albtracklist= arttracklist= composerlist= comalbumlist= dest_zone= from_zone=
exalbum= exartist= genrelist= genartistlist= genalbumlist= playlistlist=
radiolist= taglist= playlist= radio= relative= search= setdefs= noexit=
showusage=1 showexamples=1 tag= track= volume= zone= zonegroup= zonelist=
# Check for installed tools
have_brew=$(type -p brew)
have_fzf=$(type -p fzf)
have_jq=$(type -p jq)
have_rich=$(type -p rich)
have_tui=$(type -p roon-tui)
have_flat=$(type -p flatpak)
# Download URLs
fzf_url="https://raw.githubusercontent.com/junegunn/fzf/master/install"
rcl_url="https://raw.githubusercontent.com/doctorfree/RoonCommandLine"
usage() {
[ "${showusage}" ] && {
if [ "${have_rich}" ]; then
rich "[bold]Usage:[/] [bold italic green]roon[/] [cyan]-A[/] [yellow]album[/] [cyan]-a[/] [yellow]artist[/] [cyan]-bB -C[/] [yellow]composer[/] [cyan]-D[/] [yellow]destination zone[/] [cyan]-m -n -N -O[/]" --print
rich " [cyan]-F[/] [yellow]\[from zone][/] [cyan]-f[/] [yellow]\[on|onlog|off|status][/] [cyan]-g[/] [yellow]genre[/] [cyan]-G[/] [yellow]zone_group[/] [cyan]-i[/]" --print
rich " [cyan]-I -l[/] [yellow]\[albums|artists|artalbums|albtracks|arttracks|composers|comalbums|[/]" --print
rich " [yellow]genres|genalbums|genartists|playlists|playtracks|tags|zones][/]" --print
rich " [cyan]-c[/] [yellow]\[discover|group|ungroup|play|play_all|pause|pause_all|stop|stop_all|[/]" --print
rich " [yellow]next|previous|shuffle|unshuffle|repeat|unrepeat|mute|mute_all][/]" --print
rich " [cyan]-s[/] [yellow]search[/] [cyan]-p[/] [yellow]playlist[/] [cyan]-T[/] [yellow]track[/] [cyan]-t[/] [yellow]tag[/] [cyan]-z[/] [yellow]zone[/] [cyan]-L[/] [cyan]-S[/] [cyan]-r[/] [yellow]radio[/]" --print
rich " [cyan]-X[/] [yellow]ex_album[/] [cyan]-x[/] [yellow]ex_artist[/] [cyan]\[-EuU][/]" --print
rich "[bold]Where:[/]" --print
rich " [cyan]-A[/] [yellow]album[/] selects an album to play" --print
rich " [cyan]-a[/] [yellow]artist[/] selects an artist to list/play" --print
rich " [cyan]-B[/] installs the Roon Community GUI" --print
rich " [cyan]-b[/] opens the Roon Community GUI" --print
rich " [cyan]-C[/] [yellow]composer[/] selects a composer to play" --print
rich " [cyan]-D[/] [yellow]destination zone[/] specifies the zone to transfer current queue to" --print
rich " [cyan]-F[/] [yellow]from zone[/] specifies the zone to transfer from (default: last played)" --print
rich " [cyan]-g[/] [yellow]genre[/] selects a genre to list/play" --print
rich " [cyan]-i[/] displays zone information (combine with '[cyan]-z[/] [yellow]zone[/]' for extended" --print
rich " info on a specified zone, otherwise display info on all zones)" --print
rich " [cyan]-I[/] installs the [green]Roon TUI[/] terminal user interface for Roon and exits" --print
rich " [cyan]-f[/] [yellow]\[on|onlog|off|status][/] enables/disables fading/logging in specified zone" --print
rich " '[yellow]on[/]' enables fading, '[yellow]onlog[/]' fading and logging, '[yellow]off[/]' disables fading" --print
rich " (combine with '[cyan]-z[/] [yellow]zone[/]' for 'fading' in that zone)" --print
rich " [cyan]-m[/] indicates show the RoonCommandLine menu" --print
rich " [cyan]-n[/] displays 'now playing' information for zones actively playing" --print
rich " [cyan]-N[/] displays 'now playing' information for all zones" --print
rich " (combine with '[cyan]-z[/] [yellow]zone[/]' for 'now playing' in only that zone)" --print
rich " [cyan]-O[/] opens [green]Roon TUI[/] terminal user interface for Roon if available" --print
rich " [cyan]-p[/] [yellow]playlist[/] selects a playlist to play" --print
rich " [cyan]-G[/] [yellow]zone_group[/] specifies a zone grouping specified in roon_api.ini" --print
rich " [cyan]-L[/] setup roon to execute local commands rather than remote via SSH" --print
rich " [cyan]-S[/] Set Roon defaults in roon_api.ini" --print
rich " [cyan]-l[/] [yellow]\[albums|artists|artalbums|albtracks|arttracks|composers|comalbums|[/]" --print
rich " [yellow]genres|genalbums|genartists|playlists|playtracks|tags|zones][/]" --print
rich " indicates list [italic]albums, artists, albums by artist,[/]" --print
rich " [italic]composers, albums by composers, genres, albums in genre,[/]" --print
rich " [italic]artists in genre, playlists, tags,[/] or Roon [italic]zones[/]" --print
rich " [cyan]-r[/] [yellow]radio[/] selects a live radio stream to play" --print
rich " [cyan]-s[/] [yellow]search[/] specifies a term to search for in the lists retrieved with [cyan]-l[/]" --print
rich " [cyan]-T[/] [yellow]track[/] specifies a track to play" --print
rich " [cyan]-t[/] [yellow]tag[/] selects an tag to play" --print
rich " [cyan]-z[/] [yellow]zone[/] selects the Roon Zone in which to play" --print
rich " [cyan]-c[/] [yellow]\[discover|group|ungroup|play|play_all|pause|pause_all|playpause|stop|stop_all|[/]" --print
rich " [yellow]next|previous|shuffle|unshuffle|repeat|unrepeat|mute|mute_all][/]" --print
rich " issues the command in the selected zone" --print
rich " '[italic green]roon -c mute[/]' toggles the zone's muted or unmuted state" --print
rich " '[italic green]roon -c mute_all[/]' toggles all zones' muted or unmuted state" --print
rich " '[italic green]roon -c pause_all[/]' pauses playback in all zones" --print
rich " '[italic green]roon -c play_all[/]' begins playback in all zones" --print
rich " '[italic green]roon -c stop_all[/]' stops playback in all zones and releases devices" --print
rich " '[italic green]roon -c shuffle[/]' enables the zone's shuffled setting" --print
rich " '[italic green]roon -c unshuffle[/]' disables the zone's shuffled setting" --print
rich " '[italic green]roon -c repeat[/]' enables the zone's looping setting" --print
rich " '[italic green]roon -c unrepeat[/]' disables the zone's looping setting" --print
rich " [cyan]-v[/] [yellow]volume[/] sets the volume level in the selected zone" --print
rich " The volume argument has the format [yellow]\[g:]\[r:]\[s:]num[/]" --print
rich " Where '[yellow]g[/]' indicates set volume for all zones in the group" --print
rich " '[yellow]r[/]' specifies use relative method volume setting" --print
rich " '[yellow]s[/]' specifies use relative_step method volume setting" --print
rich " '[yellow]num[/]' can be absolute, relative, and negative or positive" --print
rich " [cyan]-X[/] [yellow]ex_album[/] specifies a string to exclude from album/genre names" --print
rich " [cyan]-x[/] [yellow]ex_artist[/] specifies a string to exclude from artist/composer/playlist names" --print
rich " [cyan]-u[/] displays a full usage message with examples" --print
rich " [cyan]-U[/] displays a usage message without examples" --print
rich " [cyan]-E[/] displays examples with no usage message" --print
rich "Combine '[cyan]-a[/] [yellow]artist[/]' and '[cyan]-A[/] [yellow]album[/]' to play an album by a specified artist" --print
rich "Combine '[cyan]-a[/] [yellow]artist[/]' and '[cyan]-T[/] [yellow]track[/]' to play a track by a specified artist" --print
rich "Combine '[cyan]-a[/] [yellow]artist[/]' or '[cyan]-A[/] [yellow]album[/]' with '[cyan]-g[/] [yellow]genre[/]' to play an artist or album in a specified genre" --print
printf "\n"
rich "Special search term [bold italic magenta]__all__[/] matches all entries" --print
rich "Special name [bold italic green]default[/] plays the default setting in roon_api.ini" --print
else
printf "\nUsage: roon -A album -a artist -C composer -D destination zone -m -n -N -O"
printf "\n\t-F [from zone] -f [on|onlog|off|status] -g genre -G zone_group -i"
printf "\n\t-I -l [albums|artists|artalbums|albtracks|arttracks|composers|comalbums|"
printf "\n\t genres|genalbums|genartists|playlists|playtracks|tags|zones]"
printf "\n\t-c [discover|group|ungroup|play|play_all|pause|pause_all|stop|stop_all|"
printf "\n\t next|previous|shuffle|unshuffle|repeat|unrepeat|mute|mute_all]"
printf "\n\t-s search -p playlist -T track -t tag -z zone -L -S -r radio"
printf "\n\t-X ex_album -x ex_artist [-EuU]"
printf "\nWhere:\n\t-A album selects an album to play"
printf "\n\t-a artist selects an artist to list/play"
printf "\n\t-B installs the Roon Community GUI"
printf "\n\t-b opens the Roon Community GUI"
printf "\n\t-C composer selects a composer to play"
printf "\n\t-D 'destination zone' specifies the zone to transfer current queue to"
printf "\n\t-F 'from zone' specifies the zone to transfer from (default: last played)"
printf "\n\t-g genre selects a genre to list/play"
printf "\n\t-i displays zone information (combine with '-z zone' for extended"
printf "\n\t\tinfo on a specified zone, otherwise display info on all zones)"
printf "\n\t-I installs the Roon TUI terminal user interface for Roon and exits"
printf "\n\t-f [on|onlog|off|status] enables/disables fading/logging in specified zone"
printf "\n\t\t'on' enables fading, 'onlog' fading and logging, 'off' disables fading"
printf "\n\t\t(combine with '-z zone' for 'fading' in that zone)"
printf "\n\t-m indicates show the RoonCommandLine menu"
printf "\n\t-n displays 'now playing' information for zones actively playing"
printf "\n\t-N displays 'now playing' information for all zones"
printf "\n\t\t(combine with '-z zone' for 'now playing' in only that zone)"
printf "\n\t-O opens 'Roon TUI' terminal user interface for Roon if available"
printf "\n\t-p playlist selects a playlist to play"
printf "\n\t-G zone_group specifies a zone grouping specified in roon_api.ini"
printf "\n\t-L setup roon to execute local commands rather than remote via SSH"
printf "\n\t-S Set Roon defaults in roon_api.ini"
printf "\n\t-l [albums|artists|artalbums|albtracks|arttracks|composers|comalbums|"
printf "\n\t genres|genalbums|genartists|playlists|playtracks|tags|zones]"
printf "\n\t indicates list albums, artists, albums by artist,"
printf "\n\t composers, albums by composers, genres, albums in genre,"
printf "\n\t artists in genre, playlists, tags, or Roon zones"
printf "\n\t-r radio selects a live radio stream to play"
printf "\n\t-s search specifies a term to search for in the lists retrieved with -l"
printf "\n\t-T track specifies a track to play"
printf "\n\t-t tag selects an tag to play"
printf "\n\t-z zone selects the Roon Zone in which to play"
printf "\n\t-c [discover|group|ungroup|play|play_all|pause|pause_all|playpause|stop|stop_all|"
printf "\n\t next|previous|shuffle|unshuffle|repeat|unrepeat|mute|mute_all]"
printf "\n\t issues the command in the selected zone"
printf "\n\t 'mute' toggles the zone's muted or unmuted state"
printf "\n\t 'mute_all' toggles all zones' muted or unmuted state"
printf "\n\t 'pause_all' pauses playback in all zones"
printf "\n\t 'play_all' begins playback in all zones"
printf "\n\t 'stop_all' stops playback in all zones and releases devices"
printf "\n\t 'shuffle' enables the zone's shuffled setting"
printf "\n\t 'unshuffle' disables the zone's shuffled setting"
printf "\n\t 'repeat' enables the zone's looping setting"
printf "\n\t 'repeat' disables the zone's looping setting"
printf "\n\t-v volume sets the volume level in the selected zone"
printf "\n\t\tThe volume argument has the format [g:][r:][s:]num"
printf "\n\t\tWhere 'g' indicates set volume for all zones in the group"
printf "\n\t\t'r' specifies use relative method volume setting"
printf "\n\t\t's' specifies use relative_step method volume setting"
printf "\n\t\t'num' can be absolute, relative, and negative or positive"
printf "\n\t-X ex_album specifies a string to exclude from album/genre names"
printf "\n\t-x ex_artist specifies a string to exclude from artist/composer/playlist names"
printf "\n\t-u displays a full usage message with examples"
printf "\n\t-U displays a usage message without examples"
printf "\n\t-E displays examples with no usage message"
printf "\nCombine '-a artist' and '-A album' to play an album by a specified artist"
printf "\nCombine '-a artist' and '-T track' to play a track by a specified artist"
printf "\nCombine '-a artist' or '-A album' with '-g genre' to play an artist or album in a specified genre\n"
printf "\nSpecial search term '__all__' matches all entries"
printf "\nSpecial name 'default' plays the default setting in roon_api.ini\n"
fi
}
[ "${showexamples}" ] && {
if [ "${have_rich}" ]; then
rich "[bold]Example invocations[/]" --print
rich " [magenta]Play artist:[/]" --print
rich " [bold italic green]roon -a \"Deep Purple\"[/]" --print
rich " [magenta]Play album by artist:[/]" --print
rich " [bold italic green]roon -a \"Deep Purple\" -A Burn[/]" --print
rich " [magenta]Play track by artist:[/]" --print
rich " [bold italic green]roon -a \"Aretha Franklin\" -T Think[/]" --print
rich " [magenta]Play artist in specified zone:[/]" --print
rich " [bold italic green]roon -a \"Jethro Tull\" -z \"Mac Pro DAC\"[/]" --print
rich " [magenta]Play genre:[/]" --print
rich " [bold italic green]roon -g Classical[/]" --print
rich " [magenta]Play default live radio:[/]" --print
rich " [bold italic green]roon -r default[/]" --print
rich " [magenta]Play playlist:[/]" --print
rich " [bold italic green]roon -p \"Bowie Favs\"[/]" --print
rich " [magenta]Play next track:[/]" --print
rich " [bold italic green]roon -c next[/]" --print
rich " [magenta]Stop play in specified zone:[/]" --print
rich " [bold italic green]roon -c stop -z Kitchen[/]" --print
rich " [magenta]Mute/Unmute a specified zone:[/]" --print
rich " [bold italic green]roon -c mute -z \"Mac Pro DAC\"[/]" --print
rich " [magenta]Mute/Unmute all zones:[/]" --print
rich " [bold italic green]roon -c mute_all[/]" --print
rich " [magenta]List all playlists containing the string 'Best':[/]" --print
rich " [bold italic green]roon -l playlists -s Best[/]" --print
rich " [magenta]List albums by artist:[/]" --print
rich " [bold italic green]roon -l artalbums -a \"Deep Purple\"[/]" --print
rich " [magenta]List artists containing the string 'Will' in the 'Country' genre:[/]" --print
rich " [bold italic green]roon -l genartists -a Will -g Country[/]" --print
rich " [magenta]List albums containing the string 'Magic' in the 'Rock' genre:[/]" --print
rich " [bold italic green]roon -l genalbums -A Magic -g Rock[/]" --print
rich " [magenta]Play artist containing the string 'Willie' in the 'Country' genre:[/]" --print
rich " [bold italic green]roon -a Willie -g Country[/]" --print
rich " [magenta]Play album containing the string 'Magic' in the 'Rock' genre:[/]" --print
rich " [bold italic green]roon -A Magic -g Rock[/]" --print
rich " [magenta]Group the zones listed in roon_api.ini Group_foobar:[/]" --print
rich " [bold italic green]roon -G foobar -c group[/]" --print
rich " [magenta]Set the volume level to 50 in the currently active zone[/]" --print
rich " [bold italic green]roon -v 50[/]" --print
rich " [magenta]Decrease the volume level by 10 in the currently active zone[/]" --print
rich " [bold italic green]roon -v r:-10[/]" --print
rich " [magenta]Set the volume level to 40 in all zones grouped with the zone named 'Mac Pro DAC'[/]" --print
rich " [bold italic green]roon -v g:40 -z 'Mac Pro DAC'[/]" --print
rich " [magenta]Increase the volume level by 20 in all zones grouped with the zone named 'Mac Pro DAC'[/]" --print
rich " [bold italic green]roon -v g:r:20 -z 'Mac Pro DAC'[/]" --print
rich " [magenta]Get info on all Roon zones[/]" --print
rich " [bold italic green]roon -i[/]" --print
rich " [magenta]Get extended info on Roon zone named 'Mac Pro DAC'[/]" --print
rich " [bold italic green]roon -i -z 'Mac Pro DAC'[/]" --print
rich " [magenta]Get now playing info on all zones regardless of state[/]" --print
rich " [bold italic green]roon -N[/]" --print
rich " [magenta]Get now playing info on all zones actively playing[/]" --print
rich " [bold italic green]roon -n[/]" --print
rich " [magenta]Get now playing info on Roon zone named 'Mac Pro DAC'[/]" --print
rich " [bold italic green]roon -n -z 'Mac Pro DAC'[/]" --print
rich " [magenta]Enable volume fading in default Roon zone[/]" --print
rich " [bold italic green]roon -f on[/]" --print
rich " [magenta]Disable volume fading in default Roon zone[/]" --print
rich " [bold italic green]roon -f off[/]" --print
rich " [bold]NOTE:[/] [italic]Use quotes to specify media names which contain spaces.[/]" --print
rich " For example, to [magenta]play the album 'Love Bomb':[/]" --print
rich " [bold italic green]roon -A \"Love Bomb\"[/]" --print
else
printf "\nExample invocations"
printf "\n\tPlay artist:"
printf "\n\t\troon -a \"Deep Purple\""
printf "\n\tPlay album by artist:"
printf "\n\t\troon -a \"Deep Purple\" -A Burn"
printf "\n\tPlay track by artist:"
printf "\n\t\troon -a \"Aretha Franklin\" -T Think"
printf "\n\tPlay artist in specified zone:"
printf "\n\t\troon -a \"Jethro Tull\" -z \"Mac Pro DAC\""
printf "\n\tPlay genre:"
printf "\n\t\troon -g Classical"
printf "\n\tPlay default live radio:"
printf "\n\t\troon -r default"
printf "\n\tPlay playlist:"
printf "\n\t\troon -p \"Bowie Favs\""
printf "\n\tPlay next track:"
printf "\n\t\troon -c next"
printf "\n\tStop play in specified zone:"
printf "\n\t\troon -c stop -z Kitchen"
printf "\n\tMute/Unmute a specified zone:"
printf "\n\t\troon -c mute -z \"Mac Pro DAC\""
printf "\n\tMute/Unmute all zones:"
printf "\n\t\troon -c mute_all"
printf "\n\tList all playlists containing the string 'Best':"
printf "\n\t\troon -l playlists -s Best"
printf "\n\tList albums by artist:"
printf "\n\t\troon -l artalbums -a \"Deep Purple\""
printf "\n\tList artists containing the string 'Will' in the 'Country' genre:"
printf "\n\t\troon -l genartists -a Will -g Country"
printf "\n\tList albums containing the string 'Magic' in the 'Rock' genre:"
printf "\n\t\troon -l genalbums -A Magic -g Rock"
printf "\n\tPlay artist containing the string 'Willie' in the 'Country' genre:"
printf "\n\t\troon -a Willie -g Country"
printf "\n\tPlay album containing the string 'Magic' in the 'Rock' genre:"
printf "\n\t\troon -A Magic -g Rock"
printf "\n\tGroup the zones listed in roon_api.ini Group_foobar:"
printf "\n\t\troon -G foobar -c group"
printf "\n\tSet the volume level to 50 in the currently active zone"
printf "\n\t\troon -v 50"
printf "\n\tDecrease the volume level by 10 in the currently active zone"
printf "\n\t\troon -v r:-10"
printf "\n\tSet the volume level to 40 in all zones grouped with the zone named 'Mac Pro DAC'"
printf "\n\t\troon -v g:40 -z 'Mac Pro DAC'"
printf "\n\tIncrease the volume level by 20 in all zones grouped with the zone named 'Mac Pro DAC'"
printf "\n\t\troon -v g:r:20 -z 'Mac Pro DAC'"
printf "\n\tGet info on all Roon zones"
printf "\n\t\troon -i"
printf "\n\tGet extended info on Roon zone named 'Mac Pro DAC'"
printf "\n\t\troon -i -z 'Mac Pro DAC'"
printf "\n\tGet now playing info on all zones regardless of state"
printf "\n\t\troon -N"
printf "\n\tGet now playing info on all zones actively playing"
printf "\n\t\troon -n"
printf "\n\tGet now playing info on Roon zone named 'Mac Pro DAC'"
printf "\n\t\troon -n -z 'Mac Pro DAC'"
printf "\n\tEnable volume fading in default Roon zone"
printf "\n\t\troon -f on"
printf "\n\tDisable volume fading in default Roon zone"
printf "\n\t\troon -f off"
printf "\n\tNOTE: Use quotes to specify media names which contain spaces."
printf "\n\tFor example, to play the album 'Love Bomb':"
printf "\n\t\troon -A \"Love Bomb\"\n"
fi
}
[ "${noexit}" ] || exit 1
}
# Display a heading with rich-cli or printf
heading() {
clear_screen
if [ "${have_rich}" ]; then
rich "[cyan]$1[/cyan]" -p -a rounded -c -C
else
printf "\n$1\n"
fi
}
# Add a component to the PATH environment variable
pathadd() {
if [ -d "$1" ] && [[ ":$PATH:" != *":$1:"* ]]; then
PATH="$1${PATH:+":$PATH"}"
export PATH
fi
}
# Prompt before continuing
prompt_continue() {
printf "\nPress ${BOLD}<Enter>${NORM} to continue ... "
read -r yn
clear_screen
}
# Get the latest RoonCommandLine version and release
get_control_version() {
VURL="${rcl_url}/master/VERSION"
curl -fsSL "${VURL}" > /tmp/rcv$$
rcver=$(cat /tmp/rcv$$ | grep VERSION | awk -F '=' '{ print $2 }')
rcrel=$(cat /tmp/rcv$$ | grep RELEASE | awk -F '=' '{ print $2 }')
rm -f /tmp/rcv$$
echo "v${rcver}r${rcrel}"
}
# Get the installed RoonCommandLine version and release
get_install_version() {
[ "${ROON}" ] || ROON="/usr/local/Roon"
RC_INST="${ROON}/etc/VERSION"
if [ -f ${RC_INST} ]; then
rcver=$(grep ^VERSION= ${RC_INST} | awk -F '=' '{ print $2 }')
rcrel=$(grep ^RELEASE= ${RC_INST} | awk -F '=' '{ print $2 }')
else
rcver=${VERSION}
rcrel=${RELEASE}
fi
echo "v${rcver}r${rcrel}"
}
# Compare version strings of the format major.middle.minor
# Usage: check_three_version release_version install_version
check_three_version() {
release_version="$1"
install_version="$2"
release_major=$(echo ${release_version} | awk -F '.' '{ print $1 }')
release_midde=$(echo ${release_version} | awk -F '.' '{ print $2 }')
release_minor=$(echo ${release_version} | awk -F '.' '{ print $3 }')
[ "${release_major}" ] || release_major=0
[ "${release_midde}" ] || release_midde=0
[ "${release_minor}" ] || release_minor=0
install_major=$(echo ${install_version} | awk -F '.' '{ print $1 }')
install_midde=$(echo ${install_version} | awk -F '.' '{ print $2 }')
install_minor=$(echo ${install_version} | awk -F '.' '{ print $3 }')
[ "${install_major}" ] || install_major=0
[ "${install_midde}" ] || install_midde=0
[ "${install_minor}" ] || install_minor=0
if [ ${release_major} -gt ${install_major} ]; then
echo "${release_version}"
else
if [ ${release_midde} -gt ${install_midde} ]; then
echo "${release_version}"
else
if [ ${release_minor} -gt ${install_minor} ]; then
echo "${release_version}"
else
echo ""
fi
fi
fi
}
# Display version numbers and available updates if any
show_versions() {
printf "\n"
control_version=$(get_control_version)
install_version=$(get_install_version)
if [ "${have_rich}" ]; then
if [ "${install_version}" == "${control_version}" ]; then
rich "Installed [green]RoonCommandLine[/] version: [yellow]${install_version}[/] ( current)" -p
else
rich "Installed [green]RoonCommandLine[/] version: [yellow]${install_version}[/]" -p
rich "Available [green]RoonCommandLine[/] version: [yellow]${control_version}[/]" -p
fi
else
printf "\nInstalled RoonCommandLine version: ${install_version}"
if [ "${install_version}" == "${control_version}" ]; then
printf " ( current)"
else
printf "\nAvailable RoonCommandLine version: ${control_version}"
fi
fi
release_version=$(curl -fsSL "${fzf_url}" | grep ^version= | awk -F '=' '{ print $2 }')
if [ "${have_fzf}" ]; then
install_version=$(fzf --version | awk '{ print $1 }')
else
install_version="uninstalled"
fi
if [ "${have_rich}" ]; then
if [ "${install_version}" == "${release_version}" ]; then
rich "Installed [green]fzf[/] version: [yellow]${install_version}[/] ( current)" -p
else
rich "Installed [green]fzf[/] version: [yellow]${install_version}[/]" -p
rich "Available [green]fzf[/] version: [yellow]${release_version}[/]" -p
fi
else
printf "\nInstalled fzf version: ${install_version}"
if [ "${install_version}" == "${release_version}" ]; then
printf " ( current)\n"
else
printf "\nAvailable fzf version: ${release_version}\n"
fi
fi
if [ "${have_gui}" ]; then
release_version=$(${ROON}/etc/install-roon-gui version)
gv=$(flatpak info com.theappgineer.community_remote | grep Version | awk -F ':' '{ print $2 }')
install_version="$(echo -e "${gv}" | sed -e 's/^[[:space:]]*//' -e 's/[[:space:]]*$//')"
if [ "${have_rich}" ]; then
if [ "${install_version}" == "${release_version}" ]; then
rich "Installed [green]Roon GUI[/] version: [yellow]${install_version}[/] ( current)" -p
else
rich "Installed [green]Roon GUI[/] version: [yellow]${install_version}[/]" -p
rich "Available [green]Roon GUI[/] version: [yellow]${release_version}[/]" -p
fi
else
printf "\nInstalled Roon GUI version: ${install_version}"
if [ "${install_version}" == "${release_version}" ]; then
printf " ( current)\n"
else
printf "\nAvailable Roon GUI version: ${release_version}\n"
fi
fi
else
[ "${have_flat}" ] && {
if [ "${have_rich}" ]; then
rich "[red]Roon GUI[/] not installed" -p
else
printf "\nRoon GUI not installed\n"
fi
}
fi
if [ "${have_tui}" ]; then
release_version=$(${ROON}/etc/install-roon-tui version)
install_version=$(roon-tui --version | awk '{ print $2 }')
if [ "${have_rich}" ]; then
if [ "${install_version}" == "${release_version}" ]; then
rich "Installed [green]Roon TUI[/] version: [yellow]${install_version}[/] ( current)" -p
else
rich "Installed [green]Roon TUI[/] version: [yellow]${install_version}[/]" -p
rich "Available [green]Roon TUI[/] version: [yellow]${release_version}[/]" -p
fi
else
printf "\nInstalled Roon TUI version: ${install_version}"
if [ "${install_version}" == "${release_version}" ]; then
printf " ( current)\n"
else
printf "\nAvailable Roon TUI version: ${release_version}\n"
fi
fi
else
if [ "${have_rich}" ]; then
rich "[red]Roon TUI[/] not installed" -p
else
printf "\nRoon TUI not installed\n"
fi
fi
}
set_fzf_release() {
fzf_release_version=$(curl -fsSL "${fzf_url}" | grep ^version= | awk -F '=' '{ print $2 }')
if [ "${have_fzf}" ]; then
fzf_install_version=$(fzf --version | awk '{ print $1 }')
update_fzf=$(check_three_version "${fzf_release_version}" "${fzf_install_version}")
else
fzf_install_version="uninstalled"
update_fzf=
fi
}
set_gui_release() {
gui_release_version=$(${ROON}/etc/install-roon-gui version)
if [ "${have_gui}" ]; then
gv=$(flatpak info com.theappgineer.community_remote | grep Version | awk -F ':' '{ print $2 }')
gui_install_version="$(echo -e "${gv}" | sed -e 's/^[[:space:]]*//' -e 's/[[:space:]]*$//')"
update_gui=$(check_three_version "${gui_release_version}" "${gui_install_version}")
else
gui_install_version="uninstalled"
update_gui=
fi
}
set_tui_release() {
tui_release_version=$(${ROON}/etc/install-roon-tui version)
if [ "${have_tui}" ]; then
tui_install_version=$(roon-tui --version | awk '{ print $2 }')
update_tui=$(check_three_version "${tui_release_version}" "${tui_install_version}")
else
tui_install_version="uninstalled"
update_tui=
fi
}
set_have_gui() {
if [ "${have_flat}" ]; then
flatpak info com.theappgineer.community_remote >/dev/null 2>&1
if [ $? -eq 0 ]; then
have_gui=1
else
have_gui=
fi
else
have_gui=
fi
}
install_roon_gui() {
${ROONETC}/install-roon-gui
set_have_gui
set_gui_release
}
install_roon_tui() {
${ROONETC}/install-roon-tui
have_tui=$(type -p roon-tui)
set_tui_release
}
# Display RoonCommandLine info, versions, and update availability
show_about() {
[ "${have_gum}" ] && [ "${have_figlet}" ] && {
[ -x ${ROON}/bin/roonanim ] && {
clear
${ROON}/bin/roonanim -a -q
[ $? -eq 0 ] || tput cup 0 0 2>/dev/null
sleep 3
}
}
F_URL="https://community.roonlabs.com/search?q=RoonCommandLine"
R_URL="https://github.com/doctorfree/RoonCommandLine"
W_URL="https://github.com/doctorfree/RoonCommandLine/wiki"
heading "About RoonCommandLine" "About"
if [ "${have_rich}" ]; then
rich "[cyan]RoonCommandLine[/] is an open source command line suite of utilities to" -p
rich "control the [green]Roon[/] audio system using the [green]Python Roon API[/] facility." -p
rich "[cyan]RoonCommandLine[/] enables automation of [green]Roon[/] actions and provides an" -p
rich "additional layer of convenience. Scripted [green]Roon[/] actions enable quick" -p
rich "and easy control and configuration of [green]Roon[/] in automated environments." -p
rich "[cyan]RoonCommandLine[/] is written in [yellow]Bash[/] and [yellow]Python[/] by Ronald Record." -p
rich "The [green]Python Roon API[/] is written and maintained by Greg Dowling." -p
rich "[magenta]RoonCommandLine Repo[/]: [link=${R_URL}#readme][yellow]${R_URL}[/yellow][/link]" -p
rich "[magenta]RoonCommandLine Wiki[/]: [link=${W_URL}][yellow]${W_URL}[/yellow][/link]" -p
rich "[magenta]Roon Community Forum[/]: [link=${F_URL}][yellow]${F_URL}[/yellow][/link]" -p
else
printf "\n'RoonCommandLine' is an open source command line suite of utilities to"
printf "\ncontrol the 'Roon' audio system using the 'Python Roon API' facility."
printf "\n'RoonCommandLine' enables automation of 'Roon' actions and provides an"
printf "\nadditional layer of convenience. Scripted 'Roon' actions enable quick"
printf "\nand easy control and configuration of 'Roon' in automated environments."
printf "\n'RoonCommandLine' is written in 'Bash' and 'Python' by Ronald Record."
printf "\nThe 'Python Roon API' is written and maintained by Greg Dowling."
printf "\nRoonCommandLine Repo: ${R_URL}"
printf "\nRoonCommandLine Wiki: ${W_URL}"
printf "\nRoon Community Forum: ${F_URL}\n"
fi
show_versions
}
# Get the value of the specified entry in roon_api.ini
# get_default_ini <EntryName>
get_default_ini() {
entry="$1"
de=$(grep ^${entry} ${ROON_INI} | awk -F '=' ' { print $2 } ')
# Remove leading and trailing spaces
de="$(echo -e "${de}" | sed -e 's/^[[:space:]]*//' -e 's/[[:space:]]*$//')"
echo "${de}"
}
# Display RoonCommandLine info
show_info() {
fullinfo=1
[ "$1" == "brief" ] && fullinfo=
[ "${fullinfo}" ] && {
rc_version=$(get_default_ini RoonCommandLineVersion)
rc_release=$(get_default_ini RoonCommandLineRelease)
rc_versrel="v${rc_version}r${rc_release}"
rc_port=$(get_default_ini RoonCorePort)
rc_ip=$(get_default_ini RoonCoreIP)
heading "Roon Command Line ${rc_versrel}" "${rc_versrel}"
if [ "${have_rich}" ]; then
rich "[red]Roon Core IP[/]: [link=http://${rc_ip}][yellow]${rc_ip}[/yellow][/link]" -p
rich "[red]Roon Core Port[/]: [yellow]${rc_port}[/]" -p
else
printf "\nRoon Core IP:\t${rc_ip}"
printf "\nRoon Core Port:\t${rc_port}"
fi
}
for media in Album Artist Composer Genre Playlist Radio Tag Zone; do
DEFAULT=$(get_default_ini Default${media})
if [ "${have_rich}" ]; then
numspaces=$((12-${#media}))
spaces=""
for i in $(seq ${numspaces})
do
spaces="${spaces} "
done
rich "[red]Default ${media}[/]:${spaces}[yellow]${DEFAULT}[/]" -p
else
printf "\nDefault ${media}:\t${DEFAULT}"
fi
done
[ "${fullinfo}" ] && show_now_playing
}
# Install the fzf fuzzy finder utility
install_fzf() {
printf "\nInstalling fzf\n"
[ -f ${HOME}/.local/bin/fzf ] && {
mv ${HOME}/.local/bin/fzf ${HOME}/.local/bin/fzf-bak$$
}
[ -d ${HOME}/.fzf ] && mv ${HOME}/.fzf ${HOME}/.fzf$$
git clone --depth 1 https://github.com/junegunn/fzf.git \
${HOME}/.fzf > /dev/null 2>&1
[ -f ${HOME}/.fzf/install ] && chmod 755 ${HOME}/.fzf/install
[ -x ${HOME}/.fzf/install ] && ${HOME}/.fzf/install --all > /dev/null 2>&1
[ -d ${HOME}/.fzf/bin ] && pathadd "${HOME}/.fzf/bin"
if [ -f ${HOME}/.fzf/bin/fzf ]; then
ln -s ${HOME}/.fzf/bin/fzf ${HOME}/.local/bin/fzf
rm -f ${HOME}/.local/bin/fzf-bak$$
else
[ -f ${HOME}/.local/bin/fzf-bak$$ ] && {
mv ${HOME}/.local/bin/fzf-bak$$ ${HOME}/.local/bin/fzf
}
fi
[ "${have_fzf}" ] && use_fzf=1
}
# Upgrade the fzf fuzzy finder utility
upgrade_fzf() {
[ -d ${HOME}/.fzf/.git ] && git -C ${HOME}/.fzf pull > /dev/null 2>&1
if [ -d ${HOME}/.fzf ]; then
if [ -f ${HOME}/.fzf/install ]; then
chmod 755 ${HOME}/.fzf/install
${HOME}/.fzf/install --all > /dev/null 2>&1
else
install_fzf
fi
else
[ "${have_brew}" ] && brew uninstall fzf > /dev/null 2>&1
install_fzf
fi
[ -d ${HOME}/.fzf/bin ] && pathadd "${HOME}/.fzf/bin"
}
# Successful exit gets a farewell message
farewell_exit() {
heading "$1" "Farewell"
exit 0
}
# Use 'roon -d -m' to avoid clearing the screen between menus
clear_screen() {
[ "${debug}" ] || tput clear
}
# The 'media_options' array must be set prior to calling set_zone_options
set_zone_options() {
${IFS+"false"} && unset oldifs || oldifs="$IFS"
IFS=$'\n'
if [ "${LOCAL}" == "true" ]; then
zones=$(${ROON}/bin/get_zones | sed -e 's/\, /\,/g')
else
zones=$(ssh ${user}@${server} "bash -l -c \"${ROON}/bin/get_zones | sed -e 's/\, /\,/g'\"")
fi
media_options+=($(echo "${zones}" | awk -F "," ' { for(i=1;i<=NF;i++) printf "%s\n",$i }'))
${oldifs+"false"} && unset IFS || IFS="$oldifs"
}
# Display currently playing info for specified zone or all zones
show_now_playing() {
zone="$1"
nowarg="$2"
if [ "${nowarg}" ]; then
if [ "${LOCAL}" = true ]; then
if [ "${zone}" ]; then
${ROON}/bin/now_playing ${nowarg} -z "${zone}"
else
${ROON}/bin/now_playing ${nowarg}
fi
else
if [ "${zone}" ]; then
ssh ${user}@${server} "bash -l -c \"${ROON}/bin/now_playing ${nowarg} -z ${zone}\""
else
ssh ${user}@${server} "bash -l -c \"${ROON}/bin/now_playing ${nowarg}\""
fi
fi
else
[ "${zone}" ] || zone=$(get_default_ini DefaultZone)
if [ "${have_rich}" ]; then
rich "[red]Now Playing[/]:" -p
else
printf "\nNow Playing:\n"
fi
if [ "${have_jq}" ]; then
${ROON}/bin/get_zone_info -n -z "${zone}" | \
jq -r 'to_entries[] | "\(.key)=\"\(.value)\""' | while read i
do
k=$(echo $i | awk -F '=' '{ print $1 }')
v=$(echo $i | awk -F '=' '{ print $2 }')
k="$(echo -e "${k}" | sed -e 's/^[[:space:]]*//' -e 's/[[:space:]]*$//')"
v="$(echo -e "${v}" | sed -e 's/^[[:space:]]*//' -e 's/[[:space:]]*$//')"
v="$(echo -e "${v}" | sed -e 's/^\"//' -e 's/\"$//')"
if echo "${k}" | grep Now > /dev/null; then
pre=""
siz=19
else
pre=" "
siz=15
fi
numspaces=$((${siz} - ${#k}))
spaces=""
for i in $(seq ${numspaces}); do
spaces="${spaces} "
done
if [ "${have_rich}" ]; then
rich "${pre}[red]${k}[/]:${spaces} [yellow]${v}[/]" -p
else
printf "\n\t${pre}$k:${spaces} $v"
fi
done
else
${ROON}/bin/get_zone_info -n -z "${zone}"
fi
fi
if [ "${have_jq}" ]; then
pre=" "
vol=$(${ROON}/bin/get_zone_volume -n)
if [ "${have_rich}" ]; then
rich "${pre}[red]Volume[/]: [yellow]${vol}[/]" -p
else
printf "\n\t${pre}Volume: $vol"
fi
else
${ROON}/bin/get_zone_volume
fi
}
show_roon_menu=
[ "$1" ] || show_roon_menu=1
ROON=/usr/local/Roon
ROONAPI=${ROON}/api
ROONETC=${ROON}/etc
ROON_INI=${ROONETC}/roon_api.ini
ROONCONF=${ROONETC}/pyroonconf
LOCAL=false
BOLD=$(tput bold 2>/dev/null)
NORMAL=$(tput sgr0 2>/dev/null)
# Check Python virtual environment
[ -e ${ROON}/venv/bin/python3 ] || {
printf "\nRepairing RoonCommandLine Python virtual environment ..."
[ -x ${ROONETC}/upgrade-venv ] && ${ROONETC}/upgrade-venv
printf " done\n"
}
[ -f ${ROON}/venv/bin/activate ] && source ${ROON}/venv/bin/activate
[ -x ${ROON}/venv/bin/python ] && export PYTHON=${ROON}/venv/bin/python
[[ ":$PATH:" == *":/usr/local/bin:"* ]] || export PATH=${PATH}:/usr/local/bin
[[ ":$PATH:" == *":/usr/local/Roon/bin:"* ]] || {
export PATH=/usr/local/Roon/bin:${PATH}
}
[[ ":$PATH:" == *":/usr/local/Roon/venv/bin:"* ]] || {
export PATH=/usr/local/Roon/venv/bin:${PATH}
}
if [ -x /home/linuxbrew/.linuxbrew/bin/brew ]; then
eval "$(/home/linuxbrew/.linuxbrew/bin/brew shellenv)"
else
[ -x /usr/local/bin/brew ] && eval "$(/usr/local/bin/brew shellenv)"
fi
clear_screen
set_default_conf() {
if [ -w ${ROONETC} ]; then
echo "LOCAL=true" >${ROONCONF}
DEFZONE=$(get_default_ini DefaultZone)
echo "ROON_ZONE=\"$DEFZONE\"" >>${ROONCONF}
else
echo "${ROONETC} is not writeable by this user."
echo "Correct permissions on ${ROONETC} and re-run this command."
echo "Exiting."
exit 1
fi
}
[ -f ${ROONCONF} ] || set_default_conf
bash -n ${ROONCONF} >/dev/null 2>&1
[ $? -eq 0 ] || {
echo "WARNING: Syntax errors in ${ROONCONF} have been detected."
echo "The following is the output of bash -n ${ROONCONF}"
echo ""
bash -n ${ROONCONF}
echo ""
while true; do
read -r -p "Revert to default settings and continue? (y/n) " answer
case ${answer} in
[Yy]*)
set_default_conf
break
;;
[Nn]*)
echo "Correct syntax errors in ${ROONCONF} and re-run this command."
echo "Exiting."
exit 1
;;
*)
echo "Please answer 'y' to repair configuration, or 'n' to exit."
;;
esac
done
}
[ -f ${ROONCONF} ] && . ${ROONCONF}
select_zone() {
media_options=()
set_zone_options
media_options+=("Defaults Menu [d]")
media_options+=("Main Menu [m]")
media_options+=("Quit [q]")
while true; do
clear_screen
[ "${have_rich}" ] && {
rich "[bold][cyan]Select Roon Zone[/cyan][/bold]" -p -a rounded -c -C
}
PS3="${BOLD}Please enter the Roon zone you wish to use (numeric or text): ${NORMAL}"
select opt in "${media_options[@]}"; do
case "$opt,$REPLY" in
"Main Menu"*,* | *,"Main Menu"* | "m",* | *,"m")
main_menu
break 2
;;
"Quit"*,* | *,"Quit"* | "quit"*,* | *,"quit"* | "q",* | *,"q")
farewell_exit "Exiting RoonCommandLine"
;;
"Defaults Menu"*,* | *,"Defaults Menu"* | "d",* | *,"d")
list_defaults
break 2
;;
*,*)
if [[ " ${media_options[*]} " =~ " ${opt} " ]]; then
echo "${BOLD}Executing Roon command to set default zone to: ${opt}${NORMAL}"
if [ "${LOCAL}" = true ]; then
${ROON}/bin/set_zone "${opt}"
else
ssh ${user}@${server} "bash -l -c \"${ROON}/bin/set_zone ${opt}\""
fi
status=$?
[ ${status} -eq 0 ] || {
echo "Unable to set zone for zone = $opt"
}
[ -f ${ROONCONF} ] && . ${ROONCONF}
break 2
else
printf "\n\nInvalid option: ${opt}"
printf "\n\tPlease enter either the exact text, shortcut, or"
printf "\n\tnumeric designation for one of the listed options.\n\n"
break
fi
;;
esac
done
done
}
select_default() {
media="$1"
have_python3=$(type -p python3)
if [ "${have_python3}" ]; then
pycom="python3 ${ROONAPI}/set_default.py"
else
pycom="python ${ROONAPI}/set_default.py"
fi
case "${media}" in
"Album")
setdefcom="${pycom} -A"
listcom="list_albums"
;;
"Artist")
setdefcom="${pycom} -a"
listcom="list_artists"
;;
"Composer")
setdefcom="${pycom} -c"
listcom="list_composers"
;;
"Genre")
setdefcom="${pycom} -g"
listcom="list_genres"
;;
"Playlist")
setdefcom="${pycom} -p"
listcom="list_playlists"
;;
"Radio")
setdefcom="${pycom} -r"
listcom="list_radio"
;;
"Tag")
setdefcom="${pycom} -t"
listcom="list_tags"
;;
"Track")
setdefcom="true"
listcom="list_tracks"
;;
"Zone")
setdefcom="${pycom} -z"
listcom="list_zones"
;;
*)
return 1
;;
esac
printf "\nRetrieving ${media}s in your Roon library ..."
if [ "${have_fzf}" ]; then
media_options=("Set Defaults Menu" "Main Menu" "Quit")
else
media_options=()
fi
if [ "${media}" == "Zone" ]; then
set_zone_options
else
${IFS+"false"} && unset oldifs || oldifs="$IFS"
IFS=$'\n'
if [ "${LOCAL}" = true ]; then
media_options+=($(${listcom} -q))
else
media_options+=($(ssh ${user}@${server} "bash -l -c \"${ROON}/bin/${listcom} -q\""))
fi
${oldifs+"false"} && unset IFS || IFS="$oldifs"
fi
DEFAULT=$(get_default_ini Default${media})
printf " Done\n\n"
printf "Default${media} = ${DEFAULT}\n\n"
if [ "${have_fzf}" ]; then
while true; do
heading "RoonCommandLine Default ${media}" "Default ${media}"
case ${media} in
Zone)
[ -f ${ROONCONF} ] && . ${ROONCONF}
if [ "${LOCAL}" = true ]; then
if [ "${ROON_ZONE}" ]; then
echo "Current Roon Zone: ${ROON_ZONE}"