#!/bin/sh LINES=16 # width of menu is a third of the screen; use that to centre X and use number # of lines to centre Y Z=$(echo "$(xrandr --current | grep '*' | awk '{print $1}' | cut -d 'x' -f1)/3" | bc) X=$(echo "($(xrandr --current | grep '*' | awk '{print $1}' | cut -d 'x' -f1)-$Z)/2" | bc) Y=$(echo "$(xrandr --current | grep '*' | awk '{print $1}' | cut -d 'x' -f2)/2-(8*$LINES)" | bc) if [ $# -eq 0 ]; then IMG_DIR="$HOME/Pictures/albums/" else IMG_DIR="$1" fi # remove directory prefix from list ALBUM="$(find "$IMG_DIR" -not -path '*/.*' -type f -printf "%p\n" | sed "s:$IMG_DIR::" | sort | sed '1 i\random' | dmenu -i -l $LINES -x $X -y $Y -z $Z -p "album?")" if [ $ALBUM == "random" ]; then ./rand_wall.sh else # replace prefix so correct path passed ALBUM="$(printf "%s/%s" "$IMG_DIR" "$ALBUM")" wall_gen.sh "$ALBUM" fi