2

I'm running Ubuntu 14.10, and I figured out, that it is possible to change the default icons used for notifications (basically by adding notification-audio-volume-high.svg etc. to your current theme (see screenshot))

Brightness notify-bubble with custom icon

While this is great, I was wondering if it is possible to change the appearance of the bar (the one that shows what the value of the brightness/volume is in the notification bubble) in order to make it more like the icon on the left.

Are there somewhere icons stored for this bar? Is there somewhere a XML file that describes its looks?

Thanks

  • Ohh you want the bar to be "flatter" style! I see - cool question! – Tim Dec 6 '14 at 10:58
1

By looking into its package contents, it seems hard-coded with in the daemon. It's called gauge. You need to rebuild it.

  1. Get source:

    apt-get source notify-osd
    sudo apt-get build-dep notify-osd
    cd notify-osd-0.9.35+14.04.20140213/
    
  2. Modify things you need
    src/default.c, sizes & size limits

    #define DEFAULT_GAUGE_SIZE           0.625f
    #define DEFAULT_GAUGE_OUTLINE_WIDTH  0.125f
    [...]
            property_gauge_size = g_param_spec_double (
                                    "gauge-size",
                                    "gauge-size",
                                    "Size/height (in em) of gauge/indicator",
                                    0.5f,
                                    1.0f,
    [...]
            property_gauge_outline_width = g_param_spec_double (
                                    "gauge-outline-width",
                                    "gauge-outline-width",
                                    "Width/thickness (in em) of gauge-outline",
                                    0.1f,
                                    0.2f,
    

    src/bubble.c, function that draw it.

    // color-, alpha-, radius-, width-, height- and gradient-values were determined
    // by very close obvervation of a SVG-mockup from the design-team
    static void
    _draw_value_indicator (cairo_t* cr,
                           gint     value,             // value to render: 0 - 100
                           gint     start_x,           // top of surrounding rect
                           gint     start_y,           // left of surrounding rect
                           gint     width,             // width of surrounding rect
                           gint     height,            // height of surrounding rect
                           gint     outline_thickness) // outline-thickness
    {
    [...]
    
  3. Rebuild the deb package

    debuild -us -uc
    sudo dpkg --force-depends -i ../notify-osd_0.9.35+14.04.20140213-0ubuntu1_amd64.deb
    

    modified notify-osd gauge

Example:

  1. Color, try this example quiet red, gradient points: RGB (0.9f,0.6f,0.6f),(0.5f,0.3f,0.3f) & (0.4f,0.2f,0.2f)

    In bubble.c, _draw_value_indicator() function below // draw value-bar:

            gradient = cairo_pattern_create_linear (0.0f,
                                                    start_y +
                                                    outline_thickness,
                                                    0.0f,
                                                    start_y +
                                                    outline_height -
                                                    2 * outline_thickness);
            cairo_pattern_add_color_stop_rgba (gradient,
                                               0.0f,
                                               0.9f,
                                               0.6f,
                                               0.6f,
                                               1.0f);
            cairo_pattern_add_color_stop_rgba (gradient,
                                               0.75f,
                                               0.5f,
                                               0.3f,
                                               0.3f,
                                               1.0f);
            cairo_pattern_add_color_stop_rgba (gradient,
                                               1.0f,
                                               0.4f,
                                               0.2f,
                                               0.2f,
                                               1.0f);
    
            cairo_set_source (cr, gradient);
            cairo_fill (cr);
    

    See cairo_pattern_add_color_stop_rgba () in Cairo doc's.

    Comment outline drawing instructions using /* & */ so no black outline, bar_radius = outline_height / 2; for well rounded bar.

    // draw bar-background
    /*
    cairo_set_line_width (cr, outline_thickness);
    cairo_set_source_rgba (cr, 0.0f, 0.0f, 0.0f, 0.5f);
    draw_round_rect (cr,
    [...]
    cairo_fill (cr);
    cairo_pattern_destroy (gradient);
    */
    //bar_radius = outline_radius;
    bar_radius = outline_height / 2;
    bar_width  = outline_width - 2 * outline_radius;
    //bar_height = outline_height - outline_radius;
    
    // draw value-bar
    
  2. Size to 1.2f, to look well with icon

    #define DEFAULT_GAUGE_SIZE           1.2f
    [...]
        property_gauge_size = g_param_spec_double (
                                "gauge-size",
                                "gauge-size",
                                "Size/height (in em) of gauge/indicator",
                                0.5f,
                                5.0f,
    
  3. Here why it was cropped, it should be a bug.

    In bubble.c, instead EM2PIXELS (defaults_get_icon_size (d), d) / 5.0f it should use EM2PIXELS (defaults_get_gauge_size (d), d) to set the height of drawing area for gauge.

    Replace that line:

    void
    _refresh_indicator (Bubble* self)
    {
    [...]
        // create temp. scratch surface
        normal = cairo_image_surface_create (
                CAIRO_FORMAT_ARGB32,
                EM2PIXELS (defaults_get_bubble_width (d), d) -
                3 * EM2PIXELS (defaults_get_margin_size (d), d) -
                EM2PIXELS (defaults_get_icon_size (d), d)
                + 2 * BUBBLE_CONTENT_BLUR_RADIUS,
                EM2PIXELS (defaults_get_icon_size (d), d) / 5.0f
                + 2 * BUBBLE_CONTENT_BLUR_RADIUS);
    

    to:

    void
    _refresh_indicator (Bubble* self)
    {
    [...]
        // create temp. scratch surface
        normal = cairo_image_surface_create (
                CAIRO_FORMAT_ARGB32,
                EM2PIXELS (defaults_get_bubble_width (d), d) -
                3 * EM2PIXELS (defaults_get_margin_size (d), d) -
                EM2PIXELS (defaults_get_icon_size (d), d)
                + 2 * BUBBLE_CONTENT_BLUR_RADIUS,
                EM2PIXELS (defaults_get_gauge_size (d), d)
                + 2 * BUBBLE_CONTENT_BLUR_RADIUS);
    

    example of custom notify-osd gauge

  • Super great! Can I change the color as well somehow? Wasn't able to find it in the source code... – wa4557 Jan 6 '15 at 14:04
  • btw: what values did you use to get the one depicted in the answer? – wa4557 Jan 6 '15 at 14:07
  • @wa4557, #define DEFAULT_ICON_SIZE 2.0f, increased its limit from 1.0f, to 3.0f, in property_gauge_size and commented all // draw bar-background instructions leaving only // draw value-bar instructions in _draw_value_indicator, for color let me check – user.dz Jan 6 '15 at 14:22
  • @wa4557, updated with better example. – user.dz Jan 6 '15 at 20:40
  • @user.dz In 17.04, volume notification bubble( and all x-canonical-private-synchronous bubble) overlaps the panel with your patch. Why is that? – Khurshid Alam Jun 30 '17 at 14:06

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.