mirror of
https://github.com/arthur-pbty/arthur-os.git
synced 2026-08-01 20:28:16 +02:00
Have transcode flow through walker menus rather than gum prompts
This commit is contained in:
+1
-10
@@ -102,7 +102,7 @@ show_trigger_menu() {
|
|||||||
case $(menu "Trigger" " Reminder\n Capture\n Transcode\n Share\n Toggle\n Hardware") in
|
case $(menu "Trigger" " Reminder\n Capture\n Transcode\n Share\n Toggle\n Hardware") in
|
||||||
*Reminder*) show_reminder_menu ;;
|
*Reminder*) show_reminder_menu ;;
|
||||||
*Capture*) show_capture_menu ;;
|
*Capture*) show_capture_menu ;;
|
||||||
*Transcode*) show_transcode_menu ;;
|
*Transcode*) omarchy-transcode ;;
|
||||||
*Share*) show_share_menu ;;
|
*Share*) show_share_menu ;;
|
||||||
*Toggle*) show_toggle_menu ;;
|
*Toggle*) show_toggle_menu ;;
|
||||||
*Hardware*) show_hardware_menu ;;
|
*Hardware*) show_hardware_menu ;;
|
||||||
@@ -209,14 +209,6 @@ show_share_menu() {
|
|||||||
esac
|
esac
|
||||||
}
|
}
|
||||||
|
|
||||||
show_transcode_menu() {
|
|
||||||
case $(menu "Transcode" " Picture\n Video") in
|
|
||||||
*Picture*) present_terminal "omarchy-transcode --path '$HOME/Pictures'" ;;
|
|
||||||
*Video*) present_terminal "omarchy-transcode --path '$HOME/Videos'" ;;
|
|
||||||
*) back_to show_trigger_menu ;;
|
|
||||||
esac
|
|
||||||
}
|
|
||||||
|
|
||||||
show_toggle_menu() {
|
show_toggle_menu() {
|
||||||
local options=" Screensaver\n Nightlight\n Idle Lock\n Notifications\n Top Bar\n Workspace Layout\n Window Gaps\n 1-Window Ratio\n Monitor Scaling\n Direct Boot\n Passwordless Sudo"
|
local options=" Screensaver\n Nightlight\n Idle Lock\n Notifications\n Top Bar\n Workspace Layout\n Window Gaps\n 1-Window Ratio\n Monitor Scaling\n Direct Boot\n Passwordless Sudo"
|
||||||
|
|
||||||
@@ -857,7 +849,6 @@ go_to_menu() {
|
|||||||
*toggle*) show_toggle_menu ;;
|
*toggle*) show_toggle_menu ;;
|
||||||
*hardware*) show_hardware_menu ;;
|
*hardware*) show_hardware_menu ;;
|
||||||
*share*) show_share_menu ;;
|
*share*) show_share_menu ;;
|
||||||
*transcode*) show_transcode_menu ;;
|
|
||||||
*reminder-set*) show_custom_reminder_input ;;
|
*reminder-set*) show_custom_reminder_input ;;
|
||||||
*reminder*) show_reminder_menu ;;
|
*reminder*) show_reminder_menu ;;
|
||||||
*background*) show_background_menu ;;
|
*background*) show_background_menu ;;
|
||||||
|
|||||||
+15
-39
@@ -13,7 +13,7 @@ usage() {
|
|||||||
Usage:
|
Usage:
|
||||||
omarchy transcode [--path path] [input] [format] [resolution]
|
omarchy transcode [--path path] [input] [format] [resolution]
|
||||||
|
|
||||||
With no input, fuzzy-pick a picture or video from ~/Pictures and ~/Videos,
|
With no input, pick a picture or video with Walker from ~/Pictures and ~/Videos,
|
||||||
or only from --path when provided. Then pick the output format and resolution.
|
or only from --path when provided. Then pick the output format and resolution.
|
||||||
|
|
||||||
Options:
|
Options:
|
||||||
@@ -29,30 +29,6 @@ Resolutions:
|
|||||||
EOF
|
EOF
|
||||||
}
|
}
|
||||||
|
|
||||||
pick_file() {
|
|
||||||
local search_path="$1"
|
|
||||||
local paths=()
|
|
||||||
|
|
||||||
if [[ -n $search_path ]]; then
|
|
||||||
[[ -e $search_path ]] || { echo "Path not found: $search_path" >&2; return 1; }
|
|
||||||
paths=("$search_path")
|
|
||||||
else
|
|
||||||
paths=("$HOME/Pictures" "$HOME/Videos")
|
|
||||||
fi
|
|
||||||
|
|
||||||
find "${paths[@]}" -type f \
|
|
||||||
\( -iname '*.jpg' -o -iname '*.jpeg' -o -iname '*.png' -o -iname '*.webp' -o -iname '*.gif' -o -iname '*.heic' -o -iname '*.avif' \
|
|
||||||
-o -iname '*.mp4' -o -iname '*.mov' -o -iname '*.m4v' -o -iname '*.mkv' -o -iname '*.webm' -o -iname '*.avi' \) \
|
|
||||||
-printf '%T@\t%p\n' 2>/dev/null | sort -rn | cut -f2- | fzf --layout=reverse-list --prompt="Transcode file> "
|
|
||||||
}
|
|
||||||
|
|
||||||
pick_option() {
|
|
||||||
local prompt="$1"
|
|
||||||
shift
|
|
||||||
|
|
||||||
gum choose --header "$prompt" "$@"
|
|
||||||
}
|
|
||||||
|
|
||||||
media_type() {
|
media_type() {
|
||||||
local mime
|
local mime
|
||||||
mime=$(file -b --mime-type "$1")
|
mime=$(file -b --mime-type "$1")
|
||||||
@@ -187,9 +163,10 @@ main() {
|
|||||||
input="${positional[0]:-}"
|
input="${positional[0]:-}"
|
||||||
format="${positional[1]:-}"
|
format="${positional[1]:-}"
|
||||||
resolution="${positional[2]:-}"
|
resolution="${positional[2]:-}"
|
||||||
|
search_path="${search_path:-$HOME/Pictures:$HOME/Videos}"
|
||||||
|
|
||||||
if [[ -z $input ]]; then
|
if [[ -z $input ]]; then
|
||||||
input=$(pick_file "$search_path")
|
input=$(omarchy-menu-file "Transcode picture or video" "$search_path" "jpg jpeg png webp gif heic avif mp4 mov m4v mkv webm avi")
|
||||||
fi
|
fi
|
||||||
|
|
||||||
[[ -n $input ]] || return 1
|
[[ -n $input ]] || return 1
|
||||||
@@ -199,33 +176,32 @@ main() {
|
|||||||
|
|
||||||
if [[ -z $format ]]; then
|
if [[ -z $format ]]; then
|
||||||
if [[ $type == "picture" ]]; then
|
if [[ $type == "picture" ]]; then
|
||||||
format=$(pick_option "Select format..." jpg png)
|
format=$(omarchy-menu-select "Select format" jpg png)
|
||||||
else
|
else
|
||||||
format=$(pick_option "Select format..." mp4 gif)
|
format=$(omarchy-menu-select "Select format" mp4 gif)
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [[ -z $resolution ]]; then
|
if [[ -z $resolution ]]; then
|
||||||
if [[ $type == "picture" ]]; then
|
if [[ $type == "picture" ]]; then
|
||||||
resolution=$(pick_option "Select resolution..." high medium low)
|
resolution=$(omarchy-menu-select "Select resolution" high medium low)
|
||||||
else
|
else
|
||||||
resolution=$(pick_option "Select resolution..." 4k 1080p 720p)
|
resolution=$(omarchy-menu-select "Select resolution" 4k 1080p 720p)
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
output=$(output_path "$input" "$format" "$resolution")
|
output=$(output_path "$input" "$format" "$resolution")
|
||||||
|
|
||||||
if [[ $type == "picture" ]]; then
|
if [[ $type == "video" ]]; then
|
||||||
transcode_picture "$input" "$format" "$resolution" "$output"
|
omarchy-notification-send "" "Transcoding video…" "$(basename -- "$input") to $format ($resolution)"
|
||||||
else
|
|
||||||
transcode_video "$input" "$format" "$resolution" "$output"
|
transcode_video "$input" "$format" "$resolution" "$output"
|
||||||
echo ""
|
copy_to_clipboard "$output"
|
||||||
|
omarchy-notification-send "" "Transcoded to $resolution $format" "Saved and copied to clipboard."
|
||||||
|
else
|
||||||
|
transcode_picture "$input" "$format" "$resolution" "$output"
|
||||||
|
copy_to_clipboard "$output"
|
||||||
|
omarchy-notification-send "" "Transcoded to $resolution $format" "Saved and copied to clipboard."
|
||||||
fi
|
fi
|
||||||
|
|
||||||
copy_to_clipboard "$output"
|
|
||||||
echo "Your $type has been transcoded into $format as $resolution. It's on your clipboard."
|
|
||||||
echo ""
|
|
||||||
echo "It's also in $output"
|
|
||||||
}
|
}
|
||||||
|
|
||||||
main "$@"
|
main "$@"
|
||||||
|
|||||||
@@ -44,7 +44,7 @@ bindd = SUPER CTRL, PRINT, Extract text (OCR) from screenshot, exec, omarchy-cap
|
|||||||
bindd = SUPER CTRL, S, Share, exec, omarchy-menu share
|
bindd = SUPER CTRL, S, Share, exec, omarchy-menu share
|
||||||
|
|
||||||
# Transcoding
|
# Transcoding
|
||||||
bindd = SUPER CTRL, PERIOD, Transcode, exec, omarchy-menu transcode
|
bindd = SUPER CTRL, PERIOD, Transcode, exec, omarchy-transcode
|
||||||
|
|
||||||
# Reminders
|
# Reminders
|
||||||
bindd = SUPER CTRL, R, Set reminder, exec, omarchy-menu reminder-set
|
bindd = SUPER CTRL, R, Set reminder, exec, omarchy-menu reminder-set
|
||||||
|
|||||||
Reference in New Issue
Block a user