dotfiles

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs | README | LICENSE

commit f61ab667856a6896a0395a84c85cc4c1f139c630
parent e2225d418d38e53f63bb1c279cc8b9af45ea6e3a
Author: Luke Smith <luke@lukesmith.xyz>
Date:   Tue, 10 Apr 2018 23:08:43 -0700

Overhaul of screencasting scripts

Diffstat:
M.config/i3/config | 4+---
A.scripts/audio | 27+++++++++++++++++++++++++++
D.scripts/audio_alsa.sh | 18------------------
D.scripts/audio_pulse.sh | 18------------------
A.scripts/dmenurecord | 24++++++++++++++++++++++++
D.scripts/record | 8--------
A.scripts/screencast | 36++++++++++++++++++++++++++++++++++++
D.scripts/screencast_alsa.sh | 22----------------------
D.scripts/screencast_pulse.sh | 25-------------------------
A.scripts/video | 18++++++++++++++++++
D.scripts/video.sh | 21---------------------
11 files changed, 106 insertions(+), 115 deletions(-)

diff --git 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 @@ -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 @@ -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 @@ -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 @@ -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 @@ -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 @@ -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 @@ -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 @@ -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 b/.scripts/video @@ -0,0 +1,18 @@ +#!/bin/bash + +# 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: +ffmpeg \ +-f x11grab \ +-s $(xdpyinfo | grep dimensions | awk '{print $2;}') \ +-i :0.0 \ + -c:v libx264 -qp 0 -r 30 $filename diff --git a/.scripts/video.sh b/.scripts/video.sh @@ -1,21 +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/video$n.mkv ]] -do - n=$((n+1)) -done -filename="$HOME/video$n.mkv" - - -#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