Skip to content

Commit cfa74ca

Browse files
committed
hide/toggle bar
1 parent a0f33dd commit cfa74ca

File tree

5 files changed

+72
-10
lines changed

5 files changed

+72
-10
lines changed

config/settings_constants.py

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -55,23 +55,23 @@
5555
"wallpapers_dir": WALLPAPERS_DIR_DEFAULT,
5656
"prefix_restart_inspector": "SUPER CTRL ALT",
5757
"suffix_restart_inspector": "B",
58-
"bar_position": "Top", # New default position setting
59-
"vertical": False, # Kept for backward compatibility
58+
"bar_position": "Top",
59+
"vertical": False,
6060
"centered_bar": False,
61-
"datetime_12h_format": False, # Add this line
61+
"datetime_12h_format": False,
6262
"terminal_command": "kitty -e",
63-
"auto_append_hyprland": True, # Enable auto-append of source string to hyprland.conf
63+
"auto_append_hyprland": True,
6464
"dock_enabled": True,
6565
"dock_icon_size": 28,
6666
"dock_always_show": False,
6767
"bar_workspace_show_number": False,
6868
"bar_workspace_use_chinese_numerals": False,
69-
"bar_hide_special_workspace": True, # Toggle (Hide/Show) special workspace
69+
"bar_hide_special_workspace": True,
7070
"bar_theme": "Pills",
7171
"dock_theme": "Pills",
72-
"panel_theme": "Notch", # Default panel theme
73-
PANEL_POSITION_KEY: PANEL_POSITION_DEFAULT, # Default panel position
74-
NOTIF_POS_KEY: NOTIF_POS_DEFAULT, # Nueva entrada para la posición de notificaciones
72+
"panel_theme": "Notch",
73+
PANEL_POSITION_KEY: PANEL_POSITION_DEFAULT,
74+
NOTIF_POS_KEY: NOTIF_POS_DEFAULT,
7575
"bar_button_apps_visible": True,
7676
"bar_systray_visible": True,
7777
"bar_control_visible": True,
@@ -102,5 +102,5 @@
102102
},
103103
"limited_apps_history": ["Spotify"],
104104
"history_ignored_apps": ["Hyprshot"],
105-
"selected_monitors": [], # Empty array means show on all monitors
105+
"selected_monitors": [],
106106
}

config/settings_gui.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,7 @@ def create_key_bindings_tab(self):
146146
("Emoji Picker", "prefix_emoji", "suffix_emoji"),
147147
("Power Menu", "prefix_power", "suffix_power"),
148148
("Toggle Caffeine", "prefix_caffeine", "suffix_caffeine"),
149+
("Toggle Bar", "prefix_toggle", "suffix_toggle"),
149150
("Reload CSS", "prefix_css", "suffix_css"),
150151
(
151152
"Restart with inspector",

config/settings_utils.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -267,6 +267,7 @@ def generate_hyprconf() -> str:
267267
bind = {bind_vars.get("prefix_emoji", "SUPER")}, {bind_vars.get("suffix_emoji", "PERIOD")}, exec, $fabricSend 'notch.open_notch("emoji")' # Emoji Picker
268268
bind = {bind_vars.get("prefix_power", "SUPER")}, {bind_vars.get("suffix_power", "ESCAPE")}, exec, $fabricSend 'notch.open_notch("power")' # Power Menu
269269
bind = {bind_vars.get("prefix_caffeine", "SUPER SHIFT")}, {bind_vars.get("suffix_caffeine", "M")}, exec, $fabricSend 'notch.dashboard.widgets.buttons.caffeine_button.toggle_inhibit(external=True)' # Toggle Caffeine
270+
bind = {bind_vars.get("prefix_toggle", "SUPER CTRL")}, {bind_vars.get("suffix_toggle", "B")}, exec, $fabricSend 'from utils.global_keybinds import get_global_keybind_handler; get_global_keybind_handler().toggle_bar()' # Toggle Bar
270271
bind = {bind_vars.get("prefix_css", "SUPER SHIFT")}, {bind_vars.get("suffix_css", "B")}, exec, $fabricSend 'app.set_css()' # Reload CSS
271272
bind = {bind_vars.get("prefix_restart_inspector", "SUPER CTRL ALT")}, {bind_vars.get("suffix_restart_inspector", "B")}, exec, killall {APP_NAME}; uwsm-app $(GTK_DEBUG=interactive python {home}/.config/{APP_NAME_CAP}/main.py) # Restart with inspector
272273

modules/notch.py

Lines changed: 30 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -147,6 +147,7 @@ def __init__(self, monitor_id: int = 0, **kwargs):
147147
self.is_hovered = False
148148
self._prevent_occlusion = False
149149
self._occlusion_timer_id = None
150+
self._forced_occlusion = False
150151

151152
self.icon_resolver = IconResolver()
152153
self._all_apps = get_desktop_applications()
@@ -452,6 +453,8 @@ def on_button_leave(self, widget, event):
452453
def on_notch_hover_area_enter(self, widget, event):
453454
"""Handle hover enter for the entire notch area"""
454455
self.is_hovered = True
456+
if self._forced_occlusion:
457+
return False
455458
if data.PANEL_THEME == "Notch" and data.BAR_POSITION != "Top":
456459
self.notch_revealer.set_reveal_child(True)
457460
return False
@@ -467,7 +470,6 @@ def on_notch_hover_area_leave(self, widget, event):
467470
return False
468471

469472
def close_notch(self):
470-
# Update monitor manager state
471473
if self.monitor_manager:
472474
self.monitor_manager.set_notch_state(self.monitor_id, False)
473475

@@ -483,6 +485,14 @@ def close_notch(self):
483485
if data.PANEL_THEME != "Notch":
484486
self.notch_revealer.set_reveal_child(False)
485487

488+
if self.bar and not self.bar.get_visible() and data.BAR_POSITION == "Top":
489+
if data.BAR_THEME == "Pills":
490+
self.set_margin("-40px 0px 0px 0px")
491+
elif data.BAR_THEME in ["Dense", "Edge"]:
492+
self.set_margin("-46px 0px 0px 0px")
493+
else:
494+
self.set_margin("-40px 8px 8px 8px")
495+
486496
def open_notch(self, widget_name: str):
487497
# Debug info for troubleshooting
488498
if hasattr(self, '_debug_monitor_focus') and self._debug_monitor_focus:
@@ -705,6 +715,9 @@ def _open_notch_internal(self, widget_name: str):
705715
self.bar.revealer_right.set_reveal_child(not hide_bar_revealers)
706716
self.bar.revealer_left.set_reveal_child(not hide_bar_revealers)
707717

718+
if self.bar and not self.bar.get_visible() and data.BAR_POSITION == "Top":
719+
self.set_margin("0px 8px 8px 8px")
720+
708721
self._is_notch_open = True
709722

710723
def toggle_hidden(self):
@@ -868,6 +881,22 @@ def _check_occlusion(self):
868881
self.notch_revealer.set_reveal_child(not is_occluded)
869882

870883
return True
884+
885+
def force_occlusion(self):
886+
"""Force notch to occlusion mode (hidden)."""
887+
self._forced_occlusion = True
888+
self._prevent_occlusion = False
889+
self.notch_revealer.set_reveal_child(False)
890+
891+
def restore_from_occlusion(self):
892+
"""Restore notch from occlusion mode."""
893+
import config.data as data
894+
self._forced_occlusion = False
895+
if data.PANEL_THEME == "Notch":
896+
if data.BAR_POSITION == "Top":
897+
self.notch_revealer.set_reveal_child(True)
898+
else:
899+
self._prevent_occlusion = False
871900

872901
def _get_current_window_class(self):
873902
"""Get the class of the currently active window"""

utils/global_keybinds.py

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -177,6 +177,37 @@ def get_all_monitors_info(self) -> list:
177177
return []
178178

179179
return self._monitor_manager.get_monitors()
180+
181+
def toggle_bar(self) -> bool:
182+
"""
183+
Toggle bar visibility and force notch to occlusion mode.
184+
185+
Returns:
186+
True if successful, False otherwise
187+
"""
188+
if not self._monitor_manager:
189+
return False
190+
191+
focused_monitor_id = self._monitor_manager.get_focused_monitor_id()
192+
193+
bar = self._monitor_manager.get_focused_instance('bar')
194+
notch = self._monitor_manager.get_focused_instance('notch')
195+
196+
if bar and notch:
197+
try:
198+
current_visibility = bar.get_visible()
199+
bar.set_visible(not current_visibility)
200+
201+
if not current_visibility:
202+
notch.restore_from_occlusion()
203+
else:
204+
notch.force_occlusion()
205+
206+
return True
207+
except Exception as e:
208+
print(f"GlobalKeybindHandler: Error toggling bar: {e}")
209+
210+
return False
180211

181212

182213
# Singleton accessor

0 commit comments

Comments
 (0)