-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathconfigurator.sh
executable file
·7379 lines (5567 loc) · 265 KB
/
configurator.sh
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
#!/bin/bash
#############
## STARTUP ##
#############
prerequisite() {
prerequisite_directory
prerequisite_device
prerequisite_permission
prerequisite_position
}
prerequisite_directory () {
directory_script="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )/"
directory_alerts="${directory_script}alerts/"
path_settings=$(realpath "${directory_script}../../config/settings.yaml")
directory_data_private="${directory_script}../../data/"
directory_data_public="${directory_script}data/"
directory_log="${directory_script}../../logs/"
directory_service="${directory_script}services/"
directory_video="${directory_script}../../../Videos/"
}
prerequisite_device() {
# Input.
# Microphones.
input_device_microphone_1_name="Rode"
input_device_microphone_1_name_obs="mic_mobile"
microphone_1="rode"
input_device_microphone_1_node_name="alsa_input.usb-R__DE_Wireless_PRO_RX_8006784B-01.analog-stereo"
input_device_microphone_2_name="Microphone Desk"
input_device_microphone_2_name_obs="mic_desk"
microphone_2="desk"
input_device_microphone_2_node_name="alsa_input.usb-046d_Logitech_StreamCam_11536225-02.analog-stereo"
input_device_microphone_3_name="Microphone Kitchen"
input_device_microphone_3_name_obs="mic_kitchen"
microphone_3="kitchen"
input_device_microphone_3_node_name="alsa_input.usb-Generic_Modern_USB-C_Speaker_0V33FRW211801X-00.analog-stereo"
input_device_microphone_4_name="Microphone Bathroom"
input_device_microphone_4_name_obs="mic_bathroom"
microphone_4="bathroom"
input_device_microphone_4_node_name="alsa_input.usb-Generic_Modern_USB-C_Speaker_0V33BW6222101X-00.analog-stereo"
# Output.
# Null sink.
output_device_null_sink_1_name_echo="Null Sink"
output_device_null_sink_1_name_short="n1"
output_device_null_sink_1_name_long="null_sink_1"
# OBS.
output_device_output_1_name_obs="output"
# Speakers.
default_speaker_1_volume="0.35"
output_device_speaker_1_name_echo="Speaker Desk"
output_device_speaker_1_name_short="s1"
output_device_speaker_1_name_long="speaker_1"
output_device_speaker_1_name_node="alsa_output.usb-0ac8_Zgmicro_AUDIO_962810000000-00.analog-stereo"
default_speaker_2_volume="0.4"
output_device_speaker_2_name_echo="Speaker Bathroom"
output_device_speaker_2_name_short="s2"
output_device_speaker_2_name_long="speaker_2"
output_device_speaker_2_name_node="alsa_output.usb-Generic_Modern_USB-C_Speaker_0V33BW6222101X-00.analog-stereo"
default_speaker_3_volume="0.4"
output_device_speaker_3_name_echo="Speaker Kitchen"
output_device_speaker_3_name_short="s3"
output_device_speaker_3_name_long="speaker_3"
output_device_speaker_3_name_node="alsa_output.usb-Generic_Modern_USB-C_Speaker_0V33FRW211801X-00.analog-stereo"
# Headphones.
output_device_headphones_1_name="Headset"
output_device_headphones_1_script_name="headphones_1"
output_device_headphones_1_node_name="bluez_output.E4_61_F4_4C_4D_0A.1" # "bluez_output.57_6F_BB_B0_16_8E.1" # "bluez_output.74_2A_8A_40_AD_0E.1" # "bluez_output.94_DB_56_03_17_D5.1" "$(yq -r ".device.audio_output.headset.node" "$path_settings") # "bluez_output.89_88_1F_FD_47_F7.1" #
output_device_headphones_1_address="E4:61:F4:4C:4D:0A" # "57:6F:BB:B0:16:8E" # "74:2A:8A:40:AD:0E" # "94:DB:56:03:17:D5" $(yq -r ".device.audio_output.headset.address" "$path_settings") # "89:88:1F:FD:47:F7" # headset:
# cameras
path_camera_desk_vaughan="$(yq -r ".device.camera.desk.vaughan.path" "$path_settings")"
path_camera_bed_overhead="$(yq -r ".device.camera.bed.overhead.path" "$path_settings")"
path_camera_bed_tripod="$(yq -r ".device.camera.bed.tripod.path" "$path_settings")"
}
prerequisite_permission() {
data_permission_stream="housemate"
data_permission_scene="couchsurfer"
}
prerequisite_position() {
position_1="◻ "
position_2=" ◇ "
position_3=" ├─ "
position_4=" │ ├─ "
position_5=" │ │ ├─ "
position_6=" │ │ │ ├─ "
position=$position_1
}
position_right() {
if [[ "$position" == "$position_1" ]]; then
position=$position_2
elif [[ "$position" == "$position_2" ]]; then
position=$position_3
elif [[ "$position" == "$position_3" ]]; then
position=$position_4
elif [[ "$position" == "$position_4" ]]; then
position=$position_5
elif [[ "$position" == "$position_5" ]]; then
position=$position_6
elif [[ "$position" == "$position_6" ]]; then
position=$position_7
elif [[ "$position" == "$position_7" ]]; then
position=$position_8
elif [[ "$position" == "$position_8" ]]; then
position=$position_9
elif [[ "$position" == "$position_9" ]]; then
echo_error "position_right, not enough positions."
else
echo_error "position_right, invalid position."
fi
}
position_left() {
if [[ "$position" == "$position_1" ]]; then
echo_debug "position_left, not enough positions."
elif [[ "$position" == "$position_2" ]]; then
position=$position_1
elif [[ "$position" == "$position_3" ]]; then
position=$position_2
elif [[ "$position" == "$position_4" ]]; then
position=$position_3
elif [[ "$position" == "$position_5" ]]; then
position=$position_4
elif [[ "$position" == "$position_6" ]]; then
position=$position_5
elif [[ "$position" == "$position_7" ]]; then
position=$position_6
elif [[ "$position" == "$position_8" ]]; then
position=$position_7
elif [[ "$position" == "$position_9" ]]; then
position=$position_8
else
echo_error "position_left, invalid position."
fi
}
log() {
echo "$(date +"%Y-%m-%d | %T") | $1" >> "${directory_log}configurator/$(date +"%Y-%m-%d").log"
}
echo_break() {
echo
echo
log
log
}
echo_debug() {
if [[ "$flag_verbose" == "yes" ]]; then
echo "DEBUG ${position}$1"
log "DEBUG ${position}$1"
else
:
fi
}
echo_info() {
echo " INFO ${position}$1"
log " INFO ${position}$1"
}
echo_error() {
echo -e "ERROR ${position}Error: \e[1;31m${1}\e[0m" >&2
log "ERROR ${position}$1"
paplay "${directory_alerts}debug_error.wav"
echo "ERROR ${position_1}Exiting"
lock_remove
echo_info "Done."
exit 1
}
lock_check() {
echo_debug "Checking lock file..."
while [[ -e /tmp/configurator.lock ]]; do
sleep 0.01
done
position_right
echo_debug "Lock file: created."
touch /tmp/configurator.lock
position_left
}
lock_remove() {
rm /tmp/configurator.lock
if [[ $? -eq 0 ]]; then
echo_debug "Lock file: removed."
fi
exit 0
}
error_check() {
# One check.
if [[ $1 -eq 1 ]]; then
if [[ $exit_1 -eq 0 ]]; then
exit_1=0
else
exit_1=1
fi
# Two checks.
elif [[ $1 -eq 2 ]]; then
if [[ $exit_1 -eq 0 && $exit_2 -eq 0 ]]; then
exit_1=0
else
exit_1=1
fi
# Three checks.
elif [[ $1 -eq 3 ]]; then
if [[ $exit_1 -eq 0 && $exit_2 -eq 0 && $exit_3 -eq 0 ]]; then
exit_1=0
else
exit_1=1
fi
# Four checks.
elif [[ $1 -eq 4 ]]; then
if [[ $exit_1 -eq 0 && $exit_2 -eq 0 && $exit_3 -eq 0 && $exit_4 -eq 0 ]]; then
exit_1=0
else
exit_1=1
fi
# Error.
else
echo_error "error_check, invalid check amount."
fi
# Check complete.
if [[ $exit_1 -eq 0 ]]; then
# Quiet.
if [[ "$2" == "info" ]]; then
echo_info "${3}"
# Verbose.
elif [[ "$2" == "debug" ]]; then
echo_debug "${3}"
# Error.
else
echo_error "error_check, invalid argument."
fi
# Error, check failed.
elif [[ $exit_1 -eq 1 ]]; then
echo_error "error_check, check failed: ${3}."
# Error.
else
echo_error "error_check, uknown."
fi
}
echo_error_urgent() {
echo -e "${position}Error: \e[1;31m${1}\e[0m" >&2
status_check_output_device_default all
status_check_output_device_speaker_1
setting_update_output_device_unmute_speaker_1
setting_update_output_device_volume speaker_1 0.35
setting_update_output_default_speaker_1
paplay "${directory_alerts}debug_error.wav"
echo "${position_1}Exiting"
lock_remove
echo_info "Done."
exit 1
}
echo_error_speak() {
echo -e "${position}\e[1;31m${1}\e[0m" >&2
paplay "${directory_alerts}debug_error.wav"
setting_update_output_device_volume_default 0.35
espeak "${1}"
setting_update_output_device_volume_default $temp_output_device_volume_numerical
lock_remove
exit 1
}
#############
## COMMAND ##
#############
command() {
translate_argument command $1
arg_command="$argument"
echo_info "Permission check: $arg_command"
position_right
status_current_permission_command=$(cat "${directory_data_private}permission_$arg_command.txt")
echo_info "Required permission: $status_current_permission_command"
# Owner.
if [[ "$source" == "service" || "$source" == "terminal" || "$source" == "streamdeck_bathroom" || "$source" == "streamdeck_bed" || "$source" == "streamdeck_desk" || "$source" == "streamdeck_kitchen" || "$source" == "roboty_hurts_owner" ]]; then
status_current_permission_source="owner"
# Leaseholder.
elif [[ "$source" == "roboty_hurts_leaseholder" ]]; then
status_current_permission_source="leaseholder"
# Roommate.
elif [[ "$source" == "roboty_hurts_roommate" ]]; then
status_current_permission_source="roommate"
# Housemate.
elif [[ "$source" == "roboty_hurts_housemate" ]]; then
status_current_permission_source="housemate"
# Couchsurfer.
elif [[ "$source" == "roboty_hurts_couchsurfer" ]]; then
status_current_permission_source="couchsurfer"
# Everyone.
elif [[ "$source" == "roboty_hurts_everyone" ]]; then
status_current_permission_source="everyone"
# Error.
else
echo_error "command, invalid source: $source."
fi
echo_info "Available permission: $status_current_permission_command"
# Owner.
if [[ "$status_current_permission_command" == "owner" && "$status_current_permission_source" == "owner" ]]; then
status_current_permission="granted"
# Leaseholder
elif [[ "$status_current_permission_command" == "leaseholder" && ("$status_current_permission_source" == "owner" || "$status_current_permission_source" == "leaseholder") ]]; then
status_current_permission="granted"
# Roommate.
elif [[ "$status_current_permission_command" == "roommate" && ("$status_current_permission_source" == "owner" || "$status_current_permission_source" == "leaseholder" || "$status_current_permission_source" == "roommate") ]]; then
status_current_permission="granted"
# Housemate.
elif [[ "$status_current_permission_command" == "housemate" && ("$status_current_permission_source" == "owner" || "$status_current_permission_source" == "leaseholder" || "$status_current_permission_source" == "roommate" || "$status_current_permission_source" == "housemate") ]]; then
status_current_permission="granted"
# Couchsurfer.
elif [[ "$status_current_permission_command" == "couchsurfer" && ("$status_current_permission_source" == "owner" || "$status_current_permission_source" == "leaseholder" || "$status_current_permission_source" == "roommate" || "$status_current_permission_source" == "housemate" || "$status_current_permission_source" == "couchsurfer") ]]; then
status_current_permission="granted"
# Everyone.
elif [[ "$status_current_permission_command" == "everyone" && ("$status_current_permission_source" == "owner" || "$status_current_permission_source" == "leaseholder" || "$status_current_permission_source" == "roommate" || "$status_current_permission_source" == "housemate" || "$status_current_permission_source" == "couchsurfer" || "$status_current_permission_source" == "everyone") ]]; then
status_current_permission="granted"
# Error.
else
status_current_permission="denied"
fi
# Granted.
if [[ "$status_current_permission" == "granted" ]]; then
echo_info "Permission granted."
position_left
temp_command="command_$arg_command"
$temp_command "${@:2}"
# Denied.
elif [[ "$status_current_permission" == "denied" ]]; then
echo_info "Permission denied."
position_left
# Error.
else
echo_error "command, status_current_permission: $status_current_permission."
fi
}
command_activity() {
echo_info "Activity:"
position_right
translate_argument category $1
arg_stream_category="${argument}"
translate_argument title $2
argument_current_title="${argument}"
translate_argument account $3
arg_stream_account="${argument}"
title_start_list="${directory_data_public}activity_title_${arg_stream_category}_${argument_current_title}_start.txt"
title_end_list="${directory_data_public}activity_title_${arg_stream_category}_end.txt"
operation_random title_start "$title_start_list"
operation_random title_end "$title_end_list"
title="$title_start | $title_end"
category=$(cat "${directory_data_public}activity_category_${arg_stream_category}.txt")
setting_update_stream_refresh
setting_update_stream_info
# Owner.
if [[ "$status_current_source_permission" == "owner" && "$source" != "service" ]]; then
alert_request activity ${argument_current_title}
alert_play
setting_update input output
# Other.
else
echo_info "Command didn't originate from owner, so skipping alert."
fi
position_left
}
command_automation() {
echo_info "Automation:"
position_right
current_hour=$(date +%H)
# Morning.
if [[ $current_hour -eq 5 ]]; then
command stream refresh twitch reality_hurts
command stream info all all unrestricted under_construction under_construction under_construction
command scene quad anja studio vaughan desk
# Sleeping.
elif [[ $current_hour -eq 21 ]]; then
command stream refresh twitch reality_hurts
command stream info twitch reality_hurts unrestricted sleeping sleeping sleeping
command scene quad anja bed vaughan studio
command profile uncensored unrestricted muted muted
# Error.
else
echo_error_speak "command_automation."
fi
position_left
}
command_camera() {
echo "$@"
# Camera type 1, camera 1.
if [[ -n "$1" && -n "$2" ]]; then
translate_argument camera_type $1
arg_camera_type_1="${argument}"
# translate_argument camera $2
# arg_camera_1="${argument}"
arg_camera_1="$2"
else
echo_error "command_camera, not enough arguments: \$1 \$2."
fi
# Camera type 2, camera 2.
if [[ -n "$3" && -n "$4" ]]; then
translate_argument camera_type $3
arg_camera_type_2="${argument}"
# translate_argument camera $4
# arg_camera_2="${argument}"
arg_camera_2="$4"
else
echo_info "No more arguments, skipping."
fi
# Camera type 3, camera 3.
if [[ -n "$5" && -n "$6" ]]; then
translate_argument camera_type $5
arg_camera_type_3="${argument}"
# translate_argument camera $6
# arg_camera_3="${argument}"
arg_camera_3="$6"
else
echo_info "No more arguments, skipping."
fi
# Camera type 4, camera 4.
if [[ -n "$7" && -n "$8" ]]; then
translate_argument camera_type $7
arg_camera_type_4="${argument}"
# translate_argument camera $8
# arg_camera_4="${argument}"
arg_camera_4="$8"
else
echo_info "No more arguments, skipping."
fi
setting_update camera camera_input
}
command_censor() {
translate_argument profile $1
argument_current_censor_1="${argument}"
translate_argument scene $2
arg_scene_1="${argument}"
echo_info "Censor: ${argument_current_censor_1} ${arg_scene_1}:"
position_right
alert_request_censor
alert_play
setting_update censor input output
position_left
}
command_debug() {
echo_info "Debug: $@"
position_right
"$@"
position_left
}
command_help() {
echo "Help."
}
command_input() {
echo_info "Input:"
position_right
translate_argument input $1
arg_input_device="$argument"
translate_argument attribute $2
argument_current_atribute="$argument"
translate_argument action $3
arg_input_action="$argument"
# Mute.
if [[ "$argument_current_atribute" == "mute" ]]; then
# Mute.
if [[ "$arg_input_action" == "mute" ]]; then
setting_update_input_device_mute $arg_input_device
# Toggle.
elif [[ "$arg_input_action" == "toggle" ]]; then
setting_update_input_device_mute_toggle $arg_input_device
alert_request input
alert_play
setting_update input output
# Unmute.
elif [[ "$arg_input_action" == "unmute" ]]; then
setting_update_input_device_unmute $arg_input_device
# Error.
else
echo_error "command_input, arg_input_action: $arg_input_action."
fi
# Default.
elif [[ "$argument_current_atribute" == "default" ]]; then
# Select.
if [[ "$arg_input_action" == "select" ]]; then
status_update_profile_input_default
alert_request profile_input_default
alert_play
setting_update input
# Error.
else
echo_error "command_input, arg_input_action: $arg_input_action."
fi
# Error.
else
echo_error "command_light, argument_current_light."
fi
position_left
}
command_light() {
echo_info "Light:"
position_right
translate_argument light $1
argument_current_light="${argument}"
translate_argument attribute $2
argument_current_atribute="${argument}"
translate_argument action $3
arg_light_action="${argument}"
# Litra
if [[ "$argument_current_light" == "litra" ]]; then
# Brightness.
if [[ "$argument_current_atribute" == "brightness" ]]; then
# Down.
if [[ "$arg_light_action" == "down" ]]; then
status_check light_litra_brightness
setting_update light_litra_brightness_down
status_update_light_litra_brightness
# Up.
elif [[ "$arg_light_action" == "up" ]]; then
status_check light_litra_brightness
setting_update light_litra_brightness_up
status_update_light_litra_brightness
else
echo_error "command_light, argument_current_light, argument_current_atribute, brightness, arg_light_action."
fi
# Power.
elif [[ "$argument_current_atribute" == "power" ]]; then
# Toggle.
if [[ "$arg_light_action" == "toggle" ]]; then
status_check light_litra_power
setting_update light_litra_power_toggle
status_update_light_litra_brightness
status_update_light_litra_power
# Error.
else
echo_error "command_light, argument_current_light, argument_current_atribute, power, arg_light_action."
fi
else
echo_error "command_light, argument_current_light, argument_current_atribute."
fi
else
echo_error "command_light, argument_current_light."
fi
position_left
}
command_output() {
translate_argument action $1
arg_output_action="${argument}"
echo_info "Output: $arg_output_action"
position_right
# Cycle.
if [[ "$arg_output_action" == "cycle" ]]; then
echo_info "Output: cycle."
position_right
interpret_alert_all o_c
alert_play
setting_update_output_device_default_cycle
setting_update input output
position_left
# Reset.
elif [[ "$arg_output_action" == "reset" ]]; then
echo_info "Output: link reset"
position_right
status_check_output_device all
if [[ "$status_current_output_device_default" == "$output_device_headphones_1_script_name" ]]; then
initial_device_default=$output_device_headphones_1_script_name
fi
setting_update_output_device_unlink all
setting_update_output_device_link all
setting_update_output_device_default speaker_1
if [[ -n "$initial_device_default" ]]; then
setting_update_output_device_default $initial_device_default
else
setting_update_output_device_default null_sink_1
fi
alert_request_output_link_reset
alert_play
setting_update input output
# Error.
else
echo_error "command_output, invalid argument: $arg_output_action."
fi
}
command_permission() {
echo_info "Permission update:"
position_right
# Translate arguments.
translate_argument command $1
argument_current_permission_command="${argument}"
translate_argument action $2
argument_current_permission_action="${argument}"
translate_argument role $3
argument_current_permission_role="${argument}"
status_check permission
# Select.
if [[ "$argument_current_permission_action" == "select" ]]; then
status_request_permission_role="$argument_current_permission_role"
# Toggle.
elif [[ "$argument_current_permission_action" == "toggle" ]]; then
# Owner.
if [[ "$status_current_permission_role" == "owner" ]]; then
status_request_permission_role="$argument_current_permission_role"
# Not owner.
elif [[ "$status_current_permission_role" != "owner" ]]; then
status_request_permission_role="owner"
# Error.
else
echo_error "command_permission, argument_current_permission_action, toggle."
fi
# Error.
else
echo_error "command_permission, argument_current_permission_action."
fi
status_update permission
alert_request permission
alert_play
setting_update input output
position_left
}
command_playback() {
translate_argument attribute $1
argument_current_attribute_1="${argument}"
translate_argument action $2
arg_playback_action="${argument}"
echo_info "Playback: $argument_current_attribute_1 $arg_playback_action"
position_right
# Playback.
if [[ "$argument_current_attribute_1" == "playback" ]]; then
# Monitor.
if [[ "$arg_playback_action" == "monitor" ]]; then
setting_update input output
# Toggle.
elif [[ "$arg_playback_action" == "toggle" ]]; then
setting_update_playback_playback toggle
setting_update input output
# Error.
else
echo_error "command_playback, playback."
fi
# Volume.
elif [[ "$argument_current_attribute_1" == "volume" ]]; then
status_check_output_device all
# Bathroom.
if [[ "$source" == "streamdeck_bathroom" ]]; then
# Up
if [[ "$arg_playback_action" == "up" ]]; then
wpctl set-volume $output_device_speaker_2_ID 5%+
elif [[ "$arg_playback_action" == "down" ]]; then
wpctl set-volume $output_device_speaker_2_ID 5%-
else
echo_error "command_playback, volume, invalid volume value, streamdeck_bathroom."
fi
# Bed and desk.
elif [[ "$source" == "streamdeck_desk" || "$source" == "streamdeck_bed" || "$source" == "terminal" ]]; then
# Up
if [[ "$arg_playback_action" == "up" ]]; then
wpctl set-volume $output_device_speaker_1_ID 5%+
elif [[ "$arg_playback_action" == "down" ]]; then
wpctl set-volume $output_device_speaker_1_ID 5%-
else
echo_error "command_playback, volume, streamdeck_desk."
fi
# Kitchen.
elif [[ "$source" == "streamdeck_kitchen" ]]; then
# Up
if [[ "$arg_playback_action" == "up" ]]; then
wpctl set-volume $output_device_speaker_3_ID 5%+
elif [[ "$arg_playback_action" == "down" ]]; then
wpctl set-volume $output_device_speaker_3_ID 5%-
else
echo_error "command_playback, volume, streamdeck_kitchen."
fi
else
echo_error "command_playback, volume."
fi
# Seek.
elif [[ "$argument_current_attribute_1" == "seek" ]]; then
# Back.
if [[ "$arg_playback_action" == "back" ]]; then
setting_update_playback_seek_back
# Forward.
elif [[ "$arg_playback_action" == "forward" ]]; then
setting_update_playback_seek_forward
else
echo_error "command_playback, seek."
fi
# Skip.
elif [[ "$argument_current_attribute_1" == "skip" ]]; then
# Previous.
if [[ "$arg_playback_action" == "previous" ]]; then
setting_update_playback_skip_previous
# Next.
elif [[ "$arg_playback_action" == "next" ]]; then
setting_update_playback_skip_next
else
echo_error "command_playback, skip."
fi
# Error.
else
echo_error "command_playback, invalid argument: $arg_playback_action."
fi
}
command_profile() {
translate_argument profile $1
argument_current_censor_1="${argument}"
translate_argument profile $2
arg_profile_restriction="${argument}"
translate_argument profile $3
arg_profile_input="${argument}"
translate_argument profile $4
arg_profile_output="${argument}"
#arg_profile_stream_type="$5"
echo_info "Profile: ${argument_current_censor_1} ${arg_profile_restriction} ${arg_profile_input} ${arg_profile_output}"
position_right
status_check_profile censor restriction input output
interpret_alert_all censor restriction input
alert_play
setting_update censor restriction input output
status_update profile_censor profile_restriction profile_input profile_output
position_left
}
command_restriction() {
translate_argument profile $1
arg_profile_restriction="${argument}"
translate_argument scene $2
arg_scene_1="${argument}"
request_status_restriction="${arg_profile_restriction}_${arg_scene_1}"
echo_info "Restriction: ${request_status_restriction}:"
position_right
alert_request_restriction
alert_play
setting_update restriction input output
}
command_scene() {
# Name 1, Camera 1.
if [[ -n "$1" && -n "$2" && -n "$3" ]]; then
translate_argument scene_type $1