summaryrefslogtreecommitdiff
path: root/pick_wall.sh
blob: 1e90c6c8ad96e5161b2c84074e2bc26f589497ce (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
#!/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 | dmenu -i -l $LINES -x $X -y $Y -z $Z -p "album?")"
# replace prefix so correct path passed
ALBUM="$(printf "%s/%s" "$IMG_DIR" "$ALBUM")"

wall_gen.sh "$ALBUM"