Add native notifications with OSD-style banners and a Control Center module

glassMxrph now owns org.freedesktop.Notifications. Banners drop out of the
bar like the OSD; Control Center stacks history per app like macOS
Notification Center. Do Not Disturb lives in the shell and falls back to
SwayNC while another daemon holds the bus name.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
mxandClaude Opus 5.5 committed 2026-10-15 14:47:40 +02:00
1 parent d7f0498ba0
commit 395de70b26
17 files changed
+1132 -13

No files matched your search

+11 -3
View File
@@ -57,9 +57,17 @@ def night(options):
return {'available':True,'enabled':temp<6500,'temperature':temp,'provider':'wl-gammarelay'}
def notifications():
value=bus('user','call','org.erikreider.swaync.cc','/org/erikreider/swaync/cc','org.erikreider.swaync.cc','GetDnd')[0]
# The shell keeps its own DND state; only SwayNC is controlled over DBus.
try:owner=bus('user','call','org.freedesktop.DBus','/org/freedesktop/DBus','org.freedesktop.DBus','GetConnectionUnixProcessID','s','org.freedesktop.Notifications')[0]
except ValueError:return {'available':False,'provider':'','notice':'No notification server is running'}
if owner==os.getppid():return {'available':True,'provider':'shell'}
try:value=bus('user','call','org.erikreider.swaync.cc','/org/erikreider/swaync/cc','org.erikreider.swaync.cc','GetDnd')[0]
except ValueError:
try:name=Path(f'/proc/{owner}/comm').read_text().strip().lstrip('.').removesuffix('-wrapped')
except OSError:name='Another program'
return {'available':False,'provider':name,'notice':name+' handles notifications'}
if type(value) is not bool:raise ValueError('SwayNC did not return a DND state')
return {'available':True,'enabled':value}
return {'available':True,'enabled':value,'provider':'swaync'}
def profiles():
service='net.hadess.PowerProfiles';path='/net/hadess/PowerProfiles'
@@ -111,7 +119,7 @@ def action(req):
run(['busctl','--user','--auto-start=no','--timeout=3','set-property','rs.wl-gammarelay','/','rs.wl.gammarelay','Temperature','q',str(temperature)])
elif kind=='dnd':
if type(value) is not bool:raise ValueError('DND expects a boolean')
notifications()
if notifications().get('provider')!='swaync':raise ValueError('No external Do Not Disturb provider')
run(['busctl','--user','--auto-start=no','--timeout=3','call','org.erikreider.swaync.cc','/org/erikreider/swaync/cc','org.erikreider.swaync.cc','SetDnd','b',str(value).lower()])
elif kind=='profile':
if value not in profiles()['profiles']:raise ValueError('Unsupported power profile')