Last active
November 22, 2016 15:59
-
-
Save zopieux/4b9f60de5411793fca07 to your computer and use it in GitHub Desktop.
Dependencies: i3-wm, bash, xrandr, curl, feh, imagemagick (convert), python & python-requests
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# random wallpaper | |
set $random-wall-cmd /bin/sh $HOME/.config/i3/wallpaper.sh | |
exec --no-startup-id $random-wall-cmd | |
bindsym $mod+b exec --no-startup-id $random-wall-cmd |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
import requests | |
import lxml.html | |
import sys | |
url = 'http://alpha.wallhaven.cc/search' | |
def search(**params): | |
page = requests.get(url, params=params, headers={'X-Requested-With': 'XMLHttpRequest'}) | |
html = lxml.html.fromstring(page.content) | |
links = html.xpath('//a[@class="preview"]/@href') | |
links = (l.rsplit('/', 1)[1] for l in links) | |
return ('http://wallpapers.wallhaven.cc/wallpapers/full/wallhaven-%s.jpg' % l for l in links) | |
if __name__ == '__main__': | |
print(next(search( | |
q=sys.argv[1], | |
resolutions=sys.argv[2], | |
page=1, | |
purity=100, | |
categories=100, | |
sorting='random'))) | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
set -o pipefail | |
SCRIPT=$(readlink -f "$0") | |
SCRIPTPATH=$(dirname "$SCRIPT") | |
# extract resolution of first output (you might simply hardcode that) | |
RESOLUTION=$(xrandr | grep \* | cut -d' ' -f4 | head -1) | |
# set the wallpaper from the piped image | |
function wallpaper() { | |
feh --bg-fill - | |
} | |
# generate an image with a centered message and wallpaper it | |
# ↓ message ↓ point size | |
# message "hello world" 200 | |
function message() { | |
convert -background black -fill white \ | |
-font dejavu-sans-condensed -pointsize $2 \ | |
-gravity center -size $RESOLUTION \ | |
caption:"$1" png:- | wallpaper | |
} | |
message "Please wait…" 200 | |
( curl -s $($SCRIPTPATH/wallheaven.py '"nature"' $RESOLUTION) | wallpaper ) || message "Something failed." 150 | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment