What would be the best approach to install a keyboard hook on Linux (X-windows) in order to trigger some application when some key-combo is pressed?? Is there a way to do this regardless of which window manager is running? The idea is to have an application being called ( or brought to foreground ) when some key is pressed in a way similar that Google Desktop does to Ctrl-Ctrl.
XGrabKey on the root window is how xbindkey does it. Be careful about having some alternative method of killing the grab though, it's very annoying to have to go somewhere to ssh into your own box just to kill that process... And that's why, if it was me, xbindkeys+"echo 'moo' > /tmp/moo-fifo" would be the way to do it. That way, you could also control it in any number of other ways you haven't thought of yet.
Related
On modern Fedora Linux installations, pressing the computer's "power off" button does not actually shut it down, but rather hibernates it, which is very convenient.
However, this is only true if I run the default Gnome window manager. If I use a different window manager (my favorite is the old-school ctwm), this doesn't happen - the power-off button shuts down the system instead of hibernating.
My question is: How can I tell my system (I don't mind a little coding, and it doesn't need to be inside ctwm) to do something else - and not a shutdown - when the poweroff button is pressed. Without Gnome.
I did a little digging, and it appears that I have "upowerd" running. However, it is running just the same when ctwm and Gnome are the current window manager, so Gnome must somehow be telling upowerd not to power-off the computer and instead either do something else (like hibernate) or send Gnome that the event happened. But I couldn't find any documentation on how that's done, or how I can do something similar without Gnome.
When I do not use my graphical session anymore, the screensaver automatically lock it and power off the screen to save energy.
I want it to keep locking my session but not to power off the screen, is it possible ?
I use Ubuntu 18.04 with default gnome display manager.
Thank you,
Matias
As described in this thread on ubuntu forums it looks like this is part of the gnome-screensaver-command and there is no easy way to disable it. Try replacing the default screensaver with another one, like xscreensaver.
Hint: when you manually lock your screen, just hold the buttons a second longer and the screen won't turn off.
I have a window, with several Gtk-2.0 widgets. One of them is a GtkEntry, with the corresponding GtkCompletion connected.
I need to debug the code called when a selection ('match' event) is made in the dropdown shown by the GtkCompletion. So I set a breakpoint, activate the selection, and the entire desktop hangs. The only form I found to get out is Ctl-Alt-Backspace, and delete the gdb instance.
When this happens, the entire windows manager remains as if the dropdown is still active - only responds to Ctl-Alt functions, like Ctl-Alt-F2.
I tried the --sync commandline option, but that didn't make any difference. Though there seem to be some (rather complicated) solutions such as running a nested Window server, or debug remotely, I can't imagine there isn't a more elegant solution.
Any suggestions?
I do this all the time.
You need to grab another laptop, or a console on another server, and ssh into your primary desktop/laptop. Start your GTK application on your main desktop/laptop, then attach gdb to it from your connection from your other laptop/machine.
Then, you will run your gtk application on your main screen, and debug it from a separate connection, without interfering with your primary display.
EDIT: I see that you already considered remote debugging, but in my experience it's really not that difficult. I just have another laptop on my desk, next to me, to debug my X applications.
I have Debian 2.6 running on a SBC that I plan on using in an embedded setup. What I need to do is configure it so that linux will start up and run just my Qt GUI application. Do I need a window manager to do this or can I just do it with X11. Also because it is going to be for an embedded system I do not want to load any desktop manager. Any info on how this can be done would be great!
Yes you can do this without a window manager.
first: You need to boot into a non X session, init level 1 or 3.
second: You need to start the X server, in a basic mode by just calling X or xinit.
third: Start your app. You may need to take a little more control over where your app is positioned on the screen and its dimensions in your code, as you will not have a window manager to help with this.
alternatively: you can launch one of the more basic window managers to see how they play with your system. Motif Window Manager (mwm) and Tab Window Manager (twm)
Note: While working without a window manager, you may get into a state where you cannot do some very basic operations (ex: close a window, move a window, resize a window). You may find that you cannot survive without at least some of the more basic window management functions. Until you close the loop on this, remember, Ctrl + Alt + Backspace will kill the XServer.
If you want to start your app just with X11, you need do:
copy file /etc/X11/xinit/xinitrc to ~/.xinitrc
write all you want to run to it
run command startx
It worked for me and I hope it will help you
I am working on old Motif-based application for Linux. I want to be able to programmatically change the active window of our application. I can redirect the input by using XSetInputFocus() function and the keyboard input start to go there, but XReconfigureWMWindow() and XRaiseWindow() functions just don't work.
I've read that Window Managers try to stop this behaviour, so tried to disable configure redirection, but this doesn't work either. Any ideas how to make one of my own windows on top of the window stack?
There is a tiny program called wmctrl available (at least in Debian/Ubuntu it is in standard distribution) which is able to perform many operations on windows and desktops, and handles plenty of window managers. I'd suggest testing whether it works in your environment, and if so, peeking at its sources.
You may find the answer to this is dependent on the Window Manager the user is using, or even what settings they've given to the Window Manager. I like to set my Window Managers to do "focus follows mouse", which means you can't send the focus to a window that I haven't put my mouse on, unless you also warp the mouse there (is that function called XWarpMouse?).