diff --git a/configurator.sh b/configurator.sh index e4fa666..36693f9 100755 --- a/configurator.sh +++ b/configurator.sh @@ -4205,6 +4205,63 @@ interpret_source_permission() { echo_error "setting_update_system, arg_system_application_action: $arg_system_application_action." fi + # Loopback: desk Vaughan. + elif [[ "$arg_system_application" == "loopback_desk_vaughan" ]]; then + # Start. + if [[ "$arg_system_application_action" == "start" ]]; then + setting_update_system_loopback_start_desk_vaughan + # Start OBS. + elif [[ "$arg_system_application_action" == "start_obs" ]]; then + setting_update_system_loopback_start_desk_vaughan_obs + # Start player. + elif [[ "$arg_system_application_action" == "start_player" ]]; then + setting_update_system_loopback_start_desk_vaughan_player + # Stop. + elif [[ "$arg_system_application_action" == "stop" ]]; then + setting_update_system_loopback_stop_desk_vaughan + # Error. + else + echo_error "setting_update_system, arg_system_application_action: $arg_system_application_action." + fi + + # Loopback: bed overhead. + elif [[ "$arg_system_application" == "loopback_bed_overhead" ]]; then + # Start. + if [[ "$arg_system_application_action" == "start" ]]; then + setting_update_system_loopback_start_bed_overhead + # Start OBS. + elif [[ "$arg_system_application_action" == "start_obs" ]]; then + setting_update_system_loopback_start_bed_overhead_obs + # Start player. + elif [[ "$arg_system_application_action" == "start_player" ]]; then + setting_update_system_loopback_start_bed_overhead_player + # Stop. + elif [[ "$arg_system_application_action" == "stop" ]]; then + setting_update_system_loopback_stop_bed_overhead + # Error. + else + echo_error "setting_update_system, arg_system_application_action: $arg_system_application_action." + fi + + # Loopback: bed tripod. + elif [[ "$arg_system_application" == "loopback_bed_tripod" ]]; then + # Start. + if [[ "$arg_system_application_action" == "start" ]]; then + setting_update_system_loopback_start_bed_tripod + # Start OBS. + elif [[ "$arg_system_application_action" == "start_obs" ]]; then + setting_update_system_loopback_start_bed_tripod_obs + # Start player. + elif [[ "$arg_system_application_action" == "start_player" ]]; then + setting_update_system_loopback_start_bed_tripod_player + # Stop. + elif [[ "$arg_system_application_action" == "stop" ]]; then + setting_update_system_loopback_stop_bed_tripod + # Error. + else + echo_error "setting_update_system, arg_system_application_action: $arg_system_application_action." + fi + # Error. else echo_error "setting_update_system, arg_system_application: $arg_system_application." @@ -4226,51 +4283,104 @@ interpret_source_permission() { } setting_update_system_loopback_start() { - # Desk Vaughan. - # ffmpeg -hwaccel vaapi -f v4l2 -framerate 60 -video_size 1920x1080 -input_format mjpeg -i /dev/video0 -pix_fmt yuv420p -f v4l2 /dev/video50 -pix_fmt yuv420p -f v4l2 /dev/video51 & disown - # ffmpeg -vaapi_device /dev/dri/renderD128 -f v4l2 -video_size 1920x1080 -framerate 60 -i /dev/video0 -pix_fmt yuv420p -f v4l2 /dev/video50 -pix_fmt yuv420p -f v4l2 /dev/video51 & disown - ffmpeg -hwaccel vaapi -f v4l2 -framerate 60 -video_size 1920x1080 -input_format mjpeg -i /dev/video0 -pix_fmt yuv420p -f v4l2 /dev/video50 -pix_fmt yuv420p -f v4l2 /dev/video51 & disown - - # Bed overhead. - # ffmpeg -hwaccel vaapi -f v4l2 -framerate 30 -video_size 1920x1080 -input_format mjpeg -i /dev/video8 \ - # -i "/media/archive/Social Media/Stock/Stock Footage/Still/Waterfall.mkv" \ - # -filter_complex "[0:v]colorkey=0x00FF00:0.3:0.2[ckout];[1:v][ckout]overlay[out1];[out1]split=2[out2][out3]" \ - # -map "[out2]" -pix_fmt yuv420p -f v4l2 /dev/video70 \ - # -map "[out3]" -pix_fmt yuv420p -f v4l2 /dev/video71 \ - # & disown - ffmpeg -vaapi_device /dev/dri/renderD128 -f v4l2 -video_size 1920x1080 -framerate 30 -input_format mjpeg -i /dev/video8 \ - -i "/media/archive/Social Media/Stock/Stock Footage/Still/Waterfall.mkv" \ - -filter_complex "[0:v]colorkey=0x00FF00:0.3:0.2[ckout];[1:v][ckout]overlay[out1];[out1]split=2[out2][out3]" \ - -map "[out2]" -pix_fmt yuv420p -f v4l2 /dev/video70 \ - -map "[out3]" -pix_fmt yuv420p -f v4l2 /dev/video71 \ - & disown - - # Bed tripod. - # ffmpeg -hwaccel vaapi -f v4l2 -framerate 30 -video_size 1920x1080 -input_format mjpeg -i /dev/video10 \ - # -i "/media/archive/Social Media/Stock/Stock Footage/Still/Waterfall.mkv" \ - # -filter_complex "[0:v]vflip[vflipped]; \ - # [vflipped]hflip[hflipped]; \ - # [hflipped]colorkey=0x00FF00:0.3:0.2[ckout]; \ - # [1:v][ckout]overlay[out1]; \ - # [out1]split=2[out2][out3]" \ - # -map "[out2]" -pix_fmt yuv420p -f v4l2 /dev/video60 \ - # -map "[out3]" -pix_fmt yuv420p -f v4l2 /dev/video61 \ - # & disown - - ffmpeg -vaapi_device /dev/dri/renderD128 -f v4l2 -video_size 1920x1080 -framerate 30 -input_format mjpeg -i /dev/video10 \ - -i "/media/archive/Social Media/Stock/Stock Footage/Still/Waterfall.mkv" \ - -filter_complex "[0:v]colorkey=0x00FF00:0.3:0.2[ckout];[1:v][ckout]overlay[out1];[out1]split=2[out2][out3]" \ - -map "[out2]" -f v4l2 /dev/video60 \ - -map "[out3]" -f v4l2 /dev/video61 \ - & disown - + setting_update_system_loopback_start_desk_vaughan + setting_update_system_loopback_start_bed_overhead + setting_update_system_loopback_start_bed_tripod } + setting_update_system_loopback_start_desk_vaughan() { + + ffmpeg -hwaccel vaapi -f v4l2 -framerate 60 -video_size 1920x1080 -input_format mjpeg -i /dev/video0 -pix_fmt yuv420p -f v4l2 /dev/video50 -pix_fmt yuv420p -f v4l2 /dev/video51 & disown + + } + setting_update_system_loopback_start_desk_vaughan_obs() { + + ffmpeg -hwaccel vaapi -f v4l2 -framerate 60 -video_size 1920x1080 -input_format mjpeg -i /dev/video0 -pix_fmt yuv420p -f v4l2 /dev/video50 & disown + + } + setting_update_system_loopback_start_desk_vaughan_player() { + + ffmpeg -hwaccel vaapi -f v4l2 -framerate 60 -video_size 1920x1080 -input_format mjpeg -i /dev/video0 -pix_fmt yuv420p -f v4l2 /dev/video51 & disown + + } + setting_update_system_loopback_start_bed_overhead() { + + ffmpeg -vaapi_device /dev/dri/renderD128 -f v4l2 -video_size 1920x1080 -framerate 30 -input_format mjpeg -i /dev/video8 \ + -i "/media/archive/Social Media/Stock/Stock Footage/Still/Waterfall.mkv" \ + -filter_complex "[0:v]colorkey=0x00FF00:0.3:0.2[ckout];[1:v][ckout]overlay[out1];[out1]split=2[out2][out3]" \ + -map "[out2]" -pix_fmt yuv420p -f v4l2 /dev/video70 \ + -map "[out3]" -pix_fmt yuv420p -f v4l2 /dev/video71 \ + & disown + + } + setting_update_system_loopback_start_bed_overhead_obs() { + + ffmpeg -vaapi_device /dev/dri/renderD128 -f v4l2 -video_size 1920x1080 -framerate 30 -input_format mjpeg -i /dev/video8 \ + -i "/media/archive/Social Media/Stock/Stock Footage/Still/Waterfall.mkv" \ + -filter_complex "[0:v]colorkey=0x00FF00:0.3:0.2[ckout];[1:v][ckout]overlay[out]" \ + -map "[out]" -pix_fmt yuv420p -f v4l2 /dev/video70 \ + & disown + + } + setting_update_system_loopback_start_bed_overhead_player() { + + ffmpeg -vaapi_device /dev/dri/renderD128 -f v4l2 -video_size 1920x1080 -framerate 30 -input_format mjpeg -i /dev/video8 \ + -i "/media/archive/Social Media/Stock/Stock Footage/Still/Waterfall.mkv" \ + -filter_complex "[0:v]colorkey=0x00FF00:0.3:0.2[ckout];[1:v][ckout]overlay[out]" \ + -map "[out]" -pix_fmt yuv420p -f v4l2 /dev/video71 \ + & disown + + } + setting_update_system_loopback_start_bed_tripod() { + + ffmpeg -vaapi_device /dev/dri/renderD128 -f v4l2 -video_size 1920x1080 -framerate 30 -input_format mjpeg -i /dev/video10 \ + -i "/media/archive/Social Media/Stock/Stock Footage/Still/Waterfall.mkv" \ + -filter_complex "[0:v]colorkey=0x00FF00:0.3:0.2[ckout];[1:v][ckout]overlay[out1];[out1]split=2[out2][out3]" \ + -map "[out2]" -f v4l2 /dev/video60 \ + -map "[out3]" -f v4l2 /dev/video61 \ + & disown + + } + setting_update_system_loopback_start_bed_tripod_obs() { + + ffmpeg -vaapi_device /dev/dri/renderD128 -f v4l2 -video_size 1920x1080 -framerate 30 -input_format mjpeg -i /dev/video10 \ + -i "/media/archive/Social Media/Stock/Stock Footage/Still/Waterfall.mkv" \ + -filter_complex "[0:v]colorkey=0x00FF00:0.3:0.2[ckout];[1:v][ckout]overlay[out]" \ + -map "[out]" -pix_fmt yuv420p -f v4l2 /dev/video60 \ + & disown + + } + setting_update_system_loopback_start_bed_tripod_player() { + + ffmpeg -vaapi_device /dev/dri/renderD128 -f v4l2 -video_size 1920x1080 -framerate 30 -input_format mjpeg -i /dev/video10 \ + -i "/media/archive/Social Media/Stock/Stock Footage/Still/Waterfall.mkv" \ + -filter_complex "[0:v]colorkey=0x00FF00:0.3:0.2[ckout];[1:v][ckout]overlay[out]" \ + -map "[out]" -pix_fmt yuv420p -f v4l2 /dev/video61 \ + & disown + + } setting_update_system_loopback_stop() { - kill $(pgrep ffmpeg) + setting_update_system_loopback_stop_desk_vaughan + setting_update_system_loopback_stop_bed_overhead + setting_update_system_loopback_stop_bed_tripod } + setting_update_system_loopback_stop_desk_vaughan() { + + kill $(ps aux | grep ffmpeg | grep video0 | awk '{print $2}') + + } + setting_update_system_loopback_stop_bed_overhead() { + + kill $(ps aux | grep ffmpeg | grep video8 | awk '{print $2}') + + } + setting_update_system_loopback_stop_bed_tripod() { + + kill $(ps aux | grep ffmpeg | grep video10 | awk '{print $2}') + + } setting_update_pipeware_restart() { setting_update_system_obs_stream_stop unrestricted diff --git a/services/hyprland.sh b/services/hyprland.sh index b0be040..f920d44 100755 --- a/services/hyprland.sh +++ b/services/hyprland.sh @@ -117,69 +117,11 @@ } -# Applications. +# Processes. - application_camera_desk_vaughan() { + configurator() { - # Start. - if [[ "$1" == "start" ]]; then - mpv av://v4l2:/dev/video51 --osc=no --stop-screensaver=no --panscan=1 --profile=low-latency --title="camera_desk_vaughan" >/dev/null 2>&1 & disown - - # Stop. - elif [[ "$1" == "stop" ]]; then - - if [[ -n "$(status_window_pid $camera_desk_vaughan)" ]]; then - kill "$(status_window_pid $camera_desk_vaughan)" - else - echo_info "Process '$camera_desk_vaughan' already killed, skipping." - fi - - # Error. - else - echo_error "application_camera_desk_vaughan." - fi - - } - application_camera_bed_overhead() { - - # Start. - if [[ "$1" == "start" ]]; then - kitty --title camera_bed_overhead >/dev/null 2>&1 & disown - - # Stop. - elif [[ "$1" == "stop" ]]; then - - if [[ -n "$(status_window_pid $camera_bed_overhead)" ]]; then - kill "$(status_window_pid $camera_bed_overhead)" - else - echo_info "Process '$camera_bed_overhead' already killed, skipping." - fi - - # Error. - else - echo_error "application_camera_bed_overhead." - fi - - } - application_chat() { - - # Start. - if [[ "$1" == "start" ]]; then - flatpak run com.chatterino.chatterino >/dev/null 2>&1 & disown - - # Stop. - elif [[ "$1" == "stop" ]]; then - - if [[ -n "$(status_window_pid $chat)" ]]; then - kill "$(status_window_pid $chat)" - else - echo_info "Process '$chat' already killed, skipping." - fi - - # Error. - else - echo_error "application_chat." - fi + "/media/storage/Streaming/Software/scripts/dev/configurator.sh" --source terminal --verbose --system application $1 $2 $3 } @@ -244,315 +186,334 @@ # New window order. elif [[ "$new_window_order" != "$current_window_order" ]]; then - # Monitor DP-2 and DP-3. - if [[ "$new_window_layout" == "$current_window_layout" && ("$workspace_active_monitor" == "1" || "$workspace_active_monitor" == "2") ]]; then - - #Swap. - if [[ "$new_window_order" == "next" ]]; then - echo_info "Swap." - hyprctl dispatch layoutmsg swapsplit >/dev/null 2>&1 - new_window_order="$current_window_order" - - # Toggle. - elif [[ "$new_window_order" == "previous" ]]; then - echo_info "Toggle." - hyprctl dispatch layoutmsg togglesplit >/dev/null 2>&1 - new_window_order="$current_window_order" + # Monitor DP-2 and DP-3. + if [[ "$new_window_layout" == "$current_window_layout" && ("$workspace_active_monitor" == "1" || "$workspace_active_monitor" == "2") ]]; then - # Error. - else - echo_error "update_window_layout, new_window_order, default." - fi + #Swap. + if [[ "$new_window_order" == "next" ]]; then + echo_info "Swap." + hyprctl dispatch layoutmsg swapsplit >/dev/null 2>&1 + new_window_order="$current_window_order" - # Default. - elif [[ "$new_window_layout" == "default" ]]; then + # Toggle. + elif [[ "$new_window_order" == "previous" ]]; then + echo_info "Toggle." + hyprctl dispatch layoutmsg togglesplit >/dev/null 2>&1 + new_window_order="$current_window_order" - update_window_position_hide_up $chat - update_window_position_hide_down $camera_desk_vaughan $camera_bed_overhead $camera_bed_tripod + # Error. + else + echo_error "update_window_layout, new_window_order, default." + fi - # None. - if [[ "$new_window_order" == "none" || "$new_window_order" == "startup" ]]; then - new_window_order="default_default" - fi + # Default. + elif [[ "$new_window_layout" == "default" ]]; then - echo_info "New window order: $new_window_order." - position_right + update_window_position_hide_up $chat + update_window_position_hide_down $camera_desk_vaughan $camera_bed_overhead $camera_bed_tripod - # Default. - if [[ "$new_window_order" == "default_default" ]]; then - echo_info "Default." - for application_title in "${application_titles[@]}"; do - temp_workspace_id=$(window_workspace_id $application_title) - update_window_tile $application_title - update_window_workspace_silent $temp_workspace_id $application_title - done - # for application_title in "${application_titles[@]}"; do - # temp_workspace_id=$(window_workspace_id $application_title) - # update_window_tile_toggle $application_title - # done - - #Swap. - elif [[ "$new_window_order" == "next" ]]; then - echo_info "Swap." - hyprctl dispatch layoutmsg swapsplit >/dev/null 2>&1 - new_window_order="$current_window_order" - - # Toggle. - elif [[ "$new_window_order" == "previous" ]]; then - echo_info "Toggle." - hyprctl dispatch layoutmsg togglesplit >/dev/null 2>&1 - new_window_order="$current_window_order" + configurator loopback_desk_vaughan none stop + configurator loopback_desk_vaughan none start_obs + configurator loopback_bed_overhead none stop + configurator loopback_bed_tripod none stop - # Error. - else - echo_error "update_window_layout, new_window_order, default." - fi + # None. + if [[ "$new_window_order" == "none" || "$new_window_order" == "startup" ]]; then + new_window_order="default_default" + fi - # Stream quad desk. - elif [[ "$new_window_layout" == "stream_quad_desk" ]]; then - update_window_position_hide_down $camera_desk_vaughan $camera_bed_overhead $camera_bed_tripod + echo_info "New window order: $new_window_order." + position_right + + # Default. + if [[ "$new_window_order" == "default_default" ]]; then + echo_info "Default." + for application_title in "${application_titles[@]}"; do + temp_workspace_id=$(window_workspace_id $application_title) + update_window_tile $application_title + update_window_workspace_silent $temp_workspace_id $application_title + done + # for application_title in "${application_titles[@]}"; do + # temp_workspace_id=$(window_workspace_id $application_title) + # update_window_tile_toggle $application_title + # done + + #Swap. + elif [[ "$new_window_order" == "next" ]]; then + echo_info "Swap." + hyprctl dispatch layoutmsg swapsplit >/dev/null 2>&1 + new_window_order="$current_window_order" + + # Toggle. + elif [[ "$new_window_order" == "previous" ]]; then + echo_info "Toggle." + hyprctl dispatch layoutmsg togglesplit >/dev/null 2>&1 + new_window_order="$current_window_order" + + # Error. + else + echo_error "update_window_layout, new_window_order, default." + fi - # None. - if [[ "$new_window_order" == "none" ]]; then - new_window_order="stream_quad_desk_window_chat" - fi + # Stream quad desk. + elif [[ "$new_window_layout" == "stream_quad_desk" ]]; then + update_window_position_hide_down $camera_desk_vaughan $camera_bed_overhead $camera_bed_tripod - echo_info "New window order: $new_window_order." - position_right - - # Window, chat. - if [[ "$new_window_order" == "stream_quad_desk_window_chat" ]]; then - echo_info "Window, chat." - # Applications. - for application_title in "${application_titles[@]}"; do - update_window_float $application_title - update_window_position_exact 2576 16 $application_title - update_window_size 2042 1347 $application_title - done - # Chat. - update_window_size 470 1347 Chatterino - update_window_position_exact 4634 16 Chatterino + configurator loopback_desk_vaughan none stop + configurator loopback_desk_vaughan none start_obs + configurator loopback_bed_overhead none stop + configurator loopback_bed_tripod none stop - # Error. - else - echo_error "update_window_layout, new_window_order, stream_quad_desk." - fi + # None. + if [[ "$new_window_order" == "none" ]]; then + new_window_order="stream_quad_desk_window_chat" + fi - # Stream desk. - elif [[ "$new_window_layout" == "stream_single_desk" ]]; then + echo_info "New window order: $new_window_order." + position_right + + # Window, chat. + if [[ "$new_window_order" == "stream_quad_desk_window_chat" ]]; then + echo_info "Window, chat." + # Applications. + for application_title in "${application_titles[@]}"; do + update_window_float $application_title + update_window_position_exact 2576 16 $application_title + update_window_size 2042 1347 $application_title + done + # Chat. + update_window_size 470 1347 Chatterino + update_window_position_exact 4634 16 Chatterino + + # Error. + else + echo_error "update_window_layout, new_window_order, stream_quad_desk." + fi - update_window_position_hide_down $camera_bed_overhead $camera_bed_tripod + # Stream desk. + elif [[ "$new_window_layout" == "stream_single_desk" ]]; then - # None. - if [[ "$new_window_order" == "none" ]]; then - new_window_order="stream_single_desk_window_chat_camera" - fi + update_window_position_hide_down $camera_bed_overhead $camera_bed_tripod - echo_info "New window order: $new_window_order." - position_right + configurator loopback_desk_vaughan none stop + configurator loopback_desk_vaughan none start_player + configurator loopback_bed_overhead none stop + configurator loopback_bed_tripod none stop - # Previous. - if [[ "$new_window_order" == "previous" ]]; then - if [[ "$current_window_order" == "stream_single_desk_camera_chat" ]]; then + # None. + if [[ "$new_window_order" == "none" ]]; then new_window_order="stream_single_desk_window_chat_camera" - elif [[ "$current_window_order" == "stream_single_desk_window_chat_camera" ]]; then - new_window_order="stream_single_desk_camera_chat" - else - echo_error "update_window_layout, stream_single_desk, previous." fi - # Next. - elif [[ "$new_window_order" == "next" ]]; then - if [[ "$current_window_order" == "stream_single_desk_camera_chat" ]]; then - new_window_order="stream_single_desk_window_chat_camera" - elif [[ "$current_window_order" == "stream_single_desk_window_chat_camera" ]]; then - new_window_order="stream_single_desk_camera_chat" - else - echo_error "update_window_layout, stream_single_desk, next." + echo_info "New window order: $new_window_order." + position_right + + # Previous. + if [[ "$new_window_order" == "previous" ]]; then + if [[ "$current_window_order" == "stream_single_desk_camera_chat" ]]; then + new_window_order="stream_single_desk_window_chat_camera" + elif [[ "$current_window_order" == "stream_single_desk_window_chat_camera" ]]; then + new_window_order="stream_single_desk_camera_chat" + else + echo_error "update_window_layout, stream_single_desk, previous." + fi + + # Next. + elif [[ "$new_window_order" == "next" ]]; then + if [[ "$current_window_order" == "stream_single_desk_camera_chat" ]]; then + new_window_order="stream_single_desk_window_chat_camera" + elif [[ "$current_window_order" == "stream_single_desk_window_chat_camera" ]]; then + new_window_order="stream_single_desk_camera_chat" + else + echo_error "update_window_layout, stream_single_desk, next." + fi fi - fi - - # Window, chat, camera. - if [[ "$new_window_order" == "stream_single_desk_window_chat_camera" ]]; then - echo_info "Window, chat, camera." - # Chat. - update_window_position_exact 4234 16 Chatterino - update_window_size 870 842 Chatterino - # Camera desk vaughan. - update_window_position_exact 4234 874 $camera_desk_vaughan - update_window_size 870 489 $camera_desk_vaughan - # Applications. - sleep 0.1 - for application_title in "${application_titles[@]}"; do - update_window_float $application_title - update_window_position_exact 2576 16 $application_title - update_window_size 1639 1347 $application_title - done - - # Camera, chat. - elif [[ "$new_window_order" == "stream_single_desk_camera_chat" ]]; then - echo_info "Camera chat." - status_workspace_active_id - window_title_temp="$(hyprctl clients | grep "workspace: $workspace_active_id" -A 4 | grep "title:" | awk '$2 != "camera_desk_vaughan" && $2 != "camera_bed_overhead" && $2 != "camera_bed_tripod" && $2 != "roboty_hurts" && $2 != "Chatterino" {print $2; exit}')" - update_window_position_exact 905 16 $window_title_temp - sleep 0.1 - # Camera desk Vaughan. - update_window_size 2042 1347 $camera_desk_vaughan - update_window_position_exact 2576 16 $camera_desk_vaughan - # Chat. - update_window_size 470 1347 Chatterino - update_window_position_exact 4634 16 Chatterino - - # Error. - else - echo_error "update_window_layout, new_window_order, stream_single_desk." - fi - # Stream therapy. - elif [[ "$new_window_layout" == "stream_therapy" ]]; then + # Window, chat, camera. + if [[ "$new_window_order" == "stream_single_desk_window_chat_camera" ]]; then + echo_info "Window, chat, camera." + # Chat. + update_window_position_exact 4234 16 Chatterino + update_window_size 870 842 Chatterino + # Camera desk vaughan. + update_window_position_exact 4234 874 $camera_desk_vaughan + update_window_size 870 489 $camera_desk_vaughan + # Applications. + sleep 0.1 + for application_title in "${application_titles[@]}"; do + update_window_float $application_title + update_window_position_exact 2576 16 $application_title + update_window_size 1639 1347 $application_title + done + + # Camera, chat. + elif [[ "$new_window_order" == "stream_single_desk_camera_chat" ]]; then + echo_info "Camera chat." + status_workspace_active_id + window_title_temp="$(hyprctl clients | grep "workspace: $workspace_active_id" -A 4 | grep "title:" | awk '$2 != "camera_desk_vaughan" && $2 != "camera_bed_overhead" && $2 != "camera_bed_tripod" && $2 != "roboty_hurts" && $2 != "Chatterino" {print $2; exit}')" + update_window_position_exact 905 16 $window_title_temp + sleep 0.1 + # Camera desk Vaughan. + update_window_size 2042 1347 $camera_desk_vaughan + update_window_position_exact 2576 16 $camera_desk_vaughan + # Chat. + update_window_size 470 1347 Chatterino + update_window_position_exact 4634 16 Chatterino + + # Error. + else + echo_error "update_window_layout, new_window_order, stream_single_desk." + fi - update_window_position_hide_down $camera_desk_vaughan + # Stream therapy. + elif [[ "$new_window_layout" == "stream_therapy" ]]; then - # None. - if [[ "$new_window_order" == "none" ]]; then - new_window_order="stream_therapy_tripod_chat" - fi + update_window_position_hide_down $camera_desk_vaughan - echo_info "New window order: $new_window_order." - position_right + configurator loopback_desk_vaughan none stop + configurator loopback_bed_overhead none start + configurator loopback_bed_tripod none start - # Previous. - if [[ "$new_window_order" == "previous" ]]; then - if [[ "$current_window_order" == "stream_therapy_tripod_chat" ]]; then - new_window_order="stream_therapy_overhead_chat" - elif [[ "$current_window_order" == "stream_therapy_window_chat_tripod" ]]; then + # None. + if [[ "$new_window_order" == "none" ]]; then new_window_order="stream_therapy_tripod_chat" - elif [[ "$current_window_order" == "stream_therapy_window_chat_tripod_large" ]]; then - new_window_order="stream_therapy_window_chat_tripod" - elif [[ "$current_window_order" == "stream_therapy_window_chat_overhead_tripod" ]]; then - new_window_order="stream_therapy_window_chat_tripod_large" - elif [[ "$current_window_order" == "stream_therapy_overhead_chat" ]]; then - new_window_order="stream_therapy_window_chat_overhead_tripod" - else - echo_error "update_window_layout, stream_single_desk, previous." fi - # Next. - elif [[ "$new_window_order" == "next" ]]; then - if [[ "$current_window_order" == "stream_therapy_tripod_chat" ]]; then - new_window_order="stream_therapy_window_chat_tripod" - elif [[ "$current_window_order" == "stream_therapy_window_chat_tripod" ]]; then - new_window_order="stream_therapy_window_chat_tripod_large" - elif [[ "$current_window_order" == "stream_therapy_window_chat_tripod_large" ]]; then - new_window_order="stream_therapy_window_chat_overhead_tripod" - elif [[ "$current_window_order" == "stream_therapy_window_chat_overhead_tripod" ]]; then - new_window_order="stream_therapy_overhead_chat" - elif [[ "$current_window_order" == "stream_therapy_overhead_chat" ]]; then - new_window_order="stream_therapy_tripod_chat" + echo_info "New window order: $new_window_order." + position_right + + # Previous. + if [[ "$new_window_order" == "previous" ]]; then + if [[ "$current_window_order" == "stream_therapy_tripod_chat" ]]; then + new_window_order="stream_therapy_overhead_chat" + elif [[ "$current_window_order" == "stream_therapy_window_chat_tripod" ]]; then + new_window_order="stream_therapy_tripod_chat" + elif [[ "$current_window_order" == "stream_therapy_window_chat_tripod_large" ]]; then + new_window_order="stream_therapy_window_chat_tripod" + elif [[ "$current_window_order" == "stream_therapy_window_chat_overhead_tripod" ]]; then + new_window_order="stream_therapy_window_chat_tripod_large" + elif [[ "$current_window_order" == "stream_therapy_overhead_chat" ]]; then + new_window_order="stream_therapy_window_chat_overhead_tripod" + else + echo_error "update_window_layout, stream_single_desk, previous." + fi + + # Next. + elif [[ "$new_window_order" == "next" ]]; then + if [[ "$current_window_order" == "stream_therapy_tripod_chat" ]]; then + new_window_order="stream_therapy_window_chat_tripod" + elif [[ "$current_window_order" == "stream_therapy_window_chat_tripod" ]]; then + new_window_order="stream_therapy_window_chat_tripod_large" + elif [[ "$current_window_order" == "stream_therapy_window_chat_tripod_large" ]]; then + new_window_order="stream_therapy_window_chat_overhead_tripod" + elif [[ "$current_window_order" == "stream_therapy_window_chat_overhead_tripod" ]]; then + new_window_order="stream_therapy_overhead_chat" + elif [[ "$current_window_order" == "stream_therapy_overhead_chat" ]]; then + new_window_order="stream_therapy_tripod_chat" + else + echo_error "update_window_layout, stream_single_desk, next." + fi + fi + + # Camera, chat. + if [[ "$new_window_order" == "stream_therapy_tripod_chat" ]]; then + echo_info "Camera, chat." + for application_title in "${application_titles[@]}"; do + update_window_float $application_title + update_window_position_hide_up $application_title + done + # Camera bed overhead. + update_window_position_exact $(status_window_position_horizontal $camera_bed_overhead) 1456 $camera_bed_overhead + # Chat. + update_window_size 470 1347 Chatterino + update_window_position_exact 4634 16 Chatterino + # Camera bed tripod. + update_window_size 2042 1347 $camera_bed_tripod + update_window_position_exact 2576 16 $camera_bed_tripod + + # Window, chat, camera. + elif [[ "$new_window_order" == "stream_therapy_window_chat_tripod" ]]; then + echo_info "Window, chat, camera." + # Camera bed overhead. + update_window_position_exact 3462 1456 $camera_bed_overhead + # Applications. + for application_title in "${application_titles[@]}"; do + update_window_float $application_title + update_window_position_exact 2576 16 $application_title + update_window_size 1639 1347 $application_title + done + # Chat. + update_window_position_exact 4234 16 Chatterino + update_window_size 870 842 Chatterino + # Camera bed tripod. + update_window_position_exact 4234 874 $camera_bed_tripod + update_window_size 870 489 $camera_bed_tripod + + # Window, camera, chat. + elif [[ "$new_window_order" == "stream_therapy_window_chat_tripod_large" ]]; then + echo_info "Window, camera, chat." + # Chat. + update_window_position_exact 3824 16 Chatterino + update_window_size 1280 611 Chatterino + # Camera bed tripod. + update_window_position_exact 3824 643 $camera_bed_tripod + update_window_size 1280 720 $camera_bed_tripod + # Applications. + for application_title in "${application_titles[@]}"; do + update_window_float $application_title + update_window_position_exact 2576 16 $application_title + update_window_size 1232 1347 $application_title + done + # Camera bed overhead. + update_window_position_exact $(status_window_position_horizontal $camera_bed_overhead) 1456 $camera_bed_overhead + + # Window, chat, cameras. + elif [[ "$new_window_order" == "stream_therapy_window_chat_overhead_tripod" ]]; then + echo_info "Window, chat, cameras." + # Chat. + update_window_position_exact 2576 16 Chatterino + update_window_size 670 780 Chatterino + # Camera bed tripod. + update_window_position_exact 2576 812 $camera_bed_tripod + update_window_size 870 551 $camera_bed_tripod + # Applications. + for application_title in "${application_titles[@]}"; do + update_window_float $application_title + update_window_position_exact 3262 16 $application_title + update_window_size 1842 780 $application_title + done + # Camera bed overhead. + update_window_position_exact 3462 812 $camera_bed_overhead + update_window_size 1642 551 $camera_bed_overhead + + # Bed camera, chat. + elif [[ "$new_window_order" == "stream_therapy_overhead_chat" ]]; then + echo_info "Bed camera, chat." + # Applications. + for application_title in "${application_titles[@]}"; do + update_window_float $application_title + update_window_position_hide_up $application_title + update_window_size 1842 780 $application_title + done + # Camera bed overhead. + update_window_position_hide_down $camera_bed_tripod + # Chat. + update_window_size 470 1347 Chatterino + update_window_position_exact 4634 16 Chatterino + # Camera bed tripod. + update_window_size 2042 1347 $camera_bed_overhead + update_window_position_exact 2576 16 $camera_bed_overhead + + # Error. else - echo_error "update_window_layout, stream_single_desk, next." + echo_error "update_window_layout, new_window_order, stream_therapy." fi - fi - - # Camera, chat. - if [[ "$new_window_order" == "stream_therapy_tripod_chat" ]]; then - echo_info "Camera, chat." - for application_title in "${application_titles[@]}"; do - update_window_float $application_title - update_window_position_hide_up $application_title - done - # Camera bed overhead. - update_window_position_exact $(status_window_position_horizontal $camera_bed_overhead) 1456 $camera_bed_overhead - # Chat. - update_window_size 470 1347 Chatterino - update_window_position_exact 4634 16 Chatterino - # Camera bed tripod. - update_window_size 2042 1347 $camera_bed_tripod - update_window_position_exact 2576 16 $camera_bed_tripod - - # Window, chat, camera. - elif [[ "$new_window_order" == "stream_therapy_window_chat_tripod" ]]; then - echo_info "Window, chat, camera." - # Camera bed overhead. - update_window_position_exact 3462 1456 $camera_bed_overhead - # Applications. - for application_title in "${application_titles[@]}"; do - update_window_float $application_title - update_window_position_exact 2576 16 $application_title - update_window_size 1639 1347 $application_title - done - # Chat. - update_window_position_exact 4234 16 Chatterino - update_window_size 870 842 Chatterino - # Camera bed tripod. - update_window_position_exact 4234 874 $camera_bed_tripod - update_window_size 870 489 $camera_bed_tripod - - # Window, camera, chat. - elif [[ "$new_window_order" == "stream_therapy_window_chat_tripod_large" ]]; then - echo_info "Window, camera, chat." - # Chat. - update_window_position_exact 3824 16 Chatterino - update_window_size 1280 611 Chatterino - # Camera bed tripod. - update_window_position_exact 3824 643 $camera_bed_tripod - update_window_size 1280 720 $camera_bed_tripod - # Applications. - for application_title in "${application_titles[@]}"; do - update_window_float $application_title - update_window_position_exact 2576 16 $application_title - update_window_size 1232 1347 $application_title - done - # Camera bed overhead. - update_window_position_exact $(status_window_position_horizontal $camera_bed_overhead) 1456 $camera_bed_overhead - - # Window, chat, cameras. - elif [[ "$new_window_order" == "stream_therapy_window_chat_overhead_tripod" ]]; then - echo_info "Window, chat, cameras." - # Chat. - update_window_position_exact 2576 16 Chatterino - update_window_size 670 780 Chatterino - # Camera bed tripod. - update_window_position_exact 2576 812 $camera_bed_tripod - update_window_size 870 551 $camera_bed_tripod - # Applications. - for application_title in "${application_titles[@]}"; do - update_window_float $application_title - update_window_position_exact 3262 16 $application_title - update_window_size 1842 780 $application_title - done - # Camera bed overhead. - update_window_position_exact 3462 812 $camera_bed_overhead - update_window_size 1642 551 $camera_bed_overhead - - # Bed camera, chat. - elif [[ "$new_window_order" == "stream_therapy_overhead_chat" ]]; then - echo_info "Bed camera, chat." - # Applications. - for application_title in "${application_titles[@]}"; do - update_window_float $application_title - update_window_position_hide_up $application_title - update_window_size 1842 780 $application_title - done - # Camera bed overhead. - update_window_position_hide_down $camera_bed_tripod - # Chat. - update_window_size 470 1347 Chatterino - update_window_position_exact 4634 16 Chatterino - # Camera bed tripod. - update_window_size 2042 1347 $camera_bed_overhead - update_window_position_exact 2576 16 $camera_bed_overhead # Error. else - echo_error "update_window_layout, new_window_order, stream_therapy." + echo_error "update_window_layout, new_window_order." fi - # Error. - else - echo_error "update_window_layout, new_window_order." - fi - position_left # Error. diff --git a/services/tablets.pyw b/services/tablets.pyw deleted file mode 100644 index c6f445d..0000000 --- a/services/tablets.pyw +++ /dev/null @@ -1,22 +0,0 @@ -import os -import subprocess -import time - -home_path = os.path.expanduser("~") -player_path = os.path.join(home_path, 'mpv', 'mpv.exe') -streamlink = ( - f"streamlink --twitch-low-latency twitch.tv/reality_hurts 720p60 " - f"--player \"{player_path}\" " - f"--player-args \"--no-cache --osc=no --stop-screensaver=no --no-config --border=no --geometry=0:0 --autofit-smaller=2000\"" -) - -while True: - try: - result = subprocess.run(streamlink, capture_output=True, text=True, check=True, shell=True) - print("STDOUT:") - print(result.stdout) - except subprocess.CalledProcessError as e: - print(f"An error occurred: {e}") - print("STDERR:") - print(e.stderr) - time.sleep(5) \ No newline at end of file diff --git a/services/tablets/brightness_0.cmd b/services/tablets/brightness_0.cmd new file mode 100644 index 0000000..75d2e3d --- /dev/null +++ b/services/tablets/brightness_0.cmd @@ -0,0 +1,2 @@ +PowerShell -Command "Set-ExecutionPolicy Unrestricted" >> "%TEMP%\BrightnessLog.txt" 2>&1 +PowerShell "%USERPROFILE%\brightness\brightness_0.ps1 >> "%TEMP%\BrightnessLog.txt" 2>&1 diff --git a/services/tablets/brightness_0.ps1 b/services/tablets/brightness_0.ps1 new file mode 100644 index 0000000..2ae59dd --- /dev/null +++ b/services/tablets/brightness_0.ps1 @@ -0,0 +1 @@ +(Get-WmiObject -Namespace root/WMI -Class WmiMonitorBrightnessMethods).WmiSetBrightness(1,0) \ No newline at end of file diff --git a/services/tablets/brightness_100.cmd b/services/tablets/brightness_100.cmd new file mode 100644 index 0000000..4ae9b3d --- /dev/null +++ b/services/tablets/brightness_100.cmd @@ -0,0 +1,2 @@ +PowerShell -Command "Set-ExecutionPolicy Unrestricted" >> "%TEMP%\BrightnessLog.txt" 2>&1 +PowerShell "%USERPROFILE%\brightness\brightness_100.ps1 >> "%TEMP%\BrightnessLog.txt" 2>&1 \ No newline at end of file diff --git a/services/tablets/brightness_100.ps1 b/services/tablets/brightness_100.ps1 new file mode 100644 index 0000000..aea20a9 --- /dev/null +++ b/services/tablets/brightness_100.ps1 @@ -0,0 +1 @@ +(Get-WmiObject -Namespace root/WMI -Class WmiMonitorBrightnessMethods).WmiSetBrightness(1,100) \ No newline at end of file diff --git a/services/tablets/hotspot_autostart.cmd b/services/tablets/hotspot_autostart.cmd new file mode 100644 index 0000000..cbf62e0 --- /dev/null +++ b/services/tablets/hotspot_autostart.cmd @@ -0,0 +1,2 @@ +PowerShell -Command "Set-ExecutionPolicy Unrestricted" >> "%TEMP%\StartupLog.txt" 2>&1 +PowerShell %USERPROFILE%\hotspot\hotspot_autostart.ps1 >> "%TEMP%\StartupLog.txt" 2>&1 diff --git a/services/tablets/hotspot_autostart.ps1 b/services/tablets/hotspot_autostart.ps1 new file mode 100644 index 0000000..552b655 --- /dev/null +++ b/services/tablets/hotspot_autostart.ps1 @@ -0,0 +1,53 @@ +# https://superuser.com/a/1434648 + +Add-Type -AssemblyName System.Runtime.WindowsRuntime +$asTaskGeneric = ([System.WindowsRuntimeSystemExtensions].GetMethods() | ? { $_.Name -eq 'AsTask' -and $_.GetParameters().Count -eq 1 -and $_.GetParameters()[0].ParameterType.Name -eq 'IAsyncOperation`1' })[0] + +Function Await($WinRtTask, $ResultType) { + $asTask = $asTaskGeneric.MakeGenericMethod($ResultType) + $netTask = $asTask.Invoke($null, @($WinRtTask)) + $netTask.Wait(-1) | Out-Null + $netTask.Result +} + +Function AwaitAction($WinRtAction) { + $asTask = ([System.WindowsRuntimeSystemExtensions].GetMethods() | ? { $_.Name -eq 'AsTask' -and $_.GetParameters().Count -eq 1 -and !$_.IsGenericMethod })[0] + $netTask = $asTask.Invoke($null, @($WinRtAction)) + $netTask.Wait(-1) | Out-Null +} + +Function SetHotspot($Enable) { + $connectionProfile = [Windows.Networking.Connectivity.NetworkInformation,Windows.Networking.Connectivity,ContentType=WindowsRuntime]::GetInternetConnectionProfile() + $tetheringManager = [Windows.Networking.NetworkOperators.NetworkOperatorTetheringManager,Windows.Networking.NetworkOperators,ContentType=WindowsRuntime]::CreateFromConnectionProfile($connectionProfile) + + if ($Enable -eq 1) { + if ($tetheringManager.TetheringOperationalState -eq 1) + { + "Hotspot is already On!" + } + else{ + "Hotspot is off! Turning it on" + Await ($tetheringManager.StartTetheringAsync()) ([Windows.Networking.NetworkOperators.NetworkOperatorTetheringOperationResult]) + } + } + else { + if ($tetheringManager.TetheringOperationalState -eq 0) + { + "Hotspot is already Off!" + } + else{ + "Hotspot is on! Turning it off" + Await ($tetheringManager.StopTetheringAsync()) ([Windows.Networking.NetworkOperators.NetworkOperatorTetheringOperationResult]) + } + } +} + +Function ToggleHotspot($Delay) { + SetHotspot(1) + sleep -seconds $Delay + SetHotspot(0) + sleep -seconds $Delay + SetHotspot(1) +} + +ToggleHotspot(3) \ No newline at end of file diff --git a/services/tablets/hotspot_keep_alive.bat b/services/tablets/hotspot_keep_alive.bat new file mode 100755 index 0000000..e58025c --- /dev/null +++ b/services/tablets/hotspot_keep_alive.bat @@ -0,0 +1,2 @@ +PowerShell -Command "Set-ExecutionPolicy Unrestricted" >> "%TEMP%\StartupLog.txt" 2>&1 +PowerShell %USERPROFILE%\hotspot\hotspot_keep_alive.ps1 >> "%TEMP%\StartupLog.txt" 2>&1 \ No newline at end of file diff --git a/services/tablets/hotspot_keep_alive.ps1 b/services/tablets/hotspot_keep_alive.ps1 new file mode 100644 index 0000000..c1c4e9c --- /dev/null +++ b/services/tablets/hotspot_keep_alive.ps1 @@ -0,0 +1,76 @@ +# https://superuser.com/a/1434648 + +Add-Type -AssemblyName System.Runtime.WindowsRuntime +$asTaskGeneric = ([System.WindowsRuntimeSystemExtensions].GetMethods() | ? { $_.Name -eq 'AsTask' -and $_.GetParameters().Count -eq 1 -and $_.GetParameters()[0].ParameterType.Name -eq 'IAsyncOperation`1' })[0] + +Function Await($WinRtTask, $ResultType) { + $asTask = $asTaskGeneric.MakeGenericMethod($ResultType) + $netTask = $asTask.Invoke($null, @($WinRtTask)) + $netTask.Wait(-1) | Out-Null + $netTask.Result +} + +Function AwaitAction($WinRtAction) { + $asTask = ([System.WindowsRuntimeSystemExtensions].GetMethods() | ? { $_.Name -eq 'AsTask' -and $_.GetParameters().Count -eq 1 -and !$_.IsGenericMethod })[0] + $netTask = $asTask.Invoke($null, @($WinRtAction)) + $netTask.Wait(-1) | Out-Null +} + +Function Get_TetheringManager() { + $connectionProfile = [Windows.Networking.Connectivity.NetworkInformation,Windows.Networking.Connectivity,ContentType=WindowsRuntime]::GetInternetConnectionProfile() + $tetheringManager = [Windows.Networking.NetworkOperators.NetworkOperatorTetheringManager,Windows.Networking.NetworkOperators,ContentType=WindowsRuntime]::CreateFromConnectionProfile($connectionProfile) + return $tetheringManager; +} + +Function SetHotspot($Enable) { + $tetheringManager = Get_TetheringManager + + if ($Enable -eq 1) { + if ($tetheringManager.TetheringOperationalState -eq 1) + { + "Hotspot is already On!" + } + else{ + "Hotspot is off! Turning it on" + Await ($tetheringManager.StartTetheringAsync()) ([Windows.Networking.NetworkOperators.NetworkOperatorTetheringOperationResult]) + } + } + else { + if ($tetheringManager.TetheringOperationalState -eq 0) + { + "Hotspot is already Off!" + } + else{ + "Hotspot is on! Turning it off" + Await ($tetheringManager.StopTetheringAsync()) ([Windows.Networking.NetworkOperators.NetworkOperatorTetheringOperationResult]) + } + } +} + +# Define a function to check the status of the hotspot +Function Check_HotspotStatus() { + $tetheringManager = Get_TetheringManager + return $tetheringManager.TetheringOperationalState -eq "Off" +} + +# Define a function to start the hotspot +Function Start_Hotspot() { + $tetheringManager = Get_TetheringManager + Await ($tetheringManager.StartTetheringAsync()) ([Windows.Networking.NetworkOperators.NetworkOperatorTetheringOperationResult]) +} + +$currentDateTime = Get-Date -Format "MM-dd-yyyy HH:mm:ss" +"$currentDateTime Starting hotspot keep-alive." + +# Keep alive wifi. +while ($true) { + # Get the current date and time in a specific format + $currentDateTime = Get-Date -Format "MM-dd-yyyy HH:mm:ss" + + if (Check_HotspotStatus) { + "$currentDateTime Hotspot is off! Turning it on" + Start_Hotspot + } + + Start-Sleep -Seconds 10 # Wait for 10 seconds before checking again +} \ No newline at end of file diff --git a/services/tablets/stream.pyw b/services/tablets/stream.pyw new file mode 100644 index 0000000..71ebb8e --- /dev/null +++ b/services/tablets/stream.pyw @@ -0,0 +1,24 @@ +import os +import subprocess +import time + +home_path = os.path.expanduser("~") +player_path = os.path.join(home_path, 'mpv', 'mpv.exe') +streamlink = ( + f"streamlink --twitch-low-latency twitch.tv/reality_hurts 480p " + f"--player \"{player_path}\" " + f"--player-args \"--no-cache --osc=no --stop-screensaver=no --input-test --no-config --ontop --border=no --geometry=0:0 --autofit-smaller=2000\"" +) + +while True: + while True: + try: + result = subprocess.run(streamlink, capture_output=True, text=True, check=True, shell=True) + print("STDOUT:") + print(result.stdout) + except subprocess.CalledProcessError as e: + print(f"An error occurred: {e}") + print("STDERR:") + print(e.stderr) + time.sleep(5) + time.sleep(5) \ No newline at end of file diff --git a/services/v4l2loopback.service b/services/v4l2loopback.service index 22fc392..5d5c7a2 100644 --- a/services/v4l2loopback.service +++ b/services/v4l2loopback.service @@ -3,7 +3,7 @@ Description=v4l2loopback After=network.target [Service] -ExecStart=/usr/bin/sudo /usr/bin/modprobe v4l2loopback exclusive_caps=1 video_nr=50,51,60,61,70,71,99 card_label="virtual_desk_vaughan_1","virtual_desk_vaughan_2","virtual_bed_tripod_1","virtual_bed_tripod_2","virtual_bed_overhead_1","virtual_bed_overhead_2","OBS Virtual Camera" +ExecStart=/usr/bin/sudo /usr/bin/modprobe v4l2loopback exclusive_caps=1 video_nr=40,50,51,60,61,70,71 card_label="OBS Virtual Camera","virtual_desk_vaughan_1","virtual_desk_vaughan_2","virtual_bed_tripod_1","virtual_bed_tripod_2","virtual_bed_overhead_1","virtual_bed_overhead_2" [Install] WantedBy=default.target