♻️ refactor(dock, applications): add option to hide apps in special workspaces, refactor related functions
This commit is contained in:
4 files changed
+56
No files matched your search
@@ -70,6 +70,7 @@ if os.path.exists(CONFIG_FILE):
|
||||
WORKSPACE_DOTS = config.get("workspace_dots", False)
|
||||
WINDOW_SWITCHER_ITEMS_PER_ROW = config.get("window_switcher_items_per_row", 13)
|
||||
DOCK_HIDE_SPECIAL_WORKSPACE = config.get("dock_hide_special_workspace", True)
|
||||
DOCK_HIDE_SPECIAL_WORKSPACE_APPS = config.get("dock_hide_special_workspace_apps", True)
|
||||
|
||||
NOTIF_POS = config.get(NOTIF_POS_KEY, NOTIF_POS_DEFAULT)
|
||||
|
||||
@@ -105,6 +106,7 @@ else:
|
||||
WINDOW_SWITCHER_ITEMS_PER_ROW = 13
|
||||
NOTIF_POS = NOTIF_POS_DEFAULT
|
||||
DOCK_HIDE_SPECIAL_WORKSPACE = True
|
||||
DOCK_HIDE_SPECIAL_WORKSPACE_APPS = True
|
||||
|
||||
DOCK_COMPONENTS_VISIBILITY = {
|
||||
"workspace": True,
|
||||
|
||||
@@ -59,6 +59,7 @@ DEFAULTS = {
|
||||
"dock_applications_visible": True,
|
||||
"dock_language_visible": True,
|
||||
"dock_hide_special_workspace": True,
|
||||
"dock_hide_special_workspace_apps": True,
|
||||
"workspace_nums": False,
|
||||
"workspace_use_chinese_numerals": False,
|
||||
"workspace_dots": False,
|
||||
|
||||
@@ -465,6 +465,26 @@ class HyprConfGUI(Window):
|
||||
dock_hide_special_switch_container.add(self.dock_hide_special_switch)
|
||||
layout_grid.attach(dock_hide_special_switch_container, 3, 3, 1, 1)
|
||||
|
||||
# Add dock hide special workspace apps option
|
||||
dock_hide_special_apps_label = Label(
|
||||
label="Hide Special Workspace Apps", h_align="start", v_align="center"
|
||||
)
|
||||
layout_grid.attach(dock_hide_special_apps_label, 2, 5, 1, 1)
|
||||
dock_hide_special_apps_switch_container = Gtk.Box(
|
||||
orientation=Gtk.Orientation.HORIZONTAL,
|
||||
halign=Gtk.Align.START,
|
||||
valign=Gtk.Align.CENTER,
|
||||
)
|
||||
self.dock_hide_special_apps_switch = Gtk.Switch(
|
||||
active=bind_vars.get("dock_hide_special_workspace_apps", True),
|
||||
sensitive=self.dock_switch.get_active(),
|
||||
)
|
||||
self.dock_hide_special_apps_switch.set_tooltip_text(
|
||||
"Hide applications that are in special workspaces (scratchpad) from the dock"
|
||||
)
|
||||
dock_hide_special_apps_switch_container.add(self.dock_hide_special_apps_switch)
|
||||
layout_grid.attach(dock_hide_special_apps_switch_container, 3, 5, 1, 1)
|
||||
|
||||
notification_pos_label = Label(
|
||||
label="Notification Position", h_align="start", v_align="center"
|
||||
)
|
||||
@@ -856,10 +876,12 @@ class HyprConfGUI(Window):
|
||||
self.dock_hover_switch.set_sensitive(is_active)
|
||||
self.dock_auto_hide_switch.set_sensitive(is_active)
|
||||
self.dock_hide_special_switch.set_sensitive(is_active)
|
||||
self.dock_hide_special_apps_switch.set_sensitive(is_active)
|
||||
if not is_active:
|
||||
self.dock_hover_switch.set_active(False)
|
||||
self.dock_auto_hide_switch.set_active(False)
|
||||
self.dock_hide_special_switch.set_active(False)
|
||||
self.dock_hide_special_apps_switch.set_active(False)
|
||||
|
||||
def on_select_face_icon(self, widget):
|
||||
dialog = Gtk.FileChooserDialog(
|
||||
@@ -922,6 +944,9 @@ class HyprConfGUI(Window):
|
||||
current_bind_vars_snapshot["dock_hide_special_workspace"] = (
|
||||
self.dock_hide_special_switch.get_active()
|
||||
)
|
||||
current_bind_vars_snapshot["dock_hide_special_workspace_apps"] = (
|
||||
self.dock_hide_special_apps_switch.get_active()
|
||||
)
|
||||
current_bind_vars_snapshot["dock_icon_size"] = int(
|
||||
self.icon_size_scale.get_value()
|
||||
)
|
||||
@@ -1189,9 +1214,13 @@ class HyprConfGUI(Window):
|
||||
self.dock_hide_special_switch.set_active(
|
||||
utils.bind_vars.get("dock_hide_special_workspace", True)
|
||||
)
|
||||
self.dock_hide_special_apps_switch.set_active(
|
||||
utils.bind_vars.get("dock_hide_special_workspace_apps", True)
|
||||
)
|
||||
self.dock_hover_switch.set_sensitive(self.dock_switch.get_active())
|
||||
self.dock_auto_hide_switch.set_sensitive(self.dock_switch.get_active())
|
||||
self.dock_hide_special_switch.set_sensitive(self.dock_switch.get_active())
|
||||
self.dock_hide_special_apps_switch.set_sensitive(self.dock_switch.get_active())
|
||||
self.terminal_entry.set_text(utils.bind_vars["terminal_command"])
|
||||
|
||||
default_dock_theme_val = DEFAULTS.get("dock_theme", "Pills")
|
||||
|
||||
@@ -278,6 +278,26 @@ class Applications(Box):
|
||||
normalized = normalized[: -len(suffix)]
|
||||
return normalized
|
||||
|
||||
def _is_special_workspace(self, client):
|
||||
"""Check if a client is in a special workspace"""
|
||||
if "workspace" not in client:
|
||||
return False
|
||||
|
||||
workspace = client["workspace"]
|
||||
if "name" in workspace:
|
||||
workspace_name = str(workspace["name"])
|
||||
# Special workspaces typically start with "special:" or have negative IDs
|
||||
if workspace_name.startswith("special:"):
|
||||
return True
|
||||
|
||||
if "id" in workspace:
|
||||
workspace_id = workspace["id"]
|
||||
# Special workspaces have negative IDs
|
||||
if workspace_id < 0:
|
||||
return True
|
||||
|
||||
return False
|
||||
|
||||
def update_applications(self):
|
||||
for child in self.get_children():
|
||||
self.remove(child)
|
||||
@@ -292,6 +312,10 @@ class Applications(Box):
|
||||
|
||||
running_windows = {}
|
||||
for client in clients:
|
||||
# Skip clients in special workspaces if the setting is enabled
|
||||
if data.DOCK_HIDE_SPECIAL_WORKSPACE_APPS and self._is_special_workspace(client):
|
||||
continue
|
||||
|
||||
class_name = client.get("class", "").lower()
|
||||
if class_name:
|
||||
if class_name not in running_windows:
|
||||
|
||||
Reference in new issue
Block a user