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 / 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 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
@Birchwell
Birchwell / movefilesdir.sh
Created October 17, 2015 23:55
Divide files in folder into many folders. Customizable by changing number of files.
#!/bin/bash
c=1; d=1; mkdir -p dir_${d}
for file in *
do
if [ $c -eq 600 ]
then
d=$(( d + 1 )); c=0; mkdir -p dir_${d}
fi
@Birchwell
Birchwell / file-size.sh
Created October 18, 2015 00:00
Shows the actual size of files in Thunar. Thunar has a strange problem of not reporting the correct size of files.
#! /bin/bash
kb=$((2**10))
mb=$((2**20))
for file in $@; do
if [ ! -e $file ]; then
continue
fi
b1=`ls -l $file | cut -d" " -f5`
@Birchwell
Birchwell / videotogif.sh
Created October 18, 2015 00:22
This bash script will work on multiple video files, outputting multiple GIFs renamed with incremental numbering.
#!/bin/bash
for f in ./*.mp4; do
ffmpeg -i "$f" -vf scale=420:-1 -t 10 -r 10 "${f%.*}.gif"
done