Home Forums Wiki Doc Install Extras Screenshots Source Code Projects Blog Users Groups Register
Glx-Dock / Cairo-Dock List of forums Technical discussions | Discussions techniques New Launcher Class ?
The latest stable release is the *3.4.0* : How to install it here.
Note: We just switched from BZR to Git on Github! (only to host the code and your future pull requests)
Technical discussions | Discussions techniques

Subjects Author Language Messages Last message
[Locked] New Launcher Class ?
tristangrimaux English 8 tristangrimaux [Read]
11 March 2014 à 12:27

tristangrimaux, Sunday 09 March 2014 à 15:29


Subscription date : 22 November 2011
Messages : 9
I'm creating a launcher with no command. The launcher shows an icon of a battery whenever apcupsd fires a warning "power off! Running on batteries". The icons goes away when the power is back.

The thing is I can't seem to grab the idea of class.

Using the function
cairo.Add('type':'Launcher', 'class':'apcwarning', 'name':'blabla')
sets the StartupWMClass but the class remains empty. If I print the classes of the entire set of icons, my new icon has it's class property empty.

To make things worse, the only way I find to set a hint on the launcher is by changing its name, and thus, finding it again to turn it off, or to update the remaining time turns a hard task if one wants to be sure that is grabbing the right icon.

Any thoughts?

I'm thinking to make this an applet, but I hate the idea of constantly polling the status of the ups when the power is doing well, and distributing the responsibility of making the applet visible and active whenever a power failure was triggered is not that simple.

Thanks for reading!!!

SQP, Sunday 09 March 2014 à 19:51


Subscription date : 03 July 2010
Messages : 1081
this could certainly be easier to do as a applet and without the "toggle visibility" in mind, but with another method to display the on battery status, like an emblem, or changing the icon.

I think it wouldn't have to poll anything more than what you're currently doing (connect to acpi events?).

That being said, the WM class is a X window property that we use to associate a window with a dock icon, so it shouldn't be needed for what you're doing. You can ask the class of a window by launching "xprop | grep CLASS" and clicking on the window you want.

And as you want to add a launcher icon, there is no way to change its name easily. You'd better be in an applet environment, which will provides you the dock icon with methods to change its image, label... (but harder to toggle visibility AFAIK, you'll have to act on a dock visibility)

tristangrimaux, Monday 10 March 2014 à 18:54


Subscription date : 22 November 2011
Messages : 9
I'm quoting an example from the wiki

d.GetProperties("'type=Launcher & class=firefox')


See? class there refers to something completely different and I would LOVE to know how to set THAT PROPERTY!

SQP, Monday 10 March 2014 à 19:19


Subscription date : 03 July 2010
Messages : 1081
the property is set on the firefox window. We only use the class=firefox to detect which window is firefox, and match it to the firefox icon and get its other properties.

This is what launchers do: launch commands, and with some settings, we use the class argument to link the window and the icon.

I think you're trying to do something the dock isn't really meant to do.

The way we do it:
we create an applet that will poll regularly or register to some events depending on your data source
Then on some conditions, it can update the icon display (change the image, label, quickinfo...), or another event like animation, popup...

Tell us more about your data poll or events and we may help you more.

in the meantime, as you seem to want to do it in python, the plug-ins-extras repository can help you. The applet Notifications_history is a really simple one to see interactions between a data source and a few updates on the icon.

or an example in golang with the disk free applet

tristangrimaux, Monday 10 March 2014 à 19:41


Subscription date : 22 November 2011
Messages : 9
but how is that the property is set even when the firefox application is not running?

SQP, Monday 10 March 2014 à 23:00


Subscription date : 03 July 2010
Messages : 1081
we set the class on the launcher so we are able to detect if firefox is running or not, as the dock keeps a list of opened windows for the taskbar.

Note that this WM class setting isn't required for most launchers. We only need to force it to detect programs who have a class different from the application name. (IIRC this was required at some point for firefox because it declared a class with something like firefox-2.0)

tristangrimaux, Tuesday 11 March 2014 à 00:57


Subscription date : 22 November 2011
Messages : 9
I'm building an applet of that, you are very convincing. Remains a mystery upon the class, which is different than the wmclass and appears magically if the origin is set to a valid application on the property "origin"

SQP, Tuesday 11 March 2014 à 10:42


Subscription date : 03 July 2010
Messages : 1081
here is an example of how the class option work. I use it to get a simple system monitor launcher:
command: sakura --class=Htop -x htop
class: Htop


I set a specific class to match, Htop
When I click the icon, it will open a console with the class Htop so it will be detected and monitored by my icon. The console also launch the htop command to have a nice and light process list.

here is my second use of the class setting, for my cairo-dock logs, I use another console

/usr/local/bin/cairo-dock-console
#!/bin/sh
sakura --class=DesktopTerminal -x "/usr/bin/cairo-dock"


This time it's used by the devilspie program that allow to set specific settings to windows. This is one of the window that I pack on the right on the screen for a pseudo tiling setup. (so the options I set are to remove window borders, force display below others, hide from taskbars...)

~/.devilspie/log_terminal.ds
(if

(matches (window_class) "DesktopTerminal")
(begin
(below)
(undecorate)
(skip_pager)
(skip_tasklist)
(wintype "utility")
(geometry "700x355-5+345")
)
)


You can see that the dock isn't the only program that use the class option to detect a specific window.

Note that I use sakura because it's the only terminal I found that handle that --class option provided by the GTK framework. gnome-terminal used to do it too, but that's another victim of a gnome upgrade.

tristangrimaux, Tuesday 11 March 2014 à 12:27


Subscription date : 22 November 2011
Messages : 9
Great tips! I use the wmclass to launch a separate window of tweetdeck

iceweasel -P tweetdeck -no-remote --class tweetdeck


Y used chromium in the past, but I really prefer iceweasel (or firefox) because it suits better my needs.

Technical discussions | Discussions techniques

Subjects Author Language Messages Last message
[Locked] New Launcher Class ?
tristangrimaux English 8 tristangrimaux [Read]
11 March 2014 à 12:27


Glx-Dock / Cairo-Dock List of forums Technical discussions | Discussions techniques New Launcher Class ? Top

Online users :

Powered by ElementSpeak © 2007 Adrien Pilleboue, 2009-2013 Matthieu Baerts.
Dock based on CSS Dock Menu (Ndesign) with jQuery. Icons by zgegball
Cairo-Dock is a free software under GNU-GPL3 licence. First stable version created by Fabounet.
Many thanks to TuxFamily for the web Hosting and Mav for the domain name.