From 14b5dd71def0c1f9b0c61e74d112e97e830c8978 Mon Sep 17 00:00:00 2001 From: Jonathan Hodgson Date: Fri, 26 Apr 2019 17:15:30 +0100 Subject: [PATCH 1/4] Starts work on gif and mp4 generator for sxiv --- bin/createGif | 49 +++++++++++++++++++++++++++++++++++ sxiv/exec/key-handler | 60 +++++++++++++++++++++++++++++++------------ 2 files changed, 92 insertions(+), 17 deletions(-) create mode 100755 bin/createGif diff --git a/bin/createGif b/bin/createGif new file mode 100755 index 00000000..678101a4 --- /dev/null +++ b/bin/createGif @@ -0,0 +1,49 @@ +#!/bin/bash + +# Creates a gif using a list of files from stdin +tmpdir="/tmp/sxiv-gif/" +rm -rf "$tmpdir" +mkdir -p "$tmpdir" + +framerate="prompt" +format="gif" +extension="" + +while [[ $# -gt 0 ]]; do + case "$1" in + "-r"|"--framerate") + framerate="$2" + shift + shift + ;; + "--mp4") + format="mp4" + shift + ;; + esac +done + +if [[ "$framerate" == "prompt" ]]; then + framerate=$(echo -e "0.25\n0.5\n0.75\n1\n2\n5\n10" | rofi -dmenu -p Timeout) +fi + +i=1 +while read file; do + extension="${file##*.}" + number=$(printf "%03d" $i) + echo "$number" + cp "$file" "${tmpdir}file${number}.${extension}" + i=$((i+1)) +done + +case "$format" in + "mp4") + ffmpeg -f image2 -framerate "$framerate" -i "${tmpdir}file%03d.${extension}" -crf 0 "${tmpdir}out.${format}" + ;; + *) + ffmpeg -f image2 -framerate "$framerate" -i "${tmpdir}file%03d.${extension}" "${tmpdir}out.${format}" +esac + +mv "${tmpdir}out.${format}" "$HOME/Desktop/" + +notify-send "Done" diff --git a/sxiv/exec/key-handler b/sxiv/exec/key-handler index e1967c94..0dd37ba3 100755 --- a/sxiv/exec/key-handler +++ b/sxiv/exec/key-handler @@ -1,18 +1,44 @@ #!/bin/sh -while read file -do - case "$1" in - "greater" ) - convert -rotate 90 "$file" "$file" ;; - "less") - convert -rotate 270 "$file" "$file" ;; - "y") - echo -n "$file" | xclip -selection clipboard ;; - "g") - gimp "$file" & disown ;; - "G") - optirun gimp "$file" & disown ;; - * ) - notify-send "$1" - esac -done + +# This file is run from the sxiv when ctrl+x is pushed and then another key combination +# +# The file names are passed to stdin (1 per line) +# +# The key combination pushed after ctrl+x is sent as the first argument +# +# I have organised this script so when ctrl is pushed, a single command is run using all of the selected images +# e.g. creating a gif out of all selected images +# +# If ctrl is not pushed, the command is run on each image individually +# e.g. rotating images or opening them in gimp + + +case "$1" in + "C-g") + cat | createGif ;; + "C-v") + cat | createGif --mp4 ;; + "C-"*) + # If none of the above were used and ctrl was pushed, send a notificaton with the key combination + notify-send "$1" ;; + *) + # If the above key combinations were not pushed, loop through each of the images and check the combinations below + while read file + do + case "$1" in + "greater" ) + convert -rotate 90 "$file" "$file" ;; + "less") + convert -rotate 270 "$file" "$file" ;; + "y") + echo -n "$file" | xclip -selection clipboard ;; + "g") + gimp "$file" & disown ;; + "G") + optirun gimp "$file" & disown ;; + *) + # If none of the above were used, send a notificaton with the key combination + notify-send "$1" + esac + done +esac From e764de6160dd00ceb7546cb2840c42f96d98d57d Mon Sep 17 00:00:00 2001 From: Jonathan Hodgson Date: Fri, 26 Apr 2019 17:16:16 +0100 Subject: [PATCH 2/4] Updates Vim --- vim | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/vim b/vim index 8b012330..6fc7e108 160000 --- a/vim +++ b/vim @@ -1 +1 @@ -Subproject commit 8b012330898306d1dd40260487082b5e27c41312 +Subproject commit 6fc7e108bfbb023fa028db299ec8e4b28e2fbcab From bd49b3dc223c52dc0545dd2fd9a968ac8862d6a4 Mon Sep 17 00:00:00 2001 From: Jonathan Hodgson Date: Mon, 29 Apr 2019 07:48:07 +0100 Subject: [PATCH 3/4] Adds rofi-print --- bin/rofi-print | 42 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) create mode 100755 bin/rofi-print diff --git a/bin/rofi-print b/bin/rofi-print new file mode 100755 index 00000000..5478ce31 --- /dev/null +++ b/bin/rofi-print @@ -0,0 +1,42 @@ +#!/bin/bash +# printpdf - script +# usage: +# printpdf file.pdf +# printpdf file1.pdf file2.pdf +# printpdf *.pdf +# by i_magnific0 +# Modified by jab2870 + +#COLORS=" -nb #303030 -nf khaki -sb #CCFFAA -sf #303030" +#if dmenu --help 2>&1 | grep -q '\[-rs\] \[-ni\] \[-nl\] \[-xs\]' +#then +# DMENU="dmenu -i -xs -rs -l 10" # vertical patch +#else +# DMENU="dmenu -i" # horizontal, oh well! +#fi + +DMENU="rofi -dmenu" + +printer=$( lpstat -p | awk '{print $2}' | $DMENU -p 'Printer:' $COLORS | perl -p -e 's/^.*?: ?//' ) + +set_options=$( echo -e 'No\nYes' | $DMENU -p 'Set options?' $COLORS | perl -p -e 's/^.*?: ?//' ) + +options="" + +# standard options to lpr, not in the printer lpstat -l +standard_options="page-ranges\nlandscape" + +while [ $set_options == "Yes" ]; do + custom_options=$( lpoptions -d $printer -l | grep -v NotInstalled | awk '{ print $1 }' | sed 's/:\+//g' ) + option_to_set=$( echo -e "$standard_options\n$custom_options" | $DMENU -p 'Option:' $COLORS | perl -p -e 's/^.*?: ?//' ) + option_value=$( lpoptions -d $printer -l | grep $option_to_set | awk 'BEGIN { FS = ": " } ; { print $2 }' | sed 's/ \+/\n/g' | sed 's/*\+//g' | $DMENU -p 'Setting:' $COLORS | perl -p -e 's/^.*?: ?//' ) + option_to_set_1d=$( echo $option_to_set | awk 'BEGIN { FS = "/" } ; { print $1 }' ) + if [ -z $option_value ]; then + options=$options"-o $option_to_set_1d " + else + options=$options"-o $option_to_set_1d=$option_value " + fi + set_options=$( echo -e 'No\nYes' | $DMENU -p 'Set more options?' $COLORS | perl -p -e 's/^.*?: ?//' ) +done + +lpr $options -P $printer $@ From abee8f0969adb78e84b0ea237c82cbc67cf7d00b Mon Sep 17 00:00:00 2001 From: Jonathan Hodgson Date: Wed, 1 May 2019 07:59:56 +0100 Subject: [PATCH 4/4] makes dnsmasq point local.jh to localhost --- etc/dnsmasq.conf | 1 + 1 file changed, 1 insertion(+) diff --git a/etc/dnsmasq.conf b/etc/dnsmasq.conf index 2ba253b1..46e147a6 100644 --- a/etc/dnsmasq.conf +++ b/etc/dnsmasq.conf @@ -78,6 +78,7 @@ # web-server. #address=/double-click.net/127.0.0.1 address=/local/127.0.0.1 +address=/local.jh/127.0.0.1 # --address (and --server) work with IPv6 addresses too. #address=/www.thekelleys.org.uk/fe80::20d:60ff:fe36:f83