You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
|
- #!/bin/bash
-
- INDIR="$HOME/wp/curr"
- OUTDIR="$HOME/wp/curr"
-
- mkdir -p "$OUTDIR"
-
- sedstr="\([0-9][0-9]*\)x\([0-9][0-9]*\)+\([0-9][0-9]*\)+\([0-9][0-9]*\)"
-
- function getinfo() {
- xrandr -q | grep "^$1" | grep -o "[0-9][0-9]*x[0-9][0-9]*+[0-9][0-9]*+[0-9][0-9]*"
- }
-
- function getres() {
- getinfo "$1" | sed "s:$sedstr:\1x\2:"
- }
-
- function getoff() {
- getinfo "$1" | sed "s:$sedstr:+\3+\4:"
- }
-
- function getwidth() {
- getinfo "$1" | sed "s:$sedstr:\1:"
- }
-
- function getheight() {
- getinfo "$1" | sed "s:$sedstr:\2:"
- }
-
- function getleft() {
- getinfo "$1" | sed "s:$sedstr:\3:"
- }
-
- function gettop() {
- getinfo "$1" | sed "s:$sedstr:\4:"
- }
-
- function screenres() {
- xrandr -q | grep "^Screen 0" | sed 's:^.*current \([0-9][0-9]*\) x \([0-9][0-9]*\).*$:\1x\2:'
- }
-
- function run() {
- echo "$@"
- "$@"
- }
-
- function main() {
- local joinargs=()
-
- while [ -n "$1" ] && [ "$1" != "--" ]; do
- local res="$(getres "$1")"
- run convert "$INDIR/motif.png" -resize "$res^" -gravity center -extent "$res" "$OUTDIR/$1.png"
- joinargs+=("$OUTDIR/$1.png" -geometry "$(getoff "$1")" -composite)
- shift
- done
-
- shift
-
- if [ -n "$1" ]; then
- local splitargs=()
- local off=0
- local maxh=0
- while [ -n "$1" ]; do
- splitargs+=(\( -clone 0 -gravity West -extent "$(getres "$1")+$off+0" -write "$OUTDIR/$1.png" +delete \))
- joinargs+=("$OUTDIR/$1.png" -geometry "$(getoff "$1")" -composite)
- off=$((off + $(getwidth "$1")))
- if [ "$maxh" -lt "$(getheight "$1")" ]; then
- maxh="$(getheight "$1")"
- fi
- shift
- done
-
- run convert -respect-parenthesis "$INDIR/panorama.png" -resize "${off}x${maxh}^" "${splitargs[@]}" "jpg:/dev/null"
- fi
-
- run convert -respect-parenthesis -size "$(screenres)" 'xc:#000000' "${joinargs[@]}" "$OUTDIR/all.png"
- }
-
- main "$@"
|