My goal is to get the icon which is currently on the window. (Then using some img tools I'll modify that icon, then save it to a location, I can do this part no need for help here please). Then I would like to set the window icon to the icon i have saved at a location on hard drive.
I do this in js-ctypes so it takes me a long time so if I am going in wrong direction I waste a ton of time so it really helps to ask about it. As I can't do a quick test. If you all can just point me in right direction I would really appreciate it.
Here was how I was thinking of doing it:
- I already have an array of windows (got it with
XQuerySubtree
) - Get RGBA data of currently applied icon with
XGetWindowProperty
and atom of_NET_WM_ICON
- (use my img tools to modify the icon and save to hard drive, lets take for example on the desktop
/usr/noida/Desktop/new icon.png
) - Apply icon from
/usr/noida/Desktop/new icon.png
to all of the windows in the array, so it changes icon displayed on window (if there is one, in ubuntu there isnt) and changes icon in Alt + Tab menu, and changes icon on dock.- apply path of icon with
XSendEvent
of aXClientMessageEvent
with atom_NET_WM_ICON
?
- apply path of icon with
Am I thinking in the right direction?
Thanks
Image of goal – we see here that the window doesnt have an icon dispplayed on it, but its icon is displayed in the dock at the left. And in the Alt + Tab menu. So i was hoping by changing icon on all windows to my customized icon it will change on the dock and alt+tab menu. And for linux distributions that do show icon in window I hope that to be changed as well. In image here the blue arrow points to the three related icon areas.
Best Answer
Where the icon is defined
The representation of an application in Dash and the the Unity launcher is defined in a .desktop file. Such a .desktop files includes a line to set the command to run the application, a line to set the icon of the application and a varying number of possible lines to set additional properties.
To see the current Unity launcher's content by command:
If you run this command, you will (a.o.) get a list of references to .desktop files, in the order like they appear in the launcher. An application's mention in the list looks like:
application://thunderbird.desktop
. It refers (in this example) to the file,thunderbird.desktop
.When Unity gathers its information on login, it first looks into the local directory for .desktop files, (
~/.local/share/applications
), and secondly in/usr/share/applications
. If a .desktop file exists in both directory, the local one has preference. Normally, during your session, the launcher's icon stays linked to the .desktop file in either one of these directories.When the content of the linked desktop file is edited during your session, the result is applied immediately. However, the icon as it appears in the Unity launcher does not change until you either:
Since you cannot remove the icon of a running application from the launcher, changing the icon of a running application is not possible.
To change the icon of an application in the launcher which is not running however, you can use the two scripts below.
The first one copies the .desktop file to the local directory and edits the
Icon=
line in the local copy. The second one refreshes the icon in the launcher (and relinks it if necessary).Script 1; change the icon
how to use
Copy the script below into an empty file, save it as
change_icon.py
, run it by the command:for example:
for smoother use:
create a directory
~/bin
, copy the script into the directory, remove the language extension from the script, make it executable and (after logout / login), you can simly use the script by the command:More info on where to store and how to define icons, you can find here
The script
Script 2; refresh the icon in the launcher
how to use
Copy the script below into an empty file, save it as
refresh.py
, run it by the command:for smoother use:
Like in the script above, copy the script into
~/bin
, remove the language extension, make it executable and (after logout / login), you can simly use the script by the command:for example:
The script