Bart Simons

Bart Simons


Thoughts, stories and ideas.

Bart Simons
Author

Share


Tags


.net .net core Apache C# CentOS LAMP NET Framework Pretty URLs Windows Server WireGuard WireGuard.io access log add analysis android api at the same time authentication authorization automate automation azure azurerm backup bash basics batch bootstrap build capture cheat sheet chromium chroot class cli click to close code snippet command line commands compile compiling compression containers control controller controlling convert cpu usage create credentials csv csvparser curl data dd deployment desktop detect devices disable diskpart dism distributed diy docker dom changes dotnet core drivers ease of access encryption example export file transfer files fix folders generalize getting started ghost ghost.org gui guide gunicorn gzip html html tables icewarp igd imagex import inotify install installation interactive ios iphone itunes java javascript jquery json kiosk kotlin linux live load data loading screen lock screen loopback audio lxc lxd lxml macos manage manually message messages minio mirrored mod_rewrite monitor monitoring mutationobserver mysql nexmo nginx no oobe node node.js nodejs not installing notification notifications object storage on desktop one command openssl owncloud parallels parallels tools parse perfect philips hue play port forwarding portainer.io powershell processing ps-spotify python quick raspberry pi record rip ripping rsync rtmp save save data sbapplication scraping script scripting scriptingbridge scripts security send server service sharedpreferences sms songs sonos spotify spotify api spotlight ssh stack streaming streamlink studio sudo swarm swift sync sysprep system audio systemd tables terminal tracking tutorial twilio ubiquiti ubuntu ubuntu 18.04 ui code unifi unlock unsplash source upnp uptime usb tethering wallpapers wasapi website websites webview windows windows 10 without itunes without oobe workaround xaml

Click to close notifications in Ubuntu

Do you love the way your notifications in the upper right corner of your screen look, but do you hate that there' s no way to close these notifications? Then look no further and read along as this article guides you through the process of 'patching' the notify-osd source code to make notifications clickable.

So, here's a preparation list for this little project:

The first thing to do is getting the sources cloned into the working directory with this command

Great! Now you can cd into the notify-osd source folder, for example

Now it's time to patch the source code of the bubble.c file inside the src directory.
Replace this block of code

// set an 1x1 input-region to allow click-through 
region = cairo_region_create_rectangle (&rect);
if (cairo_region_status (region) == CAIRO_STATUS_SUCCESS)
{
        gtk_widget_input_shape_combine_region (window, NULL);
        gtk_widget_input_shape_combine_region (window, region);
}
cairo_region_destroy (region);

with this

// set an 1x1 input-region to allow click-through 
region = cairo_region_create_rectangle (&rect);
if (cairo_region_status (region) == CAIRO_STATUS_SUCCESS)
{
        gtk_widget_input_shape_combine_region (window, NULL);
        gtk_widget_input_shape_combine_region (window, region);
        GdkWindow *window_ = gtk_widget_get_window (window);
        gdk_window_set_events (window_, gdk_window_get_events (window_) | GDK_BUTTON_PRESS);
}
cairo_region_destroy (region);



Replace this block

// hook up window-event handlers to window
g_signal_connect (window,
                  "draw",
                  G_CALLBACK (bubble_draw),
                  this);

with this

// hook up window-event handlers to window
g_signal_connect (window,
                  "draw",
                  G_CALLBACK (bubble_draw),
                  this);

g_signal_connect (window,
                  "button-press-event",
                  G_CALLBACK (button_press_event_handler),
                  this);



Put this function block

static gboolean
button_press_event_handler (GtkWidget* window G_GNUC_UNUSED,
        GdkEventButton* event,
        Bubble* bubble)
{
        BubblePrivate* priv;
        priv = bubble->priv;

        if (priv->mouse_over && event->button == 1)
        {
                bubble_hide (bubble);
                dbus_send_close_signal (bubble_get_sender (bubble),
                        bubble_get_id (bubble),
                        1);

                g_signal_emit (bubble, g_bubble_signals[TIMED_OUT], 0);

                return TRUE;
        }

        return FALSE;
}

above this function block

static gboolean
redraw_handler (Bubble* bubble)
{
        ...
        ...
        ...
}

Save the file, and build a Debian package with debuild -uc -us

This should work! At least it did for me ;)

Bart Simons
Author

Bart Simons

View Comments