Is that possible to use kind of constants in gnome-shell.css theme file?

Something linke

@import url("/usr/share/gnome-shell/theme/gnome-shell.css");


#panel {
    background-color: rgba(0,0,0,@PANEL_ALPHA);

.panel-corner {
    -panel-corner-background-color: rgba(0,0,0,@PANEL_ALPHA);

I also tried with @const PANEL_ALPHA:0.5; but it doesn't work.


If I understand the documentation correctly (big if), no. The CSS version implemented by GTK3 only accepts a subset of the full CSS3 functionality. Specifically:

GTK+ also supports an additional @define-color rule, in order to define a color name which may be used instead of color numeric representations. Also see the "gtk-color-scheme" setting for a way to override the values of these named colors.

@define-color bg_color #f9a039;

* {
    background-color: @bg_color;

So, you can define colors using the @define-color keyword but I don't think you can define arbitrary identifiers.

| improve this answer | |
  • Have you tried that? I've tried in my theme but it doesn't work... – lviggiani Mar 21 '14 at 9:52
  • @lviggiani no I haven't, that was a direct quote from the official documentation (see the link in my answer). However, I checked in some of the themes I have installed and many do use it. For example: Adwaita, Menta, Albatross, Xfce-cadmium, Bluebird, Clearlooks-Phenix, GreenLaguna, you should be able to find all of these on gnome-look.org, download one and see how they do it. – terdon Mar 21 '14 at 17:04

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.