You are not logged in.

#1 2009-07-14 10:31:35

atomicpookavirus
Member
Registered: 2009-06-28
Posts: 53

[SOLVED] changing wallpaper every minute in awesome

solution

#!/bin/sh
while true;
do
    feh --bg-scale "$(find $HOME/.wallpaper -type f -name '*.jpg' -o -name '*.png' | shuf -n 1)"
    sleep 15s
done &

I have the awesome configured to change to a random background each time I start but I thought it would be fun to have it change every minute.

I tried copying the command "awsetbg -r '~/images'" into the section where the clock is updated but it didn't work.

Does anyone know how to do this?

Last edited by atomicpookavirus (2009-07-15 03:49:11)

Offline

#2 2009-07-14 13:01:33

jack.mitchell
Member
From: Ely, Cambridgeshire, UK
Registered: 2008-08-28
Posts: 156
Website

Re: [SOLVED] changing wallpaper every minute in awesome

Cron job?

http://en.wikipedia.org/wiki/Cron

I'm sure someone will enlighten you more if you can't find enough material to help you on the web.

Offline

#3 2009-07-14 14:32:54

firecat53
Member
From: Lake Stevens, WA, USA
Registered: 2007-05-14
Posts: 1,542
Website

Re: [SOLVED] changing wallpaper every minute in awesome

Try this

Scott

Offline

#4 2009-07-14 14:57:31

alterecco
Member
Registered: 2009-07-13
Posts: 152

Re: [SOLVED] changing wallpaper every minute in awesome

Something like the following added to your rc.lua should work. However, I have not tested it, so YMMV
Perhaps you already have a 60 sec timer, in which case you should just add the os.execute call to that function.

I would probably use a cron job too though...

-- -- {{{ 60 Sec Timer
awful.hooks.timer.register(60, function ()
    os.execute("awsetbg -r '~/images'")
end)
-- -- }}}

.]

Offline

#5 2009-07-14 21:21:13

atomicpookavirus
Member
Registered: 2009-06-28
Posts: 53

Re: [SOLVED] changing wallpaper every minute in awesome

Thanks for all the replies!
This works but chokes on filenames with spaces.

#!/bin/sh
while true;
do
   find $HOME/.wallpaper -type f -name '*.jpg' -o -name '*.png' | shuf -n 1 | xargs feh --bg-scale
   sleep 15m
done &

Offline

#6 2009-07-14 21:31:30

brisbin33
Member
From: boston, ma
Registered: 2008-07-24
Posts: 1,796
Website

Re: [SOLVED] changing wallpaper every minute in awesome

feh --bg-scale "$(find $HOME/.wallpaper -type f -name '*.jpg' -o '*.png' | shuf -n 1)"
sleep 15m

this should fix your spaces issue.  you can also use `| sort -R | head -n1`.

oh, and be careful about your LC_ALL environment variable (it should = C).


edit:  had second thoughts, but i believe the above will work.  (tested successfully with `ls | sort -R | head -n1`, can only imagine `find | shuf` will work too.)

Last edited by brisbin33 (2009-07-14 21:41:02)

Offline

#7 2009-07-14 22:32:43

atomicpookavirus
Member
Registered: 2009-06-28
Posts: 53

Re: [SOLVED] changing wallpaper every minute in awesome

Thanks for that, brisbin.
It works with a minor alteration:

#!/bin/sh
while true;
do
    feh --bg-scale "$(find $HOME/.wallpaper -type f -name '*.jpg' -o -name '*.png' | shuf -n 1)"
    sleep 15s
done &

(I added -name before '*.png'.)

This is excellent too cool.
I'm still learning shell scripting so appreciate the help.
Eventually I hope to have it set up with a key bind/menu to switch a particular wallpapers settings such as tiled, scale, etc...and have those settings stick for next time it appears.

Offline

#8 2009-07-15 13:34:07

brisbin33
Member
From: boston, ma
Registered: 2008-07-24
Posts: 1,796
Website

Re: [SOLVED] changing wallpaper every minute in awesome

atomicpookavirus wrote:

(I added -name before '*.png'.)

sorry about that, typo on my part.  glad it's working.

Offline

Board footer

Powered by FluxBB