Move screenshot keybindings to rofi menu

This commit is contained in:
Riyyi
2021-03-09 12:52:48 +01:00
parent df3d3bffd3
commit f30eb0df6e
3 changed files with 56 additions and 6 deletions
+5 -2
View File
@@ -67,7 +67,10 @@ screencast() {
# Kill with SIGKILL, just in case it is still running
pkill -9 ffmpeg
else
NAME=${1:-"output"}
width=1280
height=720
NAME=${1:-"$CAPTURE/$(date '+%Y-%m-%d-%H%M%S')_${width}x${height}_ffmpeg"}
[ -n "$2" ] && AUDIO_CODEC="-c:a aac"
[ -n "$2" ] && AUDIO_SOURCE="-f pulse -ac 2 -i $2" # 1 = system, 2 = mic
@@ -76,7 +79,7 @@ screencast() {
-threads 8 \
-f x11grab \
-framerate 30 \
-s 1280x720 \
-s "${width}x${height}" \
-i "$DISPLAY.0+640,180" \
$AUDIO_SOURCE \
-r 30 \
+47
View File
@@ -0,0 +1,47 @@
#!/bin/sh
# Take a screenshot with the configured program
# Depends: scrot / maim / magick
# User-config---------------------------
# scrot / maim / magick import
screenshotter="scrot"
# --------------------------------------
if [ "$screenshotter" = "scrot" ]; then
fullscreen=""
selection="-s"
activeWindow="-u"
filename="-e 'mv \$f $CAPTURE'"
elif [ "$screenshotter" = "maim" ]; then
fullscreen=""
selection="-s"
activeWindow="-i \$(xdotool getactivewindow)"
filename="$CAPTURE/$(date '+%Y-%m-%d-%H%M%S')_maim.png"
elif [ "$screenshotter" = "magick import" ] || [ "$screenshotter" = "import" ]; then
fullscreen="-window root"
selection=""
activeWindow="-window \$(xdotool getactivewindow)"
filename="$CAPTURE/$(date '+%Y-%m-%d-%H%M%S')_import.png"
else
echo "Printscreen configuration is invalid"
exit 1
fi
options="\
Selection
Active Window
Fullscreen"
choice=$(echo "$options" | rofi -no-fixed-num-lines -dmenu -i -p "Screenshot") || exit 0
command="$screenshotter"
[ "$choice" = "Selection" ] && command="$command $selection"
[ "$choice" = "Active Window" ] && command="$command $activeWindow"
[ "$choice" = "Fullscreen" ] && command="$command $fullscreen"
command="$command $filename"
eval "$command"