aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.config/i3blocks/config5
-rw-r--r--.config/sway/config3
-rwxr-xr-x.local/bin/menurecord122
3 files changed, 129 insertions, 1 deletions
diff --git a/.config/i3blocks/config b/.config/i3blocks/config
index 000b092..337766a 100644
--- a/.config/i3blocks/config
+++ b/.config/i3blocks/config
@@ -1,3 +1,8 @@
+[recordingicon]
+command=cat /tmp/recordingicon 2> /dev/null
+interval=once
+signal=9
+
[packages]
command=sb-pacpackages
interval=once
diff --git a/.config/sway/config b/.config/sway/config
index 5940415..0326c79 100644
--- a/.config/sway/config
+++ b/.config/sway/config
@@ -60,6 +60,8 @@ bindsym $mod+j focus up
bindsym $mod+l focus right
bindsym $mod+f fullscreen
bindsym $mod+s layout toggle split
+bindsym Print exec menurecord
+bindsym Shift+Print exec menurecord kill
bindsym $mod+Shift+space floating toggle
bindsym $mod+Return exec $term
bindsym $mod+Shift+Return exec 'swaymsg mark swapme && swaymsg focus left && swaymsg swap container with mark swapme && swaymsg unmark swapme'
@@ -101,7 +103,6 @@ bindsym $mod+Shift+0 move container to workspace number 10
bindsym $mod+q kill
-bindsym $mod+Shift+e reload
bindsym $mod+Shift+q exec sysact
# INPUT
diff --git a/.local/bin/menurecord b/.local/bin/menurecord
new file mode 100755
index 0000000..953a1aa
--- /dev/null
+++ b/.local/bin/menurecord
@@ -0,0 +1,122 @@
+#!/bin/sh
+
+# Usage:
+# `$0`: Ask for recording type via dmenu
+# `$0 screencast`: Record both audio and screen
+# `$0 video`: Record only screen
+# `$0 audio`: Record only audio
+# `$0 kill`: Kill existing recording
+#
+# If there is already a running instance, user will be prompted to end it.
+
+getdim() {
+ screens=$(swaymsg -t get_outputs | grep name | awk -F'"' '{print $4}')
+ choice=$(printf "$screens\nExit\n" | bemenu)
+ [ "${choice}" != "Exit" ] || [ -z "${choice}" ] || exit &&
+ echo $choice
+}
+
+updateicon() { \
+ echo "$1" > /tmp/recordingicon
+ pkill -RTMIN+9 "${STATUSBAR:-i3blocks}"
+}
+
+killrecording() {
+ recpid="$(cat /tmp/recordingpid)"
+ echo $recpid
+ kill -2 "$recpid"
+ rm -f /tmp/recordingpid
+ updateicon ""
+ pkill -RTMIN+9 "${STATUSBAR:-i3blocks}"
+}
+
+screencast() { gpu-screen-recorder \
+ -w "$(getdim)" \
+ -f 60 \
+ -a default_output \
+ -a default_input \
+ -o "$HOME/screencast-$(date '+%y%m%d-%H%M-%S').mp4" &
+ echo $! > /tmp/recordingpid
+ updateicon "⏺️🎙️"
+}
+
+video() { gpu-screen-recorder \
+ -w "$(getdim)" \
+ -f 60 \
+ -o "$HOME/video-$(date '+%y%m%d-%H%M-%S').mkv" &
+ echo $! > /tmp/recordingpid
+ updateicon "⏺️"
+}
+
+webcamhidef() { ffmpeg \
+ -f v4l2 \
+ -i /dev/video0 \
+ -video_size 1920x1080 \
+ "$HOME/webcam-$(date '+%y%m%d-%H%M-%S').mkv" &
+ echo $! > /tmp/recordingpid
+ updateicon "🎥"
+}
+
+webcam() { ffmpeg \
+ -f v4l2 \
+ -i /dev/video0 \
+ -video_size 640x480 \
+ "$HOME/webcam-$(date '+%y%m%d-%H%M-%S').mkv" &
+ echo $! > /tmp/recordingpid
+ updateicon "🎥"
+}
+
+
+audio() { \
+ ffmpeg \
+ -f alsa -i default \
+ -c:a flac \
+ "$HOME/audio-$(date '+%y%m%d-%H%M-%S').flac" &
+ echo $! > /tmp/recordingpid
+ updateicon "🎙️"
+}
+
+askrecording() { \
+ choice=$(printf "screencast\\nvideo\\nvideo selected\\naudio\\nwebcam\\nwebcam (hi-def)" | bemenu -i -p "Select recording style:")
+ case "$choice" in
+ screencast) screencast;;
+ audio) audio;;
+ video) video;;
+ *selected) videoselected;;
+ webcam) webcam;;
+ "webcam (hi-def)") webcamhidef;;
+ esac
+}
+
+asktoend() { \
+ response=$(printf "No\\nYes" | bemenu -i -p "Recording still active. End recording?") &&
+ [ "$response" = "Yes" ] && killrecording
+}
+
+# needs rewrite and support by gpu-screen-recorder
+
+# videoselected()
+# {
+# slop -f "%x %y %w %h" > /tmp/slop
+# read -r X Y W H < /tmp/slop
+# rm /tmp/slop
+#
+# ffmpeg \
+# -f x11grab \
+# -framerate 30 \
+# -video_size "$W"x"$H" \
+# -i :0.0+"$X,$Y" \
+# -c:v libx264 -qp 0 -r 30 \
+# "$HOME/box-$(date '+%y%m%d-%H%M-%S').mkv" &
+# echo $! > /tmp/recordingpid
+# updateicon "⏺️"
+# }
+
+case "$1" in
+ screencast) screencast;;
+ audio) audio;;
+ video) video;;
+ # *selected) videoselected;;
+ kill) killrecording;;
+ *) ([ -f /tmp/recordingpid ] && asktoend && exit) || askrecording;;
+esac