Skip to content

Instantly share code, notes, and snippets.

@Birchwell
Birchwell / dimensionsortyad.sh
Created October 17, 2015 03:35
This YAD script will sort a directory of images by their dimensions. Linux doesn't have this native ability, so this is a very useful script.
#!/bin/bash
#expecting 1 arg:
# a directory containing images
#window size
YAD_W=800
YAD_H=800
#max number of files to delete
MAX_DELETE=50
@Birchwell
Birchwell / splitvideoyad.sh
Created October 17, 2015 02:41
This custom action will split video into clips according to a user defined number of seconds. Can be used with Thunar Custom Actions.
#! /bin/bash
eval RES=($(yad --form --quoted-output --separator=" " --field "Input file:FL" --field "Output dir:DIR" --field "Duration:NUM"))
[[ $? -ne 0 ]] && exit 1
ext=${RES[0]##*.}
out=$(basename ${RES[0]} .$ext)
$mkdir "${RES[2]}"
ffmpeg -i "${RES[0]}" -f segment -segment_time "${RES[2]}" -acodec copy -vcodec copy -reset_timestamps 1 -map 0 "${RES[1]}/$out-%d.$ext"
@Birchwell
Birchwell / watermark.sh
Created October 16, 2015 10:34
This Thunar Custom Action will create a watermark on an image, with customized text from a YAD entry form.
#!/bin/sh
command -v convert >/dev/null 2>&1 || { echo >&2 "I require convert, but it's not installed. aborting!";exit 1;}
command -v identify >/dev/null 2>&1 || { echo >&2 "I require identify, but it's not installed. aborting!";exit 1;}
command -v bc >/dev/null 2>&1 || { echo >&2 "I require bc, but it's not installed. aborting!";exit 1;}
basedir="$(dirname "$(readlink -f "${1}")")"
cd "$basedir"
caption=$(yad --entry --editable --no-buttons --width 410 \
--title="Please enter your caption and press enter:")
if [ -z "$caption" ]; then
printf "no caption was selected, aborting!\n"
@Birchwell
Birchwell / gmicmontagepics.sh
Last active February 8, 2019 10:42
This G'Mic script will go through a folder of many images and output multiple montages in the working folder. The script can be modified to customize the number of images to turn into individual montages by changing the "4" in "(expr $c % 4)" to whatever number desired. Can be used with Thunar Custom Actions.
#!/bin/bash
c=0
for i in *.jpg; do
c=$(($c+1))
f="$f $i"
test "$(expr $c % 4)" != 0 && continue
gmic $f -fx_montage 4,\""V(H(0,1),H(2,V(3,4)))"\",1,1.0,0,5,0,0,0,255,0,0,0,0,0 -o output-$c.jpg
f=""
done
@Birchwell
Birchwell / gmicmontagefolderimages.sh
Last active February 8, 2019 10:41
This G'Mic bash script allows for turning a folder of images into a montage. Can be used with Thunar Custom Actions.
#!/bin/bash
find -type d -exec sh -c '
cd "$0"
set -- *.jpg
if [ -e "$1" ]; then
gmic "$@" -fx_montage 4,\""V(H(0,1),H(2,V(3,4)))"\",1,1.0,0,5,0,0,0,255,0,0,0,0,0 -o 0000."$(date)".jpg
fi
' {} \;
@Birchwell
Birchwell / thunar-custom-action-upload-imgur.sh
Created October 16, 2015 09:36
This Thunar Custom Action will upload an image to the imagehost Imgur.
#!/bin/sh
#
# Upload a Picture to imgur.
#
# * Put this file into your home binary dir: ~/bin/
# * Make it executable: chmod +x
#
#
# Required Software:
# -------------------------