From 03cbbd2f7fed4c38451e8f21335f73d906625082 Mon Sep 17 00:00:00 2001 From: Dante897 <148303955+DanteIs897@users.noreply.github.com> Date: Tue, 11 Nov 2025 09:48:02 -0500 Subject: [PATCH] improve: add image/video share and run share commands silently (#3330) * improve: add image/video share and run share commands silently - Added 'image' and 'video' modes to omarchy-cmd-share to quickly send the most recent screenshot or video without selecting manually. - Updated show_share_menu to run share commands in the background using 'nohup' to avoid opening a terminal window. - Comments added to explain each section for clarity and maintainability. * Match names with folders * Correct here too * Don't need to keep this around * Fix these up for what's needed only --------- Co-authored-by: David Heinemeier Hansson --- bin/omarchy-cmd-share | 23 ++++++++++++++++++++++- bin/omarchy-menu | 6 ++++-- 2 files changed, 26 insertions(+), 3 deletions(-) diff --git a/bin/omarchy-cmd-share b/bin/omarchy-cmd-share index 78113a13..0fd1ca30 100755 --- a/bin/omarchy-cmd-share +++ b/bin/omarchy-cmd-share @@ -1,7 +1,7 @@ #!/bin/bash if (($# == 0)); then - echo "Usage: omarchy-cmd-share [clipboard|file|folder]" + echo "Usage: omarchy-cmd-share [clipboard|file|folder|picture|video]" exit 1 fi @@ -9,11 +9,32 @@ MODE="$1" shift if [[ $MODE == "clipboard" ]]; then + # Save clipboard content to a temporary text file TEMP_FILE=$(mktemp --suffix=.txt) wl-paste >"$TEMP_FILE" FILES="$TEMP_FILE" + +elif [[ $MODE == "picture" ]]; then + # Pick the most recent image from ~/Pictures + LAST_PICTURE=$(find "$HOME/Pictures" -maxdepth 1 -type f \( -iname "*.png" -o -iname "*.jpg" -o -iname "*.jpeg" \) -printf "%T@ %p\n" 2>/dev/null | sort -nr | head -n 1 | cut -d' ' -f2-) + if [[ -z "$LAST_PICTURE" ]]; then + echo "No .png/.jpg found in ~/Pictures" + exit 1 + fi + FILES="$LAST_PICTURE" + +elif [[ $MODE == "video" ]]; then + # Pick the most recent .mp4 video from ~/Videos + LAST_VIDEO=$(find "$HOME/Videos" -maxdepth 1 -type f -iname "*.mp4" -printf "%T@ %p\n" 2>/dev/null | sort -nr | head -n 1 | cut -d' ' -f2-) + if [[ -z "$LAST_VIDEO" ]]; then + echo "No .mp4 found in ~/Videos" + exit 1 + fi + FILES="$LAST_VIDEO" + else if (($# > 0)); then + # Use files/folders provided as arguments FILES="$*" else if [[ $MODE == "folder" ]]; then diff --git a/bin/omarchy-menu b/bin/omarchy-menu index cad261e6..d52a548e 100755 --- a/bin/omarchy-menu +++ b/bin/omarchy-menu @@ -123,10 +123,12 @@ show_screenrecord_menu() { } show_share_menu() { - case $(menu "Share" " Clipboard\n File \n Folder") in - *Clipboard*) terminal bash -c "omarchy-cmd-share clipboard" ;; + case $(menu "Share" " Clipboard\n File\n Folder\n Latest Picture\n Latest Video") in + *Clipboard*) omarchy-cmd-share clipboard ;; *File*) terminal bash -c "omarchy-cmd-share file" ;; *Folder*) terminal bash -c "omarchy-cmd-share folder" ;; + *Picture*) omarchy-cmd-share picture ;; + *Video*) omarchy-cmd-share video ;; *) back_to show_trigger_menu ;; esac }