summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLuke Smith <luke@lukesmith.xyz>2018-04-10 23:08:43 -0700
committerLuke Smith <luke@lukesmith.xyz>2018-04-10 23:08:43 -0700
commitf61ab667856a6896a0395a84c85cc4c1f139c630 (patch)
tree2d9c9c6353d837e53695cb3d664d4926a25ad33c
parente2225d418d38e53f63bb1c279cc8b9af45ea6e3a (diff)
downloadeibhear-f61ab667856a6896a0395a84c85cc4c1f139c630.tar.gz
eibhear-f61ab667856a6896a0395a84c85cc4c1f139c630.tar.zst
eibhear-f61ab667856a6896a0395a84c85cc4c1f139c630.zip
Overhaul of screencasting scripts
-rw-r--r--.config/i3/config4
-rwxr-xr-x.scripts/audio27
-rwxr-xr-x.scripts/audio_alsa.sh18
-rwxr-xr-x.scripts/audio_pulse.sh18
-rwxr-xr-x.scripts/dmenurecord24
-rwxr-xr-x.scripts/record8
-rwxr-xr-x.scripts/screencast36
-rwxr-xr-x.scripts/screencast_alsa.sh22
-rwxr-xr-x.scripts/screencast_pulse.sh25
-rwxr-xr-x.scripts/video (renamed from .scripts/video.sh)11
10 files changed, 92 insertions, 101 deletions
diff --git a/.config/i3/config b/.config/i3/config
index a14498b..021e330 100644
--- a/.config/i3/config
+++ b/.config/i3/config
@@ -26,8 +26,6 @@ set $term --no-startup-id st
set $stoprec --no-startup-id killall ffmpeg
# #---Starting External Scripts---# #
-#Increase key rate
-exec --no-startup-id xset r rate 300 50
#Music player daemon:
exec --no-startup-id mpd
#Torrent daemon:
@@ -367,7 +365,7 @@ bindsym $mod+Shift+bracketright exec $bigfor
# For screenshots and recording
bindsym Print exec --no-startup-id scrot
bindsym Shift+Print exec --no-startup-id scrot -u
-bindsym $mod+Print exec --no-startup-id record
+bindsym $mod+Print exec --no-startup-id dmenurecord
bindsym $mod+Scroll_Lock exec --no-startup-id "killall screenkey || screenkey"
bindsym $mod+Delete exec $stoprec
bindsym XF86Launch1 exec $stoprec & xset dpms force off
diff --git a/.scripts/audio b/.scripts/audio
new file mode 100755
index 0000000..cb630c8
--- /dev/null
+++ b/.scripts/audio
@@ -0,0 +1,27 @@
+#!/bin/bash
+
+# This script records audio.
+# It runs an appropriate record script for either ALSA and Pulseaudio.
+# It also names files smartly to prevent overwrites.
+
+# Picks a file name for the output file based on availability:
+while [[ -f $HOME/screencast$n.mkv ]]
+do
+ n=$((n+1))
+done
+filename="$HOME/screencast$n.mkv"
+
+# For Pulseaudio with ALSA:
+record_pulse() { \
+ffmpeg \
+-f alsa -i default \
+-c:a flac \
+$filename ;}
+
+# For ALSA:
+record_alsa() { \
+ffmpeg -y \
+-f alsa -ar 44100 -i hw:1 \
+$filename ;}
+
+if [[ $(pgrep -x pulseaudio) ]]; then record_pulse; else record_alsa; fi
diff --git a/.scripts/audio_alsa.sh b/.scripts/audio_alsa.sh
deleted file mode 100755
index cda07a2..0000000
--- a/.scripts/audio_alsa.sh
+++ /dev/null
@@ -1,18 +0,0 @@
-#!/bin/bash
-
-#This is the ffmpeg command that the screencast shortcut in i3 will run.
-
-#Picks a file name for the output file based on availability:
-
-while [[ -f $HOME/audio$n.flac ]]
-do
- n=$((n+1))
-done
-filename="$HOME/audio$n.flac"
-
-#The actual ffmpeg command:
-
-ffmpeg -y \
- -f alsa -ar 44100 -i hw:1 \
- $filename
-
diff --git a/.scripts/audio_pulse.sh b/.scripts/audio_pulse.sh
deleted file mode 100755
index 21e46ea..0000000
--- a/.scripts/audio_pulse.sh
+++ /dev/null
@@ -1,18 +0,0 @@
-#!/bin/bash
-
-#This is the ffmpeg command that the audio shortcut in i3 will run.
-
-#Picks a file name for the output file based on availability:
-
-while [[ -f $HOME/audio$n.flac ]]
-do
- n=$((n+1))
-done
-filename="$HOME/audio$n.flac"
-
-#The actual ffmpeg command:
-
-ffmpeg \
--f alsa -i default \
--c:a flac \
-$filename
diff --git a/.scripts/dmenurecord b/.scripts/dmenurecord
new file mode 100755
index 0000000..75cc6ff
--- /dev/null
+++ b/.scripts/dmenurecord
@@ -0,0 +1,24 @@
+#!/bin/bash
+
+# A dmenu recording prompt for my different recording scripts.
+
+# 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 ;}
+
+# If already running, will ask to end previous recording.
+
+asktoend() { \
+response=$(echo -e "No\nYes" | dmenu -i -p "Recording still active. End recording?") &&
+if [[ "$response" = "Yes" ]]; then killall ffmpeg; fi ;}
+
+if (( $(pgrep dmenurecord | wc -l) > 2 )); then
+asktoend;
+else
+asktype;
+fi
+echo $response
diff --git a/.scripts/record b/.scripts/record
deleted file mode 100755
index df1926f..0000000
--- a/.scripts/record
+++ /dev/null
@@ -1,8 +0,0 @@
-#!/bin/bash
-# A dmenu recording prompt for my different
-
-case $(echo -e "Screencast\nVideo only\nAudio only" | dmenu -i -p "Select recording style:") in
- Screencast) (pgrep -x pulseaudio && screencast_pulse.sh) || screencast_alsa.sh ;;
- "Audio only") (pgrep -x pulseaudio && audio_pulse.sh) || audio_alsa.sh ;;
- "Video only") video.sh ;;
-esac
diff --git a/.scripts/screencast b/.scripts/screencast
new file mode 100755
index 0000000..cd37ab9
--- /dev/null
+++ b/.scripts/screencast
@@ -0,0 +1,36 @@
+#!/bin/bash
+
+# This script records a screencast with audio and video.
+# It runs an appropriate record script for either ALSA and Pulseaudio.
+# It also names files smartly to prevent overwrites.
+
+# Picks a file name for the output file based on availability:
+while [[ -f $HOME/screencast$n.mkv ]]
+do
+ n=$((n+1))
+done
+filename="$HOME/screencast$n.mkv"
+
+# For Pulseaudio with ALSA:
+record_pulse() { \
+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 $filename ;}
+
+# For ALSA:
+record_alsa() { \
+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 $filename ;}
+
+
+if [[ $(pgrep -x pulseaudio) ]]; then record_pulse; else record_alsa; fi
diff --git a/.scripts/screencast_alsa.sh b/.scripts/screencast_alsa.sh
deleted file mode 100755
index 95c1d5d..0000000
--- a/.scripts/screencast_alsa.sh
+++ /dev/null
@@ -1,22 +0,0 @@
-#!/bin/bash
-
-#This is the ffmpeg command that the screencast shortcut in i3 will run.
-
-#Picks a file name for the output file based on availability:
-
-while [[ -f $HOME/screencast$n.mkv ]]
-do
- n=$((n+1))
-done
-filename="$HOME/screencast$n.mkv"
-
-#The actual ffmpeg command:
-
-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 $filename
- #-c:v ffvhuff -r 30 -c:a flac $filename
diff --git a/.scripts/screencast_pulse.sh b/.scripts/screencast_pulse.sh
deleted file mode 100755
index 871a5b9..0000000
--- a/.scripts/screencast_pulse.sh
+++ /dev/null
@@ -1,25 +0,0 @@
-#!/bin/bash
-
-#This is the ffmpeg command that the screencast shortcut in i3 will run.
-
-#Picks a file name for the output file based on availability:
-
-while [[ -f $HOME/screencast$n.mkv ]]
-do
- n=$((n+1))
-done
-filename="$HOME/screencast$n.mkv"
-
-#The actual ffmpeg command:
-
-ffmpeg -y \
--f x11grab \
--framerate 60 \
--s $(xdpyinfo | grep dimensions | awk '{print $2;}') \
--i :0.0 \
--thread_queue_size 2048 \
--f alsa -i default \
--r 30 \
- -c:v libx264 -r 30 -c:a flac $filename
- #-c:v ffvhuff -r 30 -c:a flac $filename
- #-f pulse -ac 1 -ar 44100 -i default \
diff --git a/.scripts/video.sh b/.scripts/video
index ac3dc5c..357464f 100755
--- a/.scripts/video.sh
+++ b/.scripts/video
@@ -1,21 +1,18 @@
#!/bin/bash
-#This is the ffmpeg command that the screencast shortcut in i3 will run.
-
-#Picks a file name for the output file based on availability:
+# This script records video.
+# It also names files smartly to prevent overwrites.
+# Picks a file name for the output file based on availability:
while [[ -f $HOME/video$n.mkv ]]
do
n=$((n+1))
done
filename="$HOME/video$n.mkv"
-
-#The actual ffmpeg command:
-
+# The actual ffmpeg command:
ffmpeg \
-f x11grab \
-s $(xdpyinfo | grep dimensions | awk '{print $2;}') \
-i :0.0 \
-c:v libx264 -qp 0 -r 30 $filename
- #-c:v ffvhuff -r 30 -c:a flac $filename