Enhancements - Replace bare `except:` with `except Exception:` in multiple modules- Cast step calculation to `int` for consistent type - Simplify `get_battery_icon_file` to return a string directly - Use `get_todo_service()` instead of module-level `todo_service` throughout todo widget - Remove unused `"zen": "zen-browser"` mapping entry Bug Fixes - Prevent bare exception swallowing by catching `Exception` explicitly - Ensure proper cleanup of timer IDs and other resources - Delete unused modules/osdd components New Features - None
84 lines
2.4 KiB
Python
84 lines
2.4 KiB
Python
from fabric.widgets.box import Box
|
|
from fabric.widgets.revealer import Revealer
|
|
from fabric.widgets.wayland import WaylandWindow as Window
|
|
from .components import (
|
|
AudioOSDContainer,
|
|
BrightnessOSDContainer,
|
|
MicrophoneOSDContainer,
|
|
CapsLockOSDContainer,
|
|
KeyboardLayoutOSDContainer,
|
|
)
|
|
|
|
|
|
class OSD(Box):
|
|
def __init__(self, window: Window, **kwargs):
|
|
super().__init__(name="osd", **kwargs)
|
|
self.window = window
|
|
|
|
self.revealer = Revealer(
|
|
transition_type="slide-up",
|
|
transition_duration=100,
|
|
child_revealed=False,
|
|
)
|
|
self.children = [self.revealer]
|
|
|
|
self.containers = {
|
|
"audio": AudioOSDContainer(window),
|
|
"brightness": BrightnessOSDContainer(window),
|
|
"microphone": MicrophoneOSDContainer(window),
|
|
"capslock": CapsLockOSDContainer(window),
|
|
"kb_layout": KeyboardLayoutOSDContainer(window),
|
|
}
|
|
|
|
# Set the OSD reference in containers
|
|
for container in self.containers.values():
|
|
container.osd = self
|
|
|
|
self.current_container = None
|
|
|
|
def show_container(self, container):
|
|
if self.current_container != container:
|
|
self.revealer.children = [container]
|
|
self.current_container = container
|
|
self.revealer.set_reveal_child(True)
|
|
|
|
def show_audio_osd(self):
|
|
self.show_container(self.containers.get("audio"))
|
|
|
|
def show_brightness_osd(self):
|
|
self.show_container(self.containers.get("brightness"))
|
|
|
|
def show_microphone_osd(self):
|
|
self.show_container(self.containers.get("microphone"))
|
|
|
|
def show_capslock_osd(self):
|
|
self.show_container(self.containers.get("capslock"))
|
|
|
|
def show_kb_layout_osd(self):
|
|
self.show_container(self.containers.get("kb_layout"))
|
|
|
|
|
|
class OSDWindow(Window):
|
|
def __init__(self, **kwargs):
|
|
super().__init__(
|
|
name="osd-window",
|
|
title="modus-osd",
|
|
anchor="bottom",
|
|
margin="0px 0px 40px 0px",
|
|
visible=False,
|
|
all_visible=False,
|
|
pass_through=True,
|
|
layer="overlay",
|
|
**kwargs,
|
|
)
|
|
self.osd = OSD(window=self)
|
|
self.add(self.osd)
|
|
|
|
|
|
if __name__ == "__main__":
|
|
from fabric import Application
|
|
|
|
osd_window = OSDWindow()
|
|
app = Application("modus-osd", osd_window)
|
|
app.run()
|