blob: d864d9fa0160024fae8205e4ba92a3c8b41b0d07 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
|
#!/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
|