summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ar/.config/lf/lfrc2
-rw-r--r--ar/.config/mimeapps.list1
-rwxr-xr-xar/.local/bin/dmenurecord103
-rw-r--r--global/.local/share/applications/music.desktop4
-rw-r--r--global/.local/share/applications/video.desktop2
5 files changed, 89 insertions, 23 deletions
diff --git a/ar/.config/lf/lfrc b/ar/.config/lf/lfrc
index 0ea7f13..76d5300 100644
--- a/ar/.config/lf/lfrc
+++ b/ar/.config/lf/lfrc
@@ -283,7 +283,7 @@ cmd open ${{
application/pgp-encrypted) $EDITOR $fx ;;
application/vnd.oasis.opendocument.text|application/vnd.oasis.opendocument.spreadsheet|application/vnd.oasis.opendocument.spreadsheet-template|application/vnd.oasis.opendocument.presentation-template|application/vnd.oasis.opendocument.presentation|application/vnd.ms-powerpoint|application/vnd.oasis.opendocument.graphics|application/vnd.oasis.opendocument.graphics-template|application/vnd.oasis.opendocument.formula|application/vnd.oasis.opendocument.database) setsid -f firefox $fx >/dev/null 2>&1 ;;
application/x-hwp|application/vnd.openxmlformats-officedocument.presentationml.presentation|application/vnd.openxmlformats-officedocument.wordprocessingml.document) libreoffice $fx ;;
- audio/*|video/x-ms-asf) mpv --x11-name=music --audio-display=no $f ;;
+ audio/*|video/x-ms-asf) setsid -f mpv --volume=50 --x11-name=music --force-window=yes --audio-display=embedded-first $f >/dev/null 2>&1 ;;
image/x-xcf) setsid -f gimp $f >/dev/null 2>&1 ;;
image/svg+xml) display -- $f ;;
image/*) rotdir $f | grep -i "\.\(png\|jpg\|jpeg\|gif\|webp\|avif\|tif\|ico\)\(_large\)*$" |
diff --git a/ar/.config/mimeapps.list b/ar/.config/mimeapps.list
index 2792367..479bbf8 100644
--- a/ar/.config/mimeapps.list
+++ b/ar/.config/mimeapps.list
@@ -5,6 +5,7 @@
# To add options for mimeopen, add MimeType in .desktop
# eg. MimeType=text/markdown;text/x-markdown;
+audio/flac=music.desktop;
application/json=librewolf.desktop;firefox.desktop;
application/pdf=pdf.desktop;
application/postscript=pdf.desktop;
diff --git a/ar/.local/bin/dmenurecord b/ar/.local/bin/dmenurecord
index 037930b..621133d 100755
--- a/ar/.local/bin/dmenurecord
+++ b/ar/.local/bin/dmenurecord
@@ -28,6 +28,43 @@ killrecording() {
pkill -RTMIN+24 "${STATUSBAR:-dwmblocks}"
}
+getmonitor() {
+ xrandr | awk '
+ /^[^ ]+ connected/ {
+ name=$1
+ if (match($0, /([0-9]+)x([0-9]+)\+([0-9]+)\+([0-9]+)/, a)) {
+ printf "%s %s %s+%s\n", name, a[1] "x" a[2], a[3], a[4]
+ }
+ }
+ '
+}
+
+selectmonitor() {
+ map=$(getmonitor)
+ [ -n "$map" ] || exit 1
+
+ names=$(printf "%s\n" "$map" | awk '{print $1}')
+ monitor_count=$(printf "%s\n" "$names" | wc -l)
+
+ if [ "$monitor_count" -ge 2 ]; then
+ options=$(printf "%s\nall" "$names")
+ choice=$(printf "%s\n" "$options" | dmenu -p "Select monitor to record:")
+ [ -n "$choice" ] || exit 1
+
+ if [ "$choice" = "all" ]; then
+ echo "all"
+ else
+ line=$(printf "%s\n" "$map" | awk -v mon="$choice" '$1 == mon')
+ [ -n "$line" ] || exit 1
+ res=$(echo "$line" | awk '{print $2}')
+ pos=$(echo "$line" | awk '{print $3}')
+ echo "$res+$pos"
+ fi
+ else
+ echo "all"
+ fi
+}
+
screencast() {
ffmpeg -y \
-f x11grab \
@@ -44,6 +81,27 @@ screencast() {
updateicon "⏺️🎙️"
}
+screencastselected() {
+ geometry=$(selectmonitor) || exit 1
+ if [ "$geometry" = "all" ]; then
+ screencast
+ else
+ ffmpeg -y \
+ -f x11grab \
+ -framerate 30 \
+ -video_size "${geometry%%+*}" \
+ -i "$DISPLAY+${geometry#*+}" \
+ -r 24 \
+ -use_wallclock_as_timestamps 1 \
+ -f alsa -thread_queue_size 1024 -i default \
+ -c:v h264 \
+ -crf 0 -preset ultrafast -c:a aac \
+ "$recordings/screencast-$(date '+%y%m%d-%H%M-%S').mp4" &
+ echo $! >/tmp/recordingpid
+ updateicon "⏺️🎙️"
+ fi
+}
+
video() {
ffmpeg \
-f x11grab \
@@ -56,6 +114,22 @@ video() {
updateicon "⏺️"
}
+videoselected() {
+ slop -f "%x %y %w %h" >/tmp/slop
+ read -r X Y W H </tmp/slop
+ rm /tmp/slop
+
+ ffmpeg \
+ -f x11grab \
+ -framerate 30 \
+ -video_size "$W"x"$H" \
+ -i :0.0+"$X,$Y" \
+ -c:v libx264 -qp 0 -r 30 \
+ "$recordings/box-$(date '+%y%m%d-%H%M-%S').mkv" &
+ echo $! >/tmp/recordingpid
+ updateicon "⏺️"
+}
+
webcamselect() {
cameras=$(
v4l2-ctl --list-devices | awk '
@@ -112,12 +186,13 @@ audio() {
}
askrecording() {
- choice=$(printf "screencast\\nvideo\\nvideo selected\\naudio\\nwebcam\\nwebcam (hi-def)" | dmenu -i -p "Select recording style:")
+ choice=$(printf "screencast\\nscreencast selected\\nvideo\\nvideo selected\\naudio\\nwebcam\\nwebcam (hi-def)" | dmenu -i -p "Select recording style:")
case "$choice" in
screencast) screencast ;;
+ "screencast selected") screencastselected ;;
audio) audio ;;
video) video ;;
- *selected) videoselected ;;
+ "video selected") videoselected ;;
webcam) webcamselect && webcam ;;
"webcam (hi-def)") webcamselect && webcamhidef ;;
*) exit ;;
@@ -125,24 +200,9 @@ askrecording() {
}
asktoend() {
- response=$(printf "No\\nYes" | dmenu -i -p "Recording still active. End recording?") &&
- [ "$response" = "Yes" ] && killrecording
-}
-
-videoselected() {
- slop -f "%x %y %w %h" >/tmp/slop
- read -r X Y W H </tmp/slop
- rm /tmp/slop
-
- ffmpeg \
- -f x11grab \
- -framerate 30 \
- -video_size "$W"x"$H" \
- -i :0.0+"$X,$Y" \
- -c:v libx264 -qp 0 -r 30 \
- "$recordings/box-$(date '+%y%m%d-%H%M-%S').mkv" &
- echo $! >/tmp/recordingpid
- updateicon "⏺️"
+ response=$(printf "No\\nYes" | dmenu -i -p "Recording still active. End recording?")
+ [ -z "$response" ] && exit
+ [ "$response" = "Yes" ] && killrecording
}
recordings="${XDG_VIDEOS_DIR:-$HOME/Videos}/recordings"
@@ -153,7 +213,8 @@ case "$1" in
-a | --audio | audio) audio ;;
-k | --kill | kill) killrecording ;;
-s | --screencast | screencast) screencast ;;
+-ss | --screencast-selected | "screencast selected") screencastselected ;;
-v | --video | video) video ;;
-*selected) videoselected ;;
+-vs | --video-selected | "video selected") videoselected ;;
*) ([ -f /tmp/recordingpid ] && asktoend && exit) || askrecording ;;
esac
diff --git a/global/.local/share/applications/music.desktop b/global/.local/share/applications/music.desktop
new file mode 100644
index 0000000..0341723
--- /dev/null
+++ b/global/.local/share/applications/music.desktop
@@ -0,0 +1,4 @@
+[Desktop Entry]
+Type=Application
+Name=Video Viewer
+Exec=/usr/bin/mpv --quiet --volume=50 --x11-name=music --force-window=yes --audio-display=embedded-first %f
diff --git a/global/.local/share/applications/video.desktop b/global/.local/share/applications/video.desktop
index 2814690..5f5def8 100644
--- a/global/.local/share/applications/video.desktop
+++ b/global/.local/share/applications/video.desktop
@@ -1,4 +1,4 @@
[Desktop Entry]
Type=Application
Name=Video Viewer
-Exec=/usr/bin/mpv -quiet %f
+Exec=/usr/bin/mpv --x11-name=video --quiet %f