Set the time of notifications in Plasma 5

This can be done by modifying the file /usr/share/plasma/plasmoids/org.kde.plasma.notifications/contents/ui/NotificationPopup.qml. So, open it in kate:

kate /usr/share/plasma/plasmoids/org.kde.plasma.notifications/contents/ui/NotificationPopup.qml

Find the line notificationTimer.interval = notification.expireTimeout and comment/change it to

    notificationTimer.interval = 1 * 1000

where 1 is the number of seconds.

Test it with notify-send "your notification"

Source here.


The other answer is a successful hack, and I upvoted, but I have found a better one for some versions of KDE, and also add the instruction to refresh plasmashell, which also needs to be done for the other answer:

Edit a variable (setting), rather than code

By design, here is the higher level place to actually edit the expireTimeout, which means you can leave NotificationPopup.qml alone, since it reads expireTimeout.

edit the expireTimeout line in ms, so for OP who wants a shorter time: If your version of KDE has the following file, set:

expireTimeout: 1000,
in
/usr/share/plasma/plasmoids/org.kde.plasma.notifications/contents/ui/Jobs.qml

source: https://www.reddit.com/r/kde/comments/5jpje5/is_there_a_way_to_change_the_amount_of_time/

Unfortunately, in a more recent version of KDE Plasma, 5.12.7, I could not find that file. I found:

    <entry name="expireTimeout" type="Int">
      <label>The timeout after which the notification will be closed</label>
      <default>1000</default>
    </entry>
in
/usr/share/plasma/services/notifications.operations

but changing the default here did not work.

Restart window manager

ALSO, in both my answer and the other one, you need to restart the plasmashell to see any effect. If you don't want to just reboot, use the below for KDE >= 5.10, or click on the source link below that for older versions.

kquitapp5 plasmashell
(wait... for me it was around 30 seconds!)
kstart5 plasmashell

source: https://askubuntu.com/questions/481329/can-i-restart-the-kde-plasma-desktop-without-logging-out