public inbox for cygwin@cygwin.com
 help / color / mirror / Atom feed
* change wallpaper periodly by cron?
@ 2003-08-20  8:02 Lucifer
  2003-08-20 12:07 ` Corinna Vinschen
  0 siblings, 1 reply; 8+ messages in thread
From: Lucifer @ 2003-08-20  8:02 UTC (permalink / raw)
  To: cygwin

I wrote a simple program to change my desktop wallpaper:

<CODE>

/* setwall.c */
#include <windows.h>

void usage()
{
        printf("Usage:\n\tsetwall <bmp_filename>\n\n");
}

int main(int argc, char **argv)
{
        int err;

        if (argc != 2) {
                usage();
                return 1;
        }

        if (SystemParametersInfo(SPI_SETDESKWALLPAPER, 0, argv[1],
                                SPIF_UPDATEINIFILE | SPIF_SENDWININICHANGE)) {
                printf("Wallpaper has been changed to: %s\n", argv[1]);
                return 0;
        } else {
                err = GetLastError();
                printf("Error: %lu\n", err);
                return err;
        }
}

</CODE>

It works well when I run it under cygwin console: the wallpaper changes
successfully.

However, when I put it in my crontab (I want to change my desktop
apperance periodly :p), the wallpaper doesn't change.  The log read:
"Error: 1459", which means "This operation requires an interactive
window station."

Is this a limitation of cron?  How can I resolve it?  Thanks in advance.

-- 
Lucifer <lucifer@tsinghua.org.cn>



--
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
Problem reports:       http://cygwin.com/problems.html
Documentation:         http://cygwin.com/docs.html
FAQ:                   http://cygwin.com/faq/

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: change wallpaper periodly by cron?
  2003-08-20  8:02 change wallpaper periodly by cron? Lucifer
@ 2003-08-20 12:07 ` Corinna Vinschen
  2003-08-21  3:34   ` Re[2]: " Lucifer
  0 siblings, 1 reply; 8+ messages in thread
From: Corinna Vinschen @ 2003-08-20 12:07 UTC (permalink / raw)
  To: cygwin

On Wed, Aug 20, 2003 at 02:12:52PM +0800, Lucifer wrote:
> I wrote a simple program to change my desktop wallpaper:
> [...]
> It works well when I run it under cygwin console: the wallpaper changes
> successfully.
> 
> However, when I put it in my crontab (I want to change my desktop
> apperance periodly :p), the wallpaper doesn't change.  The log read:
> "Error: 1459", which means "This operation requires an interactive
> window station."
> 
> Is this a limitation of cron?  How can I resolve it?  Thanks in advance.

It's a limitation of service processes.  You can only change it by setting
the "Allow service to interact with desktop" property of the service.

Corinna

-- 
Corinna Vinschen                  Please, send mails regarding Cygwin to
Cygwin Developer                                mailto:cygwin@cygwin.com
Red Hat, Inc.

--
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
Problem reports:       http://cygwin.com/problems.html
Documentation:         http://cygwin.com/docs.html
FAQ:                   http://cygwin.com/faq/

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re[2]: change wallpaper periodly by cron?
  2003-08-20 12:07 ` Corinna Vinschen
@ 2003-08-21  3:34   ` Lucifer
  2003-08-21  3:52     ` Elfyn McBratney
  0 siblings, 1 reply; 8+ messages in thread
From: Lucifer @ 2003-08-21  3:34 UTC (permalink / raw)
  To: cygwin

On Wed, 20 Aug 2003 10:20:10 +0200
Corinna Vinschen <corinna-cygwin@cygwin.com> wrote:

CV> 
CV> It's a limitation of service processes.  You can only change it by setting
CV> the "Allow service to interact with desktop" property of the service.
CV> 

I enabled the "Allow service to interact with desktop" and it works now,
thank you.  However, a DOS window titled as c:\cygwin\bin\cygrunsrv.exe
popped out.  It's ugly.  Can that be avoided?

-- 
Lucifer <lucifer@tsinghua.org.cn>




--
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
Problem reports:       http://cygwin.com/problems.html
Documentation:         http://cygwin.com/docs.html
FAQ:                   http://cygwin.com/faq/

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: change wallpaper periodly by cron?
  2003-08-21  3:34   ` Re[2]: " Lucifer
@ 2003-08-21  3:52     ` Elfyn McBratney
  2003-08-21  5:00       ` Christopher Faylor
  2003-08-21 14:30       ` Ehud Karni
  0 siblings, 2 replies; 8+ messages in thread
From: Elfyn McBratney @ 2003-08-21  3:52 UTC (permalink / raw)
  To: cygwin

Lucifer <lucifer@tsinghua.org.cn> wrote:
> On Wed, 20 Aug 2003 10:20:10 +0200
> Corinna Vinschen <corinna-cygwin@cygwin.com> wrote:
> 
> CV> 
> CV> It's a limitation of service processes.  You can only change it by setting
> CV> the "Allow service to interact with desktop" property of the service.
> CV> 
> 
> I enabled the "Allow service to interact with desktop" and it works now,
> thank you.  However, a DOS window titled as c:\cygwin\bin\cygrunsrv.exe
> popped out.  It's ugly.  Can that be avoided?

AFAIK, it cannot. It's the ugly side effect of interactive service(s) on
Windows.

-- Elfyn

--
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
Problem reports:       http://cygwin.com/problems.html
Documentation:         http://cygwin.com/docs.html
FAQ:                   http://cygwin.com/faq/

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: change wallpaper periodly by cron?
  2003-08-21  3:52     ` Elfyn McBratney
@ 2003-08-21  5:00       ` Christopher Faylor
  2003-08-21 14:30       ` Ehud Karni
  1 sibling, 0 replies; 8+ messages in thread
From: Christopher Faylor @ 2003-08-21  5:00 UTC (permalink / raw)
  To: cygwin

On Thu, Aug 21, 2003 at 04:15:29AM +0100, Elfyn McBratney wrote:
>Lucifer <lucifer@tsinghua.org.cn> wrote:
>> On Wed, 20 Aug 2003 10:20:10 +0200
>> Corinna Vinschen <corinna-cygwin@cygwin.com> wrote:
>> 
>> CV> 
>> CV> It's a limitation of service processes.  You can only change it by setting
>> CV> the "Allow service to interact with desktop" property of the service.
>> CV> 
>> 
>> I enabled the "Allow service to interact with desktop" and it works now,
>> thank you.  However, a DOS window titled as c:\cygwin\bin\cygrunsrv.exe
>> popped out.  It's ugly.  Can that be avoided?
>
>AFAIK, it cannot. It's the ugly side effect of interactive service(s) on
>Windows.

Actually, it may be better in cygwin-1.5.x due to some magic I added to
the tty code which cause an invisible console to be allocated.

Although, IIRC, Corinna may have had to change something to get it to work
right.

cgf

--
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
Problem reports:       http://cygwin.com/problems.html
Documentation:         http://cygwin.com/docs.html
FAQ:                   http://cygwin.com/faq/

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: change wallpaper periodly by cron?
  2003-08-21  3:52     ` Elfyn McBratney
  2003-08-21  5:00       ` Christopher Faylor
@ 2003-08-21 14:30       ` Ehud Karni
  2003-08-21 16:43         ` Bill C. Riemers
  1 sibling, 1 reply; 8+ messages in thread
From: Ehud Karni @ 2003-08-21 14:30 UTC (permalink / raw)
  To: lucifer; +Cc: cygwin

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On Thu, 21 Aug 2003 04:15:29 +0100, Elfyn McBratney <elfyn@cygwin.com> wrote:
>
> Lucifer <lucifer@tsinghua.org.cn> wrote:
> > On Wed, 20 Aug 2003 10:20:10 +0200
> > Corinna Vinschen <corinna-cygwin@cygwin.com> wrote:
> >
> > CV>
> > CV> It's a limitation of service processes.  You can only change it by setting
> > CV> the "Allow service to interact with desktop" property of the service.
> > CV>
> >
> > I enabled the "Allow service to interact with desktop" and it works now,
> > thank you.  However, a DOS window titled as c:\cygwin\bin\cygrunsrv.exe
> > popped out.  It's ugly.  Can that be avoided?
>
> AFAIK, it cannot. It's the ugly side effect of interactive service(s) on
> Windows.

Try to compile your program with -mwindows (without changing your
"main" function). I use this trick when I want a program without a
window (or console). If you run it from bash (or sh/csh) you wont
notice any change, but if you run it under command or cmd, it will
run without a (console) window.

Ehud.


- --
 Ehud Karni           Tel: +972-3-7966-561  /"\
 Mivtach - Simon      Fax: +972-3-7966-667  \ /  ASCII Ribbon Campaign
 Insurance agencies   (USA) voice mail and   X   Against   HTML   Mail
 http://www.mvs.co.il  FAX:  1-815-5509341  / \
 mailto:ehud@unix.mvs.co.il                  Better  Safe  Than  Sorry
-----BEGIN PGP SIGNATURE-----
Comment: use http://www.keyserver.net/ to get my key (and others)

iD8DBQE/RMnHLFvTvpjqOY0RAvbKAJ9/NisvO2AiJpdQOdUBA4dVymz5SACeJka1
qt/n45d0M2boTdaGlKIbso8=
=uhKZ
-----END PGP SIGNATURE-----

--
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
Problem reports:       http://cygwin.com/problems.html
Documentation:         http://cygwin.com/docs.html
FAQ:                   http://cygwin.com/faq/

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: change wallpaper periodly by cron?
  2003-08-21 14:30       ` Ehud Karni
@ 2003-08-21 16:43         ` Bill C. Riemers
  2003-08-21 22:35           ` Igor Pechtchanski
  0 siblings, 1 reply; 8+ messages in thread
From: Bill C. Riemers @ 2003-08-21 16:43 UTC (permalink / raw)
  To: ehud, lucifer; +Cc: cygwin

[-- Attachment #1: Type: text/plain, Size: 4091 bytes --]

There is a solution for programs which you don't compile.  That is simply to
reposition the console window off screen.  i.e.

Right click on the title bar of the window and select properties.  Then go
to layout.  Unselect "Let system position window".  Adjust the window so the
position is off screen.  Click "OK".  Finally, select "Save properties for
future windows with the same title" and click "OK".

Now your window still opens, but it doesn't clutter the screen.

If you want to avoid even having the icon, I find the successful approach
for that is to invoke your program via rxvt.  For example, for my Cygwin
icon I use a short cut of with a target of: "d:\bin\rxvt.exe -e
/bin/bash --login".  You can use the -geometry option on your rxvt windows
to hide those.

Indeed a console window still opens, but it is off screen, and closes so
quickly that most of the time I never see the icon on my task bar for it.

For crontab jobs, I found the same type of trick works if you install the
program as a service.  i.e.

    cygrunsrv -I pcphone -a -w -p /usr/local/bin/pcphone -s QUIT -o -t
manual

Next under Windows Services, check the "allowed to interact with desktop
button".

Now whenever I run "/usr/local/bin/pcphone" either interactively, or from a
crontab job, it simply starts calls "cygrunsrv -S pcphone" which in turn
invokes:

        /usr/local/bin/pcphone -w

Finally, the pcphone script when invoked as a service starts the real
pcphone.exe via a nohup call to rxvt, sleeps for five seconds and then
exits.  So the "CONSOLE" window icon exists on my task bar for no more than
five seconds.  Once the "CONSOLE" window is closed, the "rxvt" window is
also killed, however the children of "rxvt", "pcphone.exe" are not killed.
So "pcphone.exe" is left running as an orphaned process.  The reason for the
five second delay is just to give rxvt enough time to invoke the
"pcphone.exe" program.

                                                        Bill







----- Original Message ----- 
From: "Ehud Karni" <ehud@unix.mvs.co.il>
To: <lucifer@tsinghua.org.cn>
Cc: <cygwin@cygwin.com>
Sent: Thursday, August 21, 2003 9:31 AM
Subject: Re: change wallpaper periodly by cron?


> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
>
> On Thu, 21 Aug 2003 04:15:29 +0100, Elfyn McBratney <elfyn@cygwin.com>
wrote:
> >
> > Lucifer <lucifer@tsinghua.org.cn> wrote:
> > > On Wed, 20 Aug 2003 10:20:10 +0200
> > > Corinna Vinschen <corinna-cygwin@cygwin.com> wrote:
> > >
> > > CV>
> > > CV> It's a limitation of service processes.  You can only change it by
setting
> > > CV> the "Allow service to interact with desktop" property of the
service.
> > > CV>
> > >
> > > I enabled the "Allow service to interact with desktop" and it works
now,
> > > thank you.  However, a DOS window titled as
c:\cygwin\bin\cygrunsrv.exe
> > > popped out.  It's ugly.  Can that be avoided?
> >
> > AFAIK, it cannot. It's the ugly side effect of interactive service(s) on
> > Windows.
>
> Try to compile your program with -mwindows (without changing your
> "main" function). I use this trick when I want a program without a
> window (or console). If you run it from bash (or sh/csh) you wont
> notice any change, but if you run it under command or cmd, it will
> run without a (console) window.
>
> Ehud.
>
>
> - --
>  Ehud Karni           Tel: +972-3-7966-561  /"\
>  Mivtach - Simon      Fax: +972-3-7966-667  \ /  ASCII Ribbon Campaign
>  Insurance agencies   (USA) voice mail and   X   Against   HTML   Mail
>  http://www.mvs.co.il  FAX:  1-815-5509341  / \
>  mailto:ehud@unix.mvs.co.il                  Better  Safe  Than  Sorry
> -----BEGIN PGP SIGNATURE-----
> Comment: use http://www.keyserver.net/ to get my key (and others)
>
> iD8DBQE/RMnHLFvTvpjqOY0RAvbKAJ9/NisvO2AiJpdQOdUBA4dVymz5SACeJka1
> qt/n45d0M2boTdaGlKIbso8=
> =uhKZ
> -----END PGP SIGNATURE-----
>
> --
> Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
> Problem reports:       http://cygwin.com/problems.html
> Documentation:         http://cygwin.com/docs.html
> FAQ:                   http://cygwin.com/faq/
>

[-- Attachment #2: Cygwin.lnk --]
[-- Type: application/octet-stream, Size: 475 bytes --]

[-- Attachment #3: pcphone --]
[-- Type: application/octet-stream, Size: 534 bytes --]

#!/bin/bash
PATH="/usr/local/bin:/usr/bin:/bin:/cygdrive/c/WINDOWS/system32:/cygdrive/c/WINDOWS:/usr/X11R6/bin"
export PATH
PCPHONE=/cygdrive/e/PCPhone/PCPhone.exe
if [ "SYSTEM" != `whoami` ]
then
  exec cygrunsrv --start pcphone
fi
if [ ! -x "$PCPHONE" ]
then
  PCPHONE=/cygdrive/f/PCPhone.exe
fi
if [ "x$1" != "x-w" ] ; then
  exec "$PCPHONE"
else
  nohup /bin/rxvt -geometry 1x1+10000+10000 -title PcPhone -e "$PCPHONE" & rxvtid=$!
  sleep 5
  kill $rxvtid
  exec cygrunsrv --stop pcphone 2>>/dev/null
fi




[-- Attachment #4: Type: text/plain, Size: 218 bytes --]

--
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
Problem reports:       http://cygwin.com/problems.html
Documentation:         http://cygwin.com/docs.html
FAQ:                   http://cygwin.com/faq/

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: change wallpaper periodly by cron?
  2003-08-21 16:43         ` Bill C. Riemers
@ 2003-08-21 22:35           ` Igor Pechtchanski
  0 siblings, 0 replies; 8+ messages in thread
From: Igor Pechtchanski @ 2003-08-21 22:35 UTC (permalink / raw)
  To: Bill C. Riemers; +Cc: ehud, lucifer, cygwin

FYI, you can use the "run" command that comes with XFree86-bin (or get it
from Chuck Wilson's Cygwin tools page) to avoid seeing the window at all.
Also, cygrunsrv has the "-i" flag that sets the interactive bit for the
service.
	Igor

On Thu, 21 Aug 2003, Bill C. Riemers wrote:

> There is a solution for programs which you don't compile.  That is simply to
> reposition the console window off screen.  i.e.
>
> Right click on the title bar of the window and select properties.  Then go
> to layout.  Unselect "Let system position window".  Adjust the window so the
> position is off screen.  Click "OK".  Finally, select "Save properties for
> future windows with the same title" and click "OK".
>
> Now your window still opens, but it doesn't clutter the screen.
>
> If you want to avoid even having the icon, I find the successful approach
> for that is to invoke your program via rxvt.  For example, for my Cygwin
> icon I use a short cut of with a target of: "d:\bin\rxvt.exe -e
> /bin/bash --login".  You can use the -geometry option on your rxvt windows
> to hide those.
>
> Indeed a console window still opens, but it is off screen, and closes so
> quickly that most of the time I never see the icon on my task bar for it.
>
> For crontab jobs, I found the same type of trick works if you install the
> program as a service.  i.e.
>
>     cygrunsrv -I pcphone -a -w -p /usr/local/bin/pcphone -s QUIT -o -t
> manual
>
> Next under Windows Services, check the "allowed to interact with desktop
> button".
>
> Now whenever I run "/usr/local/bin/pcphone" either interactively, or from a
> crontab job, it simply starts calls "cygrunsrv -S pcphone" which in turn
> invokes:
>
>         /usr/local/bin/pcphone -w
>
> Finally, the pcphone script when invoked as a service starts the real
> pcphone.exe via a nohup call to rxvt, sleeps for five seconds and then
> exits.  So the "CONSOLE" window icon exists on my task bar for no more than
> five seconds.  Once the "CONSOLE" window is closed, the "rxvt" window is
> also killed, however the children of "rxvt", "pcphone.exe" are not killed.
> So "pcphone.exe" is left running as an orphaned process.  The reason for the
> five second delay is just to give rxvt enough time to invoke the
> "pcphone.exe" program.
>
>                                                         Bill
>
>
>
>
>
>
>
> ----- Original Message -----
> From: "Ehud Karni" <ehud@unix.mvs.co.il>
> To: <lucifer@tsinghua.org.cn>
> Cc: <cygwin@cygwin.com>
> Sent: Thursday, August 21, 2003 9:31 AM
> Subject: Re: change wallpaper periodly by cron?
>
>
> > -----BEGIN PGP SIGNED MESSAGE-----
> > Hash: SHA1
> >
> > On Thu, 21 Aug 2003 04:15:29 +0100, Elfyn McBratney <elfyn@cygwin.com>
> wrote:
> > >
> > > Lucifer <lucifer@tsinghua.org.cn> wrote:
> > > > On Wed, 20 Aug 2003 10:20:10 +0200
> > > > Corinna Vinschen <corinna-cygwin@cygwin.com> wrote:
> > > >
> > > > CV>
> > > > CV> It's a limitation of service processes.  You can only change it by
> setting
> > > > CV> the "Allow service to interact with desktop" property of the
> service.
> > > > CV>
> > > >
> > > > I enabled the "Allow service to interact with desktop" and it works
> now,
> > > > thank you.  However, a DOS window titled as
> c:\cygwin\bin\cygrunsrv.exe
> > > > popped out.  It's ugly.  Can that be avoided?
> > >
> > > AFAIK, it cannot. It's the ugly side effect of interactive service(s) on
> > > Windows.
> >
> > Try to compile your program with -mwindows (without changing your
> > "main" function). I use this trick when I want a program without a
> > window (or console). If you run it from bash (or sh/csh) you wont
> > notice any change, but if you run it under command or cmd, it will
> > run without a (console) window.
> >
> > Ehud.
> >
> >
> > - --
> >  Ehud Karni           Tel: +972-3-7966-561  /"\
> >  Mivtach - Simon      Fax: +972-3-7966-667  \ /  ASCII Ribbon Campaign
> >  Insurance agencies   (USA) voice mail and   X   Against   HTML   Mail
> >  http://www.mvs.co.il  FAX:  1-815-5509341  / \
> >  mailto:ehud@unix.mvs.co.il                  Better  Safe  Than  Sorry
> > -----BEGIN PGP SIGNATURE-----
> > Comment: use http://www.keyserver.net/ to get my key (and others)
> >
> > iD8DBQE/RMnHLFvTvpjqOY0RAvbKAJ9/NisvO2AiJpdQOdUBA4dVymz5SACeJka1
> > qt/n45d0M2boTdaGlKIbso8=
> > =uhKZ
> > -----END PGP SIGNATURE-----
> >
> > --
> > Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
> > Problem reports:       http://cygwin.com/problems.html
> > Documentation:         http://cygwin.com/docs.html
> > FAQ:                   http://cygwin.com/faq/
> >
>

-- 
				http://cs.nyu.edu/~pechtcha/
      |\      _,,,---,,_		pechtcha@cs.nyu.edu
ZZZzz /,`.-'`'    -.  ;-;;,_		igor@watson.ibm.com
     |,4-  ) )-,_. ,\ (  `'-'		Igor Pechtchanski, Ph.D.
    '---''(_/--'  `-'\_) fL	a.k.a JaguaR-R-R-r-r-r-.-.-.  Meow!

"I have since come to realize that being between your mentor and his route
to the bathroom is a major career booster."  -- Patrick Naughton

--
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
Problem reports:       http://cygwin.com/problems.html
Documentation:         http://cygwin.com/docs.html
FAQ:                   http://cygwin.com/faq/

^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2003-08-21 21:15 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2003-08-20  8:02 change wallpaper periodly by cron? Lucifer
2003-08-20 12:07 ` Corinna Vinschen
2003-08-21  3:34   ` Re[2]: " Lucifer
2003-08-21  3:52     ` Elfyn McBratney
2003-08-21  5:00       ` Christopher Faylor
2003-08-21 14:30       ` Ehud Karni
2003-08-21 16:43         ` Bill C. Riemers
2003-08-21 22:35           ` Igor Pechtchanski

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).