Mathjax

jsxgraph

Monday, August 17, 2020

Bash Slideshow Widget

On my desktop one indispensable widget/plasmoid is the photo slideshow picture frame. I was a long time user of OpenSuse KDE and really liked the desktop picture frame. It showed my family pictures in random order, you could move back to a previous image, you could open the image in an editor to rotate or touch-up the picture.

I have been trying Linux Mint because more applications are supported on the Ubuntu base.  I had read good reviews for Cinnamon desktop. The Cinnamon photo frame had some shortcomings.  It did not allow navigation to prior images or editing.  The desktop widgets did not allow locking and were often moved when clicking on windows above them.  The windows above were difficult to resize because you could not grab the border over a desktop widget.

I checked on line and it looked like the Mate version had a better widget so when I updated to version 20 I chose the Mate desktop.  After installation I find out the desktop widgets were removed.  I am a little cautious about blindly following online application download instructions.  So I ended up writing a simple bash script to use ImageMagick Display as a slideshow.

Most all of the pictures are jpeg or png.  After some tweaking and trial and error this is the script.

#!/bin/bash
cd $HOME/Pictures
while true; do
find . -iregex ".*\.\(jpg\|gif\|png\|jpeg\)" -print0 | shuf -z | xargs -0 display -delay 1000 -resize 1200x900 -geometry 1200x900-10-40
done

This works reasonably well and is independent of desktop environment.  It only requires ImageMagick be installed.  A summary of the commands:

#!/bin/bash   #   Indicate to use the bash shell to run this command

cd $HOME/Pictures   #   Change to the top directory/folder where your pictures are stored

while true; do    #   continue to repeat the commands before "done", This is optional. 

find . -iregex ".*\.\(jpg\|gif\|png\|jpeg\|bmp\)" -print0   #   search for files ending in one of the listed extensions and output them separated by null characters '\0'.  The -print0 allows spaces in file names.  You could optionally pipe an ls -R * output to a file command and use sed to select image files but this is slow.

 | shuf -z    #  send the find output to a command to shuffle the order randomly separated by '\0'

 | xargs -0 display ...   #   send the output of shuf to the display command, again separated by null characters

display -delay 1000 -resize 1200x900 -geometry 1200x900-10-40   #   Display the images with a delay of 10 seconds, resized to fit in a 1200 by 900 pixel rectangle,  placed in a window 1200 by 900 pixels located 10 pixels from the right edge and 40 pixels from the bottom of the screen. 

done   #  end of the commands to be repeated

Now the image file name is displayed on the title bar.  A left click will bring up a menu where you can go back to a previous image with File --> Former.  Then you can Transform-->Rotate Right or Transform-->Rotate Left or Transform-->Crop.  Then quickly File-->Save.  Unfortunately you need to find the file to overwrite it.

An alternative is to right click "Image Info"  which will give you the full path to the file which you can edit in another program.  The picture will hold until you close the information window.

Another advantage of this over a widget/plasmoid is you can pop the picture the the front without having to "show desktop" by clicking on it.

No comments:

Post a Comment