mirror of
				https://gitlab.com/ceda_ei/i3lock-delta
				synced 2025-11-04 08:40:05 +01:00 
			
		
		
		
	(almost?) finish bash port
This commit is contained in:
		@@ -11,7 +11,7 @@ while : ; do
 | 
			
		||||
	# If no, wait 300 secs and check again.
 | 
			
		||||
	[[ `< $HOME/.config/lock_screen.sta` -eq 0 ]] && sleep 300 && continue
 | 
			
		||||
	# Download the new image
 | 
			
		||||
	$HOME/i3lock-delta/downloader.php
 | 
			
		||||
	$HOME/i3lock-delta/downloader.sh
 | 
			
		||||
	if [[ $? -eq 0 ]]; then
 | 
			
		||||
		name_photographer="`< /tmp/name_photographer`"
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										29
									
								
								downloader.sh
									
									
									
									
									
										Executable file
									
								
							
							
						
						
									
										29
									
								
								downloader.sh
									
									
									
									
									
										Executable file
									
								
							@@ -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
 | 
			
		||||
		Reference in New Issue
	
	Block a user