Skip to content

Commit 03cbbd2

Browse files
DanteIs897dhh
andauthored
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 <[email protected]>
1 parent 8840af8 commit 03cbbd2

File tree

2 files changed

+26
-3
lines changed

2 files changed

+26
-3
lines changed

bin/omarchy-cmd-share

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,40 @@
11
#!/bin/bash
22

33
if (($# == 0)); then
4-
echo "Usage: omarchy-cmd-share [clipboard|file|folder]"
4+
echo "Usage: omarchy-cmd-share [clipboard|file|folder|picture|video]"
55
exit 1
66
fi
77

88
MODE="$1"
99
shift
1010

1111
if [[ $MODE == "clipboard" ]]; then
12+
# Save clipboard content to a temporary text file
1213
TEMP_FILE=$(mktemp --suffix=.txt)
1314
wl-paste >"$TEMP_FILE"
1415
FILES="$TEMP_FILE"
16+
17+
elif [[ $MODE == "picture" ]]; then
18+
# Pick the most recent image from ~/Pictures
19+
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-)
20+
if [[ -z "$LAST_PICTURE" ]]; then
21+
echo "No .png/.jpg found in ~/Pictures"
22+
exit 1
23+
fi
24+
FILES="$LAST_PICTURE"
25+
26+
elif [[ $MODE == "video" ]]; then
27+
# Pick the most recent .mp4 video from ~/Videos
28+
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-)
29+
if [[ -z "$LAST_VIDEO" ]]; then
30+
echo "No .mp4 found in ~/Videos"
31+
exit 1
32+
fi
33+
FILES="$LAST_VIDEO"
34+
1535
else
1636
if (($# > 0)); then
37+
# Use files/folders provided as arguments
1738
FILES="$*"
1839
else
1940
if [[ $MODE == "folder" ]]; then

bin/omarchy-menu

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -123,10 +123,12 @@ show_screenrecord_menu() {
123123
}
124124

125125
show_share_menu() {
126-
case $(menu "Share" " Clipboard\n File \n Folder") in
127-
*Clipboard*) terminal bash -c "omarchy-cmd-share clipboard" ;;
126+
case $(menu "Share" " Clipboard\n File\n Folder\n Latest Picture\n Latest Video") in
127+
*Clipboard*) omarchy-cmd-share clipboard ;;
128128
*File*) terminal bash -c "omarchy-cmd-share file" ;;
129129
*Folder*) terminal bash -c "omarchy-cmd-share folder" ;;
130+
*Picture*) omarchy-cmd-share picture ;;
131+
*Video*) omarchy-cmd-share video ;;
130132
*) back_to show_trigger_menu ;;
131133
esac
132134
}

0 commit comments

Comments
 (0)