From d7749a064a28c3c7a11a8791a8b7bc0036fe617a Mon Sep 17 00:00:00 2001 From: Raymaekers Luca Date: Wed, 7 May 2025 17:18:36 +0200 Subject: checkpoint --- bin/extra/alarm | 30 ++++++ bin/extra/compress_discord | 37 +++++++ bin/extra/discord_compress | 37 ------- config/extra/jftui/input.conf | 232 +++++++++++++++++++++++++++++++++++++++++- config/extra/jftui/mpv.conf | 23 +++++ 5 files changed, 321 insertions(+), 38 deletions(-) create mode 100755 bin/extra/alarm create mode 100755 bin/extra/compress_discord delete mode 100755 bin/extra/discord_compress mode change 120000 => 100644 config/extra/jftui/input.conf create mode 100644 config/extra/jftui/mpv.conf diff --git a/bin/extra/alarm b/bin/extra/alarm new file mode 100755 index 0000000..f7a417f --- /dev/null +++ b/bin/extra/alarm @@ -0,0 +1,30 @@ +#!/bin/sh + +if [ "$1" ] +then + AlarmTime="$1" +else + >&2 printf 'time: ' + AlarmTime="$(head -n 1)" +fi +[ "$AlarmTime" ] || exit 1 + +AlarmTimeSeconds="$(date -d "$AlarmTime" '+%s')" +[ "$AlarmTimeSeconds" ] || exit 1 + +TimeNowSeconds="$(date '+%s')" +SecondsToSleep="$((AlarmTimeSeconds - TimeNowSeconds))" +>&2 printf 'now: %s\n' "$(date '+%T')" + + +if [ "$SecondsToSleep" -gt 0 ] +then + >&2 printf 'Sleeping %s seconds...\n' "$SecondsToSleep" + sleep "$SecondsToSleep" >/dev/null 2>&1 +else + >&2 printf 'Not sleeping\n' +fi + +>&2 printf 'press [q] to quit ' +mpv --loop --volume=100 --msg-level=all=no --resume-playback=no ~/sync/share/sounds/pomo.aac 2>/dev/null +>&2 printf '\n' diff --git a/bin/extra/compress_discord b/bin/extra/compress_discord new file mode 100755 index 0000000..eacc364 --- /dev/null +++ b/bin/extra/compress_discord @@ -0,0 +1,37 @@ +#!/bin/sh + +# Compresses a video to a target size, for configuration see VARIABLES +# From: https://trac.ffmpeg.org/wiki/Encode/H.264#Two-PassExample +# +# $1: input file + +# VARIABLES +video_codec="libx264" +audio_codec="aac" +audio_bitrate="96" +target_size="8" + +MEGABIT="8388" + +# Main + +input="$1" +if [ -z "$input" ] +then + >&2 printf 'Usage: discord_compress \n' + exit 1 +fi + +duration="$(date -u -d @"$(ffprobe -show_entries format=duration -v quiet -of csv="p=0" -i "$input")" +'%s')" + +video_bitrate="$(((target_size * MEGABIT / duration) - audio_bitrate))" +[ "$video_bitrate" ] || exit 1 + +common_args="-hide_banner -v quiet -stats -y -hwaccel auto -i $input -c:v $video_codec -b:v ${video_bitrate}K" + +set -ex + +ffmpeg $common_args -pass 1 -an -f null /dev/null +ffmpeg $common_args -pass 2 -c:a "$audio_codec" -b:a "${audio_bitrate}K" compressed_"${input%.*}".mp4 + +rm -f ffmpeg2pass*.log* diff --git a/bin/extra/discord_compress b/bin/extra/discord_compress deleted file mode 100755 index eacc364..0000000 --- a/bin/extra/discord_compress +++ /dev/null @@ -1,37 +0,0 @@ -#!/bin/sh - -# Compresses a video to a target size, for configuration see VARIABLES -# From: https://trac.ffmpeg.org/wiki/Encode/H.264#Two-PassExample -# -# $1: input file - -# VARIABLES -video_codec="libx264" -audio_codec="aac" -audio_bitrate="96" -target_size="8" - -MEGABIT="8388" - -# Main - -input="$1" -if [ -z "$input" ] -then - >&2 printf 'Usage: discord_compress \n' - exit 1 -fi - -duration="$(date -u -d @"$(ffprobe -show_entries format=duration -v quiet -of csv="p=0" -i "$input")" +'%s')" - -video_bitrate="$(((target_size * MEGABIT / duration) - audio_bitrate))" -[ "$video_bitrate" ] || exit 1 - -common_args="-hide_banner -v quiet -stats -y -hwaccel auto -i $input -c:v $video_codec -b:v ${video_bitrate}K" - -set -ex - -ffmpeg $common_args -pass 1 -an -f null /dev/null -ffmpeg $common_args -pass 2 -c:a "$audio_codec" -b:a "${audio_bitrate}K" compressed_"${input%.*}".mp4 - -rm -f ffmpeg2pass*.log* diff --git a/config/extra/jftui/input.conf b/config/extra/jftui/input.conf deleted file mode 120000 index 312e856..0000000 --- a/config/extra/jftui/input.conf +++ /dev/null @@ -1 +0,0 @@ -/home/void/.config/mpv/input.conf \ No newline at end of file diff --git a/config/extra/jftui/input.conf b/config/extra/jftui/input.conf new file mode 100644 index 0000000..5615d5f --- /dev/null +++ b/config/extra/jftui/input.conf @@ -0,0 +1,231 @@ +# mpv keybindings +# +# Location of user-defined bindings: ~/.config/mpv/input.conf +# +# Lines starting with # are comments. Use SHARP to assign the # key. +# Copy this file and uncomment and edit the bindings you want to change. +# +# List of commands and further details: DOCS/man/input.rst +# List of special keys: --input-keylist +# Keybindings testing mode: mpv --input-test --force-window --idle +# +# Use 'ignore' to unbind a key fully (e.g. 'ctrl+a ignore'). +# +# Strings need to be quoted and escaped: +# KEY show-text "This is a single backslash: \\ and a quote: \" !" +# +# You can use modifier-key combinations like Shift+Left or Ctrl+Alt+x with +# the modifiers Shift, Ctrl, Alt and Meta (may not work on the terminal). +# +# The default keybindings are hardcoded into the mpv binary. +# You can disable them completely with: --no-input-default-bindings + +# Developer note: +# On compilation, this file is baked into the mpv binary, and all lines are +# uncommented (unless '#' is followed by a space) - thus this file defines the +# default key bindings. + +# If this is enabled, treat all the following bindings as default. +#default-bindings start + +#MBTN_LEFT ignore # don't do anything +#MBTN_LEFT_DBL cycle fullscreen # toggle fullscreen +#MBTN_RIGHT cycle pause # toggle pause/playback mode +#MBTN_BACK playlist-prev # skip to the previous file +#MBTN_FORWARD playlist-next # skip to the next file + +# Mouse wheels, touchpad or other input devices that have axes +# if the input devices supports precise scrolling it will also scale the +# numeric value accordingly +#WHEEL_UP seek 10 # seek 10 seconds forward +#WHEEL_DOWN seek -10 # seek 10 seconds backward +#WHEEL_LEFT add volume -2 +#WHEEL_RIGHT add volume 2 + +## Seek units are in seconds, but note that these are limited by keyframes +#RIGHT seek 5 # seek 5 seconds forward +#LEFT seek -5 # seek 5 seconds backward +#UP seek 60 # seek 1 minute forward +#DOWN seek -60 # seek 1 minute backward +# Do smaller, always exact (non-keyframe-limited), seeks with shift. +# Don't show them on the OSD (no-osd). +#Shift+RIGHT no-osd seek 1 exact # seek exactly 1 second forward +#Shift+LEFT no-osd seek -1 exact # seek exactly 1 second backward +#Shift+UP no-osd seek 5 exact # seek exactly 5 seconds forward +#Shift+DOWN no-osd seek -5 exact # seek exactly 5 seconds backward +#Ctrl+LEFT no-osd sub-seek -1 # seek to the previous subtitle +#Ctrl+RIGHT no-osd sub-seek 1 # seek to the next subtitle +#Ctrl+Shift+LEFT sub-step -1 # change subtitle timing such that the previous subtitle is displayed +#Ctrl+Shift+RIGHT sub-step 1 # change subtitle timing such that the next subtitle is displayed +#Alt+left add video-pan-x 0.1 # move the video right +#Alt+right add video-pan-x -0.1 # move the video left +#Alt+up add video-pan-y 0.1 # move the video down +#Alt+down add video-pan-y -0.1 # move the video up +#Alt++ add video-zoom 0.1 # zoom in +#Alt+- add video-zoom -0.1 # zoom out +#Alt+BS set video-zoom 0 ; set video-pan-x 0 ; set video-pan-y 0 # reset zoom and pan settings +#PGUP add chapter 1 # seek to the next chapter +#PGDWN add chapter -1 # seek to the previous chapter +#Shift+PGUP seek 600 # seek 10 minutes forward +#Shift+PGDWN seek -600 # seek 10 minutes backward +#[ multiply speed 1/1.1 # decrease the playback speed +#] multiply speed 1.1 # increase the playback speed +#{ multiply speed 0.5 # halve the playback speed +#} multiply speed 2.0 # double the playback speed +#BS set speed 1.0 # reset the speed to normal +#Shift+BS revert-seek # undo the previous (or marked) seek +#Shift+Ctrl+BS revert-seek mark # mark the position for revert-seek +#q quit +#Q quit-watch-later # exit and remember the playback position +#q {encode} quit 4 +#ESC set fullscreen no # leave fullscreen +#ESC {encode} quit 4 +#p cycle pause # toggle pause/playback mode +#. frame-step # advance one frame and pause +#, frame-back-step # go back by one frame and pause +#SPACE cycle pause # toggle pause/playback mode +#> playlist-next # skip to the next file +#ENTER playlist-next # skip to the next file +#< playlist-prev # skip to the previous file +#O no-osd cycle-values osd-level 3 1 # toggle displaying the OSD on user interaction or always +#o show-progress # show playback progress +#P show-progress # show playback progress +#` script-binding console/enable # open the console +#z add sub-delay -0.1 # shift subtitles 100 ms earlier +#Z add sub-delay +0.1 # delay subtitles by 100 ms +#x add sub-delay +0.1 # delay subtitles by 100 ms +#ctrl++ add audio-delay 0.100 # change audio/video sync by delaying the audio +#ctrl+- add audio-delay -0.100 # change audio/video sync by shifting the audio earlier +#Shift+g add sub-scale +0.1 # increase the subtitle font size +#Shift+f add sub-scale -0.1 # decrease the subtitle font size +#9 add volume -2 +#/ add volume -2 +#0 add volume 2 +#* add volume 2 +#m cycle mute # toggle mute +#1 add contrast -1 +#2 add contrast 1 +#3 add brightness -1 +#4 add brightness 1 +#5 add gamma -1 +#6 add gamma 1 +#7 add saturation -1 +#8 add saturation 1 +#Alt+0 set current-window-scale 0.5 # halve the window size +#Alt+1 set current-window-scale 1.0 # reset the window size +#Alt+2 set current-window-scale 2.0 # double the window size +#d cycle deinterlace # toggle the deinterlacing filter +#r add sub-pos -1 # move subtitles up +#R add sub-pos +1 # move subtitles down +#t add sub-pos +1 # move subtitles down +#v cycle sub-visibility # hide or show the subtitles +#Alt+v cycle secondary-sub-visibility # hide or show the secondary subtitles +#V cycle sub-ass-vsfilter-aspect-compat # toggle stretching SSA/ASS subtitles with anamorphic videos to match the historical renderer +#u cycle-values sub-ass-override "force" "no" # toggle overriding SSA/ASS subtitle styles with the normal styles +#j cycle sub # switch subtitle track +#J cycle sub down # switch subtitle track backwards +#SHARP cycle audio # switch audio track +#_ cycle video # switch video track +#T cycle ontop # toggle placing the video on top of other windows +#f cycle fullscreen # toggle fullscreen +#s screenshot # take a screenshot of the video in its original resolution with subtitles +#S screenshot video # take a screenshot of the video in its original resolution without subtitles +#Ctrl+s screenshot window # take a screenshot of the window with OSD and subtitles +#Alt+s screenshot each-frame # automatically screenshot every frame; issue this command again to stop taking screenshots +#w add panscan -0.1 # decrease panscan +#W add panscan +0.1 # shrink black bars by cropping the video +#e add panscan +0.1 # shrink black bars by cropping the video +#A cycle-values video-aspect-override "16:9" "4:3" "2.35:1" "-1" # cycle the video aspect ratio ("-1" is the container aspect) +#POWER quit +#PLAY cycle pause # toggle pause/playback mode +#PAUSE cycle pause # toggle pause/playback mode +#PLAYPAUSE cycle pause # toggle pause/playback mode +#PLAYONLY set pause no # unpause +#PAUSEONLY set pause yes # pause +#STOP quit +#FORWARD seek 60 # seek 1 minute forward +#REWIND seek -60 # seek 1 minute backward +#NEXT playlist-next # skip to the next file +#PREV playlist-prev # skip to the previous file +#VOLUME_UP add volume 2 +#VOLUME_DOWN add volume -2 +#MUTE cycle mute # toggle mute +#CLOSE_WIN quit +#CLOSE_WIN {encode} quit 4 +#ctrl+w quit +#E cycle edition # switch edition +#l ab-loop # set/clear A-B loop points +#L cycle-values loop-file "inf" "no" # toggle infinite looping +#ctrl+c quit 4 +#DEL script-binding osc/visibility # cycle OSC visibility between never, auto (mouse-move) and always +#ctrl+h cycle-values hwdec "auto" "no" # toggle hardware decoding +#F8 show-text ${playlist} # show the playlist +#F9 show-text ${track-list} # show the list of video, audio and sub tracks + +# +# Legacy bindings (may or may not be removed in the future) +# +#! add chapter -1 # seek to the previous chapter +#@ add chapter 1 # seek to the next chapter + +# +# Not assigned by default +# (not an exhaustive list of unbound commands) +# + +# ? cycle sub-forced-only # toggle DVD forced subs +# ? stop # stop playback (quit or enter idle mode) +# + +q quit-watch-later + +Alt+l cycle-values loop-file "inf" "no" # toggle infinite looping + +# Seeking +H add chapter -1 +L add chapter 1 +h seek -5 +l seek 5 +- seek -60 += seek 60 +RIGHT seek 2 exact +LEFT seek -2 exact +UP seek 2 keyframes +DOWN seek -2 keyframes + +ctrl+l cycle-values loop-file "inf" "no" # toggle infinite looping + +# Speed +] add speed 0.5 +[ add speed -0.5 +} add speed 0.25 +{ add speed -0.25 +\ set speed 1 + + +# Add/Decrease volume +j add volume -5 +k add volume 5 + +# Subtitles +s cycle sub +ctrl+s cycle sub-visibility # Toggle subtitles + +# Cycle audio tracks +v cycle audio # switch audio track +V cycle audio # switch audio track +ctrl+l cycle-values loop-file "inf" "no" # toggle infinite looping + +# Keep open after exit +P cycle keep-open up + +# OSC +K script-message osc-chapterlist +BS script-binding osc/visibility + +# show chapter title +alt+c script-message cycle-commands 'show-text "${chapter-metadata/title}" 100000000' 'show-text "" 0' + +x add audio-delay 0.100 # change audio/video sync by delaying the audio +X add audio-delay -0.100 # change audio/video sync by shifting the audio earlier +ctrl+x set audio-delay 0 diff --git a/config/extra/jftui/mpv.conf b/config/extra/jftui/mpv.conf new file mode 100644 index 0000000..9ac817b --- /dev/null +++ b/config/extra/jftui/mpv.conf @@ -0,0 +1,23 @@ +osd-font='monospace' +# Set OSD font size +osd-font-size=30 + +# Set volume to 100% on startup. +volume=60 + +# Set player max vol to 100%. +volume-max=100 + +# Force stream to be seekable even if disabled. +force-seekable=yes + +stop-screensaver=yes + +slang=eng,en,english +alang=jpn + +screenshot-directory=~/pics/screenshots/mpv +screenshot-template="%F - [%P]v%#01n" + +sub-pos=97 +sub-scale=.80 -- cgit v1.2.3-70-g09d2