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

Dunst cannot be configured through command line arguments #940

Closed
exorcist365 opened this issue Oct 21, 2021 · 25 comments
Closed

Dunst cannot be configured through command line arguments #940

exorcist365 opened this issue Oct 21, 2021 · 25 comments

Comments

@exorcist365
Copy link

Why have you removed this, it was one of the most useful functionalities of this program????

@fwsmit
Copy link
Member

fwsmit commented Oct 21, 2021

What's your use case?

@orhun
Copy link

orhun commented Oct 21, 2021

I just saw this issue and I'd like to express the same feelings towards the new release. Most of the things seems to be changed: my old config is not working as expected anymore and I guess I have to do things like "startup notification" and "shortcuts" manually now. It *almost* feels like a 2.0.0 release...

@exorcist365
Copy link
Author

What's your use case?

I have a script to get the colors from xresources and use them to configure dunst.

@exorcist365
Copy link
Author

Also removing [shortcuts] is retarded as hell, I agree.

@flipMWD
Copy link

flipMWD commented Oct 22, 2021

I also noticed [shortcuts] is not working as intended. Is there any way to keybind dunstctl close[-all] in the dunstrc config file or do I have to modify my WM to send the command itself (will probably interfere with other applications).

@fwsmit
Copy link
Member

fwsmit commented Oct 22, 2021

I just saw this issue and I'd like to express the same feelings towards the new release. Most of the things seems to be changed: my old config is not working as expected anymore and I guess I have to do things like "startup notification" and "shortcuts" manually now. It almost feels like a 2.0.0 release...

Why would you want startup notifications except for debugging? Anyways, you can keep using it with dunst --startup_notification.

[shortcuts] can easily be replaced with WM/DM bindings and using dunstctl. It's been deprecated for a long time and wasn't

I have a script to get the colors from xresources and use them to configure dunst.

Luckily this problem is already solved by https://github.com/dunst-project/dunst/blob/master/contrib/dunst_xr_theme_changer.sh. Just run the script and change your config location to ~/.config/dusnt/dunstrc_xr_colors. As always, every time you change the config, you need to restart dunst.

@exorcist365
Copy link
Author

Why not just bring these options back instead 🤯 🤯 🤯

@aleksfadini
Copy link

Please bring back shortcuts and command line arguments

@fwsmit
Copy link
Member

fwsmit commented Oct 24, 2021

For clarity, these settings weren't exactly removed, instead they weren't re-implemented after the settings refactor (#803). This was because these things weren't deemed important enough, since they have other similar alternatives.

As for the shortcuts section, I haven't heard good reasons to bring it back. There are lots of ways to add shortcuts and we don't need yet another one. On top of that, it's not possible for programs in wayland to add global shortcuts themselves, making it a X11 only feature. Just use your WM's way of defining shortcuts or use something like sxhkd. You are free to contribute your config to contrib to make it easier for others.

As for the command line arguments, the deprecation notice has existed for a long time (#328), at least regarding section-specific command line arguments. Unfortunately, due to bad timing by me, the best proposed alternative hasn't been merged yet, but is on it's way. This will come in the form of drop-in config files (#933). This will allow you to generate a simple dunst drop-in file that contains only the x resources colours, while keeping the rest of your config non-generated. I hope this alternative is sufficient, but otherwise let me know why it's not.

@EgZvor
Copy link
Contributor

EgZvor commented Oct 29, 2021

@fwsmit would be good to mention this in the README, don't you think? I can make a PR.

@fwsmit
Copy link
Member

fwsmit commented Oct 30, 2021

@fwsmit would be good to mention this in the README, don't you think? I can make a PR.

True. A PR would be appreciated :)

@fwsmit
Copy link
Member

fwsmit commented Oct 30, 2021

For clarity, I'm considering re-adding the command line options in a slightly different from. They would be with double dashes (--). It shouldn't be too complicated, it's just something I haven't gotten to.

@marcelofern
Copy link

For the record, this is a script I was using to change dunst colors based on the pywal theme. This isn't working anymore:

#!/bin/sh

# source wal colors.
source ~/.cache/wal/colors.sh

pkill --exact dunst
dunst \
    -config=~/.config/dunst/dunstrc \
    -frame_width 1 \
    -lb $color0 \
    -lf $color7 \
    -lfr $color3 \
    -cb $color0 \
    -cf $color7 \
    -cfr $color3 \
    -nb $color0 \
    -nf $color7 \
    -nfr $color3 &
@aleksfadini
Copy link

For the record, this is a script I was using to change dunst colors based on the pywal theme. This isn't working anymore:

#!/bin/sh

# source wal colors.
source ~/.cache/wal/colors.sh

pkill --exact dunst
dunst \
    -config=~/.config/dunst/dunstrc \
    -frame_width 1 \
    -lb $color0 \
    -lf $color7 \
    -lfr $color3 \
    -cb $color0 \
    -cf $color7 \
    -cfr $color3 \
    -nb $color0 \
    -nf $color7 \
    -nfr $color3 &

Would like to know what is a workaround for this, since it stopped working.

@marcelofern
Copy link

marcelofern commented Nov 1, 2021

@aleksfadini my understanding is that there is no workaround. @fwsmit your feedback on this would be appreciated.

I've created a script to manually change contents of the dunstrc based on pywal colors, but it is by no means a better solution, it is not even a good solution at all. However, at the time I am writing this I couln't find a better replacement yet:

#!/bin/sh

# source wal colors.
source ~/.cache/wal/colors.sh

DUNST_FILE=~/.config/dunst/dunstrc

# update dunst based on pywal colors.
sed -i '/background = /s/.*/background = "'$color0'"/' $DUNST_FILE
sed -i '/foreground = /s/.*/foreground = "'$color7'"/' $DUNST_FILE
sed -i '/frame_color = /s/.*/frame_color = "'$color3'"/' $DUNST_FILE

Is there a way to do this in a more elegant way? The above feels like a dirty hack.

@fwsmit
Copy link
Member

fwsmit commented Nov 3, 2021

You're almost at the workaround I think is best. Instead of overwriting the existing dunstrc, you should generate one based on a template. Then you should start Dunst with the generated config.
There's already a script that does exactly what you want here: https://github.com/dunst-project/dunst/blob/master/contrib/dunst_xr_theme_changer.sh

@aleksfadini
Copy link

aleksfadini commented Nov 3, 2021

Is there a way to do this in a more elegant way? The above feels like a dirty hack.

@marcelofern thank you for posting that. could you reply (or edit/add to the post) with a link to your dunstrc for clarity? For some reason I'm having trouble with colors since command line options were removed.

@BeyondMagic
Copy link

BeyondMagic commented Nov 11, 2021

Luckily this problem is already solved by https://github.com/dunst-project/dunst/blob/master/contrib/dunst_xr_theme_changer.sh. Just run the script and change your config location to ~/.config/dusnt/dunstrc_xr_colors. As always, every time you change the config, you need to restart dunst.

It seems a hell of a downgrade to rely on an external script for a functionality that was already implemented on dunst itself.


@marcelofern

Using a close-looking hack way as well for now, two commands actually:

  • envsubst to update with environment variables from a template dunstrc file to the real dunstrc;
  • xgetres to define those environment variables from a XResources source.

template_dunstrc

[global]
  font = ${font}
  width = ${width}
  height = ${height}
  offset = ${x}x${y}
  separator_height = ${separator_height}
  padding = ${padding}
  horizontal_padding = ${horizontal_padding}
  frame_width = ${frame_width}
  max_icon_size = ${max_icon_size}

[urgency_low]
  background = "${low_background}"
  foreground = "${low_foreground}"
  frame_color = "${low_frame_color}"

[urgency_normal]
  background = "${normal_background}"
  foreground = "${normal_foreground}"
  frame_color = "${normal_frame_color}"

[urgency_critical]
  background = "${critical_background}"
  foreground = "${critical_foreground}"
  frame_color = "${critical_frame_color}"

.XResources

dunst.font                  : Noto Sans CJK JP 10
dunst.geometry.width        : 300
dunst.geometry.height       : 80
dunst.geometry.x            : 45
dunst.geometry.y            : 60
dunst.separator_height      : 2
dunst.padding               : 10
dunst.horizontal_padding    : 10
dunst.max_icon_size         : 64
dunst.frame_width           : 2
dunst.critical.background   : #13171aAA
dunst.critical.foreground   : #fe2d3b
dunst.critical.frame_colour : #141e24
dunst.normal.background     : #13171aAA
dunst.normal.foreground     : #ffffff
dunst.normal.frame_colour   : #000000
dunst.low.background        : #000000AA
dunst.low.foreground        : #A8A8A8
dunst.low.frame_colour      : #111111

script.zsh

kill -9 $(pidof dunst)

export \
                font="$(xgetres dunst.font)" \
               width="$(xgetres dunst.geometry.width)" \
              height="$(xgetres dunst.geometry.height)" \
                   x="$(xgetres dunst.geometry.x)" \
                   y="$(xgetres dunst.geometry.y)" \
    separator_height="$(xgetres dunst.separator_height)" \
             padding="$(xgetres dunst.padding)" \
  horizontal_padding="$(xgetres dunst.horizontal_padding)" \
       max_icon_size="$(xgetres dunst.max_icon_size)" \
         frame_width="$(xgetres dunst.frame_width)" \
      low_background="$(xgetres dunst.low.background)" \
      low_foreground="$(xgetres dunst.low.foreground)" \
     low_frame_color="$(xgetres dunst.low.frame_colour)" \
   normal_background="$(xgetres dunst.normal.background)" \
   normal_foreground="$(xgetres dunst.normal.foreground)" \
  normal_frame_color="$(xgetres dunst.normal.frame_colour)" \
 critical_background="$(xgetres dunst.critical.background)" \
 critical_foreground="$(xgetres dunst.critical.foreground)" \
critical_frame_color="$(xgetres dunst.critical.frame_colour)"

envsubst < "$HOME/.config/dunst/template_dunstrc" > "$HOME/.config/dunst/dunstrc"

dunst -s -follow keyboard & disown

I'll stick with this probably since it's easier to switch themes with it.

@aleksfadini
Copy link

@BeyondMagic thank you for explaining this. We still can't understand why such a function was removed.

@zlice
Copy link

zlice commented Nov 17, 2021

just throwing my hat in the ring. broke today on me and has the ugly midnight default colors.

@fwsmit
Copy link
Member

fwsmit commented Feb 24, 2022

Drop-in files have been implemented in #997, so this should solve the underlying issue of needing to generate the entire dunstrc. The solutions mentioned above should work without any issues. I'll go ahead and close this issue.

@fwsmit fwsmit closed this as completed Feb 24, 2022
@zlice
Copy link

zlice commented Feb 24, 2022

So there won't be a -- implemented ?

I don't want another file. As petty as it is, it's just one more thing to copy between machines if I'm setting something new up or changing something.

@fwsmit
Copy link
Member

fwsmit commented Feb 24, 2022

So there won't be a -- implemented ?

There might be some time. If someone wants to submit a PR that'd be great.

I don't want another file. As petty as it is, it's just one more thing to copy between machines if I'm setting something new up or changing something.

I get where you're coming from. It's just not something that bothers me in my setup, as I'm using a dotfiles repo with a dotfiles manager. So it's easy to copy dotfiles around. If you have a different setup it might be easier to use command line arguments.
Anyways, I'll probably get to the command line arguments some time, but I don't consider it a bug right now, since the alternative of drop-ins are there now.

ecly added a commit to ecly/dotfiles that referenced this issue Aug 10, 2022
Config adapted based on docs:
    https://github.com/dunst-project/dunst/blob/master/docs/dunst.5.pod

And the somewhat controversial original issue :
    dunst-project/dunst#940

For now just using a hardcoded gruvbox, as making the theme adaptive is
a bit cumbersome
@vzaliva
Copy link

vzaliva commented Aug 5, 2024

I used to do notify-send DUNST_COMMAND_PAUSE to pause notifications. The use case is when I share my screen and doing a presentation. How can I do this now?

@Narrat
Copy link

Narrat commented Aug 5, 2024

You can use dunstctl which should come with your dunst installation :)
See man dunstctl. There is a section about is-paused, set-paused, get-paused and set-pause-level

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet