[SOLVED] Popping up new window without focus... how to do it?
ProgrammingThis forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
Distribution: openSUSE, Raspbian, Slackware. Previous: MacOS, Red Hat, Coherent, Consensys SVR4.2, Tru64, Solaris
Posts: 2,800
Rep:
Popping up new window without focus... how to do it?
I have a reminder system that I wrote a while back that plays an audio file and pops up a window--using xmessage(1)--based on other shell scripts, crontab entries, etc. While it works rather well, it has one rather annoying side effect: the popped up window takes input focus away from whatever the user is currently doing. Anyone getting one of these notices that's doing any kind of text entry (coding, writing test, etc.) loses some work when the notices pops up until they manually reset input focus to the editor or browser.
Is there a way to have xmessage open a window but not grab input focus? I've done some searching in the manpages and found nothing that appears to control that. While I might be able to modify the way that the window manager deals with new windows--KDE is my preferred but I'm hoping for a solution that is agnostic with respect to WM--I'm afraid that such a change would affect all windows; something I definitely want to avoid.
Distribution: openSUSE, Raspbian, Slackware. Previous: MacOS, Red Hat, Coherent, Consensys SVR4.2, Tru64, Solaris
Posts: 2,800
Original Poster
Rep:
Quote:
Originally Posted by hydrurga
Could you try using gxmessage instead?
Maybe except I cannot find it on the system or using any repository searches in YaST. I assume this is a GTK version of xmessage and that would work. If I can find an RPM for it. (Or, if I'm feeling adventurous and want to try and build it from sources.)
Distribution: openSUSE, Raspbian, Slackware. Previous: MacOS, Red Hat, Coherent, Consensys SVR4.2, Tru64, Solaris
Posts: 2,800
Original Poster
Rep:
Quote:
Originally Posted by ondoho
maybe you should use "notify-send" instead???
That's sort of nifty but in addition to using it for "Weekly conference call in 5 minutes"-type messages, I also use xmessage within scripts and like that it's interactive and let's me set the exit status so I can branch accord to whatever button was clicked on; notify-send doesn't appear to allow that. One other thing I like about xmessage is the ability to run it and specify a big obnoxious font size. I haven't figured out how one does that with notify-send yet. Or if it's even possible.
Maybe except I cannot find it on the system or using any repository searches in YaST. I assume this is a GTK version of xmessage and that would work. If I can find an RPM for it. (Or, if I'm feeling adventurous and want to try and build it from sources.)
That's sort of nifty but in addition to using it for "Weekly conference call in 5 minutes"-type messages, I also use xmessage within scripts and like that it's interactive and let's me set the exit status so I can branch accord to whatever button was clicked on; notify-send doesn't appear to allow that.
well it's either that, or no focus.
i fail to understand how you can both
- not have focus
- demand user input
???
Quote:
One other thing I like about xmessage is the ability to run it and specify a big obnoxious font size. I haven't figured out how one does that with notify-send yet. Or if it's even possible.
it is possible, depending on the actual notification daemon.
i use dunst as my notification daemon, and it is definitely possible with that.
other popular choices are: xfce4-notifyd, deepin-notifications, lxqt-notificationd, mate-notification-daemon, notify-osd etc.
xmessage itself doesn't take focus: in fact you'll find most normal Xlib applications are passive with regard to focus because focus stealing is considered bad behaviour. You can confirm this yourself if you start X with something like xinit /usr/bin/xterm from a tty instead of starting X the usual way and then running xmessage without a window manager present.
A program may set the 'Input field' of WM_HINTS to let the window manager know whether or not it needs or expects input focus (things like xload/xclock set this to 'false') but I'm afraid xmessage doesn't provide an option for setting this and it's entirely down to the window manager to decide whether to give focus to a window or not when it is mapped and as such that is where you'll have to look to see if you can configure it not to do this to xmessage's window.
Ah. My googling may have found that but it must have been farther down in the findings. The higher rated links weren't all that promising. I'll give that a shot. Thx...
Distribution: openSUSE, Raspbian, Slackware. Previous: MacOS, Red Hat, Coherent, Consensys SVR4.2, Tru64, Solaris
Posts: 2,800
Original Poster
Rep:
Quote:
Originally Posted by GazL
xmessage itself doesn't take focus: in fact you'll find most normal Xlib applications are passive with regard to focus because focus stealing is considered bad behaviour. You can confirm this yourself if you start X with something like xinit /usr/bin/xterm from a tty instead of starting X the usual way and then running xmessage without a window manager present.
Good point. I have started up X manually like that for a lo-o-ong time. I do recall that behaviour.
Quote:
A program may set the 'Input field' of WM_HINTS to let the window manager know whether or not it needs or expects input focus (things like xload/xclock set this to 'false') but I'm afraid xmessage doesn't provide an option for setting this and it's entirely down to the window manager to decide whether to give focus to a window or not when it is mapped and as such that is where you'll have to look to see if you can configure it not to do this to xmessage's window.
Interesting. (I'm guessing that you must have some some low-level X11 programming in the past.) So manipulating WM_HINTS must be the big feature that drove the development of gxmessage?
Another responder reminded me of an RPM finder site--that I haven't visited for ages--that looks like it has an RPM for gxmessage. Guess I've gotten too comfortable with the typical SuSE repositories; they usually have everything I need.
Distribution: openSUSE, Raspbian, Slackware. Previous: MacOS, Red Hat, Coherent, Consensys SVR4.2, Tru64, Solaris
Posts: 2,800
Original Poster
Rep:
Got it!
"hydrurga"'s suggestion of gxmessage did the trick. (Thanks.)
I found no RPMs--or SRPMs--that were built for OpenSUSE 13.2 but did find an old 2.6.0 SRPM for SUSE 9. That built against without error (w/ couple of warnings) but seems to run OK. Well, except that the window size did not auto adjust to the length of the message. Eventually I tracked down an newer SRPM (v3.4.3). That works even better. I do find it a little funky that it doesn't accept X11 font naming and one script had to change the font name from "-*-fixed-*-*-*-*-*-400-*-*-*-*-*-*" to something like "Adobe Courier 40" but that's not really a problem though it makes it not quite a drop-in replacement for xmessage.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.