(almost?) finish bash port
This commit is contained in:
parent
da50f59891
commit
742ff31bd8
|
@ -11,7 +11,7 @@ while : ; do
|
||||||
# If no, wait 300 secs and check again.
|
# If no, wait 300 secs and check again.
|
||||||
[[ `< $HOME/.config/lock_screen.sta` -eq 0 ]] && sleep 300 && continue
|
[[ `< $HOME/.config/lock_screen.sta` -eq 0 ]] && sleep 300 && continue
|
||||||
# Download the new image
|
# Download the new image
|
||||||
$HOME/i3lock-delta/downloader.php
|
$HOME/i3lock-delta/downloader.sh
|
||||||
if [[ $? -eq 0 ]]; then
|
if [[ $? -eq 0 ]]; then
|
||||||
name_photographer="`< /tmp/name_photographer`"
|
name_photographer="`< /tmp/name_photographer`"
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,29 @@
|
||||||
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
|
# Get the api key
|
||||||
|
key=$(cat ~/i3lock-delta/api_key)
|
||||||
|
# Get the queries
|
||||||
|
queries=$(cat ~/.config/lock_preferences | xargs)
|
||||||
|
# Construct the base url
|
||||||
|
url="https://api.unsplash.com/photos/random?client_id=$key&orientation=landscape&featured=false"
|
||||||
|
|
||||||
|
# Check if there are any queries
|
||||||
|
if [ -n "$queries" ]; then
|
||||||
|
url="$url&query=$(shuf -n 1 ~/.config/lock_preferences)"
|
||||||
|
fi
|
||||||
|
|
||||||
|
# make API call and check if curl fails
|
||||||
|
if ! json=$(curl -s $url); then
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Get image location from json
|
||||||
|
image_url=$(echo $json | jq -r ".links.download_location")
|
||||||
|
|
||||||
|
# Download image and check if curl fails
|
||||||
|
curl $image_url > ~/.rand_bg
|
||||||
|
if [[ $? -ne 0 ]] ; then exit 1; fi
|
||||||
|
|
||||||
|
# Write author's name to file
|
||||||
|
user_name=$(echo $json | jq -r ".user.name")
|
||||||
|
echo "$user_name" > /tmp/name_photographer
|
Loading…
Reference in New Issue