You are not logged in.

#1 2010-01-04 03:12:17

pluckypigeon
Member
Registered: 2009-01-09
Posts: 86

Having problems with cron (changing background with bash in IceWM)

I wrote a simple script to change my IceWM background big_smile

#! /bin/bash
cd ~/Pictures `ls ~/Pictures | shuf`   #Selects random folder from picture folder
cp `ls | shuf | head -1` ~/icewm.jpg  #Selects random image and copies to icewm.jpg
#sleep 2                # I thought that if I let it slept for a bit it might have helped but it didn't
icewmbg -r             #Resets Icewm Background Image

When I run this script from either the terminal or file manager it works fine. It copies the image to ~/icewm.jpg and sets it as the background.
When I use cron to run it it only copies the image to ~/icewm.jpg and doesn't "seem" to run icewmbg -r.

Any one have any ideas?? Thanks in advance!! smile

Last edited by pluckypigeon (2010-01-04 03:12:58)

Offline

#2 2010-01-04 03:18:37

ataraxia
Member
From: Pittsburgh
Registered: 2007-05-06
Posts: 1,553

Re: Having problems with cron (changing background with bash in IceWM)

cron doesn't know about your X session. Do something like

DISPLAY=:0 icewmbg -r

so it can find it.

Offline

#3 2010-01-04 03:31:26

pluckypigeon
Member
Registered: 2009-01-09
Posts: 86

Re: Having problems with cron (changing background with bash in IceWM)

ataraxia wrote:

cron doesn't know about your X session. Do something like

DISPLAY=:0 icewmbg -r

so it can find it.

Thanks for your reply, that work perfectly smile

I was tempted to throw in an xterm -e neutral

Offline

#4 2010-01-04 09:14:36

bernarcher
Forum Fellow
From: Germany
Registered: 2009-02-17
Posts: 2,281

Re: Having problems with cron (changing background with bash in IceWM)

I did use this script for some time adapted from some wiki article (I forgot which one, unfortunately). No need for cron then.

#!/bin/sh
#
# Randomly change the IceWM wallpaper every 30 minutes.

while true;
do
   sleep 30m
   WP=$(find $HOME/.wallpapers -type f -name '*.jpg' -o -name '*.png' | shuf -n 1)
   ln -sf $WP ~/.icewm/IceWMBackgroundImage.img
   icewmbg -r &>/dev/null
done

But, alas, I did switch to openbox since then (whith some similar script running, btw). tongue


To know or not to know ...
... the questions remain forever.

Offline

#5 2010-01-04 09:38:07

sHyLoCk
Member
From: /dev/null
Registered: 2009-06-19
Posts: 1,197

Re: Having problems with cron (changing background with bash in IceWM)

But, alas, I did switch to openbox since then (whith some similar script running, btw).

feh? tongue


~ Regards,
sHy
ArchBang: Yet another Distro for Allan to break.
Blog | GIT | Forum (。◕‿◕。)

Offline

#6 2010-01-04 10:25:22

bernarcher
Forum Fellow
From: Germany
Registered: 2009-02-17
Posts: 2,281

Re: Having problems with cron (changing background with bash in IceWM)

sHyLoCk wrote:

But, alas, I did switch to openbox since then (whith some similar script running, btw).

feh? tongue

In openbox? Sure!

#!/bin/bash
#
# Randomly display a wallpaper every 30 minutes.

while true;
do
   find $HOME/.wallpapers -type f -name '*.jpg' -o -name '*.png' | shuf -n 1 | xargs feh --bg-scale
   sleep 30m
done &

Icwmbg is more involved, however.


To know or not to know ...
... the questions remain forever.

Offline

#7 2010-01-04 20:09:59

pluckypigeon
Member
Registered: 2009-01-09
Posts: 86

Re: Having problems with cron (changing background with bash in IceWM)

bernarcher wrote:
ln -sf $WP ~/.icewm/IceWMBackgroundImage.img

Why the link to an img file??
Does this mean that the viewer has to work out whether it's a png or jpg??

Offline

#8 2010-01-04 22:23:29

bernarcher
Forum Fellow
From: Germany
Registered: 2009-02-17
Posts: 2,281

Re: Having problems with cron (changing background with bash in IceWM)

pluckypigeon wrote:
bernarcher wrote:
ln -sf $WP ~/.icewm/IceWMBackgroundImage.img

Why the link to an img file??
Does this mean that the viewer has to work out whether it's a png or jpg??

Sorry, I don't really remember why I did so. Could well have been caused by some tool I once experimented with.

You are free to use whatever fits. It needs only match the DesktopBackgroundImage setting in the ~/.icewm/preferences file, like e.g.:

#  Desktop background image
DesktopBackgroundImage = "/home/bp/.icewm/IceWMBackgroundImage.img"

To know or not to know ...
... the questions remain forever.

Offline

Board footer

Powered by FluxBB