aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--dotfiles/.config/sway/config9
-rwxr-xr-xdotfiles/.local/bin/barrecstatus2
-rwxr-xr-xdotfiles/.local/bin/swayrecord122
-rw-r--r--dotfiles/.profile2
4 files changed, 121 insertions, 14 deletions
diff --git a/dotfiles/.config/sway/config b/dotfiles/.config/sway/config
index 3d4b705..3320a29 100644
--- a/dotfiles/.config/sway/config
+++ b/dotfiles/.config/sway/config
@@ -186,9 +186,9 @@ bindsym --to-code {
$mod+Ctrl+v exec $term -e vis
$mod+o exec --no-startup-id notistats
$mod+c exec --no-startup-id camtoggle
- $mod+grave exec --no-startup-id menuducksearch
- $mod+Shift+grave exec --no-startup-id menuemoji
- $mod+F1 exec --no-startup-id zathura ~/.config/i3/i3guide.pdf
+ $mod+grave exec --no-startup-id menuemoji
+ $mod+Shift+grave exec --no-startup-id menuducksearch
+ # $mod+F1 exec --no-startup-id zathura ~/.config/i3/i3guide.pdf # TODO: update guide
# Network management
$mod+Shift+c exec togglevpn
@@ -198,7 +198,8 @@ bindsym --to-code {
# Screenshot and recording
Print exec --no-startup-id menugrim -q
$mod+Print exec --no-startup-id menugrim
- Shift+Print exec --no-startup-id swayrecord
+ Shift+Print exec --no-startup-id "swayrecord screencast"
+ Ctrl+Print exec --no-startup-id swayrecord
# Sound
$mod+Shift+m exec $term -e 'ncpamixer'
diff --git a/dotfiles/.local/bin/barrecstatus b/dotfiles/.local/bin/barrecstatus
index b7bb8b4..3e6317b 100755
--- a/dotfiles/.local/bin/barrecstatus
+++ b/dotfiles/.local/bin/barrecstatus
@@ -1,7 +1,7 @@
#!/bin/sh
if [ -f "$HOME/.cache/recordingpid" ]; then
- printf "⏺ rec"
+ printf "%s rec" "$(cat "$HOME/.cache/recordingicon")"
exit
fi
diff --git a/dotfiles/.local/bin/swayrecord b/dotfiles/.local/bin/swayrecord
index 378b46f..f93ae87 100755
--- a/dotfiles/.local/bin/swayrecord
+++ b/dotfiles/.local/bin/swayrecord
@@ -1,14 +1,118 @@
#!/bin/sh
+# Source settings from .bemenurc
+. $HOME/.bemenurc
+
+if ! [ -d $VREC_DIR ]; then
+ mkdir -p $VREC_DIR
+fi
+if ! [ -d $AREC_DIR ]; then
+ mkdir -p $AREC_DIR
+fi
+
+OUTPUT="$(date '+%y%m%d-%H%M-%S')"
+TYPE="$1"
+VIDEO_PID=""
+AUDIO_PID=""
+
+trap finishrecording SIGINT
+
+finishvideo () {
+ kill -2 "$VIDEO_PID"
+ notify-send "⏺ Recording" \
+ "Screen recording stopped and saved at "$VREC_DIR"/video-"$OUTPUT".mp4"
+}
+
+finishaudio () {
+ kill -2 "$AUDIO_PID"
+ notify-send "🎙 Recording" \
+ "Audio recording stopped and saved at "$AREC_DIR/$OUTPUT.flac""
+}
+
+finishscreencast () {
+ kill -2 "$VIDEO_PID"
+ kill -2 "$AUDIO_PID"
+ notify-send "📼 Recording" "One moment, screencast is being encoded..."
+ ffmpeg -i "$VREC_DIR/temp-$OUTPUT.mp4" \
+ -i "$VREC_DIR/temp-$OUTPUT.mp3" \
+ -codec copy \
+ -shortest \
+ "$VREC_DIR/screencast-$OUTPUT.mp4"
+ rm -f "$VREC_DIR/temp-$OUTPUT.mp4"
+ rm -f "$VREC_DIR/temp-$OUTPUT.mp3"
+ notify-send "📼 Recording" \
+ "Screencast recording stopped and saved at "$VREC_DIR/screencast-$OUTPUT.mp4""
+}
+
+finishrecording () {
+ case "$TYPE" in
+ video) finishvideo;;
+ audio) finishaudio;;
+ screencast) finishscreencast;;
+ esac
+ rm -f ~/.cache/recordingpid
+ rm -f ~/.cache/recordingicon
+ killall -39 waybar
+}
+
+killrecording () {
+ RECPID="$(cat "$HOME/.cache/recordingpid")"
+ kill -2 "$RECPID"
+ exit
+}
+
+video () {
+ wf-recorder -f "$VREC_DIR/video-$OUTPUT.mp4" &
+ VIDEO_PID=$!
+ echo $$ > ~/.cache/recordingpid
+ echo "⏺" > ~/.cache/recordingicon
+ notify-send "⏺ Recording" "Screen recording started"
+ killall -39 waybar
+ wait
+}
+
+screencast () {
+ wf-recorder -f "$VREC_DIR/temp-$OUTPUT.mp4" &
+ VIDEO_PID=$!
+ ffmpeg -f alsa -i default -c:a mp3 "$VREC_DIR/temp-$OUTPUT.mp3" &
+ AUDIO_PID=$!
+ echo $$ > ~/.cache/recordingpid
+ echo "📼" > ~/.cache/recordingicon
+ notify-send "📼 Recording" "Screencast recording started"
+ killall -39 waybar
+ wait
+}
+
+audio () {
+ ffmpeg -f alsa -i default -c:a flac "$AREC_DIR/$OUTPUT.flac" &
+ AUDIO_PID=$!
+ echo $$ > ~/.cache/recordingpid
+ echo "🎙" > ~/.cache/recordingicon
+ notify-send "🎙 Recording" "Audio recording started"
+ killall -39 waybar
+ wait
+}
+
+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")"
+ case "$TYPE" in
+ video) video;;
+ screencast) screencast;;
+ audio) audio;;
+ *) exit;;
+ esac
+}
+
if [ -f "$HOME/.cache/recordingpid" ]; then
- killall -SIGINT wf-recorder
- rm -f ~/.cache/recordingpid
- notify-send "⏺ Screen recording" "Recording stopped"
- killall -39 waybar
- exit
+ killrecording
+ exit
fi
-wf-recorder -f "$HOME/Videos/recordings/$(date '+%y%m%d-%H%M-%S').mp4" &
-echo $! > ~/.cache/recordingpid
-notify-send "⏺ Screen recording" "Recording started"
-killall -39 waybar
+case $1 in
+ video) video;;
+ screencast) screencast;;
+ audio) audio;;
+ kill) killrecording;;
+ *) askrecording;;
+esac
+
diff --git a/dotfiles/.profile b/dotfiles/.profile
index 5e37a2f..d2303ab 100644
--- a/dotfiles/.profile
+++ b/dotfiles/.profile
@@ -1,5 +1,7 @@
export PATH=$PATH:$HOME/.local/bin
export SCROT_DIR=$HOME/Pictures/screenshots/
+export VREC_DIR=$HOME/Videos/recordings/
+export AREC_DIR=$HOME/Documents/audio/recordings/
#export GDK_BACKEND=wayland
export EGL_PLATFORM=wayland
export CLUTTER_PLATFORM=wayland