BLU Discuss list archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Discuss] cron notifications to GUI front end
- Subject: [Discuss] cron notifications to GUI front end
- From: gaf.linux at gmail.com (Jerry Feldman)
- Date: Fri, 29 Mar 2019 16:14:40 -0400
- In-reply-to: <20190329200629.GG2200@bladeshadow.org>
- References: <CAEvgogE-q-nSnwR_dFNwAxc-sUrjkTwNEaxQrfF2Ev6f3-Xdog@mail.gmail.com> <CAEvgogFBUyXkZkp6baF3pfK35n6uyetfL-4ZWG3pKw1R_oFshw@mail.gmail.com> <5c9ceb16.1c69fb81.999d1.13c8@mx.google.com> <20190329200242.GF2200@bladeshadow.org> <20190329200629.GG2200@bladeshadow.org>
I've done some similar things with X. I plan to use python. On Fri, Mar 29, 2019, 4:06 PM Derek Martin <invalid at pizzashack.org> wrote: > I neglected to mention that the cron script also needs to set DISPLAY, > most likely to ":0", and then export it. That's probably not a > surprise to any veteran X users though... > > On Fri, Mar 29, 2019 at 03:02:42PM -0500, Derek Martin wrote: > > On Thu, Mar 28, 2019 at 11:41:09AM -0400, Rich Pieri wrote: > > > On Thu, 28 Mar 2019 11:23:26 -0400 > > > Jerry Feldman <gaf.linux at gmail.com> wrote: > > > > > > > One idea I had was to write a small GUI that would cancel any > > > > currently scheduled shutdown and reschedule and notify the user when > > > > the shutdown is imminent. If the user logs off, the shutdown would > > > > still be in effect. > > > > > > I don't think that's going to work the way you expect. One big problem > > > is that a process running from cron can't directly access your X server > > > so it can't send GUI notices. > > > > That's not actually true, though it will take a little bit of hackery > > to make it work. > > > > Modern Linux systems depend on MIT-MAGIC-COOKIE-1 authentication to > > allow access to the X display. You control this through the xauth > > command. Once you're logged in, you can see the cookies you have, > > like so: > > > > $ xauth list > > myhostname/unix:0 MIT-MAGIC-COOKIE-1 1234567890abcdef1234567890abcdef > > > > [You may have more than one, but chances are the /unix:0 entry is the > > one you want.] > > > > So when you log in, e.g. in your .xsession file or what have you, dump > > this to a file, say $HOME/tmp/xauth, and make sure it's only readable > > by you (and of course root). Then change your cron job to a script > > that adds that line to roots xauth, and runs your gui thingy. You can > > do that with something like: > > > > xauth add `cat ~myuser/tmp/xauth | grep "unix:0"` > > > > FWIW I tested this by logging into a VC on my desktop as root, setting > > up xauth essentially as above, and then running xeyes. Worked like a > > charm. :) > > > > Then, in your cron script, if the gui thingy fails (e.g. because > > there's no display to connect to, or auth failed, etc.), execute the > > shutdown command. Otherwise don't. Obviously the gui widget thingy > > needs to exit with a corresponding exit code so you can test it > > appropriately... > > > > Personally, I would never do this, but if I were to want to do this, I > > kinda like this approach--though I think Rich's is fairly equivalent. > > I suspect there's not a ton of difference in the code you'd need to > > write for either solution, though my guess is the client-server > > solution would require slightly more, depending on the language and > > GUI toolkit you chose. I would definitely use Python, but then I'd > > need to re-research GUI options for the easiest. > > > > -- > > Derek D. Martin http://www.pizzashack.org/ GPG Key ID: 0xDFBEAD02 > > -=-=-=-=- > > This message is posted from an invalid address. Replying to it will > result in > > undeliverable mail due to spam prevention. Sorry for the inconvenience. > > > > _______________________________________________ > > Discuss mailing list > > Discuss at blu.org > > http://lists.blu.org/mailman/listinfo/discuss > > -- > Derek D. Martin http://www.pizzashack.org/ GPG Key ID: 0xDFBEAD02 > -=-=-=-=- > This message is posted from an invalid address. Replying to it will > result in > undeliverable mail due to spam prevention. Sorry for the inconvenience. > > _______________________________________________ > Discuss mailing list > Discuss at blu.org > http://lists.blu.org/mailman/listinfo/discuss >
- References:
- [Discuss] cron notifications to GUI front end
- From: gaf.linux at gmail.com (Jerry Feldman)
- [Discuss] cron notifications to GUI front end
- From: gaf.linux at gmail.com (Jerry Feldman)
- [Discuss] cron notifications to GUI front end
- From: richard.pieri at gmail.com (Rich Pieri)
- [Discuss] cron notifications to GUI front end
- From: invalid at pizzashack.org (Derek Martin)
- [Discuss] cron notifications to GUI front end
- From: invalid at pizzashack.org (Derek Martin)
- [Discuss] cron notifications to GUI front end
- Prev by Date: [Discuss] cron notifications to GUI front end
- Next by Date: [Discuss] cron notifications to GUI front end
- Previous by thread: [Discuss] cron notifications to GUI front end
- Next by thread: [Discuss] cron notifications to GUI front end
- Index(es):