From ea2e7fb7704b647c64b83d71084c9b67e681e943 Mon Sep 17 00:00:00 2001 From: surtur Date: Sat, 27 Feb 2021 15:17:02 +0100 Subject: [PATCH] refactor screen-share-sway * introduce variables for common values * properly quote variables * check if directories exist before certain steps * exit on cd failure --- bin/screen-share-sway | 37 ++++++++++++++++++++++--------------- 1 file changed, 22 insertions(+), 15 deletions(-) diff --git a/bin/screen-share-sway b/bin/screen-share-sway index 0f9860f..79848fa 100755 --- a/bin/screen-share-sway +++ b/bin/screen-share-sway @@ -5,13 +5,18 @@ grep -q "alias obs" ~/.zshrc || echo 'alias obs="QT_QPA_PLATFORM=xcb obs"' >> ~/.zshrc -cd ~/utils +V4L2_VERSION="0.12.5" +U="$HOME/utils" -dotfiles/bin/v4l2pls 0.12.5 +# grab and build latest v4l2 module +"$U"/dotfiles/bin/v4l2pls "$V4L2_VERSION" # ref: https://github.com/obsproject/obs-studio/wiki/Install-Instructions#red-hatfedora-based-build-directions -git clone --recursive https://github.com/obsproject/obs-studio.git -cd ~/utils/obs-studio +if [ ! -d "$U/obs-studio" ]; then + cd "$U" || exit + git clone --recursive https://github.com/obsproject/obs-studio.git +fi +cd "$U"/obs-studio || exit git pull git submodule update --recursive mkdir -pv build && cd build @@ -20,24 +25,26 @@ make -j4 sudo make install -cd ~/utils - -git clone https://github.com/CatxFish/obs-v4l2sink.git -cd obs-v4l2sink +if [ ! -d "$U/obs-v4l2sink" ]; then + cd "$U" || exit + git clone https://github.com/CatxFish/obs-v4l2sink.git +fi +cd "$U"/obs-v4l2sink || exit git pull mkdir -pv build && cd build cmake -DLIBOBS_INCLUDE_DIR="../../obs-studio/libobs" -DCMAKE_INSTALL_PREFIX=~/.local .. make -j4 make install -cd ~/utils/obs-v4l2sink -cd ~/utils -hg clone https://hg.sr.ht/~scoopta/wlrobs -cd wlrobs +if [ ! -d "$U/wlrobs" ]; then + cd "$U" || exit + hg clone https://hg.sr.ht/~scoopta/wlrobs +fi +cd "$U"/wlrobs || exit hg pull -meson build +meson --reconfigure build ninja -C build -mkdir -pv ~/.config/obs-studio/plugins/wlrobs/bin/64bit -cp -v build/libwlrobs.so ~/.config/obs-studio/plugins/wlrobs/bin/64bit +mkdir -pv "$HOME"/.config/obs-studio/plugins/wlrobs/bin/64bit +cp -v build/libwlrobs.so "$HOME"/.config/obs-studio/plugins/wlrobs/bin/64bit