0

I am looking for a command-line solution to cover a configurable section of a virtual desktop with a rectangle of configurable color, to hide the content below. One should still be able to use a window which has part of its content hidden this way.

A screen annotation tool (as discussed in this question) does not work here because the overlay painting will affect all virtual desktops at the same time, at least in all the tools I tested.

(The application for this is covering nasty banner ads in a non-browser application. It might also be used to hide content in a live presentation.)

1 Answer 1

2

You can use the feh image viewer to diplay a transparent image on black or white background in your defined size and position and without window decorations. And then use the wmctrl command to make it stay on top of all other windows, as shown in this answer.

So an example command (here to hide Spotify visual ads on a 1280x800 screen) looks like this:

sh -c "feh --borderless --title hidemyads --geometry 980x95+302+643 \
    --image-bg black /path/to/transparent.png & \
  sleep 0.3 && \
  wmctrl -r hidemyads -b add,above"

Annotations and explanations:

  • To find out the geometry to use, position and resize any window where you want it, and find out its geometry from wmctrl -lG output.
  • wmctrl -r selects the window where the title matches the supplied string, so we make that string unique by setting the window title in feh before.
  • We need to sleep a bit after feh, as there seems to be a short delay until the window manager knows about the new window. Usually 0.1 s is enough, but depending on system load etc. more might be required, so we triple it.
  • feh does not yet support configuring the image background color beyond --image-bg black and --image-bg white, but if you really want, a patch is available.
  • To configure the color, you can of course use an image in that color. But it's not flexible: feh always shows the image in original aspect ratio, so you would have to adapt the image aspect ratio to what you want to use in --geometry.
  • The wrapping in sh -c "…" follows this technique to make the command also execute in the Alt+F2 launcher (which would otherwise only execute one, at least in LXDE). Also, the wrapping detaches the command from a terminal (so that the feh window stays open when closing the terminal window).

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .