Here is the full traceback:
Traceback (most recent call last):
File "/home/human/Documents/personal/code/python/automation/brightness/venv/lib/python3.8/site-packages/dbus/bus.py", line 177, in activate_name_owner
return self.get_name_owner(bus_name)
File "/home/human/Documents/personal/code/python/automation/brightness/venv/lib/python3.8/site-packages/dbus/bus.py", line 361, in get_name_owner
return self.call_blocking(BUS_DAEMON_NAME, BUS_DAEMON_PATH,
File "/home/human/Documents/personal/code/python/automation/brightness/venv/lib/python3.8/site-packages/dbus/connection.py", line 652, in call_blocking
reply_message = self.send_message_with_reply_and_block(
dbus.exceptions.DBusException: org.freedesktop.DBus.Error.NameHasNoOwner: Could not get owner of name 'org.freedesktop.Notifications': no such name
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/home/human/Documents/personal/code/python/automation/brightness/test.py", line 18, in <module>
notification.notify(
File "/home/human/Documents/personal/code/python/automation/brightness/venv/lib/python3.8/site-packages/plyer/facades/notification.py", line 79, in notify
self._notify(
File "/home/human/Documents/personal/code/python/automation/brightness/venv/lib/python3.8/site-packages/plyer/platforms/linux/notification.py", line 44, in _notify
obj = session_bus.get_object(_bus_name, _object_path)
File "/home/human/Documents/personal/code/python/automation/brightness/venv/lib/python3.8/site-packages/dbus/bus.py", line 241, in get_object
return self.ProxyObjectClass(self, bus_name, object_path,
File "/home/human/Documents/personal/code/python/automation/brightness/venv/lib/python3.8/site-packages/dbus/proxies.py", line 250, in __init__
self._named_service = conn.activate_name_owner(bus_name)
File "/home/human/Documents/personal/code/python/automation/brightness/venv/lib/python3.8/site-packages/dbus/bus.py", line 182, in activate_name_owner
self.start_service_by_name(bus_name)
File "/home/human/Documents/personal/code/python/automation/brightness/venv/lib/python3.8/site-packages/dbus/bus.py", line 277, in start_service_by_name
return (True, self.call_blocking(BUS_DAEMON_NAME, BUS_DAEMON_PATH,
File "/home/human/Documents/personal/code/python/automation/brightness/venv/lib/python3.8/site-packages/dbus/connection.py", line 652, in call_blocking
reply_message = self.send_message_with_reply_and_block(
dbus.exceptions.DBusException: org.freedesktop.DBus.Error.ServiceUnknown: The name org.freedesktop.Notifications was not provided by any .service files
Since you mentioned that this might be because of a bug in the plyer library, I tried using the notify2 library but it’s giving the same error.
Notify script:
import notify2
import os
if not 'DISPLAY' in os.environ:
os.environ['DISPLAY'] = ':0'
brightnessfile = "/sys/class/backlight/amdgpu_bl0/brightness"
f = open(brightnessfile, "r")
brightness_value = f.read()
f.close()
message = "Current brightness: " + brightness_value
if __name__=="__main__":
if brightness_value > "125":
notify2.init("Notifier")
n = notify2.Notification("Brightness Alert",
message
)
n.show()
Traceback:
Traceback (most recent call last):
File "/home/human/Documents/personal/code/python/automation/brightness/venv/lib/python3.8/site-packages/dbus/bus.py", line 177, in activate_name_owner
return self.get_name_owner(bus_name)
File "/home/human/Documents/personal/code/python/automation/brightness/venv/lib/python3.8/site-packages/dbus/bus.py", line 361, in get_name_owner
return self.call_blocking(BUS_DAEMON_NAME, BUS_DAEMON_PATH,
File "/home/human/Documents/personal/code/python/automation/brightness/venv/lib/python3.8/site-packages/dbus/connection.py", line 652, in call_blocking
reply_message = self.send_message_with_reply_and_block(
dbus.exceptions.DBusException: org.freedesktop.DBus.Error.NameHasNoOwner: Could not get owner of name 'org.freedesktop.Notifications': no such name
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/home/human/Documents/personal/code/python/automation/brightness/alert.py", line 18, in <module>
notify2.init("Notifier")
File "/home/human/Documents/personal/code/python/automation/brightness/venv/lib/python3.8/site-packages/notify2.py", line 102, in init
dbus_obj = bus.get_object('org.freedesktop.Notifications',
File "/home/human/Documents/personal/code/python/automation/brightness/venv/lib/python3.8/site-packages/dbus/bus.py", line 241, in get_object
return self.ProxyObjectClass(self, bus_name, object_path,
File "/home/human/Documents/personal/code/python/automation/brightness/venv/lib/python3.8/site-packages/dbus/proxies.py", line 250, in __init__
self._named_service = conn.activate_name_owner(bus_name)
File "/home/human/Documents/personal/code/python/automation/brightness/venv/lib/python3.8/site-packages/dbus/bus.py", line 182, in activate_name_owner
self.start_service_by_name(bus_name)
File "/home/human/Documents/personal/code/python/automation/brightness/venv/lib/python3.8/site-packages/dbus/bus.py", line 277, in start_service_by_name
return (True, self.call_blocking(BUS_DAEMON_NAME, BUS_DAEMON_PATH,
File "/home/human/Documents/personal/code/python/automation/brightness/venv/lib/python3.8/site-packages/dbus/connection.py", line 652, in call_blocking
reply_message = self.send_message_with_reply_and_block(
dbus.exceptions.DBusException: org.freedesktop.DBus.Error.ServiceUnknown: The name org.freedesktop.Notifications was not provided by any .service files
Edit:
I installed postfix and then ran the cron as root using the “sudo crontab -e -u root” command.
Now I am getting this error:
/bin/sh: 1: cannot create /root/Documents/personal/code/python/automation/brightness/events.log: Directory nonexistent