dmenurecord overhaul
This commit is contained in:
parent
be0b2f3aef
commit
f5cd0fefa5
2 changed files with 89 additions and 19 deletions
|
@ -24,7 +24,7 @@ gaps inner 15
|
|||
gaps outer 15
|
||||
set $term --no-startup-id $TERMINAL
|
||||
set $mod Mod4
|
||||
set $stoprec --no-startup-id killrecording
|
||||
set $stoprec --no-startup-id dmenurecord kill
|
||||
set $shutdown sudo -A shutdown -h now
|
||||
set $reboot sudo -A reboot
|
||||
set $netrefresh --no-startup-id sudo -A systemctl restart NetworkManager
|
||||
|
|
|
@ -1,25 +1,95 @@
|
|||
#!/bin/bash
|
||||
#!/bin/sh
|
||||
|
||||
# A dmenu recording prompt for my different recording scripts.
|
||||
# Usage:
|
||||
# `record`: Ask for recording type via dmenu
|
||||
# `record screencast`: Record both audio and screen
|
||||
# `record video`: Record only screen
|
||||
# `record audio`: Record only audio
|
||||
# `record kill`: Kill existing recording
|
||||
#
|
||||
# If there is already a running instance, user will be prompted to end it.
|
||||
|
||||
# Asks for type of recording and uses one of my three different scripts.
|
||||
asktype() { \
|
||||
case $(echo -e "Screencast\nVideo only\nAudio only" | dmenu -i -p "Select recording style:") in
|
||||
Screencast) screencast ;;
|
||||
"Audio only") audio ;;
|
||||
"Video only") video ;;
|
||||
esac ;}
|
||||
updateicon() { \
|
||||
echo "$1" > ~/.recordingicon
|
||||
pkill -RTMIN+9 i3blocks
|
||||
}
|
||||
|
||||
killrecording() {
|
||||
kill -9 "$(cat ~/.recordingpid)"
|
||||
rm -f ~/.recordingpid
|
||||
updateicon ""
|
||||
pkill -RTMIN+9 i3blocks
|
||||
exit
|
||||
}
|
||||
|
||||
# If already running, will ask to end previous recording.
|
||||
screencastpulse() { \
|
||||
ffmpeg -y \
|
||||
-f x11grab \
|
||||
-framerate 60 \
|
||||
-s $(xdpyinfo | grep dimensions | awk '{print $2;}') \
|
||||
-i :0.0 \
|
||||
-f alsa -i default \
|
||||
-r 30 \
|
||||
-c:v libx264rgb -crf 0 -preset ultrafast -c:a flac \
|
||||
"$HOME/screencast-$(date '+%y%m%d-%H%M-%S').mkv" &
|
||||
echo $! > ~/.recordingpid
|
||||
updateicon "⏺️🎙️"
|
||||
}
|
||||
|
||||
screencastalsa() { \
|
||||
ffmpeg -y \
|
||||
-f x11grab \
|
||||
-s $(xdpyinfo | grep dimensions | awk '{print $2;}') \
|
||||
-i :0.0 \
|
||||
-thread_queue_size 1024 \
|
||||
-f alsa -ar 44100 -i hw:1 \
|
||||
-c:v libx264 -r 30 -c:a flac \
|
||||
"$HOME/screencast-$(date '+%y%m%d-%H%M-%S').mkv" &
|
||||
echo $! > ~/.recordingpid
|
||||
updateicon "⏺️"
|
||||
}
|
||||
|
||||
video() { ffmpeg \
|
||||
-f x11grab \
|
||||
-s $(xdpyinfo | grep dimensions | awk '{print $2;}') \
|
||||
-i :0.0 \
|
||||
-c:v libx264 -qp 0 -r 30 \
|
||||
"$HOME/video-$(date '+%y%m%d-%H%M-%S').mkv" &
|
||||
echo $! > ~/.recordingpid
|
||||
updateicon "⏺️"
|
||||
}
|
||||
|
||||
audiopulse() { \
|
||||
ffmpeg \
|
||||
-f alsa -i default \
|
||||
-c:a flac \
|
||||
"$HOME/audio-$(date '+%y%m%d-%H%M-%S').mkv" &
|
||||
echo $! > ~/.recordingpid
|
||||
updateicon "🎙️"
|
||||
}
|
||||
|
||||
audioalsa() { \
|
||||
ffmpeg -y \
|
||||
-f alsa -ar 44100 -i hw:1 \
|
||||
"$HOME/audio-$(date '+%y%m%d-%H%M-%S').mkv" &
|
||||
echo $! > ~/.recordingpid
|
||||
updateicon "🎙️"
|
||||
}
|
||||
|
||||
askrecording() { \
|
||||
printf "screencast\\nvideo\\naudio" | dmenu -i -p "Select recording style:"
|
||||
}
|
||||
|
||||
asktoend() { \
|
||||
response=$(echo -e "No\nYes" | dmenu -i -p "Recording still active. End recording?") &&
|
||||
if [[ "$response" = "Yes" ]]; then killall ffmpeg; fi ;}
|
||||
response=$(printf "No\\nYes" | dmenu -i -p "Recording still active. End recording?") &&
|
||||
[ "$response" = "Yes" ] && killrecording
|
||||
}
|
||||
|
||||
if (( $(pgrep dmenurecord | wc -l) > 2 )); then
|
||||
asktoend;
|
||||
else
|
||||
asktype;
|
||||
fi
|
||||
echo "$response"
|
||||
|
||||
case "$1" in
|
||||
screencast) screencastpulse;;
|
||||
audio) audiopulse;;
|
||||
video) video;;
|
||||
kill) killrecording;;
|
||||
*) ([ -f ~/.recordingpid ] && asktoend && exit) || askrecording;;
|
||||
esac
|
||||
|
|
Loading…
Reference in a new issue