refactor(modules): clean up dock update logic and fix TOTP action closure

- Refactor dock update loop to use explicit parentheses and improve readability
- Fix closure capture in OTP plugin action to correctly pass current code
- Remove redundant lambda wrapper in player label binding
- Update logger messages with full exception context
- Adjust imports and naming for consistency across modules
- Minor code style updates and whitespace cleanup
This commit is contained in:
sankalp committed 2026-02-26 06:54:29 +05:45
1 parent 934b62ebff
commit cf7666a8a5
12 files changed
+48 -39

No files matched your search

+1 -1
View File
@@ -786,7 +786,7 @@ class PlayerBox(Box):
self.track_artist,
"label",
GObject.BindingFlags.DEFAULT,
lambda _, x: (", ".join(x) if x and isinstance(x, list) else "No Artist"), # type: ignore
lambda _, x: ", ".join(x) if x and isinstance(x, list) else "No Artist", # type: ignore
)
self.track_info = Box(
+16 -7
View File
@@ -489,12 +489,16 @@ class AppBar(Box):
try:
clients = self.get_clients()
focused_window = self.get_focused_window()
focused_address = focused_window.get("address", "") if focused_window else ""
focused_address = (
focused_window.get("address", "") if focused_window else ""
)
current_instance_ids = set()
for client in clients:
if client.get("hidden", False) or not self._should_show_app_instance(client):
if client.get("hidden", False) or not self._should_show_app_instance(
client
):
continue
instance_address = client.get("address", "")
@@ -519,7 +523,7 @@ class AppBar(Box):
self._update_separator_visibility()
self._cleanup_removed_instances(current_instance_ids)
except Exception as e:
logger.error(f"[AppBar] Error in update_dock_apps: {e}")
@@ -550,8 +554,11 @@ class AppBar(Box):
]
# Clean up removed and orphaned buttons
for instance_id in buttons_to_remove + [k for k, v in self.client_buttons.items()
if not hasattr(v, 'instance_address') or not v.get_parent()]:
for instance_id in buttons_to_remove + [
k
for k, v in self.client_buttons.items()
if not hasattr(v, "instance_address") or not v.get_parent()
]:
if instance_id in self.client_buttons:
button = self.client_buttons.pop(instance_id)
try:
@@ -633,9 +640,11 @@ class AppBar(Box):
self.client_buttons[instance_address] = client_button
self.running_apps_container.add(client_button)
self.running_items_pos.append(client_button)
except Exception as e:
logger.error(f"[AppBar] Error creating instance button for {app_class}: {e}")
logger.error(
f"[AppBar] Error creating instance button for {app_class}: {e}"
)
def _get_workspace_id(self, client):
workspace_data = client.get("workspace", {})
+10 -10
View File
@@ -167,8 +167,8 @@ class OTPPlugin(PluginBase):
if current_totp_code != old_code:
result_item.result.data["code"] = current_totp_code
self._find_and_update_title_label(result_item, current_totp_code)
result_item.result.action = (
lambda code=current_totp_code: self._copy_to_clipboard(code)
result_item.result.action = lambda code=current_totp_code: (
self._copy_to_clipboard(code)
)
new_subtitle_markup = f"{display_name} • {time_display} remaining"
@@ -431,8 +431,8 @@ class OTPPlugin(PluginBase):
"type": "totp",
"account": account_name,
"code": totp_code,
"alt_action": lambda acc=account_name: self._remove_account_and_refresh(
acc
"alt_action": lambda acc=account_name: (
self._remove_account_and_refresh(acc)
),
},
)
@@ -491,8 +491,8 @@ class OTPPlugin(PluginBase):
"type": "totp",
"account": account_name,
"code": totp_code,
"alt_action": lambda acc=account_name: self._remove_account_and_refresh(
acc
"alt_action": lambda acc=account_name: (
self._remove_account_and_refresh(acc)
),
},
)
@@ -696,8 +696,8 @@ class OTPPlugin(PluginBase):
time_display
} remaining",
icon_name="user-trash-symbolic",
action=lambda acc=acc_name: self._remove_account_and_refresh(
acc
action=lambda acc=acc_name: (
self._remove_account_and_refresh(acc)
),
relevance=0.9,
plugin_name=self.display_name,
@@ -715,8 +715,8 @@ class OTPPlugin(PluginBase):
title=f"Error: {acc_name}",
subtitle="Press Enter to remove (Invalid secret)",
icon_name="user-trash-symbolic",
action=lambda acc=acc_name: self._remove_account_and_refresh(
acc
action=lambda acc=acc_name: (
self._remove_account_and_refresh(acc)
),
relevance=0.8,
plugin_name=self.display_name,
+2 -2
View File
@@ -407,8 +407,8 @@ class RemindersPlugin(PluginBase):
target_time_str
})",
icon_name="alarm-timer",
action=lambda ts=time_str, msg=message: self._create_and_confirm_reminder(
ts, msg
action=lambda ts=time_str, msg=message: (
self._create_and_confirm_reminder(ts, msg)
),
relevance=1.0,
plugin_name=self.display_name,
+2 -2
View File
@@ -467,8 +467,8 @@ class ScreencapturePlugin(PluginBase):
if format_type != "gif"
else "image-x-generic-symbolic"
),
action=lambda fp=file_param, ft=format_type: self._run_script_with_file(
ft, fp
action=lambda fp=file_param, ft=format_type: (
self._run_script_with_file(ft, fp)
),
relevance=1.0,
plugin_name=self.display_name,
+2 -2
View File
@@ -539,8 +539,8 @@ class WallpaperPlugin(PluginBase):
status_text
}",
icon_name="color-picker-symbolic",
action=lambda c=hex_color, s=scheme: self._apply_hex_color_direct(
c, s
action=lambda c=hex_color, s=scheme: (
self._apply_hex_color_direct(c, s)
),
relevance=1.0,
plugin_name=self.display_name,
+4 -2
View File
@@ -144,8 +144,10 @@ class ExpandableNotificationGroup(Box):
icon_name="close-symbolic", icon_size=18
),
visible=True,
on_clicked=lambda *_: self._close_single_notification_and_stop_propagation(
latest_notification
on_clicked=lambda *_: (
self._close_single_notification_and_stop_propagation(
latest_notification
)
),
),
Label(
+4 -3
View File
@@ -2,17 +2,18 @@ import math
import time
from typing import ClassVar, Literal
from gi.repository import GLib, GObject
# from gi.repository import GLib, GObject
from fabric.audio import Audio
from fabric.utils import GLib, GObject
from fabric.utils.helpers import get_relative_path
from fabric.widgets.box import Box
from fabric.widgets.revealer import Revealer
from fabric.widgets.scale import Scale, ScaleMark
from fabric.widgets.svg import Svg
from fabric.widgets.wayland import WaylandWindow as Window
from services.brightness import Brightness
from utils.animator import Animator
from widgets.wayland import WaylandWindow as Window
class AnimatedScale(Scale):
+4 -5
View File
@@ -5,22 +5,22 @@ from fabric.widgets.centerbox import CenterBox
from fabric.widgets.datetime import DateTime
from fabric.widgets.revealer import Revealer
from fabric.widgets.wayland import WaylandWindow as Window
from modules.panel.components.globalmenu import GlobalMenu
from modules.panel.components.workspace import WorkspaceIndicator
from utils.utils import setup_cursor_hover, svg_file
from modules.controlcenter.main import ModusControlCenter
from modules.notification.notification_center import NotificationCenter
from modules.panel.components.enhanced_system_tray import apply_enhanced_system_tray
from modules.panel.components.globalmenu import GlobalMenu
from modules.panel.components.indicators import (
BatteryIndicator,
BluetoothIndicator,
NetworkIndicator,
)
from modules.panel.components.recording_indicator import RecordingIndicator
from modules.panel.components.workspace import WorkspaceIndicator
from services.config import get_config, on_config_change
from services.modus import notification_service
from utils.roam import modus_service
from utils.utils import setup_cursor_hover, svg_file
from widgets.mousecapture import MouseCapture
apply_enhanced_system_tray()
@@ -29,12 +29,11 @@ apply_enhanced_system_tray()
class Panel(Window):
def __init__(self, **kwargs):
super().__init__(
name="panel-window",
name="bar",
title="modus",
layer="top",
anchor="left top right",
exclusivity="auto",
pass_through=False,
visible=True,
all_visible=False,
)
+2 -3
View File
@@ -212,9 +212,8 @@ class ApplicationSwitcher(Window):
if c.get("hidden", False):
continue
# Skip clients in special workspaces if the setting is enabled
if (
data.DOCK_HIDE_SPECIAL_WORKSPACE_APPS
and self._is_special_workspace(c)
if data.DOCK_HIDE_SPECIAL_WORKSPACE_APPS and self._is_special_workspace(
c
):
continue
filtered_windows.append(c)
+1 -1
View File
@@ -1 +1 @@
# Todo module
# Todo module
-1
View File
@@ -5,7 +5,6 @@ from datetime import datetime
from fabric.utils import get_relative_path
from fabric.widgets.box import Box
from fabric.widgets.button import Button
from fabric.widgets.centerbox import CenterBox
from fabric.widgets.entry import Entry
from fabric.widgets.label import Label
from fabric.widgets.scrolledwindow import ScrolledWindow