I installed i3
, which recommends dunst
, but I'm not using i3 at the moment, and the dunst notifications don't really fit with Unity. I'd rather not uninstall dunst totally, since I might want to start using it at some point in the future; is there a way to switch back to notify-osd without uninstalling dunst?
Notification – How to Disable Dunst and Revert to Notify-OSD
dbusnotification
Related Solutions
from http://www.techmansworld.com/2012/07/how-to-restore-unitys-notification.html
So first off, open up a terminal You can do this by accessing the applications menu from XFCE, or in Unity by opening the dash and typing in “terminal”. Once the terminal is open, paste the following line into the terminal and press enter.
gksu gedit /usr/share/dbus-1/services/org.xfce.xfce4-notifyd.Notifications.service
After pressing enter, you should receive a prompt for your password because this is modifying high level parts of your system. Just enter your password and continue. A new gedit (text editor) window should open with that config file.
All you have to do now is replace one line of text in that file. In that file, just replace following line:
Exec=/usr/lib/xfce4/notifyd/xfce4-notifyd
with
Exec=/usr/lib/notify-osd/notify-osd
Note For 64 bit installations replace:
Exec=/usr/lib/x86_64-linux-gnu/xfce4/notifyd/xfce4-notifyd
with
Exec=/usr/lib/x86_64-linux-gnu/notify-osd/notify-osd
After that, save the file and log out. Log back in, and you should see Unity's notification system back. Note that after doing this, you will also get GNOME's notification system in XFCE.
If you do change your mind and want XFCE's notification system back, just edit that file again and paste the first line back to where the second line is located.
Alright, at the risk of answering my own question, I came up with a bit of a hacked together pyqt version of pvol from the link in the question above. If nothing else, maybe someone else can improve on my code. Eventually, I plan to either get rid of the parts in the script below which go unused or to take the bash scripts out of the equation and have one pyqt script handle all of the button events. Right now, the OSD times out at a constant rate from the first button press instead of staying on for a fixed amount of time after the last button press.
Just copy, paste and save the files (with the names in bold), put them all in the same directory, set the executable bits, and modify the system calls in the pyqt script according to wherever you save them, or put them all in directory that's in your path. Then map the shell scripts to Compiz commands, Openbox shortcuts, or something similar, and change the pyqt script if you're not using multimedia keyboard volume buttons.
Note: The class name Qvol was a working title, and I didn't bother to change it. Please also note that the mute button goes unhandled--This is just a prototype to express a possible avenue for fulfilling the requested features, and it is not currently associated with any kind of hosted project or standard development model. Any kind of significant development derived from the code below should probably belong on Sourceforge, GitHub or a project website. That said, feel free to edit this answer or to suggest an existing project which allows is similar in function and design.
vol_step_down
#!/bin/bash
pulseaudio --check
#if [ $? -ne 0 ] ; then
if [ $? -eq 0 ] ; then
pactl set-sink-volume 0 -- -3db
else
amixer -c0 set Master playback 3-
fi
if [ -z "$1" ] ; then
pqvol -s
fi
vol_step_up
#!/bin/bash
pulseaudio --check
#if [ $? -ne 0 ] ; then
if [ $? -eq 0 ] ; then
pactl set-sink-volume 0 -- +3db
else
amixer -c0 set Master playback 3+
fi
if [ -z "$1" ] ; then
pqvol -s
fi
pqvol
#!/usr/bin/env python2
# pvol -- Commandline audio volume utility
# with an optional GTK progressbar
# Copyright (C) 2009 Adrian C. <anrxc_sysphere_org>
# Modified by 2011 Reza Jelveh
# Ported to pyqt and renamed to pqvol 2013 by Adam R.
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
import os.path
import optparse
import alsaaudio
import sys
from PyQt4 import QtGui, QtCore
from PyQt4.QtCore import QTimer
appname = "Qvol"
#appicon = "/usr/share/icons/ubuntu-mono-light/status/24/audio-volume-high-panel.svg"
DEFAULT_STYLE = """
QProgressBar{
border: 2px solid grey;
border-radius: 5px;
background-color: transparent;
}
QProgressBar::chunk {
background-color: Gainsboro;
}
"""
class AlsaMixer():
def __init__(self, pcm=False, mute=False, arg=None):
self.mixer = alsaaudio.Mixer()
self.percent = self.mixer.getvolume()[0]
print self.percent
self.label = "dB" #% name
if arg:
self.percent = min(100, max(0, self.percent + int(arg)))
self.mixer.setvolume(self.percent)
if mute:
mutestate = self.mixer.getmute()[0]
if mutestate:
self.label = "Unmuted: "
else:
self.label = "Muted: "
self.mixer.setmute(mutestate^1)
# self.label = self.label + "%.0f%%" % self.percent
class Qvol(QtGui.QWidget):
def __init__(self):
super(Qvol, self).__init__()
# self.setWindowFlags(QtCore.Qt.WindowStaysOnTopHint)
self.setWindowFlags(QtCore.Qt.FramelessWindowHint)
self.setWindowFlags(QtCore.Qt.Popup)
self.setAttribute(QtCore.Qt.WA_TranslucentBackground)
self.setWindowTitle("Qvol")
self.initUI()
def initUI(self):
self.pbar = QtGui.QProgressBar(self)
self.pbar.setGeometry(5, 5, 20, 470)
self.pbar.setOrientation(QtCore.Qt.Vertical)
self.pbar.setRange(0,100)
volume = AlsaMixer()
self.pbar.setValue(volume.percent)
self.pbar.setTextVisible(False)
self.setStyleSheet(DEFAULT_STYLE)
self.setGeometry(1260, 180, 30, 480)
self.setWindowTitle('QtGui.QProgressBar')
self.show()
QTimer.singleShot(2000, finished)
def keyPressEvent(self, event):
if event.key()==QtCore.Qt.Key_VolumeMute:
# QtGui.QWidget.paintEvent()
finished()
elif event.key()==QtCore.Qt.Key_VolumeDown:
launch_process ("vol_step_down silent")
volume=AlsaMixer()
self.pbar.setValue(volume.percent)
# finished()
elif event.key()==QtCore.Qt.Key_VolumeUp:
launch_process ("vol_step_up silent")
volume=AlsaMixer()
self.pbar.setValue(volume.percent)
# finished()
# else:
# QtGui.QWidget.keyPressEvent(self, event)
processes = set([])
def launch_process(process):
# Do something asynchronously
proc = QtCore.QProcess()
processes.add(proc)
proc.start(process)
proc.waitForFinished(-1)
def finished():
print "The process is done!"
# Quit the app
QtCore.QCoreApplication.instance().quit()
def main():
app = QtGui.QApplication(sys.argv)
ex = Qvol()
sys.exit(app.exec_())
if __name__ == '__main__':
main()
Related Question
- Ubuntu – Xfce4 overrode the GNOME notifications (notify-osd). How to get them back
- Ubuntu – fancy vertical notification OSD that works for both ALSA and pulseaudio
- Fix Notify-OSD Notifications Appearing Unthemed in Top-Left Corner
- Notify-OSD Replaced with Dunst After Switching to Unity
- Ubuntu – Disable gnome-software’s notification bubble (notify-osd) for available updates
- Ubuntu – How to prevent notifications from grabbing focus in 18.04
Best Answer
The notification daemon is started by dbus-daemon when a notification is sent. You can see the currently-active notification daemon (assuming there is one) by searching for the
org.freedesktop.Notifications
bus name on the session bus in D-Feet; you can also examinejournalctl
output to see what dbus-daemon thinks it's doing, and why (including e.g. which application sent a notification).dbus-daemon looks at the service files in
/usr/share/dbus-1/services/
to find the service to run for each bus name. The fileorg.freedesktop.Notifications.service
is the file for notify-osd (on default Ubuntu 18.04), and dunst installs a new service atorg.knopwob.dunst.service
. Both files have aName
oforg.freedesktop.Notifications
, meaning that they're both capable of handling notifications.Unfortunately, dbus-daemon isn't very clever when it comes to working out which service to start when there are multiple possible services for a given bus name. As of 2018, it just picks the first one it finds; there's been a feature request in Red Hat Bugzilla about this for almost a decade. The only real solutions appear to be:
Moving the conflicting service files is much easier in this case: just run
sudo mv /usr/share/dbus-1/services/org.knopwob.dunst.service{,.disabled}
. If you want to start using dunst again, it's easy enough to rename the file back to what it was originally.