aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorYaroslav de la Peña Smirnov <yps@yaroslavps.com>2020-12-11 18:52:10 +0300
committerYaroslav de la Peña Smirnov <yps@yaroslavps.com>2020-12-11 19:02:21 +0300
commitd74a5a26385ebb21903da26e3d239a4929c4a5b7 (patch)
tree0705be303bc69a05a73a0e8ecbc6ca6e0020fd84
parent7cbd4c73ece6bc6b89d8b5c6febf6c3ead5de20a (diff)
downloadswayrice-d74a5a26385ebb21903da26e3d239a4929c4a5b7.tar.gz
swayrice-d74a5a26385ebb21903da26e3d239a4929c4a5b7.zip
Screen share hack
Hack to be able to share the screen under certain apps such as Zoom* by using v4l2loopback to create a fake webcam device to which wf-recorder outputs the contents of the screen. *Unfortunately because of the corona shit show my university requires to use this Chinese piece of crap spyware. This Covid nonsense seriously needs to end.
-rwxr-xr-xartix.sh20
-rwxr-xr-xdotfiles/.local/bin/camtoggle4
-rwxr-xr-xdotfiles/.local/bin/swayrecord25
3 files changed, 46 insertions, 3 deletions
diff --git a/artix.sh b/artix.sh
index e5022e9..17262e9 100755
--- a/artix.sh
+++ b/artix.sh
@@ -3,7 +3,25 @@
# Very basic helper script to install some programs and configs for an
# Artix+runit+Sway system
-pacman -Sy --noconfirm zsh zsh-syntax-highlighting openresolv wireguard-tools bind-tools sway swaylock swayidle waybar egl-wayland imv swaybg xorg-server-xwayland alacritty qt5-wayland wl-clipboard dbus tmux htop bemenu bemenu-wlroots mupdf mpd ncmpcpp mpc mpv libnotify mako cronie cronie-runit metalog metalog-runit dnsmasq dnsmasq-runit networkmanager networkmanager-runit rsync grim slurp ffmpeg w3m youtube-dl youtube-viewer newsboat wget curl inkscape gimp darktable gcc make fontconfig pkg-config fakeroot papirus-icon-theme alsa-utils pulseaudio pamixer pulseaudio-bluetooth imagemagick exiftool ntfs-3g unzip unrar gnome-themes-standard telegram-desktop qt5ct r bc udisks2 perl-term-readline-gnu transmission-cli transmission-remote-gtk python-pynvim python-pip python-pillow calcurse acpi acpid gnupg noto-fonts-cjk noto-fonts-emoji ttf-joypixels otf-latin-modern otf-latinmodern-math powerline-fonts python-pygit2 polkit polkit-gnome zathura zathura-pdf-mupdf zathura-djvu gst-libav vifm blueman bluez bluez-runit acpilight accountsservice lightdm xdg-user-dirs abook ranger terminus-font qutebrowser jq stow wdiff texlive-most units isync notmuch pass translate-shell gnome-keyring pacman-contrib
+pacman -Sy --noconfirm zsh zsh-syntax-highlighting openresolv wireguard-tools \
+ bind-tools sway swaylock swayidle waybar egl-wayland imv swaybg \
+ xorg-server-xwayland alacritty qt5-wayland wl-clipboard dbus tmux htop \
+ bemenu bemenu-wlroots mupdf mpd ncmpcpp mpc mpv libnotify mako cronie \
+ cronie-runit metalog metalog-runit dnsmasq dnsmasq-runit networkmanager \
+ networkmanager-runit rsync grim wf-recorder slurp ffmpeg w3m youtube-dl \
+ youtube-viewer newsboat wget curl inkscape gimp darktable gcc make \
+ fontconfig pkg-config fakeroot papirus-icon-theme alsa-utils pulseaudio \
+ pamixer pulseaudio-bluetooth imagemagick exiftool ntfs-3g unzip unrar \
+ gnome-themes-standard telegram-desktop qt5ct r bc udisks2 \
+ perl-term-readline-gnu transmission-cli transmission-remote-gtk \
+ python-pynvim python-pip python-pillow calcurse acpi acpid gnupg \
+ noto-fonts-cjk noto-fonts-emoji ttf-joypixels otf-latin-modern \
+ otf-latinmodern-math powerline-fonts python-pygit2 polkit polkit-gnome \
+ zathura zathura-pdf-mupdf zathura-djvu gst-libav vifm blueman bluez \
+ bluez-runit acpilight accountsservice lightdm xdg-user-dirs abook ranger \
+ terminus-font qutebrowser jq stow wdiff texlive-most units isync notmuch \
+ pass translate-shell gnome-keyring pacman-contrib linux-headers \
+ v4l2loopback-dkms
# Copy system config files
cp system/sudoers /etc/
diff --git a/dotfiles/.local/bin/camtoggle b/dotfiles/.local/bin/camtoggle
index 00fd201..a12fcb8 100755
--- a/dotfiles/.local/bin/camtoggle
+++ b/dotfiles/.local/bin/camtoggle
@@ -4,12 +4,14 @@
# If a second camera is present, use the second one
camera="/dev/video0"
[ -e /dev/video2 ] && camera="/dev/video2"
+[ -n "$1" ] && camera="$1"
pkill -f /dev/video || mpv \
--gpu-context=wayland \
+ --profile=low-latency \
--no-osc \
--no-input-default-bindings \
--input-conf=/dev/null \
--geometry=-0-0 \
--autofit=25% \
- --title="mpvfloat" "$camera"
+ --title="mpvfloat" "av://v4l2:$camera"
diff --git a/dotfiles/.local/bin/swayrecord b/dotfiles/.local/bin/swayrecord
index 5c1c2a6..23171e2 100755
--- a/dotfiles/.local/bin/swayrecord
+++ b/dotfiles/.local/bin/swayrecord
@@ -44,11 +44,18 @@ finishscreencast () {
"Screencast recording stopped and saved at "$VREC_DIR/screencast-$OUTPUT.mp4""
}
+finishscreenshare() {
+ kill -2 "$VIDEO_PID"
+ notify-send "📺 Recording" \
+ "Screen sharing stopped."
+}
+
finishrecording () {
case "$TYPE" in
video) finishvideo;;
audio) finishaudio;;
screencast) finishscreencast;;
+ screenshare) finishscreenshare;;
esac
rm -f ~/.cache/recordingpid
rm -f ~/.cache/recordingicon
@@ -71,6 +78,20 @@ video () {
wait
}
+screenshare () {
+ # Hack to share screen in certain apps under wayland wlroots-based compositors
+ loopbackcam="$(v4l2-ctl --list-devices | \
+ grep v4l2loopback -m1 -A1 | \
+ sed -e '1d' -e 's/\s//g')"
+ wf-recorder -x yuv420p -c rawvideo -m v4l2 -f $loopbackcam &
+ VIDEO_PID=$!
+ echo $$ > ~/.cache/recordingpid
+ echo "📺" > ~/.cache/recordingicon
+ notify-send "📺 Recording" "Screen share to fake webcam started"
+ killall -39 waybar
+ wait
+}
+
screencast () {
wf-recorder -f "$VREC_DIR/temp-$OUTPUT.mp4" &
VIDEO_PID=$!
@@ -94,10 +115,11 @@ audio () {
}
askrecording () {
- TYPE="$(printf "video\nscreencast\naudio\n" | bemenu -l 6 -i -p "What should be recorded?" --tf="$BEMENU_TF" --tb="$BEMENU_NB" --fb="$BEMENU_NB" --fn="$BEMENU_FN" --nb="$BEMENU_NB" --nf="$BEMENU_NF" --hf="$BEMENU_HF" --hb="$BEMENU_HB")"
+ TYPE="$(printf "video\nscreencast\nscreenshare\naudio\n" | bemenu -l 6 -i -p "What should be recorded?" --tf="$BEMENU_TF" --tb="$BEMENU_NB" --fb="$BEMENU_NB" --fn="$BEMENU_FN" --nb="$BEMENU_NB" --nf="$BEMENU_NF" --hf="$BEMENU_HF" --hb="$BEMENU_HB")"
case "$TYPE" in
video) video;;
screencast) screencast;;
+ screenshare) screenshare;;
audio) audio;;
*) exit;;
esac
@@ -111,6 +133,7 @@ fi
case $1 in
video) video;;
screencast) screencast;;
+ screenshare) screenshare;;
audio) audio;;
kill) killrecording;;
*) askrecording;;