Skip to content

Instantly share code, notes, and snippets.

@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:
# -------------------------
@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 / 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 / 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 / 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 / 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 / dimensionsortzenity.sh
Created October 17, 2015 03:38
Sort images by dimension, and check the images to delete.
#!/bin/bash
#expecting 2 args:
# function display or delete
# a directory containing images
ZENITY_X=0
ZENITY_Y=0
ZENITY_W=500
ZENITY_H=400
@Birchwell
Birchwell / chopvideoaudio.sh
Created October 17, 2015 06:09
This bash script skirts the annoying FFmpeg limitation of cutting audio or video based not on start/stop timestamps, but on seconds elapsed. With the following bash script you can enter a start time to begin the cut, and an end time to terminate the cut, which removes the sometimes necessary task of performing math to determine precisely how man…
#!/bin/bash
INPUT=$(yad --width=600 --height=400 --file-selection --file-filter='*.mp3 *.mkv *.mp4 *.avi *.flv')
eval $(yad --width=400 --form --field=start --field=end --field=output:SFL "00:00:00.000" "00:00:00.000" "${INPUT/%.*}-out.${INPUT##*.}" | awk -F'|' '{printf "START=%s\nEND=%s\nOUTPUT=\"%s\"\n", $1, $2, $3}')
[[ -z $START || -z $END || -z $OUTPUT ]] && exit 1
DIFF=$(($(date +%s --date="$END")-$(date +%s --date="$START")))
OFFSET=""$(($DIFF / 3600)):$(($DIFF / 60 % 60)):$(($DIFF % 60))
@Birchwell
Birchwell / nix.sh
Created October 17, 2015 13:07
This script will produce contact sheets of videos.
#!/usr/bin/env bash
#
# $Rev: 583 $ $Date: 2014-05-18 18:50:42 +0200 (dg, 18 mai 2014) $
#
# vcs
# Video Contact Sheet *NIX: Generates contact sheets (previews) of videos
#
# Copyright (C) 2007, 2008, 2009, 2010, 2011, 2012, 2013, 2014 Toni Corvera
#
# This program is free software; you can redistribute it and/or
@Birchwell
Birchwell / nix.sh
Created October 17, 2015 23:51
This Custom Action will produce contact sheets of videos. I found it here: http://p.outlyer.net/vcs/#issues
#!/usr/bin/env bash
#
# $Rev: 583 $ $Date: 2014-05-18 18:50:42 +0200 (dg, 18 mai 2014) $
#
# vcs
# Video Contact Sheet *NIX: Generates contact sheets (previews) of videos
#
# Copyright (C) 2007, 2008, 2009, 2010, 2011, 2012, 2013, 2014 Toni Corvera
#
# This program is free software; you can redistribute it and/or