This is a very useful X feature I use from always. For people who don't know this, it's ability of reducing window to his title bar, instead of iconify.
As I could use title bar to prompt a lot of things, like:
printf '\e];Long process running...\a'
sleep 2 # doLongProcessLike apt full-upgrade
rc=$?; printf '\e];Long process ended with %d.\a' $rc
Then I could shade my window by:
wmctrl -ir "$WINDOWID" -b add,shaded
Note: I've modified my mate settings in order to use double-click on window title to toggle shade*.
printf '\e];Long process running...\a'
wmctrl -ir "$WINDOWID" -b add,shaded
sleep 2 # doLongProcessLike apt full-upgrade
rc=$?; printf '\e];Long process ended with %d.\a' $rc
wmctrl -ir "$WINDOWID" -b remove,shaded
Using XTerm, you could alter near everything by using Xterm Control Sequences.
By using CSI 2 t
and CSI 2 t
you could iconify, de-iconify your window.
printf '\e[2t'; sleep 1 ; printf '\e[1t'
By using OSC 0 ; Window Title BEL
you could change window title, Here is a sample showing a kind or progress bar:
wmctrl -ir "$WINDOWID" -b add,shaded
for progress in {0..100};do
printf '\e];Job progress: %.2f%% \U2595%b\U258F\a' \
"$progress" \\U2$(( progress ? 581 + progress * 100 /1428 : 800))
sleep .03
done
Could look like:
I've unsuccessfully tested:
printf '\e]3;WM_STATE=WM_STATE_SHADED\a' ;sleep 1
And lot of variant, based on
xprop -id "$WINDOWID" > /tmp/xpropfile.txt
sleep 2
xprop -id "$WINDOWID" | diff /tmp/xpropfile.txt -
and toggling shade by mouse in less than 2 sec...
But I'm stuck finding a way to toggle shaded property, by Xterm Control Sequences.
The place to look is in the source-code of wmctrl
, e.g., here:
static gchar * normalize_wm_state_name(const char * name)
{
char * short_names[] = {
"modal", "sticky", "maximized_vert", "maximized_horz",
"shaded", "skip_taskbar", "skip_pager", "hidden",
"fullscreen", "above", "below", 0};
int i;
for (i = 0; short_names[i]; i++)
{
if (strcmp(short_names[i], name) == 0)
{
gchar * upcase = g_ascii_strup(name, -1);
gchar * result = g_strdup_printf("_NET_WM_STATE_%s", upcase);
g_free(upcase);
return result;
}
}
to see that the property to change is _NET_WM_STATE_SHADED
, which is documented here:
A list of hints describing the window state. Atoms present in the list MUST be considered set, atoms not present in the list MUST be considered not set. The Window Manager SHOULD honor _NET_WM_STATE whenever a withdrawn window requests to be mapped. A Client wishing to change the state of a window MUST send a _NET_WM_STATE client message to the root window (see below). The Window Manager MUST keep this property updated to reflect the current state of the window.
However, xterm uses XSetTextProperty
, which uses a different approach than the atom's existence:
The XSetTextProperty function replaces the existing specified property for the named window with the data, type, format, and number of items determined by the value field, the encoding field, the format field, and the nitems field, respectively, of the specified XTextProperty structure. If the property does not already exist, XSetTextProperty sets it for the specified window.
(To see the difference, take a look at the output of xprop
: atoms which are present to be "set" do not have values).