How to make a program skip the task bar (task list) in GNU/Linux? - linux

I'm coding a demon like program from Gambas on Ubuntu 13.10.
This is a GUI application which becomes visible when the user hits specific key.
Therefore, I don't want this program to appear on the task bar.
Is there a way I can bypass it? (Maybe from a Bash trick or a Gambas code?)
Thanks! :)

You need to add _NET_WM_STATE_SKIP_TASKBAR atom to _NET_WM_STATE - see 'Application window properties' part of emwh spec.

I don't know at all gambas, but what you want is the following for gtk (in python):
window.set_property("skip-taskbar-hint", True)
or for QT:
setWindowFlags(QtCore.Qt.SplashScreen)
basically, you need to find a way to change the properties or flags for the windows you want to display. Look at the API of the windows in gambas

Related

Can I disable autocomplete with Alt+Tab on Qt Creator under Linux?

For the most part I very much like Qt Creator, but a few projects I'm working on require me to switch between my editor and my web browser for reference. Qt Creator is currently interpreting Alt+Tab to autocomplete, and then switching my window focus; this is a mild problem but it's really starting to get to me.
I've tried going to Tools→Options→Keyboard and searching for Alt+Tab, but found nothing. Is there a way to get it to selectively ignore the key combination without disabling autocomplete on the whole?
To complete the picture, I'm on Linux Mint 19.04 using XFCE desktop environment; or occasionally Maté. If I need to access something in system settings to do this I'm happy to; I just don't want to keep excessively second-guessing my code when I return to it.
Auto-complete is bound to Ctrl+Space by default, not Alt+Tab. In tools/options/keyboard, search for "CompleteThis" to see what it's bound to.
Maybe what you want is to disable auto-complete and use only manual-complete? That is, have the auto-complete list only show when you press ctrl+space, but never automatically. You can do that in options/text editor/completion.

Linux, change text field behavior

I have an idea to write a program that modifies the behavior of text fields on Linux. What I want is that the program will automatically change the text entry language according to the textfield's text direction in all the system. For example, if I have English and Hebrew languages installed, and I click on a textfield in some software that normally outputs the text from right to left, than the program will automatically change the text entry language to Hebrew. If I click on a text field that outputs text from left to right, the program will switch the language to English.
I don't know much about system or UI programming on Linux, ( More experienced on Windows ) and I don't know where to start. Is there a way to register 'hooks' on GUI elements on Gnome and KDE? Maybe I should add this to Gnome and KDE's code?
I'd appreciate any hints as to how to start.
Many thanks,
Oded.
First some caveats:
Normally text field alignment for GUI windowing toolkits is either explicitly set by the program or is set based on the detected system locale (in Qt and GTK at least) either in relevant Text Object QLineEdit in Qt or GtkEntry in GTK or in the higher level Layout Object that contains them.
That said in order to implement the functionality at least for your own programs, you will need to identify a few things
GTK or Qt or both ? If you are implementing at base level (i.e not just bindings), then this also means C or C++ or both ?
GTK 2 or GTK 3, QT 3 or QT4 ?
Which text widgets on each GUI toolkit to you want to override ? Just the two I mentioned I above or any or all of the possible text widgets in either library ?
Do you want your behavior to work regardless of the locale set ? E.g If you have LTR locale set do you want right aligned text widgets to switch input method ?
What method of switching input method do you want to use ? SCIM, XIM, ibus or just immodule (in both its GTK and Qt forms) ? Do these input methods support being programatically changed ??
What happens if a user has 2 or more LTR languages installed or 2 more RTL languages installed ? Do they get to pick which language ? Is there current locale setting respected ?
Assuming you want to go down the immodule path
See the following resources for Qt
How to support input method in KDE/Qt application.
QInputMethodEvent Class Reference. You will want to implement this event, and the get Text widget's alignment using an alignment accessor, then set the Input Method based on alignment.
See the following resources for GTK
GtkIMContext
GtkIMContextSimple
GtkIMMulticontext
The general method is the same.
Implement the event handler for when text is typed into the widget but before it is displayed in the widget.
Switch the input method based on the widget's alignment property
Resources on learning GTK
GTK 3 Reference Manual
GTK 2 Reference Manual
Gnome Developer Centre
Resources on learning QT
QT Reference Documentation
Qt4 tutorial for absolute beginners
The Qt4 tutorial
From your comment, it seems you would be instead be writing your own InputMethod mechanism or modifying an existing one.
In order to have it loaded by default in Gnome and KDE programs not difficult to do, just set your input method based on locale association. The difficult part is having the InputMethod aware of location it is being typed into. Normally the InputMethod isn't aware of the calling application, let alone the GUI framework it is written in.
Resources on Input Methods
List of input methods for UNIX platforms
Linux input method framework brief summary
ibus
uim
scim

How can I insert text into another application?

To scratch a personal itch, I'm writing something like a cross between a character map and an on-screen keyboard. When the user selects a character, I'd like to insert it into another application, specifically, the application that would next receive focus if my application were closed. Is there any way to do this? Right now, I work around it by just putting the character into the clipboard and terminating, leaving the user to hit paste in the other application, but usage would be far more streamlined if I could just insert the text programmatically.
I'm doing this in GTK and expect to run it only on Linux. But cross-platform solutions are also appreciated, and if GTK can't do it but some other toolkit can, I'll gladly switch.
This sounds like you should use libwnck, which is a GTK-related library that lets you manipulate windows on the desktop. The documentation is a little sparse, but the function wnck_screen_get_previously_active_window() seems promising.
From a WnckWindow you can get an X window ID, and perhaps from there you can use the X libraries to send a paste message (or even send it a "Ctrl-V" keypress event), perhaps with XSendEvent().
Very good question, by the way. I wish I could answer it more knowledgeably.

How to programmatically invert screen colors in Linux

In Ubuntu, for example, you can use Super-M to invert the screen colors (requires desktop effects, see [1]). Other OSes have similar abilities, although I'm not really concerned with anything other than Linux.
Which API should I look into if I want to write a simple program that, when run, inverts the screen colors?
The language that I use the API from doesn't particularly matter to me. I am familiar enough with C/C++/Bash/Perl/Python that I can hack this up in whatever language has the easiest access to this API. Working on Ubuntu is required, working on other similar *nixes is not terribly important.
[1] https://help.ubuntu.com/community/KeyboardShortcuts#Desktop%20Effects%20enabled%20shortcuts
You could use xcalib to do what you want.
For example, a simple bash script to invert the screen colors would look like this:
#!/bin/bash
xcalib -invert -alter
Here are scripts and instructions for shifting colors using compton: https://github.com/vn971/linux-color-inversion
xrandr-invert-colors worked out of the box for me.
xcalib does not work for me using xorg and a tiling window manager, with an external display and gives me the following error: "Unable to get a display calibration".
Credit to Imat.

How to change focus in X-Windows?

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?).

Resources