You are not logged in.
Pages: 1
Just finished putting the finishing touches on a small script that does the following:
1. Randomizes the wallpaper from a directory (very, very rudimentary)
2. Changes the panel background colour to match a colour-sampled section of the wallpaper below the panel
3. Fades the panel colour from the old wallpaper's colour-sample to the new wallpaper's colour sample.
...and thought I would share it in case anyone else is interested.
Youtube video (Arch Linux)
Youtube video (Xubuntu 15.04)
Here is the script (instructions on setting it up as at the top of the script):
#!/bin/bash
###
### Description: Randomly cycles the wallpaper from a collection of wallpapers in a directory
### while changing the backgound colour of the panel to match the average colour
### of the sampled image below the panel; as well as gradually stepping between
### the sampled colours of the old a new wallpapers to create a fading effect.
###
### Requires: imagemagick
###
### Setup: For the panel that you want affected:
### Appearance >> Style = Solid Color (background-style)
### Appearance >> Alpha = 75 (adjust to taste) (background-alpha)
### Appearance >> Color = #FFFFFF (so to create the xfconf property) (background-color)
###
### To get the required configurable values:
### DEBUG -> whether you want debug information displayed. Useful if
### running this script from a terminal to see what is
### avtually happening
### PANEL -> right-click the Panel and select Panel >> Panel Preferences
### the panel number will be shown
### PANEL_DIMS -> this is the width of the panel x the height of the panel +
### the coordinates of the top left corner
### (this box is used to sample the image for colour-matching)
### F -> the factor to dim the panel by. The maximum is 257 which is the average
### colour below the panel. 128 is used to create a dimmed version
### of the average colour. (valid = 0 to 257)
### NUM_STEPS -> the number of fade steps to get from the average colour of
### the previous image to the average colour of the new image
### This creates the fading effect
### iDIR -> The path to the directory that holds the images you want to cycle
### xfIMAGE -> the xfconf property specific to your system that holds the path
### and name of the current background image. To determine it,
### run "xfconf-query -c xfce4-desktop -m" in a terminal window
### and manually change the wallpaper. The location will be
### displayed in the terminal window
###
### Make sure that you make this script executable
### chmod +x /path/to/this/script
###
### Automation: Create a new user crontab entry "crontab -e" that looks like this:
### */5 * * * * /path/to/this/script
###
### The /5 indicates every 5 minutes. To have the wallpaper change every 15 minutes,
### use: */15
################################################################################################
# START OF CONFIGURABLE PARAMETERS
################################################################################################
# debug (change to 1 for debug output)
DEBUG=0
# the panel to affect (must match xfconf panel numbering)
PANEL="1"
[ $DEBUG -eq 1 ] && echo "Panel = "$PANEL
# the panel dimensions (for image sampling)
PANEL_DIMS="1366x24+0+0"
[ $DEBUG -eq 1 ] && echo "Panel Dimensions = "$PANEL_DIMS
# the factor to multiply by (257 is the max - this darkens from the average to give a more tint look)
F=128
[ $DEBUG -eq 1 ] && echo "factor = "$F
# the number of steps for fading effect
NUM_STEPS=10
# directory to choose images from
iDIR="/home/toz/Downloads/1366x768"
[ $DEBUG -eq 1 ] && echo "Image directory = "$iDIR
# xfconf image location
xfIMAGE="/backdrop/screen0/monitorLVDS1/workspace0/last-image"
[ $DEBUG -eq 1 ] && echo "xfconf last-image location = "$xfIMAGE
################################################################################################
# END OF CONFIGURABLE PARAMETERS
################################################################################################
# set environment variables (for cron usage) - tested under Arch Linux & Xubuntu 15.04
dbus_session_address=$(grep -z DBUS_SESSION_BUS_ADDRESS /proc/$(pgrep -o xfwm4)/environ | sed 's/^DBUS_SESSION_BUS_ADDRESS=//')
display=$(grep -z DISPLAY /proc/$(pgrep -o xfwm4)/environ | sed 's/^DISPLAY=//')
export DBUS_SESSION_BUS_ADDRESS="$dbus_session_address"
export DISPLAY="$display"
############### PRE
# the base wallpaper file location
OLD_WALL="$(xfconf-query -c xfce4-desktop -p $xfIMAGE)"
[ $DEBUG -eq 1 ] && echo "Old Wallpaper = "$OLD_WALL
# get the average colour of the area under the panel
_ans=$(convert -extract $PANEL_DIMS "$OLD_WALL" -scale 1x1\! -format '%[pixel:s]' info:-)
_ans2=$(echo $_ans | sed -e 's/srgb(//' | sed -e 's/)//' | sed -e 's/,/ /g')
_RED=$(echo $_ans2 | cut -d' ' -f1)
_GREEN=$(echo $_ans2 | cut -d' ' -f2)
_BLUE=$(echo $_ans2 | cut -d' ' -f3)
[ $DEBUG -eq 1 ] && echo " _ans = "$_ans
[ $DEBUG -eq 1 ] && echo " _ans2 = "$_ans2
[ $DEBUG -eq 1 ] && echo " _RED = "$_RED
[ $DEBUG -eq 1 ] && echo " _GREEN = "$_GREEN
[ $DEBUG -eq 1 ] && echo " _BLUE = "$_BLUE
# mutliply by factor to get correct xfconf values
let _aRED=$_RED*$F
let _aGREEN=$_GREEN*$F
let _aBLUE=$_BLUE*$F
[ $DEBUG -eq 1 ] && echo " _aRED = "$_aRED
[ $DEBUG -eq 1 ] && echo " _aGREEN = "$_aGREEN
[ $DEBUG -eq 1 ] && echo " _aBLUE = "$_aBLUE
############### PRE
############### Change the wallpaper
# randomize the image (not a true randomizer)
NEW_WALL="$(shuf -n1 -e $iDIR/*)"
[ $DEBUG -eq 1 ] && echo "Changing wallpaper....."
xfconf-query -c xfce4-desktop -p $xfIMAGE -s "$NEW_WALL"
# slight delay to allow wallpaper to load
sleep 0.1
####################################
############### POST
# the base wallpaper file location
NEW_WALL="$(xfconf-query -c xfce4-desktop -p $xfIMAGE)"
[ $DEBUG -eq 1 ] && echo "New Wallpaper = "$NEW_WALL
# get the average colour of the area under the panel
ans=$(convert -extract $PANEL_DIMS "$NEW_WALL" -scale 1x1\! -format '%[pixel:s]' info:-)
ans2=$(echo $ans | sed -e 's/srgb(//' | sed -e 's/)//' | sed -e 's/,/ /g')
RED=$(echo $ans2 | cut -d' ' -f1)
GREEN=$(echo $ans2 | cut -d' ' -f2)
BLUE=$(echo $ans2 | cut -d' ' -f3)
[ $DEBUG -eq 1 ] && echo " ans = "$ans
[ $DEBUG -eq 1 ] && echo " ans2 = "$ans2
[ $DEBUG -eq 1 ] && echo " RED = "$RED
[ $DEBUG -eq 1 ] && echo " GREEN = "$GREEN
[ $DEBUG -eq 1 ] && echo " BLUE = "$BLUE
# mutliply by factor to get correct xfconf values
let aRED=$RED*$F
let aGREEN=$GREEN*$F
let aBLUE=$BLUE*$F
[ $DEBUG -eq 1 ] && echo " aRED = "$aRED
[ $DEBUG -eq 1 ] && echo " aGREEN = "$aGREEN
[ $DEBUG -eq 1 ] && echo " aBLUE = "$aBLUE
############### POST
# set the panel background colour
[ $DEBUG -eq 1 ] && echo "Adjusting Panel #$PANEL....."
# get the differences
let rDIFF=($aRED-$_aRED)
let gDIFF=($aGREEN-$_aGREEN)
let bDIFF=($aBLUE-$_aBLUE)
for i in `seq 1 $NUM_STEPS`
do
let Rval=$(echo "$_aRED $rDIFF $i $NUM_STEPS" | awk '{printf "%.0f \n", $1+($2*($3/$4))}')
let Gval=$(echo "$_aGREEN $gDIFF $i $NUM_STEPS" | awk '{printf "%.0f \n", $1+($2*($3/$4))}')
let Bval=$(echo "$_aBLUE $bDIFF $i $NUM_STEPS" | awk '{printf "%.0f \n", $1+($2*($3/$4))}')
[ $DEBUG -eq 1 ] && echo " i Rval Gval Bval = "$i $Rval $Gval $Bval
xfconf-query -c xfce4-panel -p /panels/panel-$PANEL/background-color -s $Rval -s $Gval -s $Bval -s 0
sleep 0.05
done
exit 0
Enjoy.
Please remember to mark your thread [SOLVED] to make it easier for others to find
--- How To Ask For Help | FAQ | Developer Wiki | Community | Contribute ---
Offline
Are you aware that there's already a program named wallpapoz that does exactly that?
Registered Linux user #470359
Permanently recovered BOFH
Any advice in this post is worth exactly what you paid for it.
Offline
The wallpaper rotation is the easy unimportant piece - you are right that there are many programs that do this. The unique piece here is that the background colour of the panel changes to adapt to an average colour sampling of the wallpaper behind it. And it fades between these colours. As far as I can tell, wallpapoz doesn't do this colour-matching and fading. Am I wrong?
Please remember to mark your thread [SOLVED] to make it easier for others to find
--- How To Ask For Help | FAQ | Developer Wiki | Community | Contribute ---
Offline
I don't know, as I've never tried it. I first installed it so that I could have a different wallpaper for each desktop, making it easy to know which one I was on. Once I had it, I found it much more fun to have all the desktops have the same wallpaper, rotating at random. Now, I'm using Xfce 4.10, which has that built in. If 4.12 doesn't, I may go back to wallpapoz.
Registered Linux user #470359
Permanently recovered BOFH
Any advice in this post is worth exactly what you paid for it.
Offline
Wallpapoz does not do that--right you are. That's a neat trick, BTW.
MX-23 (based on Debian Stable) with our flagship Xfce 4.18.
Offline
Thank you ToZ! Really great job. I adopted your script to rightclick menu in my file manager (caja). Works great!
Offline
Just finished putting the finishing touches on a small script that does the following:
BTW. Cay u please describe how u centered your clock? I made one more panel to do that and centered it. Everething is fine until i click anything on the main panel. after that my panel with clock becomes unreadable because it goes below main panel
Offline
Its been a while, but I believe I had one full length panel on the bottom and three separate panels on top (33%, 34%, 33%). The panel underneath (created first) was 1 pixel thinner than the others so that it could not get selected. Also, it was fully transparent. I used it to blur the gaps between the other 3 panels. The clock was centered in the middle panel.
Please remember to mark your thread [SOLVED] to make it easier for others to find
--- How To Ask For Help | FAQ | Developer Wiki | Community | Contribute ---
Offline
For xfce4-panel version 4.14.3, the property should be changed from background-color to background-rgba.
Remember to edit the subject of your topic to include the [SOLVED] tag once you're satisfied with the answers or have found a solution (in which case, don't forget to share it as well), so that other members of the community can quickly refer to it and save their time. Pretty please!
Offline
Pages: 1
[ Generated in 0.007 seconds, 7 queries executed - Memory usage: 584.68 KiB (Peak: 601.52 KiB) ]