Skip to content

Instantly share code, notes, and snippets.

@flauschtrud
Last active December 10, 2020 20:55
Show Gist options
  • Save flauschtrud/3da8ccbd770d0d30a992fefb81146ebf to your computer and use it in GitHub Desktop.
Save flauschtrud/3da8ccbd770d0d30a992fefb81146ebf to your computer and use it in GitHub Desktop.
Conky Theme with Random Image Slideshow
#!/bin/bash
# path to the images (will be recursively scanned)
DIRECTORY="/home/user/Pictures"
# desired width and height of the image (adjust conky size accordingly)
WIDTH=600
HEIGHT=450
# offset for filename bar (has to be added to conky's height)
VERTICAL_OFFSET=12
# choose an image randomly
IFS=$'\n'
images=($(find $DIRECTORY -name "*.jpg" -or -name "*.JPG" -or -name "*.png" -or -name "*.PNG" ))
let r="$RANDOM % ${#images[*]}"
randomimage=${images[$r]}
# copy and convert the image (the image will be resized and cropped)
convert $randomimage -resize ${WIDTH}x${HEIGHT}^ -gravity center -extent ${WIDTH}x${HEIGHT} random_conky_image.png
# output its name and conky image variable
echo $randomimage
echo "\${image random_conky_image.png -p 0,$VERTICAL_OFFSET}"
exit
conky.config = {
use_xft = true,
minimum_height = 462,
minimum_width = 600,
maximum_width = 600,
alignment = "bottom_left",
gap_x = 50,
gap_y = 50,
default_color = 'black',
font = 'DejaVu Sans Mono:size=6',
border_inner_margin = 1,
border_outer_margin = 1,
border_width = 1,
draw_shades = false,
update_interval = 1,
total_run_times = 0,
double_buffer = true,
imlib_cache_size = 0,
own_window = true,
own_window_colour = 'white',
own_window_type = 'desktop'
}
conky.text = [[
${execpi 600 ~/.config/conky/random_image.sh}
]]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment