Sophie Hirn 1 year ago
parent
commit
880acf2f22
4 changed files with 90 additions and 59 deletions
  1. +8
    -41
      .beacon-hooks/10-feh
  2. +2
    -1
      .beacon/need
  3. +1
    -17
      .local/bin/lock
  4. +79
    -0
      .local/bin/mkwp

+ 8
- 41
.beacon-hooks/10-feh View File

@@ -1,47 +1,14 @@
#!/bin/bash

on init reload rotate
on init reload
check [ -n "$DISPLAY" ]

if [ -e "bg-wide.png" ]; then
echo "Found bg-wide.png ..."

touch .bg-wide.md5
if [ "`md5sum bg-wide.png`" != "`cat .bg-wide.md5 2>/dev/null`" ]; then
echo "Converting ..."
sz=`xdpyinfo | grep dimensions | sed 's:^[^0-9]*\([0-9][0-9]*x[0-9][0-9]*\).*$:\1:'`
convert bg-wide.png -resize "$sz"^ -gravity center -extent "$sz" .bg-wide-scaled.png
convert bg-wide.png -crop 1920x1080+0+0 .bg-wide1.png
convert bg-wide.png -crop 1920x1080+1920+0 .bg-wide2.png
convert bg-wide.png -crop 1920x1080+3840+0 .bg-wide3.png
md5sum bg-wide.png >.bg-wide.md5
fi

feh --no-fehbg --bg-fill {%{feh-bg-paths}%}
if [ "$sgn" == "init" ]; then
import -window root /tmp/lock.jpg
( convert /tmp/lock.jpg /tmp/lock.png; rm /tmp/lock.jpg ) &
fi

else
touch .bg-rotate.md5
if [ "`md5sum bg.png`" != "`cat .bg-rotate.md5 2>/dev/null`" ]; then
echo "Converting ..."
sz=`xdpyinfo | grep dimensions | sed 's:^[^0-9]*\([0-9][0-9]*x[0-9][0-9]*\).*$:\1:'`
convert bg.png -resize "$sz"^ -gravity center -extent "$sz" .bg-scaled.png
convert .bg-scaled.png -rotate -90 .bg-right.png
convert .bg-scaled.png -rotate 90 .bg-left.png
md5sum bg.png >.bg-rotate.md5
sudo cp .bg-scaled.png /boot/bg/bg.png
fi

case `xrandr -q | grep eDP | cut -f 5 -d ' '` in
left) f=.bg-left.png ;;
inv*) f=.bg-scaled.png ;;
right) f=.bg-right.png ;;
*) f=.bg-scaled.png ;;
esac

feh --no-fehbg --bg-fill "$f"
if \
[ ! -e "$HOME/wp/curr/all.png" ] || \
[ "$HOME/wp/curr/motif.png" -nt "$HOME/wp/curr/all.png" ] || \
[ "$HOME/wp/curr/panorama.png" -nt "$HOME/wp/curr/all.png" ]; then

mkwp {%{wp-def}%}
fi

feh --no-fehbg --bg-fill --no-xinerama "$HOME/wp/curr/all.png"

+ 2
- 1
.beacon/need View File

@@ -1,2 +1,3 @@
wallpaper
sed-compositor
wallpaper
wallpaper-wp-def

+ 1
- 17
.local/bin/lock View File

@@ -1,23 +1,7 @@
#!/bin/bash

if [ -e "/tmp/lock.png" ]; then
f="/tmp/lock.png"

elif [ -e "bg-wide.png" ]; then
f="$HOME/.bg-wide-scaled.png"

else
case `xrandr -q | grep eDP | cut -f 5 -d ' '` in
left) f="$HOME/.bg-left.png" ;;
inv*) f="$HOME/.bg-scaled.png" ;;
right) f="$HOME/.bg-right.png" ;;
*) f="$HOME/.bg-scaled.png" ;;
esac

fi

killall {%{compositor}%} 2>/dev/null
xset +dpms dpms 5 5 5 s 5
i3lock -n -i "$f"
i3lock -n -i "$HOME/wp/curr/all.png"
xset -dpms s off
{%{compositor}%} {%{compositor-opts}%} &

+ 79
- 0
.local/bin/mkwp View File

@@ -0,0 +1,79 @@
#!/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 "$@"

Loading…
Cancel
Save