|
|
|
@ -1,8 +1,8 @@
|
|
|
|
|
#! /usr/bin/fish
|
|
|
|
|
#!/usr/bin/fish
|
|
|
|
|
|
|
|
|
|
# Load dependencies
|
|
|
|
|
set -l cmd (command basename (status -f) | command cut -f 1 -d '.')
|
|
|
|
|
set -l path (status filename | command xargs dirname)/../
|
|
|
|
|
set -l path (status filename | command xargs dirname)/..
|
|
|
|
|
source $path/dependency.fish \
|
|
|
|
|
-n $cmd -N unsplash-wallpaper grep sed curl
|
|
|
|
|
or exit 1
|
|
|
|
@ -26,7 +26,7 @@ set -l flag (set --name | string match -r '(?<=^_flag_).{2,}')
|
|
|
|
|
if string match -qr '^(add|remove|url)$' $flag
|
|
|
|
|
if test -z "$argv"
|
|
|
|
|
err "$cmd: Missing argument"
|
|
|
|
|
source (command dirname (status -f))/../instructions.fish "$cmd -a/--\S+"
|
|
|
|
|
source "$path/instructions.fish $cmd -a/--\S+"
|
|
|
|
|
exit 1
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
@ -40,7 +40,7 @@ end
|
|
|
|
|
|
|
|
|
|
switch "$flag"
|
|
|
|
|
case help
|
|
|
|
|
source -- "$path/instructions.fish $cmd -a/--\S+"
|
|
|
|
|
source "$path/instructions.fish $cmd -a/--\S+"
|
|
|
|
|
test -z "$argv"
|
|
|
|
|
|
|
|
|
|
case list
|
|
|
|
@ -68,7 +68,7 @@ switch "$flag"
|
|
|
|
|
case cache
|
|
|
|
|
if string match -qvr '\d' $_flag_cache
|
|
|
|
|
err "$cmd: $_flag_cache: Invalid value"
|
|
|
|
|
source (command dirname (status -f))/../instructions.fish "$cmd -a/--\S+"
|
|
|
|
|
source "$path/instructions.fish $cmd -a/--\S+"
|
|
|
|
|
exit 1
|
|
|
|
|
end
|
|
|
|
|
set -U wallpaper_cache $_flag_cache
|
|
|
|
@ -89,7 +89,7 @@ switch "$flag"
|
|
|
|
|
if echo (math (count $argv) / 3) $argv[(command seq 2 3 (count $argv))] \
|
|
|
|
|
| string match -qvr '\d'
|
|
|
|
|
err "$cmd: Invalid syntax"
|
|
|
|
|
source (command dirname (status -f))/../instructions.fish "$cmd -a/--\S+"
|
|
|
|
|
source "$path/instructions.fish $cmd -a/--\S+"
|
|
|
|
|
exit 1
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
@ -149,7 +149,7 @@ switch "$flag"
|
|
|
|
|
# Retrieve wallpaper and, if possible, set it as the current wallpaper
|
|
|
|
|
command mkdir -p $wallpapers_folder
|
|
|
|
|
cd $wallpapers_folder
|
|
|
|
|
command unsplash-wallpaper -o $argv 1>&2
|
|
|
|
|
eval (command whereis unsplash-wallpaper | awk '{print $2}') -o $argv 1>&2
|
|
|
|
|
or exit 1
|
|
|
|
|
set wallpapers (ls -t | string match -ar '^wallpaper-.+\.jpe?g$')
|
|
|
|
|
if type -qf gsettings
|
|
|
|
@ -169,4 +169,4 @@ switch "$flag"
|
|
|
|
|
test (count $wallpapers) -gt $wallpaper_cache
|
|
|
|
|
and command rm $wallpapers[(math $wallpaper_cache + 1)..-1]
|
|
|
|
|
prevd
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|