Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to configure appearence on the fly ? #1120

Closed
ghost opened this issue Oct 31, 2022 · 11 comments
Closed

How to configure appearence on the fly ? #1120

ghost opened this issue Oct 31, 2022 · 11 comments

Comments

@ghost
Copy link

ghost commented Oct 31, 2022

Issue description

I've set everything on dunstrc config to show on top left for all notifications. But I need volume level notifications to be exactly in the middle of the screen. Is it possible ?

Currently I'm using these bindings:

set $showvol notify-send -t 1500 'VOLUME' -h int:value:$(pulsemixer --get-volume | awk '{print $1}')
bindsym XF86AudioRaiseVolume $run pactl set-sink-volume @DEFAULT_SINK@ +10% && $showvol
bindsym XF86AudioLowerVolume $run pactl set-sink-volume @DEFAULT_SINK@ -10% && $showvol

But they show at the configured position. I wanna set it to middle of the screen on the fly, unlike the rest of the notifications that appear at the corner.

Installation info

  • Version: 1.9.0
  • Install type: pacman -S dunst
  • Window manager / Desktop environment: i3-gaps
Minimal dunstrc
# Dunstrc here
@apprehensions
Copy link
Contributor

apprehensions commented Nov 3, 2022

Dunst has the ability to set overrdues or settings for a notification with a specific app name:

dunst/dunstrc

Line 346 in 53a2ff1

# and you can override the

Unfortunately doesn't seem you can set origin here.

@ismay
Copy link

ismay commented Nov 26, 2022

I was just wondering about the exact same thing. Allowing a different origin and offset for certain notifications would be great. It feels much more natural to me to have volume, microphone and brightness notifications at bottom center.

Related: #1106

@voguelike
Copy link

this feature has been implemented by someone's fork here: https://github.com/FT-Labs/phyOS-dunst

you can modify the origin of a notification through dunstify.
it would be nice to have this integrated into the main version.

@apprehensions
Copy link
Contributor

@voguelike , that feature is for Xresources configuration.

@voguelike
Copy link

i'm not sure what you mean, here's a video showing off the dynamic origin feature from that fork.
https://youtu.be/Ogs_bKH2ntQ?t=307

@apprehensions
Copy link
Contributor

It reloads Xresources configuration and not the configuration file...

@voguelike
Copy link

i take it that you didn't look at the video? it has absolutely nothing to do with xresources.

the feature is in src/dbus.c at line 555
g_variant_iter_next(&i, "s", &n->appname);
        g_variant_iter_next(&i, "u", &n->id);
        g_variant_iter_next(&i, "s", &n->iconname);
        g_variant_iter_next(&i, "s", &n->summary);
        g_variant_iter_next(&i, "s", &n->body);
        g_variant_iter_next(&i, "^a&s", &actions);
        g_variant_iter_next(&i, "@a{?*}", &hints);
        g_variant_iter_next(&i, "i", &timeout);

                /* Change notification position */
        if (!strcmp(n->appname, "top-center"))
                settings.origin = ORIGIN_TOP_CENTER;
        else if (!strcmp(n->appname, "top-left"))
                settings.origin = ORIGIN_TOP_LEFT;
        else if (!strcmp(n->appname, "bottom-right"))
                settings.origin = ORIGIN_BOTTOM_RIGHT;
        else if (!strcmp(n->appname, "bottom-center"))
                settings.origin = ORIGIN_BOTTOM_CENTER;
        else if (!strcmp(n->appname, "bottom-left"))
                settings.origin = ORIGIN_BOTTOM_LEFT;
        else if (!strcmp(n->appname, "left-center"))
                settings.origin = ORIGIN_LEFT_CENTER;
        else if (!strcmp(n->appname, "center"))
                settings.origin = ORIGIN_CENTER;
        else
                settings.origin = ORIGIN_TOP_RIGHT;

        gsize num = 0;
        while (actions[num]) {
                if (actions[num+1]) {
                        g_hash_table_insert(n->actions,
                                        g_strdup(actions[num]),
                                        g_strdup(actions[num+1]));
                        num+=2;
                } else {
                        LOG_W("Odd length in actions array. Ignoring element: %s", actions[num]);
                        break;
                }
        }
and here is that same spot in the normal version for comparison
 g_variant_iter_next(&i, "s", &n->appname);
        g_variant_iter_next(&i, "u", &n->id);
        g_variant_iter_next(&i, "s", &n->iconname);
        g_variant_iter_next(&i, "s", &n->summary);
        g_variant_iter_next(&i, "s", &n->body);
        g_variant_iter_next(&i, "^a&s", &actions);
        g_variant_iter_next(&i, "@a{?*}", &hints);
        g_variant_iter_next(&i, "i", &timeout);

        gsize num = 0;
        while (actions[num]) {
                if (actions[num+1]) {
                        g_hash_table_insert(n->actions,
                                        g_strdup(actions[num]),
                                        g_strdup(actions[num+1]));
                        num+=2;
                } else {
                        LOG_W("Odd length in actions array. Ignoring element: %s", actions[num]);
                        break;
                }
        }

@apprehensions
Copy link
Contributor

@voguelike
Copy link

oh nice i didn't see that, it's a pretty neat feature but how does it relate to changing the origin of the notifications? i don't know what it has to do with this which is a completely different thing.

@bynect
Copy link
Member

bynect commented Feb 21, 2024

I think the main problem is that dunst uses a single window so you can't have multiple notifications at different origins at the same time.

#1018

@bynect
Copy link
Member

bynect commented Jul 15, 2024

for future reference now dunst supports hot reloading #1350

@bynect bynect closed this as completed Sep 12, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants