aboutsummaryrefslogtreecommitdiff
path: root/scripts/set_random
blob: 894361c29feb1eaf4e2ff0a57b81cfa7029ebd55 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
#!/usr/bin/fish

if test (count $argv) -lt 1; or not test -d $argv[1]
  echo "Usage: $(status filename) <dir>"
  exit 1
end

~/.config/scripts/set_background (
  for file in (fd . $argv[1] -t f)
    if test -z $IMG; or test $file != $IMG
      echo (math (random) % 1000)":$file"
    end
  end | sort -n | head -n 1 | cut -d ':' -f2)