echo $DISPLAY to find out what is your display number. There maybe more than one display, so you need to address/display on the right one. Check what you are actually using as per echo cmd above.
-T On Feb 6, 2018 5:46 PM, "Denis Heidtmann" <[email protected]> wrote: > I have presently export DISPLAY=:0. I do not know what the : means, and > why would you choose 1 rather than zero? Note that presently the window > does appear, but the command wmctrl -k does not seem to do anything. I > will be giving anacron an opportunity tomorrow with Wes' suggestion added. > > -Denis > > On Tue, Feb 6, 2018 at 1:57 PM, Tomas Kuchta <[email protected] > > > wrote: > > > I do not believe that you will be able to open graphical window using > cron. > > The best you can hope for is sending notifications or emails. > > > > If you have the strength to continue with random experiments. Try: export > > DISPLAY :1 > > In your script before launching the window. Although that will likely be > > blocked because the executing user is different than the user owning the > > graphical environment. > > > > The only sure way, I can think of, would be to use existing or write own > > notification system. This would run after login, by the user and accept > > your notification messages for displaying. > > > > Hope it helps, Tomas > > > > On Feb 6, 2018 1:45 PM, "Ali Corbin" <[email protected]> wrote: > > > > > Another thing to try is to use the full path, in case the cron > > environment > > > doesn't include $PATH > > > > > > On Tue, Feb 6, 2018 at 1:39 PM, wes <[email protected]> wrote: > > > > > > > try sudo wmctrl, the same way you're doing sudo zenity. > > > > > > > > -wes > > > > > > > > On Tue, Feb 6, 2018 at 1:27 PM, Denis Heidtmann < > > > [email protected] > > > > > > > > > wrote: > > > > > > > > > I have a script which runs daily via anacron. I want the script to > > > > launch > > > > > a zenity window to notify the user, so I issue the command wmctrl > -k > > on > > > > > before zenity and wmctrl - off after. This is supposed to > minimize > > > all > > > > > open windows to ensure that the zenity window will be visible. I > > > have a > > > > > test script to show that it works. Both scripts are owned by root, > > but > > > > > editable by me. I have run the test script from a command line > > login > > > > > using sudo, as well as from a Gnome terminal. The test script > > behaves > > > as > > > > > intended--the desktop is cleared of all open windows. I inserted > a > > > test > > > > > zenity window at the beginning of the real script to verity that > when > > > > > launched by anacron it would behave the same way. It does not! It > > > does > > > > > not minimize open windows, but the zenity window does appear on top > > of > > > > the > > > > > open windows. > > > > > > > > > > What is different about the anacron launch? I have been monkeying > > with > > > > > this thing for quite a while. I tried wmctrl -R but that did not > > > behave > > > > as > > > > > I had hoped. wmctrl -k does what I want except when anacron is > doing > > > the > > > > > launching. > > > > > > > > > > Ideas? > > > > > > > > > > -Denis > > > > > > > > > > Test script: > > > > > > > > > > #!/bin/bash > > > > > # test to get zenity to work when script is not called from an X > > window > > > > > # change to a non-X login (^ alt F2), call this w/sudo, then go > back > > > to X > > > > > (^ alt F7) > > > > > # to see if a zenity window shows up. > > > > > # feb 5 2018 the above worked--all open windows minimized. > > > > > > > > > > > > > > > Notification () { > > > > > # pass title, text of notice, and timeout as 3 parameters > > > > > TITLE=$1; MSG=$2; TIMOUT=$3 > > > > > wmctrl -k on > > > > > sudo -u household zenity --question --title="$TITLE" --text="$MSG" > > > > > --timeout="$TIMOUT" > > > > > RETRNCODE=$? > > > > > wmctrl -k off > > > > > return $RETRNCODE # return codes: 0 = YES, 1 = cancel, 5 = timeout > > > > > } > > > > > > > > > > sleep 30 > > > > > > > > > > export DISPLAY=:0 > > > > > # test of launch of zenity > > > > > Notification "Test of zenity (backup_checksh)" "This should > minimize > > > all > > > > > open windows." 20 > > > > > # remove when satisfied that launch works. > > > > > > > > > > Top of real script: > > > > > > > > > > #!/bin/bash > > > > > > > > > > Notification () { > > > > > # pass title, text of notice, and timeout as 3 parameters > > > > > TITLE=$1; MSG=$2; TIMOUT=$3 > > > > > wmctrl -k on > > > > > sudo -u household zenity --question --title="$TITLE" --text="$MSG" > > > > > --timeout="$TIMOUT" > > > > > RETRNCODE=$? > > > > > wmctrl -k off > > > > > return $RETRNCODE # return codes: 0 = YES, 1 = cancel, 5 = timeout > > > > > } > > > > > export DISPLAY=:0 > > > > > # test of launch of zenity > > > > > Notification "Test of zenity (backup_checksh)" "This should > minimize > > > all > > > > > open windows." 5 > > > > > # remove when satisfied that launch works. > > > > > MAX_TIME=$((7 * 24 * 3600)) > > > > > _______________________________________________ > > > > > PLUG mailing list > > > > > [email protected] > > > > > http://lists.pdxlinux.org/mailman/listinfo/plug > > > > > > > > > _______________________________________________ > > > > PLUG mailing list > > > > [email protected] > > > > http://lists.pdxlinux.org/mailman/listinfo/plug > > > > > > > _______________________________________________ > > > PLUG mailing list > > > [email protected] > > > http://lists.pdxlinux.org/mailman/listinfo/plug > > > > > _______________________________________________ > > PLUG mailing list > > [email protected] > > http://lists.pdxlinux.org/mailman/listinfo/plug > > > _______________________________________________ > PLUG mailing list > [email protected] > http://lists.pdxlinux.org/mailman/listinfo/plug > _______________________________________________ PLUG mailing list [email protected] http://lists.pdxlinux.org/mailman/listinfo/plug
